akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	if (A >= 1 && A <= 9 && B >= 1 && B <= 9) cout << A * B << "\n";
	else cout << -1 << "\n";
	return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long n=sc.nextLong();
      for(long i=n; i>0L; i--){
        double sqrtOf=Math.sqrt(i);
        if(sqrtOf==Math.floor(sqrtOf)){
        	System.out.println(i);
            return;
        }
      }
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

vector<string> ans;
int n;
void dfs(string s){
    if(s.size()==n){
        ans.push_back(s);
        return;
    }

    char ma='a';
    rep(i,s.size()){
        ma=max(ma,s[i]);
    }
    
    if(ma=='z'){
        for(char x='a';x<='z';x++){
            dfs(s+x);
        }
    }
    else{
        for(char x='a';x<=char(ma+1);x++){
            dfs(s+x);
        }
    }
    
}

int main() {
    
    cin>>n;

    dfs("a");

    sort(all(ans));
    rep(i,ans.size()) cout<<ans[i]<<endl;
}

Measured memory_bytes: 7316
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i=(a); i < (b); ++i)
#define pb push_back
#define fs first
#define sc second
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const double EPS = 1e-9;

struct node {
  int l, r;
  int x, lazy;
  node() {}
  node(int _l, int _r) : l(_l), r(_r), x(0), lazy(0) { }
  node(int _l, int _r, int _x) : node(_l,_r) { x = _x; }
  node(node a, node b) : node(a.l,b.r) { x = max(a.x, b.x); }
  void update(int v) { x = v; }
  void range_update(int v) { lazy = v; }
  void apply() { x += lazy; lazy = 0; }
  void push(node &u) { u.lazy += lazy; } };

struct segment_tree {
  int n;
  vector<node> arr;
  segment_tree() { }
  segment_tree(const vector<ll> &a) : n(a.size()), arr(4*n) {
    mk(a,0,0,n-1); }
  node mk(const vector<ll> &a, int i, int l, int r) {
    int m = (l+r)/2;
    return arr[i] = l > r ? node(l,r) :
      l == r ? node(l,r,a[l]) :
      node(mk(a,2*i+1,l,m),mk(a,2*i+2,m+1,r)); }
  node update(int at, ll v, int i=0) {
    propagate(i);
    int hl = arr[i].l, hr = arr[i].r;
    if (at < hl || hr < at) return arr[i];
    if (hl == at && at == hr) {
      arr[i].update(v); return arr[i]; }
    return arr[i] =
      node(update(at,v,2*i+1),update(at,v,2*i+2)); }
  node query(int l, int r, int i=0) {
    propagate(i);
    int hl = arr[i].l, hr = arr[i].r;
    if (r < hl || hr < l) return node(hl,hr);
    if (l <= hl && hr <= r) return arr[i];
    return node(query(l,r,2*i+1),query(l,r,2*i+2)); }
  node range_update(int l, int r, ll v, int i=0) {
    propagate(i);
    int hl = arr[i].l, hr = arr[i].r;
    if (r < hl || hr < l) return arr[i];
    if (l <= hl && hr <= r)
      return arr[i].range_update(v), propagate(i), arr[i];
    return arr[i] = node(range_update(l,r,v,2*i+1),
                         range_update(l,r,v,2*i+2)); }
  void propagate(int i) {
    if (arr[i].l < arr[i].r)
      arr[i].push(arr[2*i+1]), arr[i].push(arr[2*i+2]);
    arr[i].apply(); } };

int main() {
    cin.sync_with_stdio(false);
    int n, k, mx = 0; cin >> n >> k;
    vi a(n);
    rep(i,0,n) cin >> a[i];
    vector<ll> jnk(300001, 0);
    segment_tree st(jnk);
    for(int i = n - 1; i >= 0; --i) {
        int lo = max(0, a[i] - k);
        int hi = min(300000, a[i] + k);
        int bst = st.query(lo, hi).x + 1;
        mx = max(mx, bst);
        st.update(a[i], bst);
    }
    cout << mx << endl;
}


Measured memory_bytes: 23336
use whiteread::parse_line;

fn main() {
    let n: u32 = parse_line().unwrap();
    let a: Vec<u32> = parse_line().unwrap();
    let mut cnt = 0;

    if !a.contains(&1) {
        println!("-1");
        return;
    }
    let mut iter = a.iter();
    'outer: for i in 1..=n {
        loop {
            match iter.next() {
                Some(x) if x == &i => break,
                Some(_) => cnt += 1,
                None => break 'outer,
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4276
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}
 
int main()
{
    ll n,m,a,b,ans=0,cnt=0;
    cin >> n >> m;
    vector<pair<ll,ll>> p(n);
    rep(i,n){
        cin >> a >> b;
        p[i]=make_pair(a,b);
    }
    sort(all(p));
    while(m>0){
        p[cnt].second--;
        m--;
        ans+=p[cnt].first;
        if(p[cnt].second==0) cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;
int main() {
	cin >> N >> M;
	vector<int>l(M), r(M);
	for (int i = 0; i < M; i++)cin >> l[i] >> r[i];
	ans = *min_element(r.begin(), r.end()) - *max_element(l.begin(), l.end())+1;
	cout <<((ans>0)?ans:0) << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll N, Pos = 26, i, D=1;
string s="";
char c;
int main()
{
    cin >> N;
    while(N>Pos)
    {
        N-= Pos;
        Pos *= 26;
        D += 1;
    }
    //cout << N << endl;
    N -= 1;
    while(D--)
    {

        ll temp = N%26;
        c = 'a'+temp;
        s = c+s;
        N /= 26;
    }
    cout << s << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(){
int a[101],b,i,max=-1,min=1001,x,y,o=0;
while(1){
scanf("%d\n",&b);
if(b==0){
break;
}
else{
for(i=0;i<b;i++){
scanf("%d\n",&a[i]);
if(a[i]>=max){
max=a[i];
x=i;
}
if(a[i]<=min){
min=a[i];
y=i;
}
}
for(i=0;i<b;i++){
if(i!=x && i!=y){
o=o+a[i];
}
}
b=b-2;
printf("%d\n",o/b);
max=-1,min=1001,o=0;
}
}
return 0;
}


Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
const int N=3000;
long double prob[N], dp[N][N];
int main()
{
    int n; cin >> n;
    for (int i=1 ; i<=n ; i++)
        cin >> prob[i];
    dp[1][0]=1-prob[1];
    dp[1][1]=prob[1];
    for (int i=2 ; i<=n ; i++)
        for (int j=0 ; j<=i ; j++)
        {
            dp[i][j]=dp[i-1][j]*(1-prob[i]);
            if (j) dp[i][j]+=dp[i-1][j-1]*prob[i];
        }
    long double ans=0;
    for (int i=(n+1)/2 ; i<=n ; i++)
        ans+=dp[n][i];
    cout << fixed << setprecision(12) << ans;
    return 0;
}


Measured memory_bytes: 139008
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int L = 3;
const int M = 1000000007;

int n, m;

struct matrix
{
	int a[L][L];

	friend inline matrix operator*(const matrix &lhs, const matrix &rhs)
	{
		matrix res;
		for (int i = 0; i < L; ++i)
			for (int j = 0; j < L; ++j)
			{
				s64 s = 0;
				for (int k = 0; k < L; ++k)
					s += (s64)lhs.a[i][k] * rhs.a[k][j];
				res.a[i][j] = s % M;
			}
		return res;
	}
};
matrix p, q, r;

inline matrix matpow(matrix a, const int &n)
{
	matrix res;
	for (int i = 0; i < L; ++i)
		for (int j = 0; j < L; ++j)
			res.a[i][j] = 0;
	for (int i = 0; i < L; ++i)
		res.a[i][i] = 1;

	for (int i = n; i; i >>= 1)
	{
		if (i & 1)
			res = res * a;
		a = a * a;
	}

	return res;
}

int main()
{
	p.a[0][0] = 1, p.a[0][1] = 2, p.a[0][2] = 1;
	p.a[1][0] = 0, p.a[1][1] = 1, p.a[1][2] = 1;
	p.a[2][0] = 1, p.a[2][1] = 2, p.a[2][2] = 2;

	q.a[0][0] = 1, q.a[0][1] = 2, q.a[0][2] = 1;
	q.a[1][0] = 0, q.a[1][1] = 1, q.a[1][2] = 1;
	q.a[2][0] = 0, q.a[2][1] = 0, q.a[2][2] = 1;

	r.a[0][0] = 1, r.a[0][1] = 0, r.a[0][2] = 0;
	r.a[1][0] = 0, r.a[1][1] = 0, r.a[1][2] = 0;
	r.a[2][0] = 0, r.a[2][1] = 0, r.a[2][2] = 0;

	cin >> n >> m;

	int l = -1;
	for (int i = 0, k; i < m; ++i)
	{
		cin >> k;
		r = r * matpow(p, k - l - 1) * q;
		l = k;
	}

	r = r * matpow(p, n - l - 1);

	cout << r.a[0][2] << endl;

	return 0;
}

Measured memory_bytes: 256
import math

a,b,x = map(int,input().split())
c = 2*x/(a*b)

if c <= a:
    ans = 90 - math.degrees(math.atan(c/b))
    
else:
    d = 2*(a**2 * b - x)/a**2
    
    if d == 0:
        ans = 0
    else:
        ans = 90 - math.degrees(math.atan(a/d))
    
print(ans)

Measured memory_bytes: 9384
result = []
while True:
    info = [int(n) for n in input().split()]
    if info[0]==info[1]==info[2]==-1:
        break
    elif -1 in info[:2]:
        result.append("F")
    elif info[0] + info[1] >= 80:
        result.append("A")
    elif 65 <= info[0] + info[1] < 80:
        result.append("B")
    elif 50 <= info[0] + info[1] < 65:
        result.append("C")
    elif 30 <= info[0] + info[1] < 50 and info[2] >= 50:
        result.append("C")
    elif 30 <= info[0] + info[1] < 50:
        result.append("D")
    else:
        result.append("F")
for i in result:
    print(i)
    


Measured memory_bytes: 5604
n = int(input())
p = list(map(int,input().split()))
q = []
for i in range(n):
    if p[i] == i+1:
        continue
    else:
        q.append(i)
if len(q) == 2 or len(q) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9220
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll N,K;
    cin >> N >> K;
    cout << ((N+1)/2>=K ? "YES" : "NO" ) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>
using namespace std;
int W, H, N;
vector<vector<bool>> men(101,vector<bool>(101,true));

void menseki(int X, int Y, int A){
    
    if(A == 1){
        for(int i = 1; i <= H; i++){
            for(int j = 1; j <= X; j++){
                men[i][j] = false;
            }
        }
        return ;    
    }
    
    if(A == 2){
        for(int i = 1; i <= H; i++){
            for(int j = X+1; j <= W; j++){
                men[i][j] = false;
            }
        }
        return ;
    }
    
    if(A == 3){
        for(int i = 1; i <= Y; i++){
            for(int j = 1; j <= W; j++){
                men[i][j] = false;
            }
        }
        return ;    
    }
    
    if(A == 4){
        for(int i = Y+1; i <= H; i++){
            for(int j = 1; j <= W; j++){
                men[i][j] = false;
            }
        }
        return ;    
    }
    
}


int main(void){

    int x, y, a;
    cin >> W >> H >> N;
    for(int i = 0; i < N; i++){
        cin >> x >> y >> a;
        menseki(x, y, a);
    }
    
    int menseki_Ans = 0;
    
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            //cout << men[i][j] << " ";
            if(men[i][j]) menseki_Ans++;
        }//cout << endl;
    }
    
    cout << menseki_Ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();
 
 //   String[] s=sc.nextLine().split(" ");
   //  String[] e=sc.nextLine().split(" ");

int N=Integer.parseInt(nyuA);

//int Y=Integer.parseInt(e[1]);
//int Z=Integer.parseInt(e[2]);

String[] Ns=nyuA.split("");
int shu=0;
for(String temp:Ns){
shu+=Integer.parseInt(temp);
}

if(N%shu==0)
System.out.println("Yes");
else
System.out.println("No");


}

}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    while (i + 1 < n && vec[i] >= vec[i+1]) {
      cnt++;
      i++;
      ans = max(ans, cnt);
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 640
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C, X, Y = map(int, readline().split())
    ans = A*X+B*Y
    if X>=Y:
        ans = min(ans, C*Y*2+A*(X-Y), C*X*2)
    else:
        ans = min(ans, C*X*2+B*(Y-X), C*Y*2)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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

using namespace std;

int gcd(int a, int b){
    int r;
    if(a>b){
        swap(a, b);
    }
    while(b>0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main() {
    int N, K;
    int A[100000];
    scanf("%d %d", &N, &K);
    REP(i, N){
        scanf(" %d", &A[i]);
    }
    int r = A[0];
    int maxA = A[0];
    FOR(i, 1, N){
        r = gcd(r, A[i]);
        maxA = max(maxA, A[i]);
    }
    if(K<=maxA && K%r==0){
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    REP(i,N)cin >> A[i];
    REP(i,N)cin >> B[i];
    REP(i,N - 1)cin >> C[i];
    int bef = -2;
    int saty = 0;
    REP(i,N){
        saty += B[A[i]-1];
        if(bef + 1 == A[i]-1)saty += C[A[i] - 2];
        bef = A[i]-1;
    }
    cout <<saty<< "\n";
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  vll as(n);
  rep(i, n) cin >> as[i];

  vvll dp(n + 1, vll(k + 1, 0));
  vll csum;
  dp[0][k] = 1;
  repLRE(i, 1, n) {
    csum.assign(k + 2, 0);
    rep(j, k + 1) csum[j + 1] = (dp[i - 1][j] + csum[j])%mod;
    rep(j, k + 1) {
      ll bp = min(k + 1, j + as[i-1] + 1);
      dp[i][j] = (csum[bp] - csum[j] + mod)%mod;
    }
  }

  cout << dp[n][0] << endl;

  return 0;
}


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

int main()
{
    string str;
    int x,cnt=0;
    cin>>str;
    int len=str.length();
    for(int i=0;i<len;i++)
    {
        if(str[i]=='o')
            cnt++;
    }
    if(cnt==3)
    {
        x=700+100*3;
    }
    else if(cnt==2)
        x=700+100*2;
    else if(cnt==1)
        x=700+100;
    else
        x=700;
    cout<<x;
}

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

int a[51][51];

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];

    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '.') continue;
            a[i][j] = -1;

            for (int dy = -1; dy <= 1; dy++) {
                for (int dx = -1; dx <= 1; dx++) {
                    if (dx == 0 && dy == 0) continue;
                    int y = i + dy;
                    int x = j + dx;
                    if (y >= 0 && y < h && s[y][x] == '.') a[y][x]++;
                }
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            if (a[i][j] == -1)
                cout << '#';
            else
                cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;


void func()
{
	string S;
	cin >> S;

	if (S[1] == 'R')
		cout << "ABC\n";
	else
		cout << "ARC\n";

	return;
}

int main() {

//	while (1)
		func();
	return 0;
}


Measured memory_bytes: 3036
import math
a,b=map(int,input().split())
count=1
while True:
  c=count*0.08
  d=count*0.1
  if math.floor(c)==a and math.floor(d)==b:
    print(count)
    break
  count+=1
  if count>1500:
    print(-1)
    break

Measured memory_bytes: 9108
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

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

ll l, r;

void func() {
    cin >> l >> r;
    if (r - l + 1 >= 2019) {
        cout << 0 << endl;
        return;
    }
    l %= 2019; r %= 2019;
    if (r < l) {
        cout << 0 << endl;
        return;
    }
    ll ans = INT64_MAX;
    for (ll i = l; i <= r; i++) {
        for (ll j = i + 1; j <= r; j++) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
}

int main() {
    fast_io; cout.precision(32);
    ll t = 1; // cin >> t;
    for (ll i = 1; i <= t; i++) {
        func();
    }
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	string s;
	while (cin >> N >> s, N) {
		int num=0;
		vector<string>ans;
		int cnt = 0;
		for (int i = 0; i < 1 << (s.size() - 1); i++) {
			vector<string>box;
			int sum = 0;
			box.push_back(string(1, s[0]));
			for (int j = 0; j < s.size() - 1; j++) {
				if ((i >> j) & 1) {
					box.push_back(string(1, s[j + 1]));
				}
				else {
					box.back().push_back(s[j + 1]);
				}
			}
			for (auto j : box) {
				sum += stoi(j);
			}
			if (sum <= N && num < sum) {
				num = sum;
				ans = box;
				cnt = 1;
			}
			else if (num == sum) {
				cnt++;
			}
		}
		if (cnt == 1) {
			cout << num;
			for (auto i : ans)cout << " " << i;
			cout << endl;
		}
		else if (cnt == 0) {
			cout << "error" << endl;
		}
		else {
			cout << "rejected" << endl;
		}
	}
}


Measured memory_bytes: 3036
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#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 double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

const int lim = 50;
int n,m;
int a[lim], b[lim];
bool G[lim][lim], visited[lim];

void dfs(int v){
  visited[v] = true;
  for(int v2 = 0; v2 < n; v2++){
    if(G[v][v2]==false) continue;
    if(visited[v2]==true) continue;
    dfs(v2);
  }
}

signed main(){
	cin>>n>>m;
  rep(i,m){
    cin>>a[i]>>b[i]; a[i]--; b[i]--;
    G[a[i]][b[i]] = G[b[i]][a[i]] = true;
  }
  int ans = 0;
  rep(i,m){
    G[a[i]][b[i]] = G[b[i]][a[i]] = false;
    rep(j,n) visited[j] = false;
    dfs(0);

    bool bridge = false;
    rep(j,n) if(visited[j]==false) bridge = true;
    if(bridge) ans += 1;

    G[a[i]][b[i]] = G[b[i]][a[i]] = true;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//                                                     _        _ _ _____  ___
//                               _ __ ___   __ _ _ __ | |_ __ _/ / |___ / / _ \
//                              | '_ ` _ \ / _` | '_ \| __/ _` | | | |_ \| | | |
//                              | | | | | | (_| | | | | || (_| | | |___) | |_| |
//                              |_| |_| |_|\__,_|_| |_|\__\__,_|_|_|____/ \___/

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}


use input::*;
 
fn main() {
    let n: usize;
    input!(n);
    let mut x = 1;
    let mut y = 1;
 
    for _ in 0..n {
        let (a, b): (usize, usize);
        input!(a, b);
        let n;
 
        let mut i = x / a;
        let mut j = y / b;
        if x % a != 0 {
            i += 1;
        }
        if y % b != 0 {
            j += 1;
        }
 
        n = std::cmp::max(i, j);
 
        x = n * a;
        y = n * b;
    }
    p(x + y);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define I __int128
#define L long long
using namespace std;
const int q=998244353;
I n,x[110];
map<I,int> f;
char s[110];
inline int dp(I n,int w)
{
    if(f[n])
      return f[n];
    int i,j,k=dp(n>>1,w-1);
    if(n&1)
      k=k*2%q;
    for(i=1;i*2<=w;i++)
      {
       I m=n,l=n&x[i];
       m>>=i;
       for(j=2;i*j<=w;j++)
         {
          l&=m&x[i];
          m>>=i;
          l|=(I)1<<i;
          k=(k+(L)dp(l,i)*dp(m,w-i*j))%q;
         }
      }
    f[n]=k;
    return k;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	x[1]=1;
	for(i=2;i<=100;i++)
	  x[i]=x[i-1]*2+1;
	scanf("%s",&s);
	for(i=0,n=1;i<strlen(s);i++)
	  n=n*2+s[i]-'0';
	f[1]=1;
	printf("%d\n",dp(n,strlen(s)));
	return 0;
}


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

const double INF = 1e+5;
int n;
double pw,vw[100010],pf[100010],vf[100010],th[100010];

double f(double w){
	double ret = w * pw;
	for(int i = 0;i < n;i++){
		double fi = max(0.0,(th[i] - w * vw[i]) / vf[i]);
		ret += fi * pf[i];
	}
	return ret;
}

void solve(){
	cin >> pw;
	for(int i = 0;i < n;i++) cin >> vw[i] >> pf[i] >> vf[i] >> th[i];
	double low = 0,up = INF;
	for(int i = 0;i < 100;i++){
		double mid1 = (low * 2 + up) / 3,mid2 = (low + up * 2) / 3;
		if(f(mid1) < f(mid2)) up = mid2;
		else low = mid1;
	}
	printf("%.15lf\n",f(low));
}

signed main(){
	while(cin >> n,n) solve();
}


Measured memory_bytes: 6320
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, C;
ll D[40][40], c[510][510];
ll t[3][40];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N>>C;
    REP(i,0,C){
        REP(j,0,C){
            cin>>D[i][j];
        }
    }
    REP(i,0,N){
        REP(j,0,N){
            cin>>c[i][j];
            t[(i+j)%3][c[i][j]-1]++;  //変更前の色をカウントしておく
        }
    }

    ll ans = LLINF;

    //各グループ(0,1,2)の色がかぶらないように全探索
    REP(i,0,C){
        REP(j,0,C) {
            if(i == j) continue;
            REP(k,0,C) {
                if(i == k || j == k)continue;

                ll mi[3] = {0LL, 0LL, 0LL};
                REP(l,0,C){ //l: 変更前の色
                    mi[0] += D[l][i]*t[0][l];
                    mi[1] += D[l][j]*t[1][l];
                    mi[2] += D[l][k]*t[2][l];
                }

                ans = min(ans, mi[0]+mi[1]+mi[2]);
            }
        }
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 2304
package main

import (
	"fmt"
	"sort"
)

type Shop struct {
	A int
	B int
}

type Shops []Shop

func (shops Shops) Len() int {
	return len(shops)
}

func (shops Shops) Swap(i, j int) {
	shops[i], shops[j] = shops[j], shops[i]
}

func (shops Shops) Less(i, j int) bool {
	return shops[i].A < shops[j].A
}

func main() {
	var N, M int
	_, _ = fmt.Scan(&N, &M)
	var shops Shops = make([]Shop, N)
	for i := 0; i < N; i++ {
		_, _ = fmt.Scan(&shops[i].A, &shops[i].B)
	}
	sort.Sort(shops)
	cnt := 0
	sum := int64(0)
	for i := 0; ; i++ {
		shop := shops[i]
		if cnt + shop.B < M {
			cnt += shop.B
			sum += int64(shop.A * shop.B)
		} else if cnt + shop.B >= M {
			add := M - cnt
			cnt += add
			sum += int64(shop.A * add)
			break
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5376
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

int main(){
	string str;
	cin>>str;
	int n=str.size();
	n--;
	ll ans=0;
	for(int i=0;i<(1<<n);i++){
		int num=i;
		ll hoge=str[0]-'0';
		//ll acc=0;
		for(int j=1;j<n+1;j++){
			if(num%2==1){
				ans+=hoge;
				//cout<<hoge<<endl;
				hoge=str[j]-'0';
				if(j==n)ans+=hoge;
			}else{
				hoge=hoge*(ll)10+(ll)(str[j]-'0');
				if(j==n)ans+=hoge;
			}
			num/=2;
		}
	}
	if(n==0)ans+=str[0]-'0';
	cout<<ans<<endl;
}

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

static inline vector<vector<long>> read(vector<vector<long>> v) {
    for (auto &x: v)
        for (long &y : x)
            cin >> y;
    return move(v);
}

int main(void)
{
    long n, m, l;
    cin >> n >> m >> l;
    vector<vector<long>> a(n, vector<long>(m));
    vector<vector<long>> b(m, vector<long>(l));
    a = read(move(a));
    b = read(move(b));

    for (long i = 0; i < n; i++) {
        for (long j = 0; j < l; j++) {
            long sum = 0;
            for (long k = 0; k < m; k++)
                sum += a[i][k] * b[k][j];
            if (j)
                cout << " ";
            cout << sum;
        }
        cout << endl;
    }

    return 0;
}



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

int main(){
 string N;
 cin >> N;
  if((N[0] == N[1] && N[1] == N[2])||(N[1] == N[2] && N[2]==N[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        n: usize,
        a: [i64;n],
    }
    let mut ans = 0;
    let mut ch = a[0];
    let mut count = 1;
    for i in 1..n {
        if ch == a[i] {
            count+=1;
        }else{
            ch = a[i];
            ans+=count/2;
            count = 1;
        }
        if i==n-1 && count !=1 {
            ans+=count/2;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
N = int(input())
A = list(map(int, input().split()))
ans = 0
endflag=False
while True:
  for i in range(N):
    if A[i]%2 == 1:
      endflag = True
      print(ans)
      break
    else:
      A[i] = A[i]/2
  if endflag:
    break
  ans+=1

Measured memory_bytes: 2940
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    L = read_ints()
    answer = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and L[i]+L[j] > L[k] and L[k]+L[j] > L[i] and L[i]+L[k] > L[j]:
                    answer += 1
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 67928
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b;
}


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

void pv(vector<int>& v) {
    cout << "{ ";
    for (auto el: v) {
        cout << el << ", ";
    }
    cout << " }" << endl;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    int num;
    unordered_map<int, int> m;
    unordered_set<int> s;
    int maxi = 0;
    for (int i = 0; i < n; i++) {
        cin >> num;
        m[num] += 1;
        s.insert(num);
        maxi = max(num, maxi);
    }
        
    for (auto it: m) {
        int a = 2, b = it.first;
        while (a * b <= maxi) {
            s.erase(a * b);
            a++;
        }
    }
    int ans = 0;
    for (auto el : s) {
        if (m[el] == 1) {
            ans += 1;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 19716
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

const int N=1005;
const ll mod=1e9+7;
int n,a,b,c,d;
ll fact[1005],C[1005][1005],dp[1005][1005];

ll fpow(ll a,ll p){
	ll res=1;
	while(p){
		if(p&1) res=res*a%mod;
		a=a*a%mod;
		p>>=1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>a>>b>>c>>d;
	fact[0]=1;
	for(ll i=1;i<N;++i) fact[i]=fact[i-1]*i%mod;
	for(int i=0;i<N;++i) C[i][0]=1;
	for(int i=1;i<N;++i)
		for(int j=1;j<=i;++j)
			(C[i][j]=C[i-1][j-1]+C[i-1][j])%=mod;
	dp[a-1][0]=1;
	for(int i=a;i<=b;++i)
		for(int j=0;j<=n;++j){
			dp[i][j]=dp[i-1][j];
			for(int k=c;k<=d;++k){
				if(k*i>j) break; // O(N^2*log(N)) due to harmonic series tight bound O(logN)
				ll val=dp[i-1][j-k*i]*C[n-j+k*i][k*i]%mod*fact[k*i]%mod;
				(val*=fpow(fpow(fact[i],k),mod-2))%=mod;
				(val*=fpow(fact[k],mod-2))%=mod;
				(dp[i][j]+=val)%=mod;
			}
		}
	cout<<dp[b][n]<<'\n';
}



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

struct Node{
        int key;
        Node *parent, *left, *right;
};

static Node *root;

void insert(int v, Node *t){
        if(!root) {
                Node *a = new Node();
                a->key = v;
                a->parent = NULL;
                a->left = NULL;
                a->right = NULL;
                root = a;
        }else if(v<=t->key){
                if(!t->left) {
                        Node *a = new Node();
                        a->key = v;
                        a->parent = t;
                        a->left = NULL;
                        a->right = NULL;
                        t->left = a;
                }else{
                        insert(v, t->left);
                }
        }else{
                if(!t->right) {
                        Node *a = new Node();
                        a->key = v;
                        a->parent = t;
                        a->left = NULL;
                        a->right = NULL;
                        t->right = a;
                }else{
                        insert(v, t->right);
                }
        }
}

bool find(int v){
        Node *i = root;
        while(i!=NULL){
                if(v==i->key) return true;
                else if(v<i->key) i = i->left;
                else i = i->right;
        }
        return false;
}

void print_preorder(Node *i){
        if(!i) return;
        cout<<" "<<i->key;
        print_preorder(i->left);
        print_preorder(i->right);
}

void print_inorder(Node *i){
        if(!i) return;
        print_inorder(i->left);
        cout<<" "<<i->key;
        print_inorder(i->right);
}

int main(){
        int n,v;
        string s;
        cin>>n;
        root = NULL;
        for(int i=0;i<n;i++){
                cin>>s;
                if(s=="insert") {
                        cin>>v;
                        insert(v,root);
                }else if(s=="find"){
                        cin>>v;
                        if(find(v)) cout<<"yes"<<endl;
                        else cout<<"no"<<endl;
                }else if(s=="print"){
                        print_inorder(root);
                        cout<<endl;
                        print_preorder(root);
                        cout<<endl;
                }
        }
        return 0;
}


Measured memory_bytes: 21776
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
mod = 10**9 + 7

ans = 1

for i in range(n):
    ans *= 10
    ans %= mod

ans_2 = 1

for i in range(n):
    ans_2 *= 9
    ans_2 %= mod
ans_3 = 1

for i in range(n):
    ans_3 *= 8
    ans_3 %= mod


print((ans - 2*ans_2 + ans_3) % mod)

Measured memory_bytes: 64308
#include <iostream>

int main() {
  long long low, high, x;
  long long num = 0;
  std::cin >> low;
  std::cin >> high;
  std::cin >> x;

  if(low % x == 0)
    num++;
  low = low / x;
  high = high / x;
  num += high - low;
  std::cout << num << std::endl;
}


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

struct node {
  int key;
  struct node *prev, *next;
};

struct node *nil;

void insert(int);
void delete(struct node*);
struct node* search(int);
void listPrint(void);

int main() {
  int n, i, x;
  char str[15];

  scanf("%d", &n);
  nil = (struct node*)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;

  for(i = 0; i < n; i++) {
    scanf("%s", str);
    if(str[0] == 'i') {
      scanf("%d", &x);
      insert(x);
    }
    else if(str[0] == 'd' ) {
      if(str[6] == '\0') {
        scanf("%d", &x);
        delete(search(x));
      }
      else if(str[6] == 'F') {
        delete(nil->next);
      }
      else {
        delete(nil->prev);
      }
    }
  }
  listPrint();
  return 0;
}

void insert(int key) {
  struct node* newnode = (struct node*)malloc(sizeof(struct node));
  newnode->key = key;
  newnode->next = nil->next;
  nil->next->prev = newnode;
  nil->next = newnode;
  newnode->prev = nil;
}

void delete(struct node* delnode) {
  if(delnode == nil) {;}
  else {
    delnode->prev->next = delnode->next;
    delnode->next->prev = delnode->prev;
    free(delnode);
  }
}

struct node* search(int key) {
  struct node* searchnode = nil->next;
  while (searchnode != nil && searchnode->key != key) {
    searchnode = searchnode->next;
  }
  return searchnode;
}

void listPrint() {
  int i = 0;
  struct node* n = nil->next;
  while (1) {
    if(n == nil) break;
    if(i > 0) printf(" ");
    i++;
    printf("%d", n->key);
    n = n->next;
  }
  printf("\n");
}

Measured memory_bytes: 31784
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string S, T;
  std::cin >> S;
  std::cin >> T;
  int Q, a, b, c, d;
  std::cin >> Q;
  std::vector<int> s(S.size()+1, 0), t(T.size()+1, 0);
  for(int i=0;i<S.size();i++) s[i+1] = s[i] + (S[i]=='A'?1:2);
  for(int i=0;i<T.size();i++) t[i+1] = t[i] + (T[i]=='A'?1:2);
  for(int q=0;q<Q;q++){
    std::cin >> a >> b >> c >> d;
    //std::cout << s[b] << " " << s[a-1] << " " << t[d] << " " << t[c-1] << '\n';
    if((s[b]-s[a-1])%3==(t[d]-t[c-1])%3) std::cout << "YES" << '\n';
    else std::cout << "NO" << '\n';
  }
  return 0;
}


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

void solve() {
    int sz[6];
    int s = 0;
    for(int i=1;i<6;i++) {
        scanf("%d",&sz[i]);
        if(!s&&!sz[i]) {
            s = i;
        }
    }
    printf("%d\n",s);
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3720
a,b,k=map(int,input().split())
ans=[]
for i in range(k):
    if a<=a+i and a+i<=b:
        ans.append(a+i)
    if a<=b-i and b-i<=b:
        ans.append(b-i)
ans=list(set(ans))
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 3060
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>
//#include <utility>

using namespace std;
const long nPrime = 1000000007;

void LF_Prime_Sequence(const long &n, vector<long> &viPrime){
    if(n < 2){
        return;
    }
    viPrime.clear();
    vector<char> aiType(n + 1,0);
    for (long i = 2; i * i <= n; i++){
        for(long j = 2; j * i <= n; j++){
            aiType[j * i] = 1;
        }
    }
    for (long i = 2; i <= n; i++){
        if(aiType[i] == 0){
            viPrime.push_back(i);
        }
    }
    return;
}
void LF_Factorization(long n, vector<pair<long, long>> &viiFactor){
    if(n < 2){
        return;
    }
    vector<long> viPrime;
    LF_Prime_Sequence(sqrt(n)+1, viPrime);

    for(long i = 0; i < viPrime.size(); i++){
        if(n == 1){
            break;
        }
        long nCount = 0;
        while(n % viPrime[i] == 0){
            n /= viPrime[i];
            nCount++;
        }
        if(nCount > 0){
            viiFactor.push_back(make_pair(viPrime[i], nCount));
        }
    }
    if(n > 1){
        viiFactor.push_back(make_pair(n, 1));
    }
    return;
}

//階乗
long Factorial(const long &n){
    //nPrime = 1000000007
    long nReturn = 1;
    for(long i = 2; i <= n; i++){
        nReturn *= i;
        nReturn %= nPrime;
    }
    return nReturn;
}

//素数の逆元
long Inverse(const long &n){
    //nPrime = 1000000007
    if (n % nPrime == 0){
        return 0;
    }
    long a = n, b = nPrime, u = 1, v = 0;
    while (b > 0) {
        long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= nPrime;
    if (u < 0){
        u += nPrime;
    }
    return u;    
}

int main(){
    long n, m;
    scanf("%ld %ld", &n, &m);
    if(n == 1){
        printf("1");
        return 0;
    }
    vector<pair<long, long>> viiFactor;
    LF_Factorization(m,viiFactor);
    
    long nAns = 1;
    for(long i = 0; i < viiFactor.size(); i++){//高々32個
        long k = viiFactor[i].second;
        long nChoose = Factorial(n-1) * Factorial(k);
        nChoose %= nPrime;
        nChoose = Factorial(n - 1 + k) * Inverse(nChoose);
        nChoose %= nPrime;
        nAns *= nChoose;
        nAns %= nPrime;
    }
    
    if(nAns < 0){
        nAns += nPrime;
    }

    printf("%ld", nAns);
    return 0;
}


Measured memory_bytes: 3320