akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


struct mint {
	int x;
	mint(int x = 0) :x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= MOD)x -= MOD;
		return *this;
	}
	mint & operator-=(const mint a) {
		if ((x += MOD - a.x) >= MOD)x -= MOD;
		return *this;
	}
	mint & operator*=(const mint a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint a)const {
		return mint(*this) += a;
	}
	mint operator-(const mint a)const {
		return mint(*this) -= a;
	}
	mint operator*(const mint a)const {
		return mint(*this) *= a;
	}
	mint pow(int t)const {
		if (!t)return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1)a *= *this;
		return a;
	}

	//for prime mod
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a)const {
		mint res(*this);
		return res /= a;
	}
};
ostream& operator<<(ostream& os, const mint& m) {
	os << m.x;
	return os;
}


signed main() {
	string S;
	cin >> S;
	vector<vector<mint>>dp(S.size(), vector<mint>(13, 0));
	int num = 1;
	rep(i, S.size()) {
		int j = S.size() - 1 - i;
		if (S[j] != '?') {
			int d = S[j] - '0';
			d = (d * num) % 13;
			if (!i)dp[i][d] += 1;
			else {
				rep(k, 13) {
					int nd = (k + d) % 13;
					dp[i][nd] += dp[i - 1][k];
				}
			}
		}
		else {
			rep(D, 10) {
				int d = (D * num) % 13;
				if (!i)dp[i][d] += 1;
				else {
					rep(k, 13) {
						int nd = (k + d) % 13;
						dp[i][nd] += dp[i - 1][k];
					}
				}
			}
		}
		num *= 10;
		num %= 13;
	}
	mint ans = dp[S.size() - 1][5];
	cout << ans;
}

Measured memory_bytes: 16656
from collections import deque

N = int(input())
s = list(map(int, input().split()))
s.sort()
s = deque(s)
gosei = 0
i = 0
while len(s) > 1:
    x = s.popleft()
    y = s.popleft()
    gosei = (x + y) / 2
    s.appendleft(gosei)
print(gosei)


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<vector>
#define mp make_pair
#define fr first
#define sc second
using namespace std;

const int N=100005;

int n,ans,m,l,r,len,cnt,s,now,lft;
int a[N],b[N];
vector<int> lev[N];

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for (i=1;i<=n;i++) lev[a[i]%m].push_back(a[i]);
	if (m%2==0) ans+=lev[m/2].size()/2;
	ans+=lev[0].size()/2;
	for (i=1;i<=m/2;i++){
		if (m%2==0&&i==m/2) break;
		if (lev[i].size()<lev[m-i].size()) swap(lev[i],lev[m-i]);
		ans+=lev[m-i].size();
		len=lev[i].size()-1; cnt=0;
		for (l=0;l<=len;l=r+1){
			for (r=l;r<len&&lev[i][l]==lev[i][r+1];r++);
			b[++cnt]=r-l+1;
		}
		sort(b+1,b+1+cnt); lft=len+1-lev[m-i].size(); 
		for (j=cnt;j;j--){
			if (lft<=1) break;
			now=min(lft,b[j]);
			lft-=now/2*2; ans+=now/2;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6144
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    from itertools import accumulate

    n = int(input())
    a = list(map(int, input().split()))

    # See:
    # https://atcoder.jp/img/arc078/editorial.pdf
    # total_a = sum(a)
    summed_a = [0] + list(accumulate(a))
    total_a = sum(a)
    diff = float('inf')

    for i in range(1, n):
        diff = min(diff, abs(total_a - 2 * summed_a[i]))

    print(diff)


Measured memory_bytes: 24168
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    ll ans=1;
    rep(i,N-1){
        ans*=10;
    }
    if(N==1) ans=0;
    string anss=to_string(ans);

    vector<ll> A(N,-1);
    rep(i,M){
        ll x,y; cin>>x>>y; --x;
        if(A[x]!=-1 and A[x]!=y) dame;
        A[x]=y;
    }
    rep(i,N){
        if(A[i]==-1) continue;
        if(N!=1 and i==0 and A[i]==0) dame;
        anss[i]='0'+A[i];
    }
    cout<< anss <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  if(A*N>B) cout << B << endl;
  else  cout << A*N << endl;

  return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  int ans=0;
  int x=min(k,n);
  for(int i=0;i<=x;i++){
    for(int j=0;i+j<=x;j++){
      int score=0;
      int t=k-i-j;
      int s[i+j];
      for(int p=0;p<i;p++){
        s[p]=a[p];
        score+=s[p];
      }
      for(int p=i;p<i+j;p++){
        s[p]=a[p-i-j+n];
        score+=s[p];
      }
      sort(s,s+i+j);
      for(int p=0;p<t;p++){
        if(p<i+j&&s[p]<0){
          score-=s[p];
        }
      }
      ans=max(ans,score);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int abs(int x){
    if (x > 0) {
        return x;
    }else{
        return -x;
    }
}

int main(){
    int n, l;
    cin >> n >> l;
    int sm = 0;
    int mn = 10000;
    for(int i = 0; i < n; i++){
        sm += l + i;
        if (abs(mn) > abs(l + i)) {
            mn = l + i;
        }
    }
    int ans = sm - mn;
    cout << ans << endl;

}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    deque<int> vec;
    rep(i, n){
        int a;
        cin >> a;

        if(i % 2 == 0){
            vec.push_back(a);
        }else{
            vec.push_front(a);
        }
    }
    if(n % 2 == 1) reverse(all(vec));

    for (auto& p : vec) {
        cout << p << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,c=100;
  cin>>n;
  int i=0;
  while(true){
    c+=c/100;
    i++;
    if(c>=n){
      cout<<i;return 0;
    }
  }
}

Measured memory_bytes: 3636
#f_listとf_r_listの要素数は状況に応じて変えよう

MOD = 10**9 + 7
list_size = 2000003

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

def f(x, y):
	if x * y == 0:
		return 0
	elif x == 1:
		return y * (y+3) // 2
	else:
		return comb(x+y+2, x+1) - x - y - 2


r1, c1, r2, c2 = list(map(int, input().split()))
ans = (f(r2, c2) + f(r1-1, c1-1) - f(r1-1, c2) - f(r2, c1-1)) % MOD
print(ans)

Measured memory_bytes: 72172
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

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

    let &max_num = a.iter().max().unwrap();
    let is_set_wise = a.iter().fold(0, |acc, ai| acc.gcd(ai)) == 1;

    let era = Eratosthenes::new(max_num);
    let mut divisor_counter = vec![0; max_num + 1];

    for ai in a {
        let hm = era.factorization(ai);

        for (k, _v) in hm {
            divisor_counter[k] += 1;
        }
    }

    let is_pair_wise = *divisor_counter.iter().max().unwrap() <= 1;

    let ans = if is_pair_wise {
        "pairwise coprime"
    } else if is_set_wise {
        "setwise coprime"
    } else {
        "not coprime"
    };

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

use itertools::Itertools;
use std::collections::HashMap;
use num::Integer;
use rustc_hash::FxHashMap;
use smallvec::alloc::collections::BTreeMap;

/// 二分累乗法
pub fn pow(x: isize, n: usize) -> isize {
    if n == 0 {
        1
    } else if n == 1 {
        x
    } else if n % 2 == 1 {
        x * pow(x, n - 1)
    } else {
        pow(x * x, n / 2)
    }
}

/// エラトステネスの篩
/// 構築 O(N log log N)
/// 素因数分解 O(log N)
/// 素数判定 O(log N)
pub struct Eratosthenes {
    smallest_prime_factors: Vec<usize>,
}

impl Eratosthenes {
    pub fn new(n: usize) -> Self {
        let mut smallest_prime_factors = (0..=n).collect_vec();

        for i in 2.. {
            if i * i > n {
                break;
            }

            if smallest_prime_factors[i] != i {
                continue;
            }

            let mut j = i * i;
            while j <= n {
                if smallest_prime_factors[j] == j {
                    smallest_prime_factors[j] = i;
                }

                j += i;
            }
        }

        Self {
            smallest_prime_factors,
        }
    }

    pub fn factorization(&self, mut i: usize) -> BTreeMap<usize, usize> {
        assert_ne!(i, 0);

        let mut factors = BTreeMap::new();

        while i != 1 {
            let divisor = self.smallest_prime_factors[i];
            *factors.entry(divisor).or_insert(0) += 1;

            i /= divisor;
        }

        factors
    }

    pub fn is_prime(&self, i: usize) -> bool {
        i >= 2 && self.smallest_prime_factors[i] == i
    }
}


Measured memory_bytes: 28368
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    max_val = max(A)
    AA = A[:]
    AA.remove(max_val)
    second_max_val = max(AA)
    for a in A:
        if a != max_val:
            print(max_val)
        else:
            print(second_max_val)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14080
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

const double PI = acos(-1.0);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double total = h * 60 + m;
  double a1 = m / 60 * 360;
  double a2 = total / (12 * 60) * 360;
  double deg = abs(a1 - a2);
  cout << setprecision(17) << fixed;
  cout << sqrt(a * a + b * b - 2 * a * b * cos(deg * PI / 180));
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

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

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

void solve() {
  string t = "yuiophjklnm";
  auto check = [&](char c) {
    rep(i, t.size()) if (t[i] == c) return true;
    return false;
  };
  while (true) {
    string s; cin >> s;
    if (s == "#") return;
    bool prev = check(s[0]);
    int ans = 0;
    reps(i, s.size() - 1) {
      if (prev != check(s[i])) {
        ans++;
        prev = !prev;
      }
    }
    cout << ans << '\n';
  }
}



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

using namespace std;
typedef long long ll;

int main(void)
{   int A,B,C;
    cin>>A>>B>>C;

    if(A+B+C>=22){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }


    return 0;
}

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

// ??°???input????????????string??¨??????????´??????????????????¨
// ???????????????????????\???char??¨????????????????????????c - '0'??§int???

int main() {
	vector<string> v;
	string temp;
	int n;
	long sum = 0;
	while(1) {
		cin >> temp;
		if (temp == "0") break;
		v.push_back(temp);
	}

	for (auto str : v) {
		temp = str;
		for (char& c : str) {
			n = c - '0';
			sum += n;
		}
		cout << sum << endl;
		sum = 0;
	}
	return 0;
}

Measured memory_bytes: 3128
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

l = S_LIST() 
op = l[1]
a = int(l[0])
b = int(l[2])
if op == "-":
    print(a-b)
else:
    print(a + b)


Measured memory_bytes: 5192
n, q = gets.chomp.split(" ").map(&:to_i)
ans = Array.new(n, 0)
g = Array.new(n).map{Array.new}
bfs = []
(n-1).times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    g[a-1] << b-1
    g[b-1] << a-1
end
q.times do
    pi, xi = gets.chomp.split(" ").map(&:to_i)
    ans[pi-1] += xi
end
flag = Array.new(n, false)
queue = [0]
while !queue.empty?
    v = queue.shift()
    flag[v] = true
    g[v].each do |e|
        next if flag[e]
        ans[e] += ans[v]
        queue.push(e)
    end
end
print ans.join(" ")

Measured memory_bytes: 28924
#include<stdio.h>
int main(){
    int b,i,n,a[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;i>=0;i--){
        printf("%d",a[i]);
        if(i!=0){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}



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

const int MAX = 110;

int main()
{
    int N, M, ans = 0;
    string tmp, word[MAX];
    map<string, int> s_map;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        word[i] = tmp;
        s_map[tmp]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> tmp;
        s_map[tmp]--;
    }
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, s_map[word[i]]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"CODEFESTIVAL"# => r#"CODE FESTIVAL"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        s: chars,
    }
    let mut ans = "".to_string();

    for i in 0..s.len() {
        ans.push_str(&s[i].to_string());
        if i == 3 {
            ans.push_str(&" ");
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  int ans = 0;
  for (int i = 0; i < n; i++)
    cin >> p[i];
  map<int, int> mp;
  for (int i = n - 1; i >= 0; i--) {
    mp[p[i]] = mp[p[i] + 1] + 1;
    ans = max(ans, mp[p[i]]);
  }
  cout << n - ans << endl;
  return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
#define mx 1000011
int dp[mx];
void solve()
{

  int n;
  cin>>n;
 for(int i=2;i<mx;i++)
 {if(!dp[i])
 {
     for(int j=i;j<mx;j+=i)
            dp[j]=i;
 }
 }
 int ans=1;

 for(int i=2;i<=n-1;i++)
 {
     int x=i;
    map<int,int> mp;
    while(x!=dp[x])
    {
        int f=dp[x];
        mp[f]+=1;
        x/=dp[x];
    }
    mp[x]+=1;
        map<int,int>::iterator it=mp.begin();
        int res=1;
        for(;it!=mp.end();it++)
        {
            int r=it->second;
            res*=(r+1);
        }
        ans+=res;
 }
 cout<<ans<<endl;

}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
    return 0;
}


Measured memory_bytes: 11468
#include <iostream>
#include<stdio.h>
#include<cctype>
using namespace std;
int main() {
char ch;
while(true){
  scanf("%c",&ch);
  if(isupper(ch))ch=tolower(ch);
  else ch=toupper(ch);
  cout<<ch;
  if(ch=='\n')break;
}
  return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll n;
	cin>>n;
	ll ans = 1e18;
	for(int i=0;i<n;i++) {
		ll x,temp=0;cin>>x;
		while(x%2==0)
			temp++,x/=2;
		ans=min(ans,temp);
	}
	cout<<ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}

int main() {
	VI a(3); CI a; sort(all(a));

	CO a[0] * a[1] / 2 EN;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

int main() {
	std::string S;
	std::set<char> exit;

	std::cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (exit.count(S[i]) == 0) {
			exit.insert(S[i]);
		}
	}

	if (exit.size() == 2) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int a[N], b[N], c[N];
  int dp[N+1][3];
  for(int i=0; i<N+1; i++) for(int j=0; j<3; j++) dp[i][j] = 0;
  for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];
  for(int i=0; i<N; i++){
    dp[i+1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
    dp[i+1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
    dp[i+1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
  }
  int ans = 0;
  ans = max(dp[N][0], dp[N][1]);
  ans = max(ans, dp[N][2]);
  cout << ans << endl;
  return 0;
}


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

string c="Christmas";
string eve="Eve";
int main(){
    int d;
    cin>>d;
    cout<<c;
    for(int i=0;i<25-d;i++){
        cout<<" "<<eve;
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

#ifndef errOut
#define errOut(s)
#endif

using Value = int64_t;

struct Row {
    Value a;
    Value b;

    Row(Value a_ = INT64_C(0), Value b_ = INT64_C(0)) : a(a_), b(b_) {
    }

    Value diff() const {
        return a - b;
    }
};

ostream &operator<<(ostream &os, const Row &row) {
    os << "a: " << row.a << ", " << "b: " << row.b;
    return os;
}

Value calc(std::vector<Row> &rows) {
    Value ret = 0;
    for (auto &&row: rows) {
        if (row.diff() >= 0) {
            continue;
        }
        ret += row.a;
        row.b -= row.a;
        row.a = 0;
    }

    std::sort(rows.begin(), rows.end(), [](Row x, Row y) -> bool {
        if (x.diff() == 0 && y.diff() == 0) {
            return x.b > y.b;
        }
        if (x.diff() == 0) {
            return true;
        }
        if (y.diff() == 0) {
            return false;
        }
        if (x.diff() > 0 && y.diff() > 0) {
            return x.b > y.b;
        }
        if (x.diff() >= 0) {
            return true;
        }
        if (y.diff() >= 0) {
            return false;
        }
        return x.diff() > y.diff();
    });

    auto itr = rows.rbegin();
    for (; itr != rows.rend(); ++itr) {
        const auto &row = *itr;
        if (row.diff() < 0) {
            continue;
        }
        ret += row.diff();
        ++itr;
        break;
    }
    for (; itr != rows.rend(); ++itr) {
        const auto &row = *itr;
        ret += row.a;
    }
    return ret;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<Row> rows(n, Row());
    bool anyDiff = false;
    for (int i = 0; i < n; ++i) {
        std::cin >> rows[i].a >> rows[i].b;
        if (rows[i].diff()) {
            anyDiff = true;
        }
    }
    if (!anyDiff) {
        std::cout << 0 << std::endl;
        return 0;
    }
    std::cout << calc(rows) << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;


struct Edge{
    int from,to;
    LL capacity;
    Edge(int from,int to, LL capacity)
        : from(from),to(to),capacity(capacity) {};
};
typedef pair<int,int> pii;
typedef vector<vector<Edge>> Graph;
typedef vector<unordered_map<int, LL>> Flow; //(to,flow)
//typedef vector<vector<LL>> Flow;

LL add_flow(const Graph &g, Flow &flow, const vector<int> &level, vector<int> &iter, int u, int t, LL cur){
    if(u==t || cur==0) return cur;
    //if(iter[u]==g[u].size()) return 0;
    //fin[u]=true;
    for(int &i= iter[u];i<g[u].size();++i){
        auto e=g[u][i];
        if(level[e.to] > level[u]){
            LL f= add_flow(g, flow, level, iter, e.to, t, min(cur,e.capacity-flow[e.from][e.to]));
            if(f > 0){
                flow[e.from][e.to] += f;
                flow[e.to][e.from] -= f;
                //fin[u]=false;
                return f;
            }
        }
    }
    return 0;
}

LL MaximumFlow(const Graph &g, Flow &flow, int s, int t){
    const LL INF=1<<30;
    int n=g.size();
    LL total=0;
    for(bool cont = true ; cont;){
        cont =false;
        vector<int> level(n,-1);
        level[s]=0;
        queue<int> Q;
        Q.push(s);
        for(int d = n; !Q.empty() && level[Q.front()] < d;){
            int u = Q.front();
            Q.pop();
            if(u == t) d = level[u];
            for(auto e : g[u]){
                if(e.capacity>flow[e.from][e.to] && level[e.to]==-1){
                    Q.push(e.to);
                    level[e.to]=level[u]+1;
                }
            }
        }
        vector<bool> fin(n);
        vector<int> iter(n);
        for(LL f=1 ; f>0;){
            f=add_flow(g,flow,level,iter,s,t,INF);
            if(f==0)break;
            total += f;
            cont = true;
        }
    }
    return total;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; //vertex,edge
    cin >> n >> m;
    vector<vector<Edge> > G(n);
    Flow flow(n);
    for(int i = 0 ; i < m ; i++){
        int a,b;
        LL cost,cap;
        cin >> a >> b >>cap;
        G[a].push_back(Edge(a,b,cap));
        G[b].push_back(Edge(b,a,0));
    }
    cout << MaximumFlow(G,flow,0,n-1) << endl;

    return 0;
}

Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 4000
#define offset 220010
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<double,double> iib;
typedef pair<ll,ii> iii;
typedef pair<map<ll,ll> ,ll> mi;
typedef pair<ii,ii> iiii;
typedef vector<ll> vi;
vector<string> ops;
int dp[123456];
string txt;

bool f(int pos)
{
    if (pos==txt.size())
        return true;
    if (dp[pos]!=-1)
        return dp[pos];
    bool tot=0;
    forr(i,0,ops.size())
    {
        bool cond=1;
        forr(j,0,ops[i].size())
        {
            if (txt[pos+j]!=ops[i][j])cond=false;
        }
        if (cond)
            tot|=f(pos+ops[i].size());
    }
   // cout<<pos<<" "<<tot<<endl;
    return dp[pos]=tot;
}
int  main()
{
    ops.pb("dream");
    ops.pb("dreamer");
    ops.pb("erase");
    ops.pb("eraser");
    cin>>txt;
    memset(dp,-1,sizeof dp);
    if (f(0)==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
} 

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

int main(){
  int N,M;cin>>N>>M;
  vector<int> A(N),B(N),C(M),D(M);
  for(int i=0;i<N;i++) cin>>A.at(i)>>B.at(i);
  for(int i=0;i<M;i++) cin>>C.at(i)>>D.at(i);
  vector<int> ans;
  for(int i=0;i<N;i++){
    int count;
    int X=1000000000;
    for(int j=0;j<M;j++){
      int Y=abs(A.at(i)-C.at(j))+abs(B.at(i)-D.at(j));
      if(X>Y){
        count=j+1;
        X=Y;
      }
    }
    ans.push_back(count);
  }
  for(int i=0;i<N;i++) cout<<ans.at(i)<<endl;
}
    


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
int main()
{
    fast;
   
    string s;
    cin>>s;
    if(s=="AAA" or s=="BBB") cout<<"No";
    else cout<<"Yes";
}

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

int n;
vector<vector<bool>> check(3, vector<bool>(3, false));

void checked(vector<vector<int>> &a, vector<int> &b) {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a.at(i).at(j) == b.at(k)) {
                    check.at(i).at(j) = true;
                }
            }
        }
    }
}

bool bingo() {
    for (int i = 0; i < 3; i++) {
        if (check.at(i).at(0) == true && check.at(i).at(1) == true && check.at(i).at(2) == true) {
            return true;
        }
    }

    for (int j = 0; j < 3; j++) {
        if (check.at(0).at(j) == true && check.at(1).at(j) == true && check.at(2).at(j) == true) {
            return true;
        }
    }

    if (check.at(0).at(0) == true && check.at(1).at(1) == true && check.at(2).at(2) == true) {
        return true;
    }

    if (check.at(0).at(2) == true && check.at(1).at(1) == true && check.at(2).at(0) == true) {
        return true;
    }

    return false;
}

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a.at(i).at(j);
        }
    }
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b.at(i);
    }

    checked(a, b);

    cout << (bingo() ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int n, m;
    int i, j;
    scanf("%d %d", &n, &m);
    int a[100][100], b[100], c[100];
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for (j = 0; j < m; j++)
    {
        scanf("%d", &b[j]);
    }
    for (i = 0; i < n; i++)
    {
        c[i] = 0;
        for (j = 0; j < m; j++)
        {
            c[i] += (a[i][j] * b[j]);
        }
    }
    for (i = 0; i < n; i++)
    {
        printf("%d\n", c[i]);
    }
}


Measured memory_bytes: 2752
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	char ch;
	cin>>ch;
	if(ch=='a' || ch=='e' ||ch =='i'||ch=='o'||ch=='u')
		cout<<"vowel"<<endl;
	else
		cout<<"consonant"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  ans=0
  for i in range(k,n+2):
    mn=i*(0+i-1)//2
    mx=i*(n-i+1+n)//2
    # print(mn,mx)
    ans+=mx-mn+1
    ans%=mod

  return ans

# main()
print(main())


Measured memory_bytes: 10796
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    K = int(input())

    S = [s for s in S]
    D = [ord('z') - ord(s) + 1 if s != 'a' else 0 for s in S]
    T = []
    for s, d in zip(S, D):
        if d <= K:
            T.append('a')
            K -= d
        else:
            T.append(s)

    c = ord(T[-1])
    K %= 26
    for _ in range(K):
        if c == ord('z'):
            c = ord('a')
        else:
            c += 1
    T[-1] = chr(c)

    print(''.join(T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 52912
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int[] dif = {4,0,1,4,6,2,4,0,3,5,1,3};
		String[] day = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
		String[] result = new String[10000];
		int index = 0;
		
		int m = stdIn.nextInt();
		int d = stdIn.nextInt();
		while( m != 0 ){
			result[index] = day[(dif[m-1]+d-1)%7];
			index++;
			m = stdIn.nextInt();
			d = stdIn.nextInt();
		}
		for(int i = 0; i < index; i++){
			System.out.println(result[i]);
		}
	}
}

Measured memory_bytes: 12000
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    while(true){
        int n, r;
        cin >> n >> r;
        if(n == 0 && r == 0){
            break;
        }
        vector<int> fuda(n);
        for(int i = 0 ; i < n ; i++){
            fuda[i] = n - i;
        }
        for(int i = 0 ; i < r ; i++){
            int x, y;
            cin >> x >> y;
            x--;
            for(int j = 0 ; j < y ; j++){
                int tmp = fuda[x + j];
                fuda.erase(fuda.begin() + x + j);
                fuda.insert(fuda.begin() + j, tmp);
            }
        }
        cout << fuda[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int setnums = scan.nextInt();

		for(int i=0; i<setnums; i++) {
			String str1 = scan.next();
			String str2 = scan.next();
			String longer = "";
			String smaller = "'";
			if(str1.length() > str2.length()) {
				longer = str1;
				smaller = str2;
			}else {
				smaller = str1;
				longer = str2;
			}
			longestSeq(longer, smaller);
		}
		
	}
	
	static void longestSeq(String large, String small) {
		int[][] map = new int[large.length()+1][small.length()+1];
		//System.out.println("mp: " + map[1][1]);
		int seqlength = 0;
		for(int i=0; i<=large.length(); i++){ 
	      for (int j=0; j<=small.length(); j++) { 
	        if (i == 0 || j == 0) {
	            map[i][j] = 0; 
	        } else {
	        	char largeChar = large.charAt(i-1);
	        	char smallChar = small.charAt(j-1);
	        	if (largeChar == smallChar) {
	        		map[i][j] = map[i-1][j-1] + 1; 
	        	} else {
	        		int largeVal = map[i-1][j];
	        		int smallVal = map[i][j-1];
	        		if(largeVal>smallVal){
	        			map[i][j] = map[i-1][j];
	        		} else {
	        			map[i][j] = map[i][j-1];
	        		}
	        	}
	        }
	        seqlength = map[large.length()][small.length()];
	      }
		}
        System.out.println(seqlength);

	}
}
//		for(int i=0; i<small.length(); i++) {
//		for(int j=0; j<large.length(); j++) {
//			
//		}
//	}
//	
			
//	for(int j=0; j<small.length(); j++) {
//		t1 = j;
//		boolean cont = true;
//		//for(int k = 0; k<large)
//		for(int k=0; k<large.length(); k++) {
//			t2 = k;
//		while(cont) {
//			if((small.length() > t1) && (small.charAt(t1) == large.charAt(t2))) {
//				System.out.println(small.charAt(t1) + " t1:" + t1 + " t2:" + t2);
//				current += small.charAt(t1);
//				//System.out.println("here if");
//				t1++;
//				t2++;
//			}else {
//				//System.out.println("here else");
//				cont = false;
//				t1 = 0;
//				t2 = 0;
//			}		
//			if(current.length()>longest.length()) {
//				longest = current;
//			}
//			//System.out.println("cur: " + current);
//		}
//		}
//	}
//	System.out.println("longest: " + longest);



Measured memory_bytes: 65616
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))


a,b = m()

if a <= 5:
	print(0)
elif a <= 12:
	print(b//2)
else:
	print(b)

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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	int cnt=1;
	int maxi=arr[0];
	for(int i=1;i<n;i++)
	{
		if(arr[i]>=maxi)
		{cnt++;
		maxi=arr[i];
			
		}
		
	}
	cout<<cnt;
	return 0;
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine((double)(2 * r * Math.PI));

        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


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

using namespace std;

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

  int n;
  cin >> n;
  int cnt[65][65] = {0};
  long long ans = 0;
  vector<pair<int, int>> kek;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int m = s.size();
    int id = -1;
    for (int j = 0; j < m; ++j) {
      if (s[j] == '.') id = j;
    }
    int need = 0;
    if (id != -1) {
      need = 9 - (m - id - 1);
      s.erase(s.begin() + id);
    } else {
      need = 9;
    }
    long long x = stoll(s);
    while (need--) x *= 10;
    int a = 0, b = 0;
    while (x % 2 == 0) ++a, x /= 2;
    while (x % 5 == 0) ++b, x /= 5;
    ++cnt[a][b];
    if (min(a, b) >= 9) --ans;
    kek.emplace_back(a, b);
  }
  for (int i = 59; i >= 0; --i) {
    for (int j = 59; j >= 0; --j) {
      cnt[i][j] += cnt[i + 1][j] + cnt[i][j + 1] - cnt[i + 1][j + 1];
    }
  }
  for (auto [a, b] : kek) {
    ans += cnt[max(0, 18 - a)][max(0, 18 - b)];
  }
  cout << ans / 2;

  return 0;
}


Measured memory_bytes: 5296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a = scanner.nextInt() / 2;
		int two = numFact2(a);
		long lcm = a;
		for (int i = 1; i < n; i++) {
			a = scanner.nextInt() / 2;
			lcm = lcm(lcm, a);
			if (numFact2(a) != two || lcm > m) {
				System.out.println(0);
				return;
			}

		}
		System.out.println((m / lcm + 1) / 2);
	}

	static int numFact2(int x) {
		int count = 0;
		while (x % 2 == 0) {
			count++;
			x /= 2;
		}
		return count;
	}

	static long lcm(long x, long y) {
		return x * y / gcd(x, y);
	}

	static long gcd(long x, long y) {
		if (x % y == 0)
			return y;
		return gcd(y, x % y);
	}

}


Measured memory_bytes: 49048
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll n,k,a[100010],ans,mod=7+1e9,fact[100010],v1,v2;

ll expBin( ll A , ll B ){
    if( !B ) return 1LL;
    ll myAns = expBin( A , B/2 );
    myAns = (myAns*myAns)%mod;
    if( B&1 ) myAns = (myAns*A)%mod;
    return myAns;
}

ll choose( ll x , ll y ){
    if( y > x ) return 0LL;
    return ((fact[x]*expBin( fact[y] , mod-2 )%mod)*expBin( fact[ x-y ] , mod-2 ))%mod;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    for(ll i=0; i<n; i++) cin >> a[i];

    if( k==1 ){
        cout << 0;
        return 0;
    }

    sort( a , a+n );


    fact[0] = 1LL;
    for(ll i=1; i<=n+2; i++) fact[i] = (fact[i-1]*i)%mod;

    for(ll i=n-1; i>=0; i--){

        //cout << i << " " << a[i] << " " << choose( i , k ) << " " << choose( n-1-i , k ) << "\n";

        v1 = (choose( i , k-1 )*a[i])%mod;
        v2 = (choose( n-1-i , k-1 )*a[i] )%mod;

        ans = ( ans + v1  )%mod;
        ans = ( ans - v2 );
        if( ans < 0 ) ans+=mod;
        ans%=mod;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}
int main(){
	int K;
	cin>>K;
	Graph G;
	for(int i=0;i<K;i++){
		Edges E;
		G.push_back(E);
	}
	for(int i=0;i<K;i++){
		G[i].pb(Edge(i,(i+1)%K,1));
		G[i].pb(Edge(i,(10*i)%K,0));
	}
	vector<Weight> dist;
	vint prev;
	shortestPath(G,1,dist,prev);
	cout<<dist[0]+1<<endl;
	return 0;
}

Measured memory_bytes: 8432
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int a[5],k;
    rep(i,5)cin >> a[i];
    cin >> k;
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            if(abs(a[i]-a[j])>k){
                cout<<":("<<endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256