akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc131/tasks/abc131_c
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

template <class T>
T calcgcd(T x, T y)
{
    if (x < y)
    {
        std::swap(x, y); //小さい方をyとする
    }
    T r = x % y;
    while( r != 0 )
    {
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = B - A + 1;
    ll E = C * D / calcgcd(C, D);
    ll cnt = B / C + B / D - B / E - A / C - A / D + A / E;
    if (A % C == 0 || A % D == 0) ++cnt;
    ans -= cnt;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int n, a, b, k, i, j;
int main(){
	scanf("%d\n", &k);
	scanf("%d%d", &a, &b);
	if(a%k == 0 || b%k == 0) printf("OK");
	else{
		i = a/k + 1;
		n = k*i;
		if(n > b) printf("NG");
		else printf("OK");
	}
	return 0;
}


Measured memory_bytes: 3804
#include <iostream>

using namespace std;

int main(){
  int lmax = 0;
  int rmin;
  int n, m;
  cin >> n >> m;
  rmin = n;
  for (int i=0;i<m;i++) {
    int l, r;
    cin >> l >> r;
    lmax = lmax < l?l:lmax;
    rmin = r < rmin?r:rmin;
  }
  if (rmin < lmax) {
    cout << 0 << endl;
  } else {
    cout << rmin - lmax + 1 << endl;
  }
  return(0);
}


Measured memory_bytes: 888
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

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

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

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

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N, T = li_input()
    A = []

    for i in range(N):
        A.append(li_input())

    ans = 9999999999999999999

    for a in A:
        c, t = a

        if t <= T and c < ans:
            ans = c

    if ans != 9999999999999999999:
        print(ans)
    else:
        print("TLE")


main()


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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define MOD 998244353
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

long long mod_pow(const long long x, long long n, const long long mod) {
    long long res = 1;
    if (n == 0) return 1;
    if (n & 1) res = x;
    long long y = mod_pow(x, n >> 1, mod);
    res = (res * (y * y % mod)) % mod;
    return res;
}

const int MAX_K = 300000;
bool fact_initialized = false;
long long fact[MAX_K], fact_inv[MAX_K], inv[MAX_K];

// This will be automatically called during combination_mod
void combination_init(int mod)
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;

    for(int i = 2; i < MAX_K; ++i)
    {
        fact[i] = fact[i-1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i-1] * inv[i] % mod;
    }
}

// Used:
//   ABC151-E
long long combination_mod(int n, int k, int mod)
{
    if (n < k || n < 0 || k < 0) return 0;
    if(!fact_initialized)
    {
        combination_init(mod);
        fact_initialized = true;
    } 
    return fact[n] * (fact_inv[k] * fact_inv[n-k] % mod) % mod;
}

int main(){
    std::ios::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    ll ret = 0;
    for(int i=0;i<=k;++i)
    {
        ll tmp = 0;
        tmp = m * mod_pow(m-1, n-1-i, MOD) % MOD;
        tmp *= combination_mod(n-1, i, MOD);
        tmp %= MOD;
        ret += tmp;
        ret %= MOD;
    }
    cout << ret << endl;
}

Measured memory_bytes: 10684
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int s;
map<int, int> mp;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  int ans = 1;
  while (1) {
    mp[s]++;
    int ns = (s & 1 ? 3*s+1 : s/2);
    ans++;
    if (mp.count(ns)) break;
    s = ns;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int d;cin>>d;
    if(d==25) cout << "Christmas" << endl;
    else if(d==24) cout << "Christmas Eve" << endl;
    else if(d==23) cout << "Christmas Eve Eve" << endl;
    else if(d==22) cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n, m;
  cin >> n >> m;
  int maxl = 0, minr = n;
  for(int i = 0;i<m;i++)
  {
      int l,r;
      cin >> l >> r;
      if(maxl < l) maxl = l;
      if(r < minr) minr = r;
  }
  if(minr - maxl + 1 < 0) cout << 0 << endl;
  else cout << minr - maxl + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()

if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, T;
	cin >> N >> T;
	ll A[N + 1];
	for(int i = 0; i < N; i++) cin >> A[i];
	ll ans = T, right = (int)1e9 + 10, left = 0;
	bool flag = false;
	for(int i = 0; i < N - 1; i++)
	{
		ans += min(T, A[i + 1] - A[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> A(M);
    for(int i = 0; i < M; i++) cin >> A[i];
    int C = 0;
    int CMin = 0;
    for(int i = X; i < N; i++){
        for(int j = 0; j < M; j++){
            if(i == A[j]) CMin++;
        }
    }
    for(int i = X; 0 < i; i--){
        for(int j = 0; j < M; j++){
            if(i == A[j]) C++;
        }
    }
    cout << min(CMin,C) << endl;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add_self(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int add(int a,int b){
	int c=a+b;
	if(c>=mod){
		c-=mod;
	}
	return c;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

bitset<4000000>dp;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	dp[0]=true;
	for(int i=0;i<n;i++){
		dp=dp|dp<<a[i];
	}
	ll tot=accumulate(all(a),0ll);
	if(tot%2){
		tot++;
	}
	tot/=2;
	for(int i=tot;i<=4000000;i++){
		if(dp[i]){
			cout<<i<<' ';
			return;
		}
	}
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


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

using namespace std;

using int64 = long long;

constexpr int DEBUG = 0;

struct Int2D {
  int64 x, y;
};

vector<Int2D> Solve();

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

  vector<Int2D> ans = Solve();
  if (ans.empty()) {
    cout << -1 << endl;
  } else {
    cout << ans.size() << endl;
    for (auto p : ans) {
      cout << p.x << " " << p.y << "\n";
    }
  }
}

vector<Int2D> Solve() {
  int64 k;
  int64 x, y;
  cin >> k >> x >> y;
  bool x_inverted = false;
  bool y_inverted = false;
  if (x < 0) {
    x *= -1;
    x_inverted = true;
  }
  if (y < 0) {
    y *= -1;
    y_inverted = true;
  }

  // In the following, x >= 0 and y >= 0.

  auto restore_vector = [&](const vector<Int2D> ps) {
    vector<Int2D> qs;
    for (int i = 0; i < ps.size(); i++) {
      Int2D p = ps[i];
      if (x_inverted) p.x *= -1;
      if (y_inverted) p.y *= -1;
      qs.push_back(p);
    }
    return qs;
  };

  auto solve_normalized = [&]() -> vector<Int2D> {
    // Turn 1
    if (x + y == k) {
      return {{x, y}};
    }

    int ans_turn = (x + y + k - 1) / k;
    if (ans_turn == 1) ans_turn++;

    if (k % 2 == 1) {
      if ((x + y) % 2 == 1) {
        if (ans_turn % 2 == 0) ans_turn++;
      } else {
        if (ans_turn % 2 == 1) ans_turn++;
      }
    } else {
      if ((x + y) % 2 == 1) {
        return {};
      } else {
        // OK
      }
    }

    int64 current_x = 0;
    int64 current_y = 0;
    vector<Int2D> ans;
    if (DEBUG) cout << "x: " << x << " y: " << y << endl;
    if (DEBUG) cout << "ans_turn: " << ans_turn << endl;
    while (true) {
      if (DEBUG) cout << current_x << " " << current_y << endl;

      int remaining_turn = ans_turn - ans.size();
      int64 distance = (x - current_x) + (y - current_y);
      if (remaining_turn == 2) {
        int64 extra = (2 * k - distance) / 2;

        int64 dx = x - current_x;
        int64 dy = y - current_y;
        if (dx >= dy) {
          int64 r = k;
          r -= extra;
          current_y -= extra;
          current_x += r;
          ans.push_back({current_x, current_y});
          ans.push_back({x, y});
          return ans;
        } else {
          int64 r = k;
          r -= extra;
          current_x -= extra;
          current_y += r;
          ans.push_back({current_x, current_y});
          ans.push_back({x, y});
          return ans;
        }
      } else {
        if (distance < k) {
          current_x -= k;
          ans.push_back({current_x, current_y});
        } else {
          int64 r = k;
          if (current_x < x) {
            int64 x_move = min(x - current_x, k);
            r -= x_move;
            current_x += x_move;
          }
          current_y += r;
          ans.push_back({current_x, current_y});
        }
      }
    }
  };

  return restore_vector(solve_normalized());
}


Measured memory_bytes: 12012
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void){
    int n, k, s;
    int i;
    scanf("%d%d%d",&n ,&k ,&s);
        for(i=0;i<n;i++){
            if(i<k){
                printf("%d ",s);
            }
            else if(s == 1000000000){
                printf("1 ");
            }
            else{
                printf("%d ",s+1);
            }
        }
        printf("\n");
    return 0; 
}


Measured memory_bytes: 1280
/**
 * Created by hiramekun at 20:56 on 2019-09-28.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

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

ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;
    return ((m / gcd(m, n)) * n);
}

void solve() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);

    ll ans = 0;
    map<ll, ll> mp = prime_factor(g);
    ans = mp.size();

    cout << ans + 1 << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

// #include <bits/stdc++.h>
// using namespace std;

const int mod = 1000000007;
// const int mod = 998244353;

struct mint {
  long long x;
  mint(long long 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 -= a.x) < 0) 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 operator++() const { return mint(*this) += mint(1);}
  mint operator--() const { return mint(*this) -= mint(1);}
  mint pow(long long 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

/*int main () {
  mint a= mod-1;
  cout << a.pow(2) << endl;
  cout << a.inv() << endl;
  mint b = 123;
  cout << b.inv() << endl;
  return 0;
}*/


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

  cout << mint(10).pow(n) - mint(9).pow(n) - mint(9).pow(n) + mint(8).pow(n) << endl;

  return 0;
}


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

int num[60][3010];

int main(){
  int n,m,s;

  while(scanf("%d %d %d",&n,&m,&s) && (n||m||s)){
    n = n*n;

    for(int i=0;i<=n;i++)
      for(int j=0;j<=s;j++)num[i][j] = 0;
    num[0][0] = 1;

    for(int i=1;i<=m;i++){
      for(int j=n-1;j>=0;j--){
	for(int k=s-i;k>=0;k--){
	  if(num[j][k]>0){
	    num[j+1][k+i] += num[j][k];
	    num[j+1][k+i] %= 100000;
	  }
	}
      }
    }

    printf("%d\n",num[n][s]);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
  int N; cin >> N;
  vint L(2 * N);
  rep(i, 2 * N) cin >> L[i];
  sort(L.begin(), L.end());
  int sum = 0;
  rep(i, N) {
      sum += min(L[2 * i], L[2 * i + 1]);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105;

int n = 100, m = 40;
int w, b;
char c[MAXN][MAXN];
bool used[MAXN][MAXN];

void dfs(int i, int j, char col) {
  if (i < 0 || i >= n || j < 0 || j >= m || used[i][j] || c[i][j] != col) {
    return;
  }
  const int di[] = {-1, 1, 0, 0};
  const int dj[] = {0, 0, -1, 1};
  used[i][j] = true;
  for (int k = 0; k < 4; k++) {
    dfs(i + di[k], j + dj[k], col);
  }
}

void comps() {
  int wc = 0, bc = 0;
  memset(used, 0, sizeof(used));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!used[i][j]) {
        if (c[i][j] == '#') {
          bc++;
        } else {
          wc++;
        }
        dfs(i, j, c[i][j]);
      }
    }
  }
  cerr << "White: " <<  wc << " black: " << bc << endl;
}

int main() { 

  cin >> w >> b;

  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 20; j++) {
      c[i][j] = '#';
    }
  }
  for (int i = 1; i < 100; i += 2) {
    for (int j = 0; j < 20; j += 2) {
      c[i][j] = '.';
    }
  }
  c[99][19] = '.';

  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 20; j++) {
      c[i][20 + j] = '.';
    }
  }
  for (int i = 0; i < 100; i += 2) {
    for (int j = 1; j < 20; j += 2) {
      c[i][20 + j] = '#';
    }
  }
  c[0][20] = '#';

  // for (int i = 0; i < n; i++) {
  //   for (int j = 0; j < m; j++) {
  //     printf("%c", c[i][j]);
  //   }
  //   printf("\n");
  // }

  comps();

  int wc = 500, bc = 500;

  for (int j = 18; j >= 0; j -= 2) {
    for (int i = 98; i >= 2; i -= 2) {
      if (wc == w) {
        break;
      }
      c[i][j] = '.';
      wc--;
    }
    if (wc == w) {
      break;
    }
    c[99][j - 1] = '.';
    wc--;
  }

  for (int j = 21; j < 40; j += 2) {
    for (int i = 1; i <= 97; i += 2) {
      if (bc == b) {
        break;
      }
      c[i][j] = '#';
      bc--;
    }
    if (bc == b) {
      break;
    }
    c[0][j + 1] = '#';
    bc--;
  }

  cout << n << " " << m << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%c", c[i][j]);
    }
    printf("\n");
  }
  comps();

  return 0;
}


Measured memory_bytes: 384
import heapq
INFTY = 10**6
N,M = map(int,input().split())
G = {}
for _ in range(M):
    a,b,c = map(int,input().split())
    if a not in G:
        G[a] = []
    G[a].append((b,c))
    if b not in G:
        G[b] = []
    G[b].append((a,c))
F = {}
for s in range(1,N+1):
    F[s] = {}
    d = [INFTY for _ in range(N+1)]
    d[s] = 0
    hist = [0 for _ in range(N+1)]
    heap = [(0,s)]
    while heap:
        cur = heapq.heappop(heap)
        hist[cur[1]] = 1
        for x in G[cur[1]]:
            if hist[x[0]]==0:
                if d[x[0]]>cur[0]+x[1]:
                    d[x[0]] = cur[0]+x[1]
                    F[s][x[0]] = cur[1]
                    heapq.heappush(heap,(d[x[0]],x[0]))
E = []
for s in range(1,N+1):
    for i in range(1,N+1):
        if i!=s:
            cur = i
            while cur!=s:
                j = F[s][cur]
                if (cur,j) in E or (j,cur) in E:
                    break
                else:
                    E.append((cur,j))
                cur = j
print(M-len(E))

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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

const ll INF = 1LL << 60;
vector<ll> a;
vector<vector<int>> graph;
ll dp[5005][5005][2];
ll sdp[5005][2];
// num[v]: num of vertices in the subtree under v
vector<int> num(5005);

// p: parent
void rec(int v, int p) {
  num[v] = 1;
  for(auto e: graph[v]) {
    if (e == p) continue;
    rec(e, v);
    num[v] += num[e];
  }
  for(int j=0; j<=num[v]; j++) {
    sdp[j][0] = sdp[j][1] = INF;
  }

  sdp[0][0] = a[v];
  if (a[v] > 0) {
    sdp[0][1] = a[v];
  }

  int curnum = 0;
  for(auto e: graph[v]) {
    if (e == p) continue;
    for(int j=curnum; j>=0; j--) {
      ll tmp0 = sdp[j][0];
      ll tmp1 = sdp[j][1];
      sdp[j][0] = sdp[j][1] = INF;
      for(int k=0; k<=num[e]; k++) {
        chmin(sdp[j+k][0], tmp0 + dp[e][k][0]);
        // check if we can cut between v and e
        if (dp[e][k][0] < 0 || dp[e][k][1] < INF/2) {
          chmin(sdp[j+k+1][0], tmp0);
        }
        if (a[v] > 0) {
          chmin(sdp[j+k][1], tmp1 + dp[e][k][1]);
          // check if we can cut between v and e
          if (dp[e][k][0] < 0 || dp[e][k][1] < INF/2) {
            chmin(sdp[j+k+1][1], tmp1);
          }
        }
      }
    }
    curnum += num[e];
  }
  for(int j=0; j<=num[v]; j++) {
    dp[v][j][0] = sdp[j][0];
    dp[v][j][1] = sdp[j][1];
  }
}

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

  int n; cin >> n;
  a.resize(n);
  rep(i, n) {
    cin >> a[i];
  }
  graph.assign(n, vector<int>());
  for(int i=0; i<n-1; i++) {
    int u, v; cin >> u >> v;
    u--; v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  rep(i, 5005) {
    rep(j, 5005) {
      dp[i][j][0] = INF;
      dp[i][j][1] = INF;
    }
  }

  rec(0, -1);
  int ans = n;
  for(int i=0; i<=n; i++) {
    if (dp[0][i][0] < 0) chmin(ans, i);
    if (dp[0][i][1] < INF/2) chmin(ans, i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 392576
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int N;
vector<int> v;

int main(){
	cin >> N;
	int a, sum = 0;
	for(int i = 0; i < N; i++){
		cin >> a;
		sum += a;
		v.push_back(a);
	}
	int x = sum % 10;
	if(x != 0){
		cout << sum << endl;
		return 0;
	}

	sort(v.begin(), v.end());

	for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
		if(*it % 10 != 0){
			cout << sum - *it << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;

}


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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define REP(i,n) FOR(i,0,n)

int N;
int X[200000];
int sortedX[200000];

int main() {
  scanf("%d", &N);
  REP(i,N) {
    scanf("%d", &X[i]);
    sortedX[i] = X[i];
  }
  sort(sortedX, sortedX+N);

  int before_med = sortedX[N/2-1], after_med = sortedX[N/2];
  if (before_med == after_med) {
    REP(i,N) printf("%d\n", before_med);
  }
  else {
    REP(i,N) {
      if (X[i] < after_med) printf("%d\n", after_med);
      else printf("%d\n", before_med);
    }
  }
  return 0;
}

Measured memory_bytes: 3712
# -*- coding: utf-8 -*-
S = input()

buf = [[0]]
for i in range(1, len(S)):
    buf2 = [b + [i] for b in buf] + buf
    buf = buf2
buf = [b + [len(S)] for b in buf]

ans = 0
for b in buf:
    for i in range(len(b) - 1):
        right, left = b[i], b[i+1]
        ans += int(S[right: left])
print(ans)


Measured memory_bytes: 9204
n,c = map(int,input().split())
a = [(0,0)]
for _ in range(n):
  x,v = map(int,input().split())
  a += [(x,v)]
a += [(0,0)]
max_r, max_l = [0], [0]
s = 0
for i in range(1, n+1):
  s += a[i][1]
  max_r += [max(max_r[i-1], s-a[i][0])]
max_r += [0]
s = 0
for i in range(1, n+1):
  s += a[-i-1][1]
  max_l += [max(max_l[i-1], s-c+a[-i-1][0])]
max_l += [0]
max_l.reverse()
ans = 0
for i in range(1, n+1):
  ans = max(ans, max_r[i], max_l[i], max_r[i]+max_l[i+1]-a[i][0], max_r[i-1]+max_l[i]-c+a[i][0])
print(ans)

Measured memory_bytes: 24484
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
 ll N,L;
  cin >>N>>L;
  vs S(N);
  rep(i,N) in(S[i]);
  sort(all(S));
  rep(i,N) cout << S[i];
  cout <<endl;
}


Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())
if A<C  and B<C:
  print(A*X+B*Y)
  
elif C<=A and C<=B:
  if X<=Y:
    a = 2*C*X+(Y-X)*B
    b = 2*C*Y 
    print(min(a,b))
  else:
    a = 2*C*Y+(X-Y)*A
    b = 2*C*X
    print(min(a,b))
    
elif A<=C and B>=C:
  if X<=Y:
    a = 2*C*X+(Y-X)*B
    b = A*X +B*Y
    print(min(a,b))
  else:
    a = 2*C*Y+(X-Y)*A
    b = A*X +B*Y
    print(min(a,b))
else:
  if X<=Y:
    a = 2*C*X+(Y-X)*B
    b = A*X +B*Y
    print(min(a,b))
  else:
    a = 2*C*Y+(X-Y)*A
    b = A*X +B*Y
    print(min(a,b))

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void){
  int a,b,c,d,win;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  while(1){
    c -= b;
    if(c <= 0){
      win = 1;
      break;
    }
    a -= d;
    if(a <= 0){
      win = 0;
      break;
    }
  }
  
  switch (win){
    case 1 : puts("Yes"); break;
    case 0 : puts("No"); break;
  }
  
  return 0;
}

Measured memory_bytes: 1664
/**
 *     author: qodjf
 *     created: 05.05.2020 09:01:54
 */
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) begin(a), end(a)
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

ll mul(ll a, ll b) { return a * b % MOD; }

ll add(ll a, ll b) { return (a + b) % MOD; }

ll sub(ll a, ll b) { return (a - b + MOD) % MOD; }

ll my_pow(ll a, ll b);
ll my_inv(ll a) { return my_pow(a, MOD - 2); }

ll my_pow(ll a, ll b) {
  if (b < 0) {
    a = my_inv(a);
    b = -b;
  }
  ll r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}

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

  int N;
  cin >> N;
  vector<int> c(N);
  rep(i, 0, N) { cin >> c[i]; }

  sort(all(c));
  reverse(all(c));
  ll ans = 0;
  ll c1 = my_pow(2, N - 1);
  ll c2 = my_pow(2, N - 2);
  rep(i, 0, N) { ans = add(ans, mul(c[i], add(c1, mul(i, c2)))); }

  ans = mul(ans, my_pow(2, N));
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod=1e9+7;
ll power(ll a,ll b)
{
    ll result=1;
    while(b>0)
    {
        if(b%2==1)
        {
            result=(result*a)%mod;
        }
        a=(a*a)%mod;
        b/=2;
    }
    return result;
}
int main(){
  
   vector<ll> fact(2e6,1);
   for(int i=2;i<2e6;i++){
       fact[i]=(fact[i-1]*i)%mod;
   }
  
   ll n; cin>>n;
   ll result=power(10ll,n);
   ll result2=power(8ll,n);
   ll sum=0;
   for(int i=1;i<=n;i++){
       ll val=(fact[n]*power(fact[i],mod-2))%mod;
       val=(val*power(fact[n-i],mod-2))%mod;
       val=(val*power(8,n-i))%mod;
       sum=(sum+val)%mod;
   }
   cout<<(result-result2-2*sum+2*mod)%mod;
    
}


Measured memory_bytes: 18656
/*Always success does not build on success,success build on failure and hardwork*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<long long>
#define map         map<long long,long long>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(long long i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const long long N=1e5+5;
int main()
{
   int n;
   scn(n);

   string s;
   cin>>s;

   int r=0,w=0;

   for(int i=0;i<n;i++)
   {
      if(s[i]=='R')
      r++;
      else
      w++;
   }

   int ans=min(r,w);

   if(ans==0)
   {
      cout<<ans<<endl;
   }
   else
   {
      int r1=0,w1=0;
      for(int i=0;i<r;i++)
      {
         if(s[i]=='R')
         r1++;
      }

      ans=min(ans,r-r1);

      cout<<ans<<endl;
   }
}

Measured memory_bytes: 3828
def mod_inverse(x, mod):
    return pow(x, mod - 2, mod)


# return nCk % mod
# it takes O(k)
def mod_comb(n, k, mod):
    numer, denom = 1, 1
    for i in range(k):
        numer = numer * ((n - i) % mod) % mod
        denom = denom * ((i + 1) % mod) % mod

    return numer * mod_inverse(denom, mod) % mod


def main():
    mod = 10**9 + 7
    X, Y = map(int, input().split())

    t1, t2 = 2 * Y - X, 2 * X - Y
    if t1 % 3 != 0 or t2 % 3 != 0 or t1 < 0 or t2 < 0:
        print(0)
        return

    a, b = t1 // 3, t2 // 3
    print(mod_comb(a + b, a, mod))


main()

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int p[3],ju[2];
  int min=4000,nowmin=0;
  for(int i=0;i<3;i++){
    cin>>p[i];
  }for(int i=0;i<2;i++){
    cin>>ju[i];
  }
  for(int i=0;i<3;i++){
    for(int j=0;2>j;j++){
      nowmin=p[i]+ju[j]-50;
      if(nowmin<min){
	min=nowmin;
      }
    }
  }
  cout<<min<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	int x; cin >> x;
	int h = x / 100;
	int r = x % 100;
	int n = (r + 4) / 5;
	if (h >= n)co(1);
	else co(0);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
#include <queue>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007



// ice rink game


signed main(){

	int N;
	cin >> N;
	int a[123456], b[123456], p[123456];
	for (int i = 0; i < N; i++)
		cin >> p[i];

	for (int i = 0; i < N; i++){
		a[i] = (i + 1) * 30000;
		b[i] = (N - i) * 30000;
	}
	for (int i = 0; i < N; i++){
		a[p[i] - 1] += i;
	}
	for (int i = 0; i < N; i++){
		cout << a[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < N; i++){
		cout << b[i] << " ";
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 2816
N, M = gets.split(" ").map(&:to_i)
a = Array.new(M) {gets.to_i}
fivo = [0, 1]
skip = a.shift

1.upto(N) do |i|
    if i == skip
        fivo << 0 
        skip = a.shift
        next
    end
    fivo << (fivo[i] + fivo[i - 1]) % (10**9 + 7)
end 

puts fivo[-1]

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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

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

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int N=10000;
int n,tot;
ll a[505][505];
bool fl[10005];
int prm[10005];

ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
ll lcm(ll x,ll y){return x==0?y:y==0?x:x/gcd(x,y)*y;}

void getprime(){
	fl[1]=1;
	for(int i=2;i<=N;i++){
		if(!fl[i]) prm[++tot]=i;
		for(int j=1;j<=tot&&i*prm[j]<=N;j++){
			fl[i*prm[j]]=1;
			if(i%prm[j]==0) break;
		}
	}
}

int main(){
	getprime();
	n=readint();
	if(n==2) return printf("4 7\n23 10\n"),0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if((i+j)&1) continue;
			a[i][j]=prm[(i+j)/2]*prm[n+(i-j+n+1)/2];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(!((i+j)&1)) continue;
			a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++) printf("%lld ",a[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int data[4][3][10];
	REP(i,4) REP(j,3) REP(k,10) data[i][j][k] = 0;
	int n;
	cin >> n;
	REP(i,n){
		int b,f,r,v;
		cin >> b >> f >> r >> v;
		data[b-1][f-1][r-1]+=v;
	}
	REP(i,4){
		REP(j,3){
			REP(k,10){
				cout << " " << data[i][j][k];
			}
			cout << endl;
		}
		if(i!=3) cout << "####################" << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int64_t N;
  cin>>N;
  int x=N;
  string t;
  while(x){
   int r=x%(2);
   if(r<0){r+=2;}
   x-=r;
   x/=(-2);
   t+=(char)('0'+r);
  }
  reverse(t.begin(),t.end());
  if(t==""){t='0';}
  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 3596
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define ctz __builtin_ctz
typedef pair<int, int> pii;
const int maxn = 1e6;
 
int n ,k ,a[maxn] ,res;


int main()
{FAST;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    (n - 1) % (k - 1) ? res += (n - 1) /(k - 1) + 1 : res += (n - 1) / (k - 1);
        cout << res;
        
        

    return 0;
}
 












Measured memory_bytes: 640
N = int(input())
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


def next_time(i, t):
    a = S[i]
    if t - a < 0:
        return a
    if t % F[i] == 0:
        return t
    b = (t - a + F[i] - 1) // F[i]
    # print(i, t, a, b, t + b * F[i])
    assert (a + b * F[i]) % F[i] == 0
    return a + b * F[i]


for i in range(N):
    time = 0
    for j in range(i, N - 1):
        time = next_time(j, time)
        time += C[j]

    print(time)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;
 
//snuke
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll 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;
  }
};
 
 
 
void mod_build(int n=101010){  
  fact.resize(n+1);
  inv.resize(n+1);
  invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1;
  inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
  k%=mod-1;
  if(k<0)k+=mod-1;
  ll ret=1;
  while(k){
    if(k&1)ret=ret*n%mod;
    n=n*n%mod;
    k>>=1;
  }
  return ret;
}

int main(){
  mod_build();
  int n;
  cin >> n;
  vector<int> a(n+1);
  int dn=-1;
  int dn_pos=-1;
  int dn_nxt=-1;
  map<int,int> mp;
  rep(i,n+1){ 
    cin >> a[i]; a[i]--;
    if(mp.find(a[i])==mp.end()){ 
      mp[a[i]]=i; 
    } else {
      dn = a[i];
      dn_pos = mp[a[i]];
      dn_nxt = i;
    }
  }
  int dn_dis = dn_nxt-dn_pos-1;
  
  rep(i,n+1){
    mint ans = comb(n+1,i+1);
    ans -= comb(n+1-dn_dis-2,i+1-1);
    cout << ans.x << endl;
  }
  return 0;
}

Measured memory_bytes: 8704
n = gets.chomp.to_i
s = gets.chomp


result ={}
count =0
10.times do |i|
  index_i = s.index(i.to_s)
  next if index_i.nil?
  tmp_j = s[(index_i+1)..-1]
  10.times do |j|
    index_j = tmp_j.index(j.to_s)
    next if index_j.nil?
    tmp_k = tmp_j[(index_j+1)..-1]
    10.times do |k|
      unless tmp_k.index(k.to_s).nil?
        count += 1
      end
    end
  end
end


puts count

Measured memory_bytes: 1788
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[100],k[100];
	cin>>a>>k;
	int x=-1;
	char temp[100];
	int lena=strlen(a),lenk=strlen(k);
	for(int i=0;i<lena;i++)
	{
		for(int j=i;j<lenk+i&&j<lena;j++)
		{
			if(a[j]!='?')
				if(a[j]!=k[j-i])
					break;
			if(j==lenk+i-1)
				x=i;
		}
	}
	if(x==-1)
		cout<<"UNRESTORABLE"<<endl;
	else
	{
		//cout<<"x=> "<<x<<endl;
		for(int i=0;i<lenk;i++)
			a[i+x]=k[i];
		for(int i=0;i<lena;i++)
			if(a[i]=='?')
				a[i]='a';
		for(int i=0;i<lena;i++)
			cout<<a[i];
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]);
        }
    }
}*/
long long mod = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}


int a[100005];
int b[100005];
int c[100005];



int main(void){
    int n;
    int i;
    unsigned long long answer = 0;
    int ai, ci;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%d", &b[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%d", &c[i]);
    }
 
    qsort(a, n, sizeof(int), ascending_compare);
    qsort(b, n, sizeof(int), ascending_compare);
    qsort(c, n, sizeof(int), ascending_compare);
 
    
    for (i = 0; i < n; i++){
        ai = lower_bound(a, n, b[i]);
        ci = lower_bound(c, n, b[i]+1);
            answer += (unsigned long long)(ai)*(n-ci);
        }
 
    printf("%lld\n", answer);
    return 0;
}

Measured memory_bytes: 1788