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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// identity permutation
vi id(int n) {
	vi p(n + 1);
	rep(i, 1, n + 1) p[i] = i;
	return p;
}

// multiply permutation
vi pmul(vi p1, vi p2) {
	vi v(p1.size());
	rep(i, 1, p1.size()) v[i] = p1[p2[i]];
	return v;
}

const ll mod = 1000000007;
ll bm(ll b, ll p, ll m) {
	ll r = 1;
	for (; p; p >>= 1, b = b * b % m) if (p & 1) r = r * b % m;
	return r;
}
ll inv(ll x) { return bm(x, mod - 2, mod); }

typedef vector<ll> vll;

const ll primes[12] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	int n, q; cin >> n >> q;
	vi p(n + 1);
	rep(i, 1, n + 1) cin >> p[i];
	
	vector<vi> powers(41);
	powers[0] = id(n);
	rep(i, 1, 41) powers[i] = pmul(powers[i - 1], p);

	vll deg(n + 1);
	rep(i, 1, n + 1) {
		rep(j, 1, 41) if (i == powers[j][i]) { deg[i] = j; break; }
	}

	vll val(n + 1), ps(n + 1);
	rep(i, 1, n + 1) {
		int a = i;
		rep(j, 0, deg[i]) { val[i] += a; a = p[a]; }
		val[i] = val[i] * inv(deg[i]) % mod;
		ps[i] = (ps[i - 1] + val[i]) % mod;
	}

	// sparse table of prime factors
	vector<vector<vi>> degpf(12, vector<vi>(17, vi(n + 1)));
	rep(i, 1, n + 1) {
		int d = deg[i];
		rep(j, 0, 12) while (d % primes[j] == 0) degpf[j][0][i]++, d /= primes[j];
	}
	rep(i, 0, 12) rep(j, 1, 17) rep(k, 1, n + 1) if (k + (1 << (j - 1)) <= n) {
		degpf[i][j][k] = max(degpf[i][j - 1][k], degpf[i][j - 1][k + (1 << (j - 1))]);
	}

	rep(i, 0, q) {
		int l, r; cin >> l >> r;
		ll lcm = 1;
		ll l2v = 0; // value of log2
		while ((1 << (l2v + 1)) < r - l + 1) l2v++;
		rep(j, 0, 12) {
			int mx = max(degpf[j][l2v][l], degpf[j][l2v][r - (1 << l2v) + 1]);
			rep(k, 0, mx) lcm = lcm * primes[j] % mod;
		}
		ll sum = (ps[r] - ps[l - 1] + mod) % mod;
		cout << sum * lcm % mod << endl;
	}

	/* naive solution
	rep(i, 0, q) {
		int l, r; cin >> l >> r;
		ll lcm = 1; // wrong, need prime fact
		rep(i, l, r + 1) lcm = lcm * deg[i] / __gcd(lcm, deg[i]);
		ll sum = ps[r] - ps[l - 1];
		cout << sum * lcm % mod << endl;
	}
	*/
}



Measured memory_bytes: 108500
#include <stdio.h>
int main(void){
    int a,b,j,w[5],n=0;
    scanf("%d%d\n",&a,&b);
    for (j=a;j<=b;j++){
	w[0]='0'+j%10;
	w[1]='0'+(j/10)%10;
	w[2]='0'+(j/100)%10;
	w[3]='0'+(j/1000)%10;
	w[4]='0'+(j/10000)%10;

	if(w[0]==w[4]&&w[1]==w[3])n++;
    } 
    printf("%d\n",n);
    return 0;
    }



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

int main(){
	string s;
    cin >> s;
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
  {
   cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  k = min(n,k);
  ll ans = 0;
  rep(i,k) {
    h.pop_back();
  }
  rep(i,h.size()) ans += h[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	type work struct{ t, l int }
	ws := make([]work, n)
	for i := range ws {
		ws[i].t, ws[i].l = scanInt(), scanInt()
	}

	sort.Slice(ws, func(i, j int) bool { return ws[i].l < ws[j].l })
	sum := 0
	for _, w := range ws {
		sum += w.t
		if sum > w.l {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 7580
import itertools
from functools import cmp_to_key
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

string = readline().decode().replace(".", "")
A, B = [int(i) for i in string.split()]

ret = A*B
ret = ret//100

print(ret)


Measured memory_bytes: 9640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000009;
//ll mod = 998244353;

int gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n%m);
}

int main() {
	ll n, a, d;
	cin >> n >> a >> d;
	if (d == 0) {
		if (a == 0) cout << 1 << endl;
		else {
			cout << n + 1 << endl;
		}
		return 0;
	}
	ll na = abs(a), nd = abs(d);
	ll g = gcd(na, nd);
	a /= g; d /= g;
	if (d < 0) {
		a = a + d * (n - 1);
		d = -d;
	}
	vector<ll> nu;
	for (int i = 0; i < n; i++) {
		nu.push_back(a);
		a += d;
	}
	ll ans = 0;
	ll v = min(n, d);
	vector<ll> cnt1(v + 3, LINF), cnt2(v + 3, -LINF);
	ll l = 0, r = 0;
	for (ll i = 1; i <= n; i++) {
		l += nu[i - 1];
		r += nu[n - i];
		ans += i * (n - i) + 1;
		if (cnt1[i%d] != LINF) {
			if (l <= cnt1[i%d] && cnt2[i%d] <= r) {
				ans -= (cnt2[i%d] - cnt1[i%d]) / d + 1;
			}
			else if (l <= cnt1[i%d] && cnt1[i%d] <= r && r <= cnt2[i%d]) {
				ans -= (r - cnt1[i%d]) / d + 1;
			}
			else if (cnt1[i%d] <= l && l <= cnt2[i%d] && cnt2[i%d] <= r) {
				ans -= (cnt2[i%d] - l) / d + 1;
			}
			else if (cnt1[i%d] <= l && r <= cnt2[i%d]) {
				ans -= (r - l) / d + 1;
			}
		}
		cnt1[i%d] = min(cnt1[i%d], l);
		cnt2[i%d] = max(cnt2[i%d], r);
	}
	ll x = 0, y = 0;
	if (n >= d) {
		for (int i = 0; i < d; i++) x += nu[i];
		for (int i = n - 1; i >= n - d; i--) y += nu[i];
		if (x>0&&y>0) ans++;
		if (x < 0 && y < 0) ans++;
	}
	else ans++;
	cout << ans << endl;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int i,n,a[52];
long long x;
string s,t;
main(){
  cin>>n>>s>>t;
  if(s[0]==s[1])i=2,x=6;
  else i=1,x=3;
  for(;i<s.size();){
    if(s[i]==s[i+1]){
      if(s[i-2]==s[i-1])x=x*3%MOD;
      else x=x*2%MOD;
      i+=2;
    }
    else if(s[i-1]==t[i-1])x=x*2%MOD,++i;
    else ++i;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 10000000
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
using namespace std;
int main()
{
	long n, q;
	cin >> n >> q;
	long p = 0;
	for(int i = 0; i < q; i++)
	{
		long t, k;
		cin >> t >> k;
		if(t == 1)
		{
			p += k;
		}
		else
		{
			cout << (p + k - 1) % n + 1 << endl;
		}
	}	
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
const int mod=1e9+7;

int qpow(int a,int b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

int n,h,d,fac=1,sfac=1,f[N],s[N];

int main() {
	cin>>n>>h>>d;
	for(int i=2;i<=n;i++) fac=1ll*fac*i%mod,sfac=(sfac+fac)%mod;
	f[0]=s[0]=1;
	for(int i=1;i<=h;i++) f[i]=1ll*(s[i-1]-(i-d<1?0:s[i-d-1])+mod)*sfac%mod,s[i]=(s[i-1]+f[i])%mod;
	cout<<1ll*f[h]*fac%mod*qpow(sfac,mod-2)%mod;
	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

map<int64_t, int> 
prime_factor(int64_t n){
    map<int64_t, int> ret;
    for (int64_t i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

int main() {
    ll N;
    cin >> N;
    int ans = 0;
    for (auto p : prime_factor(N)){
        int num = p.second;
        for(int i=1;i<=num;i++){
            num -= i;
            ans ++;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    ll K;cin>>K;
    cout<<50<<endl;
    ll a=K/50,b=K%50;
    vector<ll> S(50);
    for(int i=0;i<50;i++){
        S[i]=i;
    }
    for(int i=0;i<b;i++){
        S[49-i]++;
    }
    for(int i=0;i<50;i++){
        if(i) cout<<" ";
        S[i]+=a;
        cout<<S[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll solve(vector<ll> v){
  int base = 0;
  for(int i=61; i>=0; i--){
    bool flg = false;
    REP(j,base,v.size()){
      if((v[j]>>i)&1){
        swap(v[base], v[j]);
        flg = true;
      }
    }
    if(flg){
      rep(j,v.size()){
        if(j == base) continue;
        if((v[j]>>i)&1){
          v[j] ^= v[base];
        }
      }
      base++;
    }
  }

  ll ret = 0;
  rep(i,v.size()){
    ret ^= v[i];
  }
  return ret << 1;
}


int main(){
  int N;
  cin >> N;
  vector<ll> v;

  vector<int> w(65,0);
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
    rep(j,62){
      if((a>>j)&1) w[j]++;
    }
  }

  ll ret = 0;
  rep(j,62){
    if(w[j]%2==1){
      ret |= (1LL<<j);
    }
  }
  
  vector<ll> vv;
  rep(i,N){
    ll a = v[i];
    ll b = 0;
    rep(j,62){
      if(w[j]>0 && w[j]%2==0){
        b |= (1LL<<j) & a;
      }
    }
    vv.push_back(b);
  }

  ret += solve(vv);

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 2676
import sys
import io
import math
import re

datalist = input().split()
data_a = str(datalist[0])

if data_a == 'A':
  print('T')
elif data_a == 'T':
  print('A')
elif data_a == 'C':
  print('G')
elif data_a == 'G':
  print('C')

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

    private static Scanner sc;

    public Main() {
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();
    }

    private void solve() {
        int n = sc.nextInt();

        int ans = Integer.MIN_VALUE;
        int min = sc.nextInt();
        for (int i = 0; i < n - 1; i++) {
            int tmp = sc.nextInt();
            ans = Math.max(ans, tmp - min);
            min = Math.min(min, tmp);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 99044
awk '$0=NR%2FS$NF' RS=\ |sort|uniq -c|sort -n|awk '{s+=$1}$2{b=a;a=$1;c=$3}!$2{e=d;d=$1;f=$3}END{print s-(c~f?a+e<b+d?b+d:a+e:a+d)}'

Measured memory_bytes: 11752
n = int(input())
s = list(input())
mod = 10 ** 9 + 7
alph_count = [0] * 200
ans = 0
for i in s:
    m = ord(i)
    alph_count[m] += 1
    c = 1
    for j in range(97, 123):
        if not m == j:
            c *= alph_count[j] + 1
        c %= mod
    ans += c
    ans %= mod
print(ans)

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

  


void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
    int X;cin>>X;
     vec[X-1] = i + 1;
  }
  vector<int> A (N,0);
  vector<int> B (N,0);
  for (int i = 0; i < N; i++)
  {
    A[i] = 30000*(i+1);
    B[i] = 30000*(N-i-1) + vec[i];
  }
  for (int i = 0; i < N; i++)
  {
    if(i != 0)cout<<char(32);
    cout<<A[i];
  }
  cout<<endl;
  for (int i = 0; i < N; i++)
  {
    if(i != 0)cout<<char(32);
    cout<<B[i];
  }
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main(){
    int n; cin >> n;
    int x = 1; int y = 2;
    bool ok = false;
    while(x*y <= 2*n){
        if(x*y == 2*n){
            ok = true; break;
        }
        x++; y++;
    }
    if(!ok){
        cout<<"No"<<endl;
        return 0;
    }else cout<<"Yes"<<endl;

    vector<vector<int>> sets(y);
    rep(i,0,y) sets[i].push_back(x);
    sets[0].push_back(1); sets[1].push_back(1); 
    int now = 1; int stop = 3; int step = 3; int h2 = 2;
    while(now < n){
        int h1 = 0;
        while(now < stop){
            now++;
            sets[h1++].push_back(now);
            sets[h2].push_back(now);
        }
        h2++; stop+=step++;
    }

    cout<<y<<endl;
    rep(i,0,y){
        rep(j,0,x+1){
            cout<<sets[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 2304
<?php
fscanf(STDIN, "%d", $n);
$inputs = array_map('intval', explode(' ', trim(fgets(STDIN))));
$max = max($inputs);

$decs = [];
for ($i = 1; $max >= $i; $i++) {
    $tmp = 0;
    foreach ($inputs as $input) {
        $x = $input - $i;
        $y = pow($x, 2);
        #echo join(", ", [$input, $i, $n, $x, $y]) . "\n";
        $tmp += $y;
    }
    #echo "=" . $tmp . "\n";
    $decs[] = $tmp;
}
#echo join(",", $decs) . "\n";
echo min($decs);


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

int main() {
    int time, hour, minute, second;
    cin >> time;
    hour = time / 60 / 60;
    minute = time / 60 % 60;
    second = time % 60 % 60;
    cout << hour << ":" << minute << ":" << second << endl;
}


Measured memory_bytes: 3120
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#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>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long N, M;
    cin >> N >> M;

    long long ans = (1900 * M + (N - M) * 100) * pow(2, M);
    cout << ans << endl;

    return 0;
}




















































































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

int main() {
	int n,r;//1~50
	int p,c;
	int card[50]={};
	int cut[50]={};
	int i,j;
	int finish=0;
	
	scanf("%d%d",&n,&r);
	while(finish==0){
	for(i=0;i<n;i++){
		card[i]=n-i;
//		printf("0\t %d\n",card[i]);
	}
	for(j=0;j<r;j++){
		scanf("%d%d",&p,&c);
		for(i=0;i<c;i++){
			cut[i]=card[p+i-1];
//			printf("1\t %d\n",cut[i]);
		}
		for(i=p-2;i>-1;i--){
			card[i+c]=card[i];
//			printf("2\t %d\n",card[i]);
		}
		for(i=0;i<c;i++){
			card[i]=cut[i];
		}
	}
//	for(i=0;i<n;i++){
//		printf("3\t %d\n",card[i]);
//	}
	printf("%d\n",card[0]);
	scanf("%d%d",&n,&r);
	if((n==0)&&(r==0)){finish=1;}
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111





	void solve(){

		ini(n);
		vi morty(3*n);
		FOR(i,0,3*n){
			in(morty[i]);
		}
		multiset<pair<int,int>>ll,rrin,rrout;
		int tmp =0 ;
		int tmp1 = 0;
		FOR(i,0,n){
			ll.insert({morty[i],i});
			tmp+=morty[i];
		}
		FOR(i,n,n*3){
			rrout.insert({morty[i],i});
		}
		FOR(i,0,n){
			rrin.insert(*rrout.begin());
			tmp1+= (*rrout.begin()).first;
			rrout.erase(rrout.begin());
		}
		int rick = tmp-tmp1;
		FOR(i,n,n*2){
			tmp+=morty[i];
			ll.insert({morty[i],i});
			tmp-=(*ll.begin()).first;
			ll.erase(ll.begin());

			if(rrin.count({morty[i],i})){
				tmp1-=morty[i];
				rrin.erase({morty[i],i});
				rrin.insert(*rrout.begin());
				tmp1+=(*rrout.begin()).first;
				rrout.erase(rrout.begin());
			}
			else{
				rrout.erase({morty[i],i});
			}
			rick = max(rick,tmp-tmp1);
		}
		out(rick);














	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 23040
def main():
    mod = pow(10, 9)+7
    k = int(input())
    s = input()
    n = len(s)
    ans = 0
    key = pow(26, k, mod)
    sub = 1
    c = 1
    for i in range(k+1):
        ans += key*sub*c
        ans %= mod
        sub *= 25
        sub %= mod
        key = key*pow(26, mod-2, mod)%mod
        c *= (n+i)
        c *= pow(i+1, mod-2, mod)
        c %= mod
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 75224
N = int(input())
a = [int(i) for i in input().split()]

counter = 0
for i in range(N):
    A = a[i]
    # while 2 * 2 <= A:
    while A % 2 == 0:
        A /= 2
        counter += 1
        # break
print(int(counter))


Measured memory_bytes: 4148
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] arrayA = new int[n][m];
		int[] arrayB = new int[m];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				arrayA[i][j] = scan.nextInt();
			}
		}
		for(int i = 0; i< m; i++){
			arrayB[i] = scan.nextInt();
		}
		int intCount = 0;
		for(int i = 0; i < n; i++){
			intCount = 0;
			for(int j = 0; j < m; j++){
				intCount += arrayA[i][j] * arrayB[j];
			}
			System.out.println(intCount);
		}
		scan.close();
	}
}

Measured memory_bytes: 31868
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 	int64_t N,T;
	 cin>>N>>T;
	vector<int64_t>t(N);
	for(int i=0;i<N;i++){
		cin>>t[i];
	}
    int64_t sum=0;
	for(int i=0;i<N;i++){
		if(i<N-1){sum+=min(T,t[i+1]-t[i]);}
		else{sum+=T;}		  
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
_DEC = lambda x: x-1
MIIZ = lambda: list(map(_DEC, MII()))

def main():
    n = II()
    aa = MII()
    aa.sort(reverse=True)
    alice = aa[0::2]
    bob = aa[1::2]
    print(sum(alice)-sum(bob))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;
import static java.lang.Math.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int p =sc.nextInt();

        int sum = a*3 + p;

        System.out.println(sum/2);
    }
}
    

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN 402
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
ll dp[MAXN][MAXN];
int main()
{
	fastio;
	int n;cin>>n;
	vll a(n+1);
	for(int i=1;i<=n;i++)cin>>a[i];
	memset(dp,0,sizeof(dp));
	vll prefix(n+1);
	for(int i=1;i<=n;i++)
	{
		prefix[i]=prefix[i-1]+a[i];
	}
	for(int len=0;len<n;len++)
	{
		for(int i=1;i+len<=n;i++)
		{
			int j=i+len;
			if(len==0)dp[i][i]=0;
			else
			{
				dp[i][j]=LLONG_MAX;				
				for(int k=i;k<j;k++)
				{
					dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+prefix[k]-prefix[i-1]+prefix[j]-prefix[k]);
				}
			}
		}
	}
	cout<<dp[1][n]<<endl;
}


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

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 111;
int n; int a[maxn], b[maxn];

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

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

  for (int i=1; i<=n; i++) {
    cin>>b[i];
    b[i] += b[i-1];
  }

  int best = 0;

  for (int i=1; i<=n; i++) {
    //step down at ith step
    int cur = a[i] + (b[n] - b[i-1]);
    best = max(best, cur);
  }

  out(best);  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <unordered_set>
#include <map>
#include <cstring>

using namespace std;

int Solve(string s) {
    int n = s.size();
    int cnt = 1;
    char tmp = s[0];
    for (int i = 1; i < n; i++) {
        if (cnt == 0) {
            cnt = 1;
            tmp = s[i];
            continue;
        }
        if (s[i] != tmp) {
            cnt--;
        }
        else {
            cnt++;
        }
    }
    return n - cnt;
}


int main() {
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    cout << Solve(S);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;
    int contest[3] = {0};
    rep(i, n) {
        int p; cin >> p;
        if (p <= a) ++contest[0];
        else if (p >= a + 1 && p <= b) ++contest[1];
        else ++contest[2];
    }

    cout << *min_element(contest, contest + 3) << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

if (N - 1) * (N  - 2) // 2 < K:
    print(-1)
    
else:
    M = (N - 1) + ((N - 1) * (N - 2) // 2 - K)
    print(M)
    
    for i in range(N - 1):
        print(i + 1, N)
    
    cnt = M - (N - 1)
    start = 1
    while cnt != 0:
        for i in range(start, N - 1):
            print(start, i + 1)
            cnt -= 1
            if cnt == 0:
                break
        start += 1

Measured memory_bytes: 42736
-- 1_3_D
main = do cs <- getLine
          let [a, b, c] = map (\x -> read x :: Int) $ words cs
          print $ length $ filter (is_divisor c) [a..b]

is_divisor :: Int -> Int -> Bool
is_divisor a b = if a `mod` b == 0
                    then True
                    else False

Measured memory_bytes: 4064
l=input()
n=len(l)
mod=10**9+7
dp=[[0]*2 for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
  dp[i][1]+=dp[i-1][1]*3
  if l[i-1]=='1':
    dp[i][0]+=2*dp[i-1][0]
    dp[i][1]+=dp[i-1][0]
  else:
    dp[i][0]+=dp[i-1][0]
  dp[i][0]%=mod
  dp[i][1]%=mod
print((dp[i][0]+dp[i][1])%mod)

Measured memory_bytes: 19700
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()	
	{
		string[] S = new string[3];
		for(int i = 0; i < 3; i++)
			S[i] = GetString();
		
		int[] index = new int[3];
		char turn = 'a';
		while(true)
		{
			switch(turn)
			{
				
			case 'a':
				if(index[0] == S[0].Length)
				{
					Console.WriteLine("A");
					return;
				}
				turn = S[0][index[0]];
				index[0]++;
				break;

			case 'b':
				if(index[1] == S[1].Length)
				{
					Console.WriteLine("B");
					return;
				}
				turn = S[1][index[1]];
				index[1]++;
				break;

			case 'c':
				if(index[2] == S[2].Length)
				{
					Console.WriteLine("C");
					return;
				}
				turn = S[2][index[2]];
				index[2]++;
				break;
		
			}
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <time.h>

typedef long long int ll;
using namespace std;
#define vl vector<ll>
#define vi vector<int>
#define ff first
#define ss second

void solve() {
    int n, W;
    cin >> n >> W;
    vl dp(W + 1, 0);
    for (int i = 0; i < n; i++) {
        int weight, value;
        cin >> weight >> value;
        for (int w = W; w >= 0; w--) {
            if (w - weight >= 0) dp[w] = max(dp[w], value + dp[w - weight]);
        }
    }
    ll ans = 0;
    for (auto op : dp) ans = max(op, ans);
    cout << ans << endl;
}


int main() {
#ifdef _DEBUG // place in cmake-build-debug folder
    freopen("in.txt", "r", stdin);
    freopen(
    for (int i = idx + 1; i < n; i++) {
        res[i] = min(res[i - 1], m[i]);
    }
    for (int i = idx - 1; i >= 0; i--) {
        res[i] = min(res[i + 1], m[i])"out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    int q;
//    cin >> q;
//    for (int i = 1; i <= q; i++) {
//        // cout << "Case #" << i << ": ";
//        solve();
//    }
    solve();

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
#define fastscan ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define error(x) cout << #x <<": " << x <<"\n"
#define exit exit(0);

using namespace std;



int32_t main(){

    fastscan;

    std::vector<int> g[5];

    for(int i = 0; i < 3; ++i){
        int u,v;

        cin >> u >> v;

        g[u].push_back(v);
        g[v].push_back(u);

    }

    for(int i = 1; i <= 4; ++i){
        if(g[i].size() == 3){
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";

    return 0;
}

Measured memory_bytes: 256
#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#from decimal import Decimal
#mod = 1000000007
#mod = 998244353
#N = int(input())
N, K = map(int, input().split())
S = input()
#A = list(map(int, input().split()))
#flag = True
if N==1:
  print(0)
  exit()
cnt = 0
if S[0] == 'R':
  if S[1] == 'R':
    cnt += 1
if S[-1] == 'L':
  if S[-2] == 'L':
    cnt += 1
for k in range(1,N-1):
  if S[k] == 'L':
    if S[k-1] =='L':
      cnt += 1
  else:
    if S[k+1] == 'R':
      cnt += 1

ans = min(N-1, cnt+2*K)

print(ans)
#print('Yes')
#print('No')

Measured memory_bytes: 66552
# frozen_string_literal: true

n = gets.to_i

ans = 1e9
(1...n).each do |i|
  j = n - i
  i_sum = 0
  i.to_s.split('').map(&:to_i).each do |k|
    i_sum += k
  end

  j_sum = 0
  j.to_s.split('').map(&:to_i).each do |k|
    j_sum += k
  end

  ans = i_sum + j_sum if ans > (i_sum + j_sum)
end

puts ans


Measured memory_bytes: 2044
#include <iostream>
#include <cstdlib>

using namespace std;
int main() {
  int N;
  int X;
  int sum=0;
  int min=100001;
  int tmp;
  cin>>N>>X;
  for(int i=0;i<N;++i){
      cin>>tmp;
      sum+=tmp;
      if(tmp<min){
          min=tmp;
      } 
  }
  X-=sum;
  cout<<N+X/min<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
//static const int MIN = -2000000000;

int main() {
    // insert code here...
    int x;
    int n;
    int R[200000];
    int maxv;
    int minv;
    
    cin >> n;
    
    for (x=0; x<n; x++)
    {
        cin >> R[x];
    }
    
    maxv = -2000000000;
    minv = R[0];
    
    for (x=1; x<n; x++)
    {
        maxv = max(maxv,R[x]-minv);
        minv = min(minv,R[x]);
    }
    
    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3848
n = int(input())
a = []
lists = []
for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        a.append('FizzBuzz')
    elif i % 3 == 0:
        a.append('Fizz')
    elif i % 5 == 0:
        a.append('Buzz')
    else:
        a.append(str(i))

for item in a:
    item = item.replace('FizzBuzz', '0')
    item = item.replace('Fizz', '0')
    item = item.replace('Buzz', '0')
    lists.append(item)

print(sum([int(i) for i in lists]))


Measured memory_bytes: 112748
#include<algorithm>
#include<cstdio>
#define N 200005
#define p 1000000007
using namespace std;
int a[N],b[N],c[N],d[N],f[N],l,m,n,r,s[N],t;
inline bool cmp(int u,int v){return a[u]<a[v];}
inline bool CMP(int u,int v){return c[u]==c[v]?b[u]<b[v]:c[u]<c[v];}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",a+i,b+i),c[i]=d[i]=i;
	sort(c+1,c+n+1,cmp);
	for(int i=1;i<=n;i++)a[i]=b[c[i]];
	for(int i=1,l,o,r;i<=n;b[i++]=s[l])
	{
		for(l=0,r=t;l<r;)o=l+r>>1,a[s[o]]>a[i]?r=o:l=o+1;
		if(l==t)s[t++]=i;
	}t=0;
	for(int i=n,l,o,r;i;c[i--]=s[l])
	{
		for(l=0,r=t;l<r;)o=l+r>>1,a[s[o]]<a[i]?r=o:l=o+1;
		if(l==t)s[t++]=i;
	}
	sort(d+1,d+n+1,CMP),*f=1;
	for(int i=1,j=0;i<=n;i++)
	{
		while(j<=n&&c[d[j+1]]<i)j++;
		if(b[d[j]])f[i]=f[i-1]>=f[b[d[j]]-1]?f[i-1]-f[b[d[j]]-1]:p+f[i-1]-f[b[d[j]]-1];
		else f[i]=f[i-1];
		f[i]=f[i]+f[i-1]>=p?f[i]+f[i-1]-p:f[i]+f[i-1];
	}
	printf("%d\n",f[n]>=f[b[d[n]]-1]?f[n]-f[b[d[n]]-1]:p+f[n]-f[b[d[n]]-1]);
	return 0;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 200010;
const ll INF = 1LL << 60;

struct Node {
  int l, r;
  ll v;
  Node *ls, *rs;

  void ch(int k, ll x) {
    if (l == r) {
      v = x;
      return;
    }
    (k <= ls->r ? ls : rs)->ch(k, x);
    v = min(v, x);
  }

  ll qry(int l, int r) {
    if (this->l == l && this->r == r) return v;
    if (r <= ls->r) return ls->qry(l, r);
    if (l >= rs->l) return rs->qry(l, r);
    return min(ls->qry(l, ls->r), rs->qry(rs->l, r));
  }
};

Node* build(int l, int r) {
  static Node pool[N * 2], *top = pool;
  Node *p = top++;
  p->l = l;
  p->r = r;
  p->v = INF;
  if (l == r) {
    return p;
  }
  int mid = (l + r) >> 1;
  p->ls = build(l, mid);
  p->rs = build(mid + 1, r);
  return p;
}

vector<pair<int, int>> seg[N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;
  while (m--) {
    int l, r, c;
    cin >> l >> r >> c;
    seg[l].emplace_back(r, c);
  }
  Node* segTree = build(1, n);
  segTree->ch(n, 0);
  for (int i = n - 1; i; --i) {
    ll cur = INF;
    for (const auto& pr : seg[i]) {
      int r = pr.first, c = pr.second;
      cur = min(cur, segTree->qry(i + 1, r) + c);
    }
    segTree->ch(i, cur);
    if (i == 1) {
      if (cur >= INF) cur = -1;
      cout << cur << '\n';
    }
  }

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 15616
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <cstdlib>


using namespace std;

int main() {
    

    int a,b,c;
    int sum = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++ ){
        if (c%i == 0){
            sum += 1;
        }
    }
    cout << sum << endl;

}



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

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N;
	cin >>N;
	vector<string> s(N, "");
	vector<int> t(N, 0);
	Rep0(i, N)
		cin >>s.at(i) >>t.at(i);
	string X;
	cin >>X;
	int i=0;
	while(s.at(i)!=X)
		i++;
	int S=0;
	i++;
	while (i<N) {
		S +=t.at(i);
		i++;
	}
	cout <<S <<endl;
	return 0;
}



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

int main(){
	int a, b, c;

	cin >> a >> b >> c;

	for(int i = 1; i <= b; ++i){
		if((a * i) % b == c){
			cout << "YES\n";
			break;
		}else if(i == b){
			cout << "NO\n";
			break;
		}
	}

	return 0;
}
		

Measured memory_bytes: 256
n=gets.to_i
h=gets.split.map &:to_i
m=0
c=0
(n-1).times do |i|
  if h[i]>=h[i+1]
    c+=1
  else
    if m<c
      m=c
    end
    c=0
  end
end
if m<c
  m=c
end
p m


Measured memory_bytes: 9604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    string s;cin>>s;
    bool yes=true;

    if(s[0]!='A') yes=false;

    ll cnt = 0;
    bool BIG=false;
    ll key=-1;
    for(ll i=2;i<=s.size()-2;i++){
        if(s[i]=='C'){
            cnt++;
            key=i;
        }
    }

    rep(i,s.size()){
        if(i==0 || i==key) continue;
        if(!('a'<=s[i] && s[i]<='z')) BIG=true;
    }

    if (cnt != 1)
        yes = false;
    if (BIG)
        yes = false;

    if(yes) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;

    return 0;
}

Measured memory_bytes: 3564
class Node
  def initialize(key, priority)
    @key = key
    @priority = priority
    @parent = nil
    @left = nil
    @right = nil
  end
  attr_accessor :key, :priority, :parent, :left, :right
end

def right_rotate(node_t)
  node_s = node_t.left
  node_t.left = node_s.right
  node_s.right = node_t
  return node_s
end

def left_rotate(node_t)
  node_s = node_t.right
  node_t.right = node_s.left
  node_s.left = node_t
  return node_s
end

def insert(node_t, key, priority)
  if node_t == nil
    return Node.new(key,priority)
  end
  if key == node_t.key
    return node_t
  end

  if key < node_t.key
    node_t.left = insert(node_t.left, key, priority)
    if node_t.priority < node_t.left.priority
      node_t = right_rotate(node_t)
    end
  else
    node_t.right = insert(node_t.right, key, priority)
    if node_t.priority < node_t.right.priority
      node_t = left_rotate(node_t)
    end
  end
  return node_t
end

def find?(key)
  node_x = @root
  loop do
    if node_x == nil
      return false
    elsif node_x.key == key
      return node_x
    elsif key < node_x.key
      node_x = node_x.left
    else
      node_x = node_x.right
    end
  end
end

def delete(node_t, key)
  if node_t == nil
    return nil
  end
  if key < node_t.key
    node_t.left = delete(node_t.left, key)
  elsif key > node_t.key
    node_t.right = delete(node_t.right, key)
  else
    return _delete(node_t, key)
  end
  return node_t
end

def _delete(node_t, key)
  if node_t.left == nil && node_t.right ==nil
    return nil
  elsif node_t.left == nil
    node_t = left_rotate(node_t)
  elsif node_t.right == nil
    node_t = right_rotate(node_t)
  else
    if node_t.left.priority > node_t.right.priority
      node_t = right_rotate(node_t)
    else
      node_t = left_rotate(node_t)
    end
  end
  return delete(node_t, key)
end


def inorder_tree_walk(node)
  if node != nil
    inorder_tree_walk(node.left)
    print " "
    print node.key
    inorder_tree_walk(node.right)
  end
end

def preorder_tree_walk(node)
  if node != nil
    print " "
    print node.key
    preorder_tree_walk(node.left)
    preorder_tree_walk(node.right)
  end
end

def print_tree
  inorder_tree_walk(@root)
  puts
  preorder_tree_walk(@root)
  puts
end


@root = nil

m = gets.to_i
m.times do |t|
  input = gets.split(" ")
  command = input.shift
  input.map!{|x| x.to_i}
  if command == "insert"
    @root = insert(@root, input[0], input[1])
  elsif command == "find"
    if find?(input[0])
      puts "yes"
    else
      puts "no"
    end
  elsif command == "delete"
    @root = delete(@root, input[0])
  else
    print_tree
  end
end



Measured memory_bytes: 26488
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int c = 0;
	string s;
	cin >> s;
	for(int i = 1; i < int(s.length() - 1); i++){
		c++;
	}
	cout << s[0] + to_string(c) + s[int(s.length()) - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int q = scanner.nextInt();
			scanner.nextLine();
			long[] s = new long[a];
			IntStream.range(0, a).forEach(i -> {
				s[i] = scanner.nextLong();
				scanner.nextLine();
			});
			long[] t = new long[b];
			IntStream.range(0, b).forEach(i -> {
				t[i] = scanner.nextLong();
				scanner.nextLine();
			});
			long[] result = new long[q];
			IntStream.range(0, q).forEach(i -> {
				long x = scanner.nextLong();
				result[i] = nearest(x, s, t);
			});
			Arrays.stream(result).forEach(System.out::println);
		}
	}

	private static long nearest(long x, long[] s, long[] t) {
		long s1, s2, t1, t2;
		int sIndex = Arrays.binarySearch(s, x);
		int tIndex = Arrays.binarySearch(t, x);
		if (sIndex >= 0) {
			s1 = s2 = s[sIndex];
		} else {
			if (sIndex == -1) {
				s1 = s2 = s[0];
			} else if (sIndex == -s.length - 1) {
				s1 = s2 = s[s.length - 1];
			} else {
				s1 = s[-sIndex - 2];
				s2 = s[-sIndex - 1];
			}
		}
		if (tIndex >= 0) {
			t1 = t2 = t[tIndex];
		} else {
			if (tIndex == -1) {
				t1 = t2 = t[0];
			} else if (tIndex == -t.length - 1) {
				t1 = t2 = t[t.length - 1];
			} else {
				t1 = t[-tIndex - 2];
				t2 = t[-tIndex - 1];
			}
		}
		return min(distance(x, s1, t1), distance(x, s1, t2), distance(x, s2, t1), distance(x, s2, t2));
	}

	private static long distance(long x, long s1, long t1) {
		return Math.abs(s1 - t1) + min(Math.abs(s1 - x), Math.abs(t1 - x));
	}

	private static long min(long... x) {
		return Arrays.stream(x).min().getAsLong();
	}
}

Measured memory_bytes: 283556
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  if (a > 9 || b > 9)
    cout << -1 << endl;
  else
    cout << a * b << endl;
}

Measured memory_bytes: 3500
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int res = 0;
    for (int i = a; i <= b; i++) {
        if (i % 10 == i / 10000 && (i / 10) % 10 == (i / 1000) % 10) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;

int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}

signed main(){
	int n, a, b;
	cin >> n >> a >> b;
	int ans = mod_pow(2, n, mod)-1;
	ans = (ans + 2 * mod - comb(n, a) - comb(n, b))%mod;
	cout << ans << endl;
}

Measured memory_bytes: 256
/* Ashish Joshi
   NIT Hamirpur */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;
const int MAXN = 300005;

int  t[4*MAXN];

void build(int a[],int v, int tl, int tr){
    if(tl == tr){
        t[v] = a[tl];
    }else{
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2 + 1, tm + 1, tr);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}

int query(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(query(v*2, tl, tm, l, min(r, tm))
           , query(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void update(int v, int tl, int tr, int pos, int new_v){
    if(tl == tr){
        t[v] = max(t[v],new_v);
    }else{
        int tm = (tl + tr)/2;
        if(pos <= tm){
            update(v*2, tl, tm, pos, new_v);
        }else{
            update(v*2 + 1, tm + 1, tr, pos, new_v);
        }
        t[v] = max(t[v*2],t[v*2 + 1]);
    }
}

int dp[MAXN];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int temp[MAXN]={0};
    int n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    build(temp,1,0,MAXN-1);
    int ans=0;
    for(int i=0;i<n;i++){
        int l = max(0, a[i] - k), r = min(a[i] + k, (int)MAXN-1);
        int val = query(1, 0, MAXN-1, l, r);
        ans=max(ans,val+1);
        update(1, 0, MAXN-1, a[i], val+1);
    }
    cout<<ans;

}

Measured memory_bytes: 9760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int N, T, A;
    cin >> N >> T >> A;
    vector<pair<double, double> > H(N);
    rep(i, N){
        cin >> H[i].first;
        H[i].second = (double)max(T - H[i].first * 0.006 - A, A - (T - H[i].first * 0.006));
        //cout << H[i].second << endl;
    }
    double mdf = H[0].second;
    int m = 0;
    rng(i, 1, N){
        if(H[i].second < mdf){
            mdf = H[i].second;
            m = i;
        }
    }
    cout << m + 1 << endl;
    return 0;
}

Measured memory_bytes: 256