akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n, c;
    cin >> n >> c;
    vector<vector<int>> v(c, vector<int>(c, 0));
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> v[i][j];
        }
    }
    vector<vector<int>> m(3, vector<int>(c, 0));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            int x;
            cin >> x;
            m[(i+j)%3][x-1]++;
        }
    }
    ll ans = INF<ll>;
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            if(i == j) continue;
            for (int k = 0; k < c; ++k) {
                if(j == k) continue;
                if(i == k) continue;
                ll p = 0;
                for (int l = 0; l < c; ++l) {
                    p += v[l][i]*m[0][l] + v[l][j]*m[1][l] + v[l][k]*m[2][l];
                }
                ans = min(ans, p);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println(solve(a, b, c));
    }

    private static int solve(int a, int b, int c) {
        int count = 1;

        if (a != b) count++;
        if (a != c && b != c) count++;

        return count;
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll> a(N),x,y;
	rep(i,N)cin >> a[i];
	ll mx = -INF;
	ll mn  = INF;
	for(int i=0;i<N;i++){
		mx = max(mx,a[i]);
		mn = min(mn,a[i]);
	}
	if(abs(mx)>abs(mn)){
		//全部にmxを足す
		int p = -1;
		rep(i,N)if(a[i]==mx)p = i;
		//p以外にa[p]を足す
		cout << (N-1) + (N-1) << endl;
		rep(i,N){
			if(p==i)continue;
			cout << p+1 << " " << i+1 << endl;
		}
		rep(i,N-1){
			cout << i+1 << " " << i+1+1 << endl;
		}
	}else{
		int p = -1;
		rep(i,N)if(a[i]==mn)p=i;
		cout << (N-1) + (N-1) << endl;
		rep(i,N){
			if(p==i)continue;
			cout << p+1 << " " << i+1 << endl;
		}
		for(int i=N;i>=2;i--){
			cout << i << " " << i-1 << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    string s; cin >> s;
    int pos = s.size()-1;
    vector<int> ans;

    while(pos != 0) {

        for(int i = m; i > -1; i--) {
            if (i == 0) {
                ans.push_back(-1);
                pos = 0;
                break;
            }
            if (pos-i < 0) continue;
            if (s[pos-i] == '0') {
                ans.push_back(i);
                pos -= i;
                break;
            }
        }
    }
    if (ans.back() != -1) {
        for (auto it = ans.rbegin(); it+1 < ans.rend(); it++) {
            cout << *it << " ";
        }
        cout << ans.front() << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1096
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        s: String,
        range: [(usize, usize); q],
    }

    let mut sums = vec![0; n+1];

    for i in 1..(s.len()) {
        if s[(i-1)..=i].chars().collect::<String>().starts_with("AC") {
            sums[i+1] = sums[i] + 1;
        } else {
            sums[i+1] = sums[i];
        }
    }

    for (l, r) in range {
        println!("{}", sums[r] - sums[l]);
    }
}


Measured memory_bytes: 5252
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

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

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	vector<int> h(n),dp(n);
	rep(i,n){
		cin >> h[i];
	}
	reps(i,n-1){
		int minv = INF;
		for(int j = i-1;j >= i-k && j >= 0;--j){
			minv = min(minv,abs(h[i]-h[j]) + dp[j]);
		}
		dp[i] = minv;
	}
	cout << dp[n-1] << '\n';
	return 0;	
}


Measured memory_bytes: 1792
#include <iostream>
#include <bits/c++io.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
 int a[3];
 cin>>a[0]>>a[1]>>a[2];
 sort(a,a+3);
 cout<<a[0]+a[1]<<endl;
}



Measured memory_bytes: 3640
#include <iostream>
typedef long long ll; 

using namespace std; 

int main() {
	int x, y, a, b;
	cin >> x >> y;
	b = (y - 2*x)/2; 
	a = x - b;
	if(2*a + 4 * b == y && a + b == x && a >= 0 && b >= 0) {
		cout << "Yes";
	} else cout << "No";
	
	return 0;
}


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

ll N, K;
ll dp[1010101];


int main() {
    cin >> N;
    vector<int> A(N), T(N);
    REP(i, N)cin >> T[i];
    REP(i, N)cin >> A[i];
    if (T[N - 1] != A[0]) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    FOR(i, 1, N - 2) {
        if (T[i - 1] == T[i] && A[i] == A[i + 1]) {
            ans = ans * min(T[i], A[i]) % MOD;
        } else if (T[i - 1] == T[i] && A[i] > A[i + 1]) {
            if (T[i] < A[i]) {
                cout << 0 << endl;
                return 0;
            }
        } else if (T[i - 1] < T[i] && A[i] == A[i + 1]) {
            if (T[i] > A[i]) {
                cout << 0 << endl;
                return 0;
            }
        } else if (T[i - 1] < T[i] && A[i] > A[i + 1]) {
            if (T[i] != A[i]) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;  
  	int n,m,i,ans=0;
  	cin>>n>>m;
  	int a[n+1],dp[n+1]={0};
  	for(i=1;i<=n;++i)
    	cin>>a[i];
  	for(i=0;i<m;++i)
    {
      	int u,v;
      	cin>>u>>v;
      	if(a[u]>a[v])
        {
          if(dp[u]!=-1)
          	dp[u]=1;
          dp[v]=-1;
        }
      	else if(a[u]<a[v])
        {
          if(dp[v]!=-1)
          	dp[v]=1;
          dp[u]=-1;
        }
      	else
        {
          dp[u]=-1;
          dp[v]=-1;
        }
    }
  	for(i=1;i<=n;++i)
      if(dp[i]!=-1)
        ans++;
  	cout<<ans;
}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

const int MAX_N = 100000;
int N;
int dp[MAX_N+1][3];

void solve() {

    cin >> N;
    vector<vector<int>> D(N, vector<int>(3, 0));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> D[i][j];
        }
    }

    for (int i = 0; i < MAX_N+1; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = 0;
        }
    }

    for (int j = 0; j < 3; j++) {
        dp[0][j] = D[0][j];
    }
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                dp[i][j] = max(dp[i][j], D[i][j] + dp[i-1][k]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        ans = max(ans, dp[N-1][i]);
    }

    print(ans);

}

signed main() {
    solve();
}


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

using namespace std;

int N;
int ans=0;

void input(){
  cin >> N;
}

void solve(){
  for(int i=1;i<=N;i++){
    int tmp=i;
    int keta=0;
    while(tmp>0){
      tmp=tmp/10;
      keta++;
    }
    if(keta%2==1){
      ans++;
    }
  }
}

int main(){
  input();
  solve();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll>dist;
int main(){
  ll arr[100004];
  ll n,l;
   arr[l+1];
  cin >> n >> l;
  //int first;
  for(int i=0;i<l;i++){
     cin >> arr[i];
  }
  sort(arr,arr+l);
  ll sumd=0;
  for(int i=0;i<l-1;i++){
     ll dis=abs(arr[i]-arr[i+1]);
     dist.push_back(dis);
     sumd+=dis;
  }
  //cout << "sum of dis " << sumd <<endl;
  sort(dist.begin(),dist.end(),greater<int>());
  if(l<n){
    cout << "0" <<endl;
    return 0;
  }
  ll exdis=0;
  for(int i=0;i<=n-2;i++){
    exdis+=dist[i];
  }
  cout << sumd-exdis<<endl;


  return 0;
}


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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	
	if (x-r<0 || y-r<0)
		cout << "No\n";
	else if (x+r>W || y+r>H)
		cout << "No\n";
	else
		cout << "Yes\n";
		
	// your code goes here
	return 0;
}

Measured memory_bytes: 3056
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int x;
    int n;
    cin >> n >> x;
//    cout << "x=" << x << "n=" << n << endl;
    int l[n];
    int tmp;
    for (int k=0;k<n;k++){
        cin >> tmp;
//        cout << "tmp=" << tmp;
        l[k] = tmp;
    }
    int sum = 0;
    int i = 0;
    while (sum<=x) {
        sum += l[i];
        i++;
    }
    if (i>101){
        i=101;
    }    
    
    cout << i;
    return 0;
}

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

#define MAX 10000000

using namespace std;

int f(int a) {
  int b;
  if (a % 2 == 0) {
    b  = a / 2;
  } else {
    b = 3 * a +1;
  }
  return b;
}

int main(){
  int m;
  cin >> m;
  vector<int> mp;
  int a = m;
  mp.push_back(a);
  for (int i=0;i<MAX;i++) {
    a = f(a);
    mp.push_back(a);
    auto itr = std::find(mp.begin(), mp.end()-1, a);
    if (itr != mp.end()-1) {
      cout << mp.size();
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> x1 >> y1 >> x2 >> y2;
	x2 -= x1;
	y2 -= y1;
	x3 = x2 - y2;
	y3 = y2 + x2;
	x4 = -x2 + x3;
	y4 = -y2 + y3;
	x3 += x1;
	y3 += y1;
	x4 += x1;
	y4 += y1;
	cout << x3 << " " <<  y3 << " " << x4 << " " << y4 << endl;
	return 0;
}

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

H, W = map(int, input().split())
HW = [list(input()) for i in range(H)]

# 入力より一回り大きい2次元配列を#埋めで準備
ans = [["#" for i in range(W+2)] for j in range(H+2)]
# 必要な部分を入力の配列で上書き
for i in range(H):
    for j in range(W):
        ans[i+1][j+1] = HW[i][j]

for i in range(H+2):
    print("".join(ans[i]))

Measured memory_bytes: 3188
def next_permutation(lst) :
    length = len(lst);
    #print(lst);
    for i in range(-1,-n,-1) :
        if lst[i-1] < lst[i] :
            lst[i:]=sorted(lst[i:]);
            #print(i,lst);
            for j in range(i,0) :
                if lst[j] > lst[i-1] :
                    tmp = lst[i-1];
                    lst[i-1] = lst[j];
                    lst[j] = tmp;
                    break;
            lst[i:]=sorted(lst[i:]); 
            break;   
    return
n = int(input());
p = [int(x) for x in input().split()];
q = [int(x) for x in input().split()];

init = [x for x in range(1,n+1)];
cnt = 1;
a = 0;
b = 0;

while a == 0 or b == 0 :
    if p == init :
        a = cnt;
    if q == init :
        b = cnt;
    cnt += 1;
    next_permutation(init);
    #print(init);

print(abs(a-b));

#next_permutation(init);
#print(init);

Measured memory_bytes: 9228
def p_d():
    n, m = map(int, input().split())
    a = map(int, input().split())
    c = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    inf = 10 ** 9
    costs = {m: c[m - 1] for m in a}
    # dp(i) := ちょうど i 本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
    dp = [0]

    for i in range(1, n + 1):
        dp.append(max(
            [dp[i - c] if i - c >= 0 else -inf for c in costs.values()]
        ) + 1)

    digits = list(costs.keys())
    digits.sort(reverse=True)
    num = n
    result = []
    for _ in range(dp[n]):
        for digit in digits:
            if num >= costs[digit] and dp[num - costs[digit]] != -inf and dp[num - costs[digit]] == dp[num] - 1:
                result.append(str(digit))
                num -= costs[digit]
                break
    print("".join(result))


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 42460
// e-colorful-blocks.yml
#include "bits/stdc++.h"
using namespace std;

// Defines
#define pb push_back
#define mpr make_pair
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
// Basic type definitions
using ll = long long; using ull = unsigned long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<long long, long long>;
// PBDS order statistic tree
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
template <typename T, class comp = less<T>> using os_tree = tree<T, null_type, comp, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V, class comp = less<K>> using treemap = tree<K, V, comp, rb_tree_tag, tree_order_statistics_node_update>;
// HashSet
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };
template <typename T, class Hash> using hashset = gp_hash_table<T, null_type, Hash>;
template <typename K, typename V, class Hash> using hashmap = gp_hash_table<K, V, Hash>;
// More utilities
template <typename C> int SZ(C &v) { return v.size(); }
template <typename T, typename U> void maxa(T &a, U b) { a = max(a, b); }
template <typename T, typename U> void mina(T &a, U b) { a = min(a, b); }
const ll INF = 0x3f3f3f3f, LLINF = 0x3f3f3f3f3f3f3f3f;

const ll MOD = 998244353;
ll madd(ll a, ll b, ll mod = MOD) { return (a + b) % mod; }
ll msub(ll a, ll b, ll mod = MOD) { return (a - b + mod) % mod; }
ll mmul(ll a, ll b, ll mod = MOD) { return (a * b) % mod; }
ll fpow(ll x, ll y, ll mod = MOD) {
    if (!y) return 1LL;
    return mmul(fpow(mmul(x, x, mod), y >> 1, mod), (y & 1) ? x : 1LL, mod);
}
ll mdiv(ll x, ll y, ll mod = MOD) { return mmul(x, fpow(y, mod - 2, mod), mod); }
vector<ll> fact, invf;
void init_nchooser(int MN) {
    fact.resize(MN + 1); invf.resize(MN + 1);
    fact[0] = invf[0] = 1LL;
    for (int i = 1; i <= MN; i++) {
        fact[i] = mmul(fact[i - 1], i);
        invf[i] = mdiv(1, fact[i]);
    }
}
ll choose(ll N, ll K) { return mmul(fact[N], mmul(invf[K], invf[N - K])); }
ll permute(ll N, ll K) { return mmul(fact[N], invf[N - K]); }

const int MN = 2e5 + 1;
int N, M, K;

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

    cin >> (N) >> (M) >> (K);
    init_nchooser(N);

    ll ans = 0;
    for (auto i = 0; i <= K; i++) {
        ll cur = mmul(mmul(M, fpow(M - 1, N - (i + 1))), choose(N - 1, i));
        ans = madd(ans, cur);
    }
    cout << (ans) << '\n';

    return 0;
}



Measured memory_bytes: 6324
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	ll x;
	cin >> n >> m >> x;
	ll a = 0;
	ll b = 0;
	rep(i, m) {
		ll p;
		cin >> p;
		if (p < x) {
			++a;
		}
		else {
			++b;
		}
	}
	cout << min(a, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b; cin>>a>>b;
	if(a>=10||b>=10) cout << -1;
	else cout << a*b;


  return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << a - b + 1 << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int d, n;
	scanf("%d %d", &d, &n);
	unsigned long int dn = (d == 1) ? 100 : (d == 2) ? 10000 : 1;
	n = (n == 100)? 101: n;
	printf("%ld\n", dn * n);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
main(){
  double n,m;
  while(scanf("%lf %lf",&n,&m)!=EOF){
    if(n<35.50 && m<71){
      printf("AAA\n");
    }
    else if(n<37.50 && m<77){
      printf("AA\n");
    }
    else if(n<40 && m<83){
      printf("A\n");
    }
    else if(n<43 && m<89){
      printf("B\n");
    }
    else if(n<50 && m<105){
      printf("C\n");
    }
    else if(n<55 && m<116){
      printf("D\n");
    }
    else if(n<70 && m<148){
      printf("E\n");
    }
    else{
      printf("NA\n");
    }
  }
  return 0;
}

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

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

    for(int i=s.size()-2;i>=1;i--){
        if(!(i%2))continue;
        int i2=i/2;                    
        bool flag=true;
        for(int j=0;j<=i2;j++){
            if(s[j]!=s[i2+1+j]){
                flag=false; break;
            }    
        }
        
        if(flag) {
            cout<<i+1<<"\n";
            break;
        }    
    }       
    return 0;
}



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

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

	cin >> a >> b >> c;

	if(a > b){
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	if(a > c){
		int tmp1 = a;
		a = c;
		c = tmp1;
	}

	if(b > c){
		int tmp2 = b;
		b = c;
		c = tmp2;
	}

	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int s = (x - a) * (x - a);
	int t = (x - b) * (x - b);
	if (s < t) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
S = input()

a = 1
b = 1
first = S[0]
second = ""
for i in range(3):
    if S[i+1] == first:
        a += 1
    elif second == "":
        second = S[i+1]
    elif second == S[i+1]:
        b+= 1

if a == 2 and b == 2:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
import kotlin.math.max

fun main() {
    val (n, m) = readIntList()
    val h = readIntList()
    val ma = IntArray(n)
    val path = Array(m) { mutableListOf<Int>() }
    repeat(m) {
        val (a, b) = readIntList()
        ma[a - 1] = max(ma[a - 1], h[b - 1])
        ma[b - 1] = max(ma[b - 1], h[a - 1])
    }
    var ans = 0
    h.forEachIndexed { index, i ->
        if (i > ma[index])
            ans++
    }
    println(ans)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 68312
K, N = map(int, input().split())
A = list(map(int, input().split()))
result = 0
mx = -float("inf")
for i in range(N-1):
    mx = max(mx, A[i+1] - A[i])
mx = max(mx, K - A[-1] + A[0])

result = K - mx
print(result)

Measured memory_bytes: 26436
#include<bits/stdc++.h>
#define M 100005
#define YXQAK {printf("Impossible\n"); return 0;}
using namespace std;

int a[M]={0},aa[M]={0};
int n,m,ji=0,now=1;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",aa+i);
		if(aa[i]&1) ji++;
	}
	if(ji>2) YXQAK
	if(ji==0){
		for(int i=1;i<=m;i++) a[i]=aa[i];
	}else{
		for(int i=1;i<=m;i++){
			if(aa[i]&1){
				if(a[1]==0) a[1]=aa[i];
				else a[m]=aa[i];
			}else a[++now]=aa[i];
		}
	}
	if(m==1){
		printf("%d\n",aa[1]);
		if(aa[1]==1) printf("1\n1\n");
		else printf("2\n%d %d\n",aa[1]-1,1);
		return 0;
	}
	for(int i=1;i<=m;i++) printf("%d ",a[i]);
	printf("\n");
	a[1]++; a[m]--; if(a[m]==0) m--;
	printf("%d\n",m);
	for(int i=1;i<=m;i++) printf("%d ",a[i]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a[n],b[n],c[m],d[m];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=0;i<m;i++){
    cin>>c[i]>>d[i];
  }
  for(int i=0;i<n;i++){
    int mi=1000000000,e;
    for(int j=0;j<m;j++){
      if(mi>abs(a[i]-c[j])+abs(b[i]-d[j])){
        mi=abs(a[i]-c[j])+abs(b[i]-d[j]);
        e=j+1;
      }
    }
    cout<<e<<endl;
  }
}
         

Measured memory_bytes: 256
#include <stdio.h>

int digits(int N)
{
	int ret = 0;
	while (N > 0)
	{
		ret += N % 10;
		N /= 10;
	}
	return ret;
}
int main()
{
	int N;
	scanf("%d", &N);
	int temp = digits(N);
	if (N%temp == 0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    double[] x, y;
    int i, j;
    double s1x, s1y, s2x, s2y, sjx, sjy, max, l;

    n = sc.nextInt();
    x = new double[n];
    y = new double[n];

    for(i = 0;i < n;i++){
      x[i] = sc.nextDouble();
      y[i] = sc.nextDouble();
    }

    max = 0.0;
    for(i = 0;i < n;i++){
      s1x = y[(i - 1 + n) % n] - y[i];
      s1y =  - x[(i - 1 + n) % n] + x[i];
      s2x =  - y[(i + 1) % n] + y[i];
      s2y = x[(i + 1) % n] - x[i];
      for(j = i + 1;j < n;j++){
        if(s1x * s2y - s2x * s1y == 0.0)break;
        sjx = x[j] - x[i];
        sjy = y[j] - y[i];
        if((s1x * sjy - sjx * s1y) * (s2x * sjy - s2y * sjy) <= 0){
          l = sjx * sjx + sjy * sjy;
          if(l > max)max = l;
        }
      }
    }

    System.out.println(Math.sqrt(max));

/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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


void solve(long long n, long long m){
    cout << (n-1)*(m-1) << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    long long m;
    scanf("%lld",&m);
    solve(n, m);
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int m = 0, cu = 0;
    for (char c : s) {
       if (c == 'R') {
            cu++;
       } else {
            cu = 0;
       }

       m = max(m, cu);
    }
    cout << m;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
int s[8][8];
int a[8],book[8],b[16],c[16];
void add(int x)
{
    int i,j;
    if(x==8)
    {
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
            {
                if(s[i][j])
                {
                    if(a[i]!=j)
                        return;
                }
            }
        }
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
            {
                if(a[i]==j)
                    printf("Q");
                else
                    printf(".");
            }
            printf("\n");
        }
        return;
    }
    for(i=0;i<8;i++)
    {
        if(book[i]||b[x+i]||c[x-i+7])
            continue;
        a[x]=i;
        book[i]=b[x+i]=c[x-i+7]=1;
        add(x+1);
        book[i]=b[x+i]=c[x-i+7]=0;
    }
}
int main()
{
    memset(s,0,sizeof(s));
    memset(a,0,sizeof(a));
    memset(book,0,sizeof(book));
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    int n;
    scanf("%d",&n);
    int r,l;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&r,&l);
        s[r][l]=1;
    }
    add(0);
    return 0;
}



Measured memory_bytes: 2128
//Priyanshu Kumar : IIIT Allahabad
#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define MAX 100005
#define MOD 1000000007
#define sz size()
#define ln length()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pin(n) printf("%d\n",n);
#define pl(n) printf("%lld",n)
#define pln(n) printf("%lld\n",n);
#define FUCK_YEAH ios_base::sync_with_stdio(false);cin.tie(NULL)
inline ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
inline ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
inline ll powmod(ll a,ll b,ll mod) 
{
	ll res=1;
	a%=mod; 
	assert(b>=0); 
	for(;b;b>>=1)
	{
		if(b&1)res=res*a%mod;
		a=a*a%mod;
	}
	return res;
}
inline ll mulmod(ll a, ll b, ll c)
{
	if(!b)return 0;
	ll x = mulmod(a, b/2, c);
	if (b & 1)return (x+x+a)%c;
	return (x+x)%c;
}

vector <int> v;
int isP[100005];
 
void sieve()
{
    int i, j;
    for (i = 2; i <= 100000; ++i) {
        if (!isP[i]) {
            v.pb(i);
            for (j = 2; i*j <= 100000; ++j)
                isP[i*j] = 1;
        }
    }
}
ll pre[MAX];

int main()
{
	FUCK_YEAH;
	sieve();
	isP[0] = 1;
	isP[1] = 1;
	for(int i = 1; i < MAX; i++) {
		if(isP[i] == 0 && isP[(i+1)/2] == 0 && i%2 == 1) {
			pre[i] = pre[i-1] + 1;
		}
		else {
			pre[i] = pre[i-1];
		}
	}
	ll q, l ,r;
	cin >> q;
	while(q--) {
		cin>> l >> r;
		cout << pre[r] - pre[l-1] << endl;
	}
	return 0;
}

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

int main(){
    int n,i,j,v,u,k;
    cin>>n;
    int A[n+1][n+1];
    for(i=0;i<=n;i++)for(j=0;j<=n;j++)A[i][j]=0;
    for(i=0;i<n;i++){
        scanf("%d %d",&v,&u);
        for(j=0;j<u;j++){scanf("%d",&k);A[v][k]++;}
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            if(j!=1)printf(" ");
            printf("%d",A[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; string s[3];
  cin>>n;
  for(int i=0;i<3;i++)cin>>s[i];
  int ans=0;
  for(int i=0;i<n;i++){
    map<char,int> m;
    for(int j=0;j<3;j++){
      m[s[j][i]]++;
    }
    ans+=(int)m.size()-1;
  }
  cout<<ans<<endl;
}

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

#define N 200123
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.in", "r", stdin);
    //     freopen("output.out", "w", stdout);
    // #endif
    int n, m, b, iter = 0;
    ll a[N], c, ans = 0;
    vector<pair<ll, int> > v;
    cin >> n >> m;
  	for(int i = 0 ; i < n ; i++) cin >> a[i];

  	sort(a, a+n);

    for(int i = 0 ; i < m ; i++){
    	cin >> b >> c;
    	v.pb(mp(c, b));
    }

    sort(v.begin(), v.end(), greater<pair<ll, int> >());
    int i = 0;
    while(i < n){
    	if(iter < m){
    		a[i] = max(a[i], v[iter].first);
    		v[iter].second--;	
			if(v[iter].second == 0)
    			iter++;
    	}
    	ans += a[i];
    	i++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 

using namespace std; 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() << x; }
template<typename T> void db(T x , T y){ debug() << x <<" "<< y; }
template<typename T> void db(T x , T y , T z){ debug() << x <<" "<< y <<" "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() << x <<" " << y <<" "<< z <<" "<< a; }

const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

int Pow(int x , int y){
    int res = 1;
    while(y>0){
        if(y&1)
            res = res*x;
        y=y>>1;
        x = x*x;
    }
    return res;
}

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

  int X;
  cin >> X;
  map<int,int>mp;
  map<int,int>vis;

  for(int i=0;i<=xx;i++){
    int x = Pow(i,5);
    mp[x] = i;
    vis[x] = 1;
  }

  for(int i=0;i<=xx;i++){
    int x = Pow(i,5) - X;
    int M = abs(x);
    dg4(i , x , M , mp[M]);
    if(vis[M]){
      int ans = mp[M];
      if(x < 0) ans = ans * -1;

      cout << i <<" " << ans << '\n';
      return 0;
    }

  }

}

Measured memory_bytes: 28200
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        int alla = a[0];
        for(int i = 1; i < n; i++){
            alla = alla^a[i];
        }
        for(int i = 0; i < n; i++){
            System.out.println(alla^a[i]);
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

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

using namespace std;
typedef  long long ll;

#define pf printf
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) for(int i=(n-1);i>=(0);--i)
#define REPSZ(i,v) REP(i,SZ(v))
#define pll pair <ll, ll>

const ll mxn = 1e5+5;
ll mod = 1e9+7;
ll arr[mxn];
ll brr[mxn];
vector<ll>v;
bitset<mxn>used;
double eps = 1e-7;
ll n,m,k,cont,tc;
void print(vector <ll> &v){cout << v.size() << endl;for(int i = 0; i < v.size(); i++){pf("%lld ", v[i]);}pf("\n");}
void print(vector <pll> &v){ cout << v.size() << endl; for(int i = 0; i < v.size(); i++){pf("%lld %lld\n", v[i].first, v[i].second);}}
void print(set<ll> s){set <ll> :: iterator itr;for (itr = s.begin(); itr != s.end(); ++itr){cout << *itr << " ";}cout << endl;}
void print(double d){cout << fixed << setprecision(2) << d << endl;}
void print (ll *arr){REP(i,n)cout << arr[i] << " "; cout << endl;}

void from_file(void){ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}

/* ------------------main section-------------! */
ll Power(ll a, ll b) {
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

ll NcR(int n, int r) 
{ 
  
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
  
            ll m = __gcd(p, k); 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
    } 
  
    else
        p = 1; 
    return p;
} 

void solve()
{
    
}

void run() {
    fastio;
    ll n;
    cin >> n;
    if(n == 1)
    {
        cout << 0 << endl;
        return;
    }
    if(n == 2)
    {
        cout << 2 << endl;
        return;
    }
    ll all = Power(10,n);
    ll bad = ((2*Power(9,n))%mod - Power(8,n))%mod;
    ll ans = (all - bad + mod)%mod;
    cout << ans << endl;
}

int main() {
    #ifndef ONLINE_JUDGE
       from_file();
    #endif
    run();
    return 0;
}


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

int main() {

  long long int w, h;

  int walls[30][30];
  int wallv[30][30];

  while( true ) {

    cin >> w >> h;

    if ( w == 0 ) break;

    for ( long long int i = 0; i < h; i++ ) {

      for ( long long int j = 0; j < w - 1; j++ ) {
	cin >> walls[j][i];
      }
      if ( i == h - 1 ) break;
      for ( long long int j = 0; j < w; j++ ) {
	cin >> wallv[j][i];
      }

    }

    int map[30][30] = {};
    map[0][0] = 1;
    queue<int> qx, qy;
    qx.push(0);
    qy.push(0);

    while( qx.size() > 0 ) {

      int x = qx.front();
      int y = qy.front();
      qx.pop();
      qy.pop();

      if ( x > 0 ) {
	if ( walls[x-1][y] == 0 && map[x-1][y] == 0 ) {
	  map[x-1][y] = map[x][y] + 1;
	  qx.push(x-1);
	  qy.push(y);
	}
      }
      if ( x < w - 1 ) {
	if ( walls[x][y] == 0 && map[x+1][y] == 0 ) {
	  map[x+1][y] = map[x][y] + 1;
	  qx.push(x+1);
	  qy.push(y);
	}
      }
      if ( y > 0 ) {
	if ( wallv[x][y-1] == 0 && map[x][y-1] == 0 ) {
	  map[x][y-1] = map[x][y] + 1;
	  qx.push(x);
	  qy.push(y-1);
	}
      }
      if ( y < h - 1 ) {
	if ( wallv[x][y] == 0 && map[x][y+1] == 0 ) {
	  map[x][y+1] = map[x][y] + 1;
	  qx.push(x);
	  qy.push(y+1);
	}
      }

      if ( map[w-1][h-1] != 0 ) break;

    }

    cout << map[w-1][h-1] << endl;

  }

  return 0;

}

Measured memory_bytes: 1240
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc076.contest.atcoder.jp/tasks/arc076_a>
問題文============================================================
 すぬけ君は、犬を N 匹と猿を M 匹飼っています。すぬけ君は、この N+M 匹を一列に並べようと思っています。
 
 文字通り犬猿の仲の犬たちと猿たちを仲直りさせたいすぬけ君は、
 犬同士、または猿同士が隣り合うところができないように並べようと思っています。
 
 このような並べ方は何通りあるでしょうか。
 犬と猿は 10^9+7 以上の数を理解できないので、並べ方の個数を 10^9+7 で割ったあまりを求めてください。
 ただし、犬同士、また猿同士は互いに区別します。また、左右が反転しただけの列も異なる列とみなします。
=================================================================

解説=============================================================

 良くある組み合わせ問題
 
 NとMの差が２以上であれば、交互に配置することができないので 1
 差が1であれば、 N!*M!
 差が0であれば 2*N!*M!
================================================================
*/
const ll MOD = 1e9+7;
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,M; cin >> N >> M;
    ll ans = 1;
    if(abs(N-M)>=2){
        ans = 0;
    }else if(abs(N-M)==1){
        if(M < N) swap(N,M);
        for(ll i = 1; i <= N; i++){
            (ans *= i)%=MOD;
        }
        ans = (ans * ((ans*M)%MOD))%MOD;
    }else{
        for(ll i = 1; i <= N; i++){
            (ans *= i)%=MOD;
        }
        ans = (((ans * ans)%MOD)*2)%MOD;
    }
    cout << ans << endl;
	return 0;
}


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

bool f(int x)
{
    int keta = 0;
    while (x)
    {
        keta++;
        x /= 10;
    }
    return keta % 2 == 1;
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (f(i))
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

const int maxn=2e5+10;
long long n,d,a,c[maxn];
struct Node
{
    long long x,h;
}p[maxn];
bool cmp(Node A,Node B)
{
    return A.x<B.x;
}
int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    scanf("%lld%lld%lld",&n,&d,&a);
    for(int i = 1 ; i<=n ; i++)
    {
        scanf("%lld",&p[i].x);
        scanf("%lld",&p[i].h);
    }
    sort(p+1,p+n+1,cmp);
    long long ans=0;
    for(int i=1,j=1;i<=n;i++)
    {
        while(j<=n&&p[j].x<=p[i].x+2*d) ++j;
        long long need=max(0ll,(p[i].h-c[i]*a+a-1)/a);
        ans+=need;
        c[i]+=need;
        c[j]-=need;
        c[i+1]+=c[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

bool isGumogiretsu(string s)
{
	for(int i = 0; i < s.length() / 2; i++){
		if(s[i] != s[i + s.length() / 2]) return false;
	}
	return true;
}

int main()
{
	string s;
	cin >> s;
	int l = s.length() - 1;
	if(l % 2 == 1) l--;
	for(int i = l; i >= 0; i -= 2){
		if(isGumogiretsu(s.substr(0, i))){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int ans = 1;
long long n, num = 0;

int main(){
	cin >> n;

	for (long long i = 1; i <= sqrt(n); i++){
		if (n % i == 0){
			num = n / i;
		}
	}
	while (num / 10 > 0){
		num /= 10;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
int main(void){
	int a,b;
	
	while(1){
		scanf("%d %d",&a,&b);
		if(a == 0&&b == 0)break;
		if(a < b)printf("%d %d\n",a,b);
		else printf("%d %d\n",b,a);
	}
		
	return 0;
}

Measured memory_bytes: 596