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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int D, N, M;
    while( cin >> D, D ){
        cin >> N >> M;
        vector<int> d( N + 1 );
        d[0] = 0;
        d[N] = D;
        REP( i, N - 1 ) cin >> d[i + 1];

        sort( ALL( d ) );

        int ans = 0;
        REP( i, M ){
            int k; cin >> k;
            auto it = lower_bound( ALL( d ), k );
            ans += min( abs( *it - k ), abs( k - *prev( it ) ) ) ;
        }

        cout << ans << endl;
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


int main() {

	ll n;
	cin >> n;
	vector<ll> p(n);

	ll ans = 0;
	rep(i, n) {
		cin >> p[i];
		
	}


	rep(i, n) {
		if (i > 0 && i < n - 1) {
			if ((p[i] < p[i - 1] && p[i] > p[i + 1]) || (p[i] > p[i - 1] && p[i] < p[i + 1])) {
				ans += 1;
			}
		}
	}

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)

store = 0
big = 0

for i in range (0, N-1):
	if store == 1:
		store = 0
	else:
		if A[i] == A[i+1] and big == 0:
			big = A[i]
			store = 1
		elif A[i] == A[i+1]:
			print(A[i]*big)
			exit()
            
print(0)

Measured memory_bytes: 20000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {


            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();


            int c = 0;
            for (int i = 1; i < n - 1; i++)
            {
                if (p[i - 1] < p[i] && p[i] < p[i + 1])
                {
                    c++;
                }
                else if (p[i - 1] > p[i] && p[i] > p[i + 1])
                {
                    c++;
                }
                else if ((p[i - 1] == p[i] && p[i] < p[i + 1]) || (p[i + 1] == p[i] && p[i] < p[i - 1]))
                {
                    c++;

                }

            }

            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13396
from decimal import Decimal
W, H, x, y = map(int, input().split())
Wi = W * 10 ** 9
Hi = H * 10 ** 9
men = Decimal(W * H / 2)
judge = 0
if x == W / 2 and y == H / 2:
  judge = 1
print("{0:.10f} {1:.0f}".format(men, judge))

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
  ll n;
  cin >> n;
  vector<ll> l(n);
  rep(i,n) cin >> l[i];
  sort(ALL(l));
 
  ll ans = 0;
  
  rep(i,n){
    for(ll j = 0;j < i - 1;j++){
      ll b = l[i] -l[j];
      auto itr = upper_bound(l.begin() + j + 1,l.begin() + i - 1,b);
      	if(*itr > b){
      		size_t pos = distance(upper_bound(l.begin() + j + 1,l.begin() + i - 1,b),l.begin() + i);
       		//cout << l[j] << ' ' << l[i] << endl;
        	//cout << b << ' ' << *itr  <<  ' ' <<  pos << endl << endl;
       		ans+=pos;
        }
    }
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <cstdlib>
#include <iomanip>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <iterator>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <cstring>
#include <sstream>
#include <stack>
#include <random>

using namespace std;

#define vi vector<int> 
#define vvi vector<vi>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define io ios::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(a) int((a).size()) 
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define loop(i,b) for (int i = 0; i < b; ++i)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define INF numeric_limits<int>::max()
#define LLINF numeric_limits<ll>::max()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define F first
#define S second
#define MOD 1000000007
#define cflout(x) cout << fixed << setprecision(8) << x << endl
#define setzero(x) memset(x, 0, sizeof(x))

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

random_device _random_device;
default_random_engine _generator(_random_device());
uniform_int_distribution<long long unsigned> _distribution(0, 0xFFFFFFFFFFFFFFFF);

inline long long unsigned get_random_number() {
    return _distribution(_generator);
}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

inline ll nxt() {
	ll x;
	cin >> x;
	return x;
}

namespace aux {	
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) {
		v.emplace_back(x);
    }
    return v;
}
}


int n;

int main() {
	io;
	n = nxt();
	if (n % 10 == 9 || (n/10) % 10 == 9) cout << "Yes\n";
	else cout << "No\n";




	return 0;
}













Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().strip().split(' ')))
A=sorted(A)[::-1]
change=len(A)-1
for i in range(len(A)):
    if A[i]<0:
        change=i
        break

if change==0:
    change=1
MAX=sum(A[:change])+sum([-A[i] for i in range(change,len(A))])


prefix=[]
pre=0
for i in range(len(A)):
    if i<change:
        pre+=A[i]
        prefix+=[pre]
    else:
        pre-=A[i]
        prefix+=[pre]

queries=[]

if change>=2:
    pre=A[change]
    for i in range(change-1):
        queries+=[(pre,A[i])]
        pre-=A[i]
    queries+=[(A[change-1],pre)]
    pre=A[change-1]-pre
    for i in range(change+1,len(A)):
        queries+=[(pre,A[i])]
        pre-=A[i]
else:
    pre=A[0]
    for i in range(1,len(A)):
        queries+=[(pre,A[i])]
        pre-=A[i]

print(MAX)
for (a,b) in queries:
    print(a,b)
        
        

    

Measured memory_bytes: 23436
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        decimal[] ab = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
        var a = ab[0];
        var b = ab[1];

        decimal ans = a * b;
        ans = Math.Floor(ans);

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28256
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define INF -1
using namespace std;

int main()
{
	int h, w, n;
	int large;
	int ans;

	cin >> h >> w >> n;
	large = max(h, w);
	
	if (n % large) {
		ans = n / large + 1;
	} else {
		ans = n / large;
	}

	printf("%d", ans);
}

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

start = -1
for i in range(N-1):
    if A[i] + A[i + 1] >= L:
        start = i
if start < 0:
    print("Impossible")
    exit()

ans = [start + 1]
for i in range(start + 1, N - 1):
    ans.append(i+1)
for i in reversed(range(start)):
    ans.append(i+1)

ans.reverse()
print("Possible")
print(*ans, sep="\n")

Measured memory_bytes: 19976
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,C,D,E;

 cin >> A >>B >>C >>D >>E ;
   int a,b,c,d,e;
   a = A%10;
   b = B%10;
   c = C%10;
   d = D%10;
   e = E%10;

int k;
   k = 10;
   if(k>a && a!=0){k=a;}
   if(k>b && b!=0){k=b;}
   if(k>c && c!=0){k=c;}
   if(k>d && d!=0){k=d;}
   if(k>e && e!=0){k=e;}
  
   if(a==0){a=10;}
   if(b==0){b= 10;}
   if(c==0){c= 10;}
   if(d==0){d= 10;}
   if(e==0){e= 10;}

  cout << (A+B+C+D+E-a-b-c-d-e+40+k);

}

Measured memory_bytes: 256
(defun solve (n s)
  (labels ((main (s start)
             (let ((pos (search "ABC" s :start2 start)))
               (if pos
                   (1+ (main s (1+ pos)))
                   0))))
    (main (format nil "~A~A~A"
                  (subseq s (- n 2))
                  s
                  (subseq s 0 2))
          0)))

#-swank
(let ((n (read))
      (s (read-line)))
  (format t "~A~%" (solve n s)))


Measured memory_bytes: 12772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
ll b[61];
void ins(ll x){
    for (ll i=60;i>=0;i--) {
        if (x & (1LL<<i)) {
            if (b[i] == 0) {
                b[i] = x;
                return;
            }
            x ^= b[i];
        }
    }
}
ll cal(ll x){
    for (ll i=60;i>=0;i--) {
        if (x & (1LL<<i)) {
            x ^= b[i];
        }
    }
    return x != 0;
}
int main(){
    IOS();
    int t;
    cin >> t;
    while (t--) {
        RST(b,0);
        int n;
        cin >> n;
        REP (i,n) cin >> d[i];
        string s;
        cin >> s;
        ll ans = 0;
        for (int i=n-1;i>=0;i--) {
            if (s[i] == '0') ins(d[i]);
            else ans |= cal(d[i]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x;
	scanf("%lld",&x);
  ll ans=0;
  ans+=(1000*(x/500));
  	x-=(500*(x/500));
  
  ans+=(5*(x/5));
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define mod1 1000000007
#define mod2 998244353
#define debug(x) cout<<#x<<" : "<<x<<endl

int main()
{
	optimize

	lli n,m,k;
	cin>>n>>m>>k;
	vector<lli>a(n+1LL);
	vector<lli>b(m+1LL);
	a[0] = 0LL;
	b[0] = 0LL;
	forab(i,1,n+1)
	{
		cin>>a[i];
		a[i] += a[i-1];
	}

	forab(i,1,m+1)
	{
		cin>>b[i];
		b[i] += b[i-1];
	}

	int ans = 0;

	int j = m;

	forab(i,0, n+1)
	{
		if(a[i] > k)
			break;

		while(a[i]+b[j] > k)
			j--;

		ans = max(ans, i+j);
	}


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

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

int main()
{
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int k; cin >> k;
	set<string> substrs;
	for (char c = 'a'; (int)substrs.size() < k && c <= 'z'; c++)
	{
		for (int i = 0; i < (int)s.length(); i++)
		{
			if (s[i] != c)
				continue;
			string substr = string(1, c);
			substrs.insert(substr);
			for (int j = i + 1; j < i + 5 && j < (int)s.length(); j++)
			{
				substr += s[j];
				substrs.insert(substr);
			}
		}
	}
	int ind = 0;
	for (auto it = substrs.begin(); it != substrs.end(); it++, ind++)
	{
		if (ind == k - 1)
		{
			cout << *it << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

template<typename T>
struct BIT{
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1){}

  T sum(int k){
    T ret = 0;
    for(++k;k>0;k-=k&-k) ret += d[k];
    return ret;
  }

  void add(int k, T x=1){
    for(++k; k<=n; k+= k&-k) d[k] += x;
  }
};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N+1,0);
  vector<int> w(N+1,0);
  rep(i,N){
    int x;cin >> x; --x;
    ++v[x];
  }
  rep(i,N) ++w[v[i]];
  rep(i,N+1) v[i] = w[i];
  rep(i,N) v[i+1] += v[i];
  rep(i,N+1) w[i] *= i;
  rep(i,N) w[i+1] += w[i];
  vector<int> h(N+1);
  h[0] = MAX_I;
  repp(X,1,N+1) h[X] = (w[X] + X*(v[N] - v[X]))/X;
  int id = N;
  repp(k,1,N+1){
    while(k>h[id])id--;
    cout << id << endl;
  }
  return 0;
}


Measured memory_bytes: 4352
# AOJ 0524: Searching Constellation
# Python3 2018.7.1 bal4u

def check(dx, dy):
	f = True
	for x, y in goal:
		if (x+dx, y+dy) not in star: 
			f = False
			break
	return f

while True:
	m = int(input())
	if m == 0: break
	goal, star = [], []
	for i in range(m):
		x, y = map(int, input().split())
		goal.append((x, y))
	for i in range(int(input())):
		x, y = map(int, input().split())
		star.append((x, y))
	for x, y in star:
		dx, dy = x-goal[0][0], y-goal[0][1]
		if check(dx, dy): break
	print(dx, dy)


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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    int n, m;
    cin >> n >> m;

    vector<int> nums(m), dist(m);
    rep(i, m){
        cin >> nums[i];
    }

    sort(all(nums));
    rep(i, m){
        if(i != 0) dist[i] = nums[i] - nums[i-1];
    }
    sort(all(dist));
    rep(i, n-1){
        if(m-1-i > 0)dist[m-1-i] = 0;
    }

    cout << accumulate(all(dist), 0) << endl;
}

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

int	main()
{
	string	line;
	vector<int>	cnt_vec(26, 0);
	while (getline(cin, line)) {
		for (char c : line) {
			if ('a' <= c && c <= 'z') 
				++cnt_vec.at(c - 'a');
			if ('A' <= c && c <= 'Z')
				++cnt_vec.at(c - 'A');
		}
	}
	for (char c = 'a'; c <= 'z'; ++c) {
	   cout << c << " : " << cnt_vec.at(c - 'a') << endl;
	}
}	


Measured memory_bytes: 3184
#include <iostream>
#include <string>
int  N;
int *A;
int *ans;


int main(void){
    std::cin >> N;
    A = new int[N];
    ans = new int[N];

    for(int i = 0; i < N; i++){
        std::cin >> A[i];
        ans[A[i]-1] = i+1;
    }
    for(int i = 0; i < N; i++){
        std::cout << ans[i] << " ";
    }
    delete[] A;
    delete[] ans;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
typedef set<ll> Set;
const ll max_s=1000010;
const ll MOD=1e9+7;

int main(){
    ll n,k;
    cin >> n >>k;
    ll a[n],f[n];
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    sort(a,a+n,greater<ll>());
    sort(f,f+n);
    
    ll lb=-1, ub=1e12+1;
        
    while(ub-lb>1){
        ll mid=(lb+ub)/2;
        ll score=0;
        rep(i,n){
            ll at=a[i]-mid/f[i];
            if(at>0) score+=at;
        }
        if(score<=k){
            ub=mid;
        }
        else lb=mid;
    }
    kaku(ub);
}



Measured memory_bytes: 3328
#include <stdio.h>

int output[10000][2];
int output_sz = 0;

int main()
{
	int N, K;

	scanf("%d %d", &N, &K);
	
	for (int i = 2; i <= N; ++i)
	{
		output[output_sz][0] = 1, output[output_sz][1] = i;
		output_sz++;
	}

	for (int i = 2; i <= N; ++i)
	{
		for (int j = i + 1; j <= N; ++j)
		{
			output[output_sz][0] = i, output[output_sz][1] = j;
			output_sz++;
		}
	}

	if (K > (N - 1)*(N - 2) / 2) printf("-1\n");
	else
	{
		for (int i = 0; i < K; ++i) output_sz--;

		printf("%d\n", output_sz);
		for (int i = 0; i < output_sz; ++i) printf("%d %d\n", output[i][0], output[i][1]);
	}
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    if(count(all(s), '9')) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7740
d={}
k=0
j=0
l=[]
for i in range(int(input())):
    s=input()
    if d.get(s) is None:
        d[s]=1
    else:
        d[s]+=1
for i in sorted(d,key=d.get,reverse=True):
    l.append(i)
    k=d[i]
    break
for i in sorted(d,key=d.get,reverse=True):
    j+=1
    if j>1:
        if d[i]==k:
            l.append(i)
l.sort()
for i in l:
    print(i)


Measured memory_bytes: 32220
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  string s;
  cin >> s;
  n = s.size();
  vi v(n);
  rep(i, n) v[i] = (s[i] == '0') ? 0 : 1;
  int ans = 0;
  rep(i, n - 1){
    if(i < 0) continue;
    //cout << i << " ";
    if(v[i] + v[i + 1] == 1){
      n -= 2;
      for(int j = i; j < n; j++){
        //cout << j << " ";
        v[j] = v[j + 2];
      }
      ans++;
      i -= 2;
    }
  }
  cout << endl;
  cout << ans * 2 << endl;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
using namespace std;
string n;
int main(int argc, char const* argv[])
{
    cin >> n;
    if(n[0] == n[1] && n[1] == n[2]) puts("Yes");
    else if(n[2] == n[3] && n[1] == n[2]) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 1000000007
#define MAX_N 100002
using namespace std;
using ll = long long;

ll fact[2*MAX_N];
ll invf[2*MAX_N];
ll h,w,a,b;


ll fast_pow(ll x,ll k, ll p)
{
    ll res = 1;
    while(k>0){
        if(k&1)res = (res*x) %p;
        x = (x*x)%p;
        k>>=1;
    }
    return res;
}

void init()
{
    ll n = h+w;
    fact[0]=1;
    for(ll i = 1;i<=n;i++){
        fact[i] = (fact[i-1]*i)%INF; 
    }
    invf[n] = fast_pow(fact[n],INF-2,INF);
    for(ll i = n - 1;i>=0;i--){
        invf[i] = (invf[i+1]*(i+1))%INF;
    }
}

ll C(ll n, ll m)
{
    return ((fact[n]*invf[n-m])%INF * invf[m])%INF;
}

void solve()
{
    init();
    ll res = 0;
    for(ll i = 0;i<w-b;i++){
        //cout<<b+i+h-a-1<<" "<<h-a-1<<" ";
        //cout<<w-b-i-1+a-1<<" "<<a-1<<endl;
        res = (res + (C(b+i+ h-a-1,h-a-1) * C(w-b-i-1+a-1,a-1))%INF)%INF;   
    }
    cout<<res<<endl;
}
int main()
{
    cin>>h>>w>>a>>b;
    solve();

}


Measured memory_bytes: 3328
n = int(input())
a_l = [int(_) for _ in input().split(' ')]
a_r = [_ for _ in a_l]

b = [int(_) for _ in input().split(' ')]

ans_l = 0
for i in range(n):
    if b[i] >= a_l[i] + a_l[i + 1]:
        ans_l += a_l[i] + a_l[i + 1]
        a_l[i] = 0
        a_l[i + 1] = 0
    elif b[i] >= a_l[i]:
        ans_l += b[i]
        a_l[i + 1] -= b[i] - a_l[i]
        a_l[i] = 0
    else:
        ans_l += b[i]
        a_l[i] -= b[i]

ans_r = 0
for i in range(n):
    if b[i] >= a_l[i] + a_l[i + 1]:
        ans_r += a_l[i] + a_l[i + 1]
        a_l[i] = 0
        a_l[i + 1] = 0
    elif b[i] >= a_l[i + 1]:
        ans_r += b[i]
        a_l[i] -= b[i] - a_l[i + 1]
        a_l[i + 1] = 0
    else:
        ans_r += b[i]
        a_l[i + 1] -= b[i]

print(max(ans_l, ans_r))


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

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

    bool flag = true;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] % 2 == 1) flag = false;
    }

    if(flag == false) cout << "first" << endl;
    if(flag == true)  cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 3712
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, K) = get!(i64, i64);

    let ans = if N > 2 * (K - 1) {
        "YES"
    } else {
        "NO"
    };

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


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

using namespace std;

int main() {
	int N, K, A[220000] = {}, Baket[220000] = {};
	int Ans = 0;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		Baket[A[i]]++;
	}
	sort(Baket,Baket+N+1,greater<>());

	for (int i = 0; i < N-K; i++) {
		Ans += Baket[K + i];
	}
	cout << Ans << endl;

	return 0;
}

Measured memory_bytes: 1920
n, a, b, c, d = map(int, input().split())

s = input()

if c < d:
    if "##" in s[a-1:c] or "##" in s[b-1:d]:
        print("No")
    else:
        print("Yes")
else:
    if "..." in s[b-2:d+1] and "##" not in s[a-1:c] and "##" not in s[b-1:d]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3572
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>

using namespace std;

int main(){
    double x1, x2;
    double y1, y2;
    double a1,a2;
    
    cin >> x1 >> y1 >> x2 >> y2;
    
    a1 = (x2-x1) * (x2-x1) + (y2-y1) * (y2-y1) ;
    a2 = sqrt(a1);
    
    printf("%12.8f\n",a2);
    
    return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int a,b,c;
int main(){
  scan(a);scan(b);scan(c);
  prin(min(b/a,c));

  return 0;
}


Measured memory_bytes: 256
# マイナスが大きいものの開催頻度をあげる
d=int(input())
c= list(map(int, input().split()))
D= [list(map(int, input().split())) for i in range(d)]
cc=[0]*26
for i in range(26):
    cc[i]=[c[i],i+1]
cc.sort(reverse=True)

ans=[0]*d
# 最後にどの試験がいつ行われたか？
PL=[0]*26

for i in range(d):
    cnt=0
    cntt=-10**9
    x=1
    for k in range(len(c)):
        v=PL[:]
        cnt = D[i][cc[k][1]-1]
        v[cc[k][1]-1] = i+1
        for j in range(len(c)):
            cnt-=(i+1-v[j])*c[j]
        if cnt>cntt+20:
            x=cc[k][1]
            cntt=max(cnt,cntt)
    ans[i]=x
    PL[x-1]=i


for i in range(d):
    print(ans[i])

Measured memory_bytes: 68696
/*
ABHIJEET BISWAS
CSE (2017-2021)
MNNIT ALLAHBAD
*/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e15
#define ll long long
#define ld long double
#define int ll
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define F first
#define S second
#define popi __builtin_popcount
#define popll __builtin_popcountll
#define grp vector<int> graph[MAX];
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//////////////////////TEMPLATE ENDS///////////////////////////////////////////////////////////////////////
ll power(ll,ll);
ll mpower(ll,ll);
//////////////////////////////////////////////////////////////////////////////////////////////////////////


int32_t main() {
	fastIO


	int d;
	string in;
	cin>>in>>d;
	
	int n = in.size();
	int dp[n+1][d][2];
	memset(dp,0,sizeof dp);
	dp[n][0][0]=dp[n][0][1] =1;
	for(int id=n-1;id>=0;id--)
	{
		for(int j=0;j<d;j++)
		{
			for(int m=0;m<2;m++)
			{
				//cout<<((m==1)?(in[id]-'0'):9)<<" "<<id<<endl;
				for(int k=0;k<=((m==1)?(in[id]-'0'):9);k++)
				{
					
					dp[id][j][m]=(dp[id][j][m]+dp[id+1][(j+k)%d][m==1 and k==(in[id]-'0')])%MOD;
				}
			}
		}
	}

	
	int ans =( dp[0][0][1]-1+MOD)%MOD;
	cout<<ans<<endl;
	
	
	return 0;
}







/*_________________________________________________Utility Functions HERE_______________________________*/

ll power(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b%2==1)
		res=res*a;
		a=a*a;
		b=b/2;
	}
	return res;
}
ll mpower(ll a ,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return res;
}

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

int num[9]={2,5,5,4,5,6,3,7,6};

int main(){
	int n,m;
	cin >> n >> m;
	int usenum[9]={};
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		usenum[a-1]=1;
	}

	int dp[n+1];
	dp[0]=0;
	for(int i=1;i<=n;i++) dp[i]=-1e9;
	for(int i=1;i<=n;i++){
		for(int j=0;j<9;j++){
			if(usenum[j]==0) continue;
			if(i-num[j]>=0) dp[i]=max(dp[i],dp[i-num[j]]+1);
		}
	}
	while(n){
		for(int i=9;i>0;i--){
			if(usenum[i-1]==0) continue;
			if(n-num[i-1]<0) continue;
			if(dp[n-num[i-1]]==(dp[n]-1)){
				cout << i;
				n-=num[i-1];
				break;
			}
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
(defun f(lst)
  (labels((rec(lst acc)
            (if (null (cdr lst))
              acc
              (rec (cdr lst) (+ acc (reduce #'+ (mapcar (lambda(x) (* x (car lst))) (cdr lst))))))))
    (rec lst 0)))
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))
(let* ((line0 (read-line nil nil))
       (line (read-line nil nil))
       (lst (mapcar #'parse-integer (splitat #\space line))))
  (format t "~A" (f lst)))


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

int main(){
    int n;
    cin>>n;
    vector<int>x(n),y(n);
    for(int i=0; i<n; ++i)cin>>x[i];
    for(int i=0; i<n; ++i)cin>>y[i];
    int a1=0,ainf=0; double a2=0,a3=0;
     for(int i=0; i<n; ++i){
         a1+=abs(x[i]-y[i]);
         a2+=(x[i]-y[i])*(x[i]-y[i]);
         a3+=(abs(x[i]-y[i]))*(abs(x[i]-y[i]))*(abs(x[i]-y[i]));
         ainf=max(ainf,abs(x[i]-y[i]));
     }
     a2=pow(a2,1.0/2.0);
     a3=pow(a3,1.0/3.0);
     printf("%d\n%.10f\n%.10f\n%d\n",a1,a2,a3,ainf);
     return 0;
}


Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define dl double
#define pii pair<int,int>
#define pb push_back
#define all() begin(),end()
#define nl '\n'
#define adm(a,b,m) ((a+b)%m)
#define gum(a,b,m) ((a*1LL*b)%m)
#define lo(i,j,n) for(int i=j;i<n;i++)
ll a[200010],n;
ll f(ll k){
	ll an=0;
	lo(i,0,n){
		k++;
		an+=abs(a[i]-k);
	}
	return an;
}
int main(){
	cin>>n;
	lo(i,0,n){
		cin>>a[i];
	}
	ll lo=0,hi=1000000000LL;
	lo=-hi;
	ll an=10000000000000000LL;
	while(lo<hi){
		//cout<<lo<<' '<<hi<<nl;
		ll mid=(lo+hi)>>1;
		ll p=f(mid);
		ll q=f(mid+1);
		an=min(p,q);
		if(p<q)hi=mid;
		else lo=mid+1;
	}
	//	lo(i,0,10)cout<<i<<' '<<f(i)<<nl;
	cout<<an<<nl;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n, k; cin >> n >> k;
        vector<int> rsp(3); cin >> rsp;
        string t; cin >> t;
        string choice(n, 'X');
        int ans = 0;
        for (int i = 0; i < n; i++) {
                if (t[i] == 'r') choice[i] = 'p';
                if (t[i] == 's') choice[i] = 'r';
                if (t[i] == 'p') choice[i] = 's';
        }

        for (int i = 0; i < n; i++) {
                if (i - k >= 0 && choice[i - k] == choice[i]) {
                        choice[i] = 'X';
                } else {
                        if (choice[i] == 'r') ans += rsp[0];
                        else if (choice[i] == 's') ans += rsp[1];
                        else ans += rsp[2];
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3780
#include <iostream> // cout, endl, cin
#include <vector>   // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main(void)
{
  int a, b, c, flag = 0;
  cin >> a >> b >> c;
  for(int i = a;i <= b;i++)
  {
    if(c % i == 0) flag++;
  }
  cout << flag << endl;
  return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


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

  int A, B;
  cin >> A >> B;
  cout << A*B / __gcd(A, B) << endl;

}

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

ll mpow(ll a,ll b){
    ll res=1;
    a%=mod;
    while(b){
    	if(b%2) res=res*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return res;
}

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

void solve(){
	//code
	int n,count=0;
	cin>>n;
	string s;
	cin>>s;
	
	for(int i=0;i<n-2;i++){
		if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
			count+=1;
	}
	cout<<count;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3568
#include"bits/stdc++.h"
using namespace std;

/**
 * Copyright (c)
 * author        :   Sujeet Kumar 
 * question name :   
 * link          :   
 */

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rep(i,a,n) for (ll i=a;i<=n;i++)
#define repA(i,v) for(auto i:v)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define vi vector<int>
#define vll vector<ll>
#define vi2(n,m) vector<vector<int> > v(n,vector<int>(m));
ll power(ll x,ll y,ll p){ll res=1; x=x%p;if(x==0) return 0;while(y>0)
{if(y&1) res=(res*x)%p;y=y>>1; x=(x*x)%p;}return res;}


void solve(){
	int n;cin>>n;
	vector<int> v;
	int temp = n;
	int res = 0,i = 1;
	while(1){
		if(temp%i==0)	res+=((temp/i)-1);
		else	res+=(temp/i);
		i++;
		if(temp/i<=0)	break;
	}
	cout<<res<<endl;
	// repA(i,v)	cout<<i<<' ';
	// cout<<endl;
	return ;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    clock_t start=clock();

	ll test = 1;
	// cin>>test;
	while(test--)	solve();

	clock_t end=clock();
	cerr<<fixed<<setprecision(15)<<((double)(end-start))/CLOCKS_PER_SEC<<endl;
	return 0;
}
/**
 * Test Cases:-
 */


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll n,k;
ll a[2010];

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

  cin>>n>>k;
  rep(i,n)cin>>a[i];

  ll res=0;
  rep(i,n)repl(j,i+1,n){
    if(a[i]>a[j])res++;
  }
  res*=k; res%=mod;

  ll sum=0;
  rep(i,n)rep(j,n){
    if(a[i]>a[j])sum++;
  }

  sum*=(k*(k-1)%mod)*mod_pow(2,mod-2)%mod;
  sum%=mod;

  cout<<(res+sum)%mod<<endl;

  return 0;
}


Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >>n;
    vector<int> v(n), c(n);
    for(int i = 0; i < n; i++)
        cin >>v[i];
    for(int i = 0; i < n; i++)
        cin >>c[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(v[i] > c[i])
            ans += (v[i] - c[i]);
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

X = [tuple(p) for p in permutations(range(1, N + 1), r=N)]
X.sort()

print(abs(X.index(P) - X.index(Q)))


Measured memory_bytes: 7924
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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;
}

int main()
{
  INT(N);
  INT(M);
  INT(R);
  vector<int> r(R);
  REP(i, R){
    cin >> r[i];
    r[i]--;
  }
  sort(ALL(r));
  vector<vector<ll>> A(M,vector<ll>(3));
  vector<vector<ll>> List(N,vector<ll>(N,INF));
  REP(i,N){
    REP(j,N){
      if(i==j){
        List[i][j]=0;
      }
    }
  }
  REP(i, M){
    REP(j, 3){
      cin >> A.at(i).at(j);
    }
    A.at(i).at(0)--;
    A.at(i).at(1)--;
    List[A[i][0]][A[i][1]]=A[i][2];
    List[A[i][1]][A[i][0]]=A[i][2];
  }
  REP(i,N){
    REP(j,N){
      REP(k,N){
        chmin(List[j][k],List[j][i]+List[i][k]);
      }
    }
  }

  // REP(i,N){
  //   REP(j,N){
  //     cout << List[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  ll ans=INF;
  do{
    ll cnt = 0;
    REP(i,R-1){
      cnt+=List[r[i]][r[i+1]];
    }
    chmin(ans,cnt);
  }while(next_permutation(ALL(r)));
  
  cout << ans << endl;
}

Measured memory_bytes: 4576
import { readFileSync } from 'fs'

function main(input: string) {
  const [header, cards, ...lines] = input.split('\n').map(v => v.split(' ').map(Number))

  const list = [
    ...cards.map(v => [1, v]),
    ...lines,
  ]

  list.sort(([, a], [, b]) => b - a)

  let result = 0

  let j = 0, maxLength = cards.length
  for (const [count, value] of list) {
    for (let i = 0; i < count && j < maxLength; ++i, ++j) {
      result += value
    }
  }

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int ans = 0;
    int left = 0;
    int right = 0;
    int remain = K;
    if (S[0] == '0') {
        remain--;
    }
    while (left < N) {
        while (remain >= 0 && right < N) {
            if (S[right] == '1' && right + 1 < N && S[right + 1] == '0') {
                remain--;
            }
            right++;
        }
        ans = max(ans, right - left);
        if (right == left) {
            right++;
        }
        if (S[left] == '0' && left + 1 >= 0 && S[left + 1] == '1') {
            remain++;
        }
        
        left++;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n){
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[110000];

int main()
{
  int i,j,n,ans;
  scanf("%d",&n);
  for (i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    a[i]--;
  }
  ans=0;
  for (i=0;i<n;i++)
    if (i==a[i])
    {
      if (i+1<n) swap(a[i],a[i+1]);
      else swap(a[i],a[i-1]);
      ans++;
    }
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

int main() {

	long k;
	cin >> k;
	long a,b;
	cin >> a >> b;

	for (long i = a; i <= b; i++) {
		if (i%k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
	return 0;

}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
 char s[4];
 int a=0,i;
 scanf("%s",s);
 for(i=0;i<4;i++){
  if(s[i]=='+'){
   a++;
  }else{
   a--;
  }
 }
 printf("%d\n",a);
 return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>

using namespace std;
typedef struct point{
	double x,y;
} point;


double cross(point p1, point p2, point p3, point p4){  
    return ( (p1.x-p2.x)*(p3.y-p1.y) + (p1.y-p2.y)*(p1.x-p3.x)) * ((p1.x-p2.x)*(p4.y-p1.y) + (p1.y-p2.y)*(p1.x-p4.x));  
}

int main(){
	char a;
	double l[4];
	while(1){
	bool ans = true;
	point p[4]; 
		for(int i=0;i<4;i++)
	if(scanf("%lf,%lf,",&p[i].x,&p[i].y) == EOF) return 0;
	
    if(cross(p[0],p[2],p[1],p[3]) > 0.0 || cross(p[1],p[3],p[0],p[2] ) > 0.0) ans = false;
	
	
	if(ans == true) {cout << "YES" << endl;} else {cout << "NO" << endl; }
}


}

Measured memory_bytes: 1224