akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
dx4[4] = { 0,1,0,-1 },
dy4[4] = { 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
	setc;

	lint a,b;cin>>a>>b;
	co((a-1)*(b-1));
	gc();
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int ans=9999999;
  for(int i=-100;i<=100;i++){
  int sum=0;
  for(int j=0;j<N;j++){
    sum+=(a[j]-i)*(a[j]-i);
  }
  ans=min(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

int n;
int cl[N*2], cr[N*2];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int l, r;
        cin >> l >> r;
        l += N;
        r += N;
        cl[l]++;
        cr[r]++;
    }
    cl[N]++;
    cr[N]++;

    ll ans = 0;
    int wl = 0, wr = 0;
    for (int i = 0; i < 2*N; ++i)
        wr += cl[i];
    for (int i = 0; i < 2*N - 1; ++i) {
        wl += cr[i];
        wr -= cl[i];
        ans += min(wl, wr);
    }
    cout << ans*2 << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,k,val,sum=0;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> val;
		sum += min(abs(val-k),val) * 2;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
def hantei(bit):
    list=[]
    for i in range(8):
        for j in range(8):
            if bit[i*8+j]=='1':
                list.append(i*8+j) 
    second=list[1]-list[0]
    third=list[2]-list[0]
    fourth=list[3]-list[0]
    sum=second+third+fourth
    return sum


while True:
    try:
        bit=[0]*64
        for i in range(8):
            line=raw_input()
            for j in range(8):
                bit[i*8+j]=line[j]
        result=hantei(bit)
        if result==18:
            print "A"
        elif result==48:
            print "B"
        elif result==6:
            print "C"
        elif result==30:
            print "D"
        elif result==20:
            print "E"
        elif result==34:
            print "F"
        else:
            print "G"
        raw_input()
    except:
        break

Measured memory_bytes: 4248
use std::collections::VecDeque;
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let s: String = read();
	let q: usize = read();
	let queries: Vec<Vec<String>> = read_vec2(q as u32);

	let mut s: VecDeque<char> = s.chars().collect();
	let mut reverse_flag: bool = false;

	for i in 0..queries.len() {
		if queries[i][0] == String::from("1") {
			if s.len() > 1 {
				reverse_flag = !reverse_flag
			}
		}  else {
			let target = queries[i][2].chars().nth(0).unwrap();
			if queries[i][1] == String::from("1") {
				if reverse_flag { s.push_back(target) }
				else { s.push_front(target) }
			} else {
				if reverse_flag { s.push_front(target) }
				else { s.push_back(target)}
			}
		}
	}

	if reverse_flag {
		for i in 0..s.len() {
			print!("{}", s[s.len()-1 - i])
		}
		println!();
	} else {
		for si in s {
			print!("{}", si);
		}
		println!();
	}
}


Measured memory_bytes: 37372
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long k = x;
        long cnt = 0;
        while (k <= y) {
            if (!(k >= x && k <= y)) {
                break;
            }
            k *= 2;
            cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 23252
N,M,V,P = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i).sort

require 'pp'
PP.pp [N,M,V,P], STDERR
PP.pp A, STDERR
def check a
  return true if a >= A[-P]
  return false if A[-P] > a + M
  if V <= P
    return A[-P] <= a + M
  end

  point = (V-P) * M
  skip_self = false
  A[0,A.size - (P - 1)].each do |aa|
    if aa == a && !skip_self
      skip_self = true
      next
    end
    if aa <= a
      point -= M
    elsif aa > a && (a+M) > aa
      point -= (a+M-aa)
    end
    return true if point <= 0
  end
  return true if point <= 0
  return point <= 0
end
line = A.bsearch{|a| check a }
puts A.find_all{|a| a >= line}.size

Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n;
    string s;
    cin >> n;
    cin >> s;
    pint le=pint(0,0), ri=pint(0,0);
    REP(i, n)
    {
        if (s[i] == '.'){
            ++ri.FI;
        }
        else
        {
            ++ri.SE;
        }
    }
    int ans = INF;
    REP(i,n+1){
        ans = min(ans, ri.FI+le.SE);
        if (i < n){
            if (s[i] == '.'){
                --ri.FI;
                ++le.FI;
            }
            else
            {
                --ri.SE;
                ++le.SE;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include<stdio.h>

int main(void){
	int i, n, major = 0;
	scanf("%d", &n);
	char s[n];
	scanf("%s", s);
	
	for(i = 0; i < n; i++){
		if(s[i] == 'R'){
			major++;
		}else{
			major--;
		}
	}
	if(major>0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	ini(a,b,c);
	if(a == b and b == c){
		out("No");
	}
	else if(a == b or a == c or b == c){
		out("Yes");
	}
	else{
		out("No");
	}
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> A, long long N, std::vector<long long> b){

    string ans = NO;

    for( int n = 0; n < N; n++){
        for( int i=0; i < 3; i++){
            for (int j=0; j < 3; j++){

                if(A[i][j] == b[n]){
                    A[i][j] = 0;
                    //cout << A[i][j] << endl;
                }

            }
        }
    }


    for(int i=0; i < 3; i++){
        if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0){
            ans = YES;
            cout << ans << endl;
            return;
        }
    }

    for(int j=0; j < 3; j++){
        if(A[0][j] == 0 && A[1][j] == 0 && A[2][j] == 0){
            ans = YES;
            cout << ans << endl;
            return;
        }
    }

    if(A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0){
        ans = YES;
        cout << ans << endl;
        return;
    }

    if(A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0){
        ans = YES;
        cout << ans << endl;
        return;
    }

    cout << ans << endl;
    return;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<std::vector<long long>> A(3, std::vector<long long>(3));
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    long long N;
    scanf("%lld",&N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(std::move(A), N, std::move(b));
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")

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

#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define endl "\n"
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
typedef long long ll;
#define mk(arr, n, type) type *arr = new type[n]
const int mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

#define watch(x) cout << (#x) << " is : " << (x) << "\n"
#define watch2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << "\n"

void b_v_r()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    b_v_r();
    int x;
    cin >> x;
    if(x>=30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3620
(n,m),*s,p=[list(map(int,t.split()))for t in open(0)]
a=0
for i in range(1<<n):
 c=[0]*m
 for j in range(n*m):c[j%m]+=i>>j//m&(j//m+1in s[j%m][1:])
 a+=all(j==i%2for i,j in zip(c,p))
print(a)

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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

int main(){

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

	cout<<setprecision(20)<<fixed;
	double n;
	cin>>n;
	cout<<(n/3)*(n/3)*(n/3)<<endl;

	return 0;
}

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

const int MOD = 1e9+7;

// A*B　の　計算
mat mul( mat &A, mat &B){
 mat  C(A.size(), vector<ll>(B[0].size()));
 for(ll i = 0; i < A.size(); i++){
   for(ll k = 0; k < B.size(); k++){
     for(ll j = 0; j < B[0].size();j++){
       A[i][k] %= MOD;
       B[k][j] %= MOD;
       C[i][j] = (C[i][j]+A[i][k]*B[k][j])%MOD;
     }
   }
 }
return C;
}


// A^nの計算
// mat は vecvecint
mat pow(mat A, ll n){
  mat B(A.size(), vector<ll>(A.size()));
  
  for(int i = 0; i < A.size(); i++){
    B[i][i] = 1;}
 
  while( n > 0){
    if( n & 1){  
      B = mul(B,A);}
      A = mul(A,A);
      n >>= 1;
    }
    
    return B;
  
}


signed main(void){ 
  int N,K; cin >> N >> K;
  vector<vector<int>> A(N,vector<int>(N));
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){ 
      cin >> A[i][j];
    }
  }
  
  auto B = pow(A,K);
  
  int ans = 0;
  
  for(int i = 0; i < N; i++){ 
    for(int j = 0; j < N; j++){ 
      
      ans += B[i][j];
      ans %= MOD;
      
    }
  }

  cout << ans << endl;
  
  return 0;
}
  

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    CoutYn(s[2] == s[3] && s[4] == s[5]);
}

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

using namespace std;
const long long INF = 2e18;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n), c(n);
    for (int i = 0; i < n; ++i) cin >> p[i], --p[i];
    for (int i = 0; i < n; ++i) cin >> c[i];
    long long ans = -INF;
    vector<bool> used(n, false);
    vector<vector<long long> > ss;
    for (int i = 0; i < n; ++i) {
        if (used[i]) continue;
        int cur = i;
        vector<long long> s;
        while (!used[cur]) {
            used[cur] = true;
            s.push_back(c[cur]);
            cur = p[cur];
        }
        ss.push_back(s);
    }
    for (auto vec:ss) {
        long long m = vec.size();
        vector<long long> sum(2 * m + 1, 0);
        for (int i = 0; i < 2 * m; ++i) sum[i + 1] = sum[i] + vec[i % m];

        vector<long long> rem(m, -INF);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < m; ++j) {
                rem[j] = max(rem[j], sum[i + j] - sum[i]);
            }
        }

        for (int r = 0; r < m; ++r) {
            if (r > k) continue;
            long long q = (k - r) / m;
            if (r == 0 && q == 0) continue;

            if (sum[m] > 0) ans = max(ans, rem[r] + sum[m] * q);
            else if (r > 0) ans = max(ans, rem[r]);
        }
    }
    cout << ans << endl;
    return 0;
}


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


int main() {
  int A, B;
  cin >> A >> B;
  
  int cnt = 0, roll;
  for (int i=A/10000; i<=B/10000; i++) {
    for (int j=0; j<10; j++) {
      for (int k=0; k<10; k++) {
    	roll = i*10001 + j*1010 + k*100;
        if (A<=roll && roll<=B) cnt++;
      }
    }
  }
  
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <climits>
using namespace std; 
#define ll long long int


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    vector<vector<ll> > d(n + 1, vector<ll>(50*50+1));

    d[0][0] = 1;

    for(int i = 0; i < n; ++i){
        for(int j = i; j >= 0; --j){
            for(int x = 0; x + a[i] <= 50*50; ++x){
                d[j + 1][x + a[i]] += d[j][x];
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        ans += d[i][k * i];
    }
    cout << ans;
}


Measured memory_bytes: 1280
# coding: utf-8
# Your code here!
# ITP1_8_C
import sys


alphabet={chr(i) : 0 for i in range(97, 97+26)}
R=""
for text in sys.stdin:
    R += text.lower()
    
for j in R:
    if j in alphabet:
        alphabet[j] += 1

for alpha in sorted(alphabet.items(), key = lambda x: x[0]):
    print(" : ".join(list(map(str,alpha))))


Measured memory_bytes: 5576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define per(i,n) for (int i = (n)-1; i >=0; --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n;cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    
    bool start = true;
    int ans = 0, dir = 0, bdir = 0;
    
    vv b(1);
    vi c,o;
    
    for(int i=0; i<n; i++){
        
        if(b.back().size()==0){
            b.back().push_back(a[i]);
            
        }else if(b.back().size()==1){
            if(a[i]>b.back().back())
                c.push_back(1);
            if(a[i]<b.back().back())
                c.push_back(-1);
            if(a[i]==b.back().back())
                c.push_back(0);
            
            b.back().push_back(a[i]);
            
        }else{
            if(a[i]>b.back().back() && c.back()==-1){
                ans++;
                b.push_back(o);
                b.back().push_back(a[i]);
            }else if(a[i]<b.back().back() && c.back()==1){
                ans++;
                b.push_back(o);
                b.back().push_back(a[i]);
            }else{
                if(c.back()==0){
                    if(a[i]>b.back().back())
                        c.back()=1;
                    if(a[i]<b.back().back())
                        c.back()=-1;
                    if(a[i]==b.back().back())
                        c.back()=0;
                }
                b.back().push_back(a[i]);
            }
        }
        
    }
    /*
    rep(i,b.size()){
        rep(j,b[i].size()){
            cout << b[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << b.size() << endl;
    
    return 0;
}

Measured memory_bytes: 3384
from collections import deque

n, m = map(int, input().split())
E = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

INF = 2 * m

dists = [INF for i in range(n)]

def bfs(cur, pre, dist):
    stack = deque([[cur, pre, dist]])
    while stack:
        cur, pre, dist = stack.popleft()
        if dist < dists[cur]:
            dists[cur] = dist
            for e in E[cur]:
                if e != pre:
                    stack.append([e, cur, dist + 1])
bfs(0, -1, 0)

print('Yes')

for i in range(1,n):
    di = dists[i]
    for e in E[i]:
        if di - 1 == dists[e]:
            print(e+1)
            break


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

long long n;
vector<long long> res;

int main() {
  cin >> n;
  res.assign(n + 1, 0);
  for (long long i = 1; i * i <= n; ++i)
    for (long long j = 1; j * j <= n; ++j)
      for (int k = 1; k * k <= n; ++k) {
        long long now = i * i + j * j + k * k + i * j + j * k + k * i;
        if (now <= n) ++res[now];
      }
  for (int i = 1; i <= n; ++i) cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 3672
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

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

int main(){
  int n;
  cin >> n;
  int par[n+1];
  vector<int> child[n+1];
  for(int i=2;i<n+1;i++){
    cin >> par[i];
    child[par[i]].push_back(i);
  }
  for(int i=1;i<n+1;i++) cout << child[i].size() << endl;
  return 0;
}


Measured memory_bytes: 15268
import java.io.*;

public class Main {

    public static void main(String[] argv) throws IOException {
        //*
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String s = in.readLine();
            if (s == null) {
                break;
            }
            f(s);
        }
        //*/
    }

    public static void f(String s) {
        double a = 0;
        try {
            a = Double.parseDouble(s);
            if (a < 1.0 || 10.0 < a) {
                return;
            }
        } catch (NumberFormatException numberFormatException) {
            return;
        }
        double sum = a;
        for (int i = 2; i <= 10; i++) {
            if (i % 2 == 0) {
                a *= 2;
            } else {
                a /= 3;
            }
            sum += a;
        }
        System.out.printf("%.8f\n", sum);
    }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<string.h>

int main(){
  char s[101],t[101];
  scanf("%s%s",s,t);
  int i,j=0,k,l=strlen(s);
  for(i=0;i<l;i++){
    if(strcmp(s,t)==0){
      j++;
      break;
    }
    for(k=l;k>0;k--){
      t[k]=t[k-1];
    }
    t[0]=t[l];
    t[l]=0;
  }
  puts(j?"Yes":"No");
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cfloat>
using namespace std;

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

  int t[n+2];
  double v[n+2];
  t[0] = t[n+1] = v[0] = v[n+1] = 0;

  for(int i = 1; i <= n; i++) cin >> t[i];
  for(int i = 1; i <= n; i++) cin >> v[i];

  double answer = 0.0;

  for(double a = 0.0; a < accumulate(t, t+n+2, 0); a+=0.5){
    double va = DBL_MAX, vb = DBL_MAX;
    int now = 0;
    for(int i = 0; i < n+2; i++){
      double tmpva, tmpvb;
      if(a < now)            tmpva = (now-a) + v[i];
      else if(a > now+t[i])  tmpva = (a-(now+t[i])) + v[i];
      else                   tmpva = v[i];
      if(a+0.5 < now)            tmpvb = (now-(a+0.5)) + v[i];
      else if(a+0.5 > now+t[i])  tmpvb = (a+0.5-(now+t[i])) + v[i];
      else                       tmpvb = v[i];
      va = min(va, tmpva);
      vb = min(vb, tmpvb);
      now += t[i];
    }
    answer += (va + vb) * 0.5 / 2;
  }

  cout << fixed << setprecision(10) << answer << endl;

  return 0;
}

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

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n, Abel SUM_UNITY) {
        init(n, SUM_UNITY);
    }

    void init(int n, Abel SUM_UNITY) {
        par.resize(n+1); rank.resize(n+1); diff_weight.resize(n+1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int sisu(string ju){
    bool minus=0;
    int i=3;
    int w=0;
    if(ju[3]=='-'){
        minus=1;
        i++;
    }
    for(;i<(int)ju.length(); i++){
        w=10*w+(int)(ju[i]-'0');
    }
    if(minus){
        w= -w;
    }
    return w;
}

int main(){
    int N;
    int i,j;
    int a, b, w;
    cin >> N;
    while(N>0){
        string one[N], tan[N], eq[N], ju[N], tantan[N];
        set<string> st;
        set<string>::iterator ite;
        for(i=0; i<N; i++){
            cin >> one[i] >> tan[i] >> eq[i] >> ju[i] >> tantan[i];
            st.insert(tan[i]);
            st.insert(tantan[i]);
        }
        vector<string> jisho((int)st.size());
        UnionFind<int> uf((int)st.size(),0);
        ite=st.begin();
        for(i=0; i<(int)st.size(); i++){
            jisho[i]= *ite;
            ++ite;
        }
        for(i=0; i<N; i++){
            a=lower_bound(jisho.begin(),jisho.end(),tan[i])-jisho.begin();
            b=lower_bound(jisho.begin(),jisho.end(),tantan[i])-jisho.begin();
            w=sisu(ju[i]);
            if(uf.issame(a,b)){
                if(uf.diff(a,b)!=w){
                    break;
                }
            }else{
                uf.merge(a,b,w);
            }
        }
        if(i==N){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        cin >> N;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

int main() {
    ll N;
    cin >> N;

    vector<ll> B(N - 1);
    REP(i, B.size()) {
        cin >> B[i];
    }

    vector<ll> A(N);
    A[0] = B[0];
    A[A.size() - 1] = B[B.size() - 1];
    FOR(i, 1, A.size() - 1) {
        A[i] = min(B[i - 1], B[i]);
    }

    ll ans = 0;
    REP(i, A.size()) {
        ans += A[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    map<ll, ll> num;
    ll ans = 0;
    rep(i,N){
        ans += num[i - a[i]];
        ++num[a[i] + i];
    }
    cout<<ans<<endl;
}

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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

/*
#define mod 1000000007 /*/
#define mod 998244353 //*/

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


void solve(){
    string S;
    cin >> S;
    int ans;
    if(S.find("RRR")!=S.npos) ans = 3;
    else if(S.find("RR")!=S.npos) ans = 2;
    else if(S.find("R")!=S.npos) ans = 1;
    else ans = 0;
    cout <<ans << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3628
def main():
  n = int(input())
  #s = input()
  #s = input().split()
  l = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  lis = sorted(l)
  
  for i in range(n):
    if i == n-1:
      if ans > lis[i]:
        print("Yes")
      else:
        print("No")
    else:    
      ans += lis[i]

if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


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


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

int op(int a, int b){
  return max(a,b);
}
int e(){
  return 0;
}

int main(){
  int n, k;
  cin >> n >> k;
  int b[n];
  segtree<int,op,e> seg(300001);
  for(int i=0; i<n; i++){
    cin >> b[i];
    int tmp=seg.prod(max(b[i]-k,0),min(b[i]+k+1,300001))+1;
    seg.set(b[i],tmp);
  }
  cout << seg.all_prod();
  return 0;
}


Measured memory_bytes: 8520
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while ( sc.hasNext() ) {
			int h = 0 , b = 0;
			int[] data = new int[8];
			for ( int i = 0; i < 8; i++ )
				data[i] = sc.nextInt();
			for ( int i = 0; i < 4; i++ ) {
				if ( data[i] == data[i+4] )
					h++;
				else {
					for ( int j = 4; j < 8; j++ )
						if ( data[i] == data[j] ) b++;
				}
			}
			System.out.println(h+" "+b);
		}
	}
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
const ll MOD = 1e9+7;
const vi dx = {1, 0, -1, 0, 1, -1, -1, 1};
const vi dy = {0, 1, 0, -1, 1, 1, -1, -1};


int main() {
    int N,M; cin>>N>>M;
    vi A(N);
    rep(i,N) cin>>A[i];

    int sum =0;
    rep(i,N){
        sum += A[i];
    }

    int number = 0;
    rep(i,N){
        if(A[i] >= double(sum) / (4 * double(M)) ){
            number++;
        }
    }

    cout<<(number>= M ? "Yes" : "No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int n, a[101], max, min, i;

	scanf("%d", &n);

	scanf("%d", a);
	max = a[0];
	min = a[0];

	for (i = 1; i < n; i++) {
		
		scanf("%d", a + i);

		if (a[i] > max) {
			max = a[i];
		}

		if (a[i] < min) {
			min = a[i];
		}
	}
	printf("%d", max - min);

	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	M := nextInt()
	Q := nextInt()
	A := make([]int, N)
	ques := make([]que, Q)
	for i := 0; i < Q; i++ {
		ques[i].a = nextInt() - 1
		ques[i].b = nextInt() - 1
		ques[i].c = nextInt()
		ques[i].d = nextInt()
	}
	ans := 0
	var dfs func([]int, int)
	dfs = func(a []int, idx int) {
		if idx == len(a) {
			sum := 0
			for _, q := range ques {
				if a[q.b]-a[q.a] == q.c {
					sum += q.d
				}
			}
			ans = max(ans, sum)
		} else {
			for i := a[idx-1]; i <= M; i++ {
				a[idx] = i
				dfs(a, idx+1)
			}
		}
	}
	for i := 1; i <= M; i++ {
		A[0] = i
		dfs(A, 1)
	}
	fmt.Println(ans)
}

type que struct {
	a, b, c, d int
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 1792
N = int(input())
a_list = list(map(int,input().split()))

cur=a_list[0]
pat=0 #0:change,1:asc,2:desc 
ans=0
for a in a_list:
    if a==cur:
        continue
    if pat==0:
        if cur<a:
            pat=1
        else:
            pat=2
        cur=a
        continue
    if pat==1 and cur>a:
        ans+=1
        pat=0
    elif pat==2 and cur<a:
        ans+=1
        pat=0

    cur=a
print(ans+1)

Measured memory_bytes: 62704
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    String[] d = new String[k];
    for (int i = 0; i < k; i++) {
      d[i] = sc.next();
    }
    for (int i = 1; i < Integer.MAX_VALUE; i++) {
      int price = i;
      String price_s = Integer.toString(i);
      boolean skip = false;
      for (int j = 0; j < k; j++) {
        if (price_s.contains(d[j])) {
          skip = true;
        }
      }
      if (skip) {
        continue;
      }
      if (price >= n) {
        System.out.println(price);
        return;
      }
    }
  }
}

Measured memory_bytes: 25364
#include <bits/stdc++.h>
using namespace std;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
 
int main() {
    int n,k,c,countt,countu;
    string s,t,u;
    cin >> n >> k >> c >> s;
    t = s;
    u = s;
    countt = 0;
    countu = 0;
    vector<int> anst, ansu, ans;
    for (int i = 0; i < n && countt < k; i++){
        if (t.at(i) == 'o') {
            for (int j = i; j - i <= c && j < n; j++){
                t.at(j) = 'x';
            }
            anst.push_back(i);
            i += c;
            countt++;
        }
    }
    for (int i = n-1; i >= 0 && countu < k; i -= 1){
        if (u.at(i) == 'o') {
            for (int j = i; i - j <= c && j >= 0; j -= 1){
                u.at(j) = 'x';
            }
            ansu.push_back(i);
            i -= c;
            countu++;
        }
    }
    if (t.find('o') != -1 || u.find('o') != -1 ){
        cout << endl;
    }
    else {
        int i = 0;
        int j = k-1;
        while (i < k && j >= 0){
            if (anst.at(i) == ansu.at(j)){
                printf("%d\n", anst.at(i)+1);
                i++;
                j -= 1;
            }
            else if (anst.at(i) > ansu.at(j)){
                j -= 1;
            }
            else {
                i++;
            }
        }
    }
}

Measured memory_bytes: 3832
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <sstream>

using namespace std;

string makeDigits(int a, int L) {
	stringstream ss;
	ss << a;
	string ret = "000000" + ss.str();
	return ret.substr(ret.size() - L);
}

string next(string d) {
	sort(d.begin(), d.end());
	int smallest = atoi(d.c_str());

	reverse(d.begin(), d.end());
	int largest = atoi(d.c_str());

	return makeDigits(largest - smallest, (int)d.size());
}

int main() {
	map<string, int> pos;
	int a, n;
	while (cin >> a >> n && (a || n)) {
		string digits = makeDigits(a, n);
		for (int i=0; ; ++i) {
			if (pos.count(digits)) {
				cout << pos[digits] << " " << atoi(digits.c_str()) << " " << i - pos[digits] << endl;
				break;
			}
			if (i < 20) {
				pos.insert(make_pair(digits, i));
			}
			digits = next(digits);
		}
		pos.clear();
	}
	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, M;
  cin >> N >> M;

  vector<pair<int, int>> ab(N);
  for (int i = 0; i < N; i++) {
    cin >> ab[i].first >> ab[i].second;
  }

  vector<pair<int, int>> cd(M);
  for (int i = 0; i < M; i++) {
    cin >> cd[i].first >> cd[i].second;
  }

  vector<int> answer(N);

  for (int i = 0; i < N; i++) {
    answer[i] = 0;
    int minD = abs(ab[i].first - cd[0].first) + abs(ab[i].second - cd[0].second);
    for (int j = 1; j < M; j++) {
      int d = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
      if (d < minD){
        minD = d;
        answer[i] = j;
      }
    }
    cout << answer[i] + 1 << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUM 1000000007
#define ll long long int
int main(void){
	ll n,i;
	int ans=1;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		ans = ans*i%NUM;
	}
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n,q;
    cin>>n>>q;
    vector<int>a(n);
    f(i,0,n-1)cin>>a[i];
    vector<int>x(q);
    f(i,0,q-1)cin>>x[i];
    vector<int>s(n+1);
    f(i,0,n-1)s[i+1]=s[i]+a[i];
    vector<int>s2(n);
    f(i,0,n-1)
    {
        s2[i]=a[i];
        if(i>1)s2[i]+=s2[i-2];
    }
    f(i,0,q-1)
    {
        int lo=0,hi=n;
        int val=x[i];
        while(lo+1<hi)
        {
            int mid=(lo+hi)/2;
            int flag=1;
            if(a[n-mid]<val)
            {
                flag=0;
            }
            else
            {
                int gap=a[n-mid]-val;
                int bam=lower_bound(a.begin(),a.end(),val-gap)-a.begin();
                if(n-mid-bam+1<mid)flag=0;
            }
            if(flag==0)hi=mid;
            else lo=mid;
        }
        int ses=s[n]-s[n-lo];
        if(n-1-2*lo>=0)ses+=s2[n-1-2*lo];
        cout<<ses<<"\n";
    }
    return 0;

}














Measured memory_bytes: 6296