akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/


//MODなしバージョン
vector<vector<ll>> memo(60, vector<ll>(60, -1));
//コンビネーション
ll comb(int n, int k){
    if(memo[n][k] != -1) return memo[n][k];
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    if(n == 0 || k == 0) return 1;
    return memo[n][k] = comb(n-1, k) + comb(n-1, k-1);
}


ll N, M;
string S, T;
ll solve(string blue, string red){
  //Tを使って、red, blueを作る。
  if(blue.size() < red.size()) swap(red, blue);

  ll rl = red.size();
  ll dp[N+1][rl+1];
  rep(i, N+1){
    rep(j, rl + 1){
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  rep(i, N){
    rep(j, rl + 1){
      if(j != rl && T[i] == red[j]){
        dp[i+1][j+1] += dp[i][j];
      }
      if(T[i] == blue[i-j]){
        dp[i+1][j] += dp[i][j];
      }
    }
  }
  return dp[N][rl];
}

int main(){
  cin >> N >> S;
  T = S;
  reverse(T.begin(), T.end());
  ll ans = 0;
  rep(i, (1 << N)){
    string red = "", blue = "";
    rep(j, N){
      if((i >> j) & 1) red += S[j];
      else blue += S[j];
    }
    ans += solve(red, blue);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

ans = B[A[0] - 1]
for i in range(1, n):
    ans += B[A[i] - 1]
    if A[i] == A[i - 1] + 1:
        ans += C[A[i - 1] - 1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())

struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n) { par.assign(n, -1); }

  int root(int a) {
    if (par[a] < 0)
      return a;
    return par[a] = root(par[a]);
  }
  int size(int a) { return -par[root(a)]; }
  void unite(int a, int b) {
    int ra = root(a), rb = root(b);
    if (ra == rb)
      return;
    if (par[a]>par[b])
      swap(a, b);
    par[ra] += par[rb];
    par[rb] = ra;
    return;
  }
  bool same(int a, int b) {
    int ra = root(a), rb = root(b);
    return ra == rb;
  }
};
UnionFind uft(100001);

struct edge {
  ll cost;
  int n1;
  int n2;
  bool operator<(const edge& right) const {
    return cost<=right.cost;
  }
};

int main() {
  int N;
  cin >> N;
  vector<pair<ll,int>> X(N),Y(N);
  rep(i,N) {
    ll x,y;
    cin >> x >> y;
    X[i] = {x,i};
    Y[i] = {y,i};
  }
  set<edge> S;
  sort(all(X));
  sort(all(Y));
  rep1(i,N-1) {
    S.insert({X[i].first-X[i-1].first, X[i].second, X[i-1].second});
    S.insert({Y[i].first-Y[i-1].first, Y[i].second, Y[i-1].second});
  }
  ll ans = 0;
  while (!S.empty()) {
    auto it = S.begin();
    S.erase(it);
    if (uft.same(it->n1,it->n2)) {
      continue;
    }
    uft.unite(it->n1,it->n2);
    ans += it->cost;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 20724
use std::io::{BufRead, BufWriter, Write};

const P: usize = 1000000007;

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    solve(&mut stdin.lock(), &mut BufWriter::new(stdout.lock()));
}

fn solve<R: BufRead, W: Write>(stdin: &mut R, stdout: &mut BufWriter<W>) {
    let (n, k): (usize, usize) = stdin.gets().split(' ').values();
    let alist = stdin.gets().split(' ').map(|x| x.parse().unwrap()).collect::<Vec<u32>>();

    let mut x = 0;
    for i in 0..n {
        for j in i + 1..n {
            if alist[i] > alist[j] {
                x += 1;
            }
        }
    }
    let mut ans = k * x;
    x = 0;
    for i in 0..n {
        for j in 0..n {
            if i != j && alist[i] > alist[j] {
                x += 1;
            }
        }
    }
    ans = (k * (k - 1) / 2 % P * x + ans) % P;
    writeln!(stdout, "{}", ans).unwrap();
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }

trait Values<T> { fn values(&mut self) -> T; }
impl<'a, I, T1, T2> Values<(T1, T2)> for I
    where I: Iterator<Item=&'a str>,
          T1: std::str::FromStr, T1::Err: std::fmt::Debug,
          T2: std::str::FromStr, T2::Err: std::fmt::Debug {
    fn values(&mut self) -> (T1, T2) {
        (self.next().unwrap().parse().unwrap(),
         self.next().unwrap().parse().unwrap())
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		while (scanner.hasNext()) {

			int n = input();
			int count = 0;
			boolean[] flag = new boolean[n + 1];

			for (int i = 2; i <= n; i++) {

				if (! flag[i]) {

					count++;

					for (int j = 2; i * j <= n; j++) {

						flag[i * j] = true;

					}
				}
			}

			System.out.println(count);

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 41032
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
LL gcd(LL a, LL b) {
	return b ? gcd(b, a%b) : a;
}
LL lcm(LL a, LL b) {
	return a / gcd(a, b)*b;
}
int main() {
	int n;
	cin >> n;
	LL ans = 1;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  int a[n],b[m];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  for(int z=y;z>x;z--){
    bool f=true;
    for(int i=0;i<n;i++){
      if(z<=a[i]) f=false;
    }
    for(int i=0;i<m;i++){
      if(z>b[i]) f=false;
    }
    if(f){
      cout<<"No War";
      return 0;
    }
  }
  cout<<"War";
}

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

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);rep(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;rep(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define rep(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl

const ull INF = (ull)(-1LL);

typedef ull ntype;

typedef vector<ntype> vntype;
typedef list<ntype> lntype;

ntype func(ntype a, ntype b, ntype x)
{
	return a * x / b - a * (x / b);
}

int main(void)
{
	init(ntype, a);
	init(ntype, b);
	init(ntype, n);

	if(n<b || (n + 1) % b == 0)outl(func(a, b, n));
	else outl(func(a, b, (n / b) * b - 1));

	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
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...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
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);
}

//main code
int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	VL a(n);
	cin >> a;
	VL rui(n+1);
	rui[0] = 0;
	for (int i = 0; i < n; i++) {
		rui[i+1] = rui[i] + a[i];
	}
	VL al;
	for (int i = 0; i <= n; i++) {
		for (int j = i+1; j <= n; j++) {
			al.push_back(rui[j] - rui[i]);
		}
	}
	RSORT(al);
	LL x = 0;
	for (LL i = ((LL)1<<41); i > 0; i = (i>>1)) {
		int count = 0;
		for (auto&& var : al) {
			if (((i+x) & var) == i+x) {
				count++;
			}
		}
		if (count >= k) {
			x += i;
		}
	}

	cout << x << endl;
	return 0;
}



Measured memory_bytes: 6512
#pragma GCC optimize(3)
#pragma GCC optimize(s)
#include <cstdio>

inline void read(int& sum)
{
    char ch; sum=0;
    ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9')
        sum=(sum<<3)+(sum<<1)+ch-'0',ch=getchar();
}

int main()
{
	int n;
	read(n);
	std::printf("ABC%d\n",n);
	return 0;
}

Measured memory_bytes: 128
#include <set>
#include <cstdio>
#include <vector>
 
using namespace std;
inline int Abs(int a) {return (a > 0? a:-a);}
int minl = 1000;
int main()
{
    int i,n,l,tot = 0;
    scanf("%d%d",&n,&l);
    for(i = 1;i <= n;i++)
    {
    	tot += (i + l - 1);
    	if(Abs(i + l - 1) < Abs(minl))
    		minl = i + l - 1;
	}
	printf("%d",tot - minl);
    return 0;
}

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

int main()
{
    char str[105];
    int k, ln, i;
    //int unused __attribute__((unused));
    /*unused = */scanf("%d",&k);
    char n[k];
    n[k]='\0';
    /*unused = */scanf("%s", str);
    ln = strlen(str);

    if(ln <=k){
        printf("%s\n", str);
    }
    else{
        for(i=0; i<k; i++){
       n[i]=str[i];
        }
        printf("%s...\n", n);
    }

}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 



int main()
{
    fastio
    ll i,j;
    
    ll n;
    cin>>n;
    
    ll a[n];
    ll x=0;
    
    for(i=0;i<n;i++)
    {cin>>a[i];x^=a[i];}
    
    
    
    for(i=0;i<n;i++)
    {
        ll y=x^a[i];
        cout<<y<<" ";
    }
}


Measured memory_bytes: 5204
import java.util.Scanner;

public class Main {
    static final int mod = 998244353;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int S = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        long res = 0;
        long[] dp = new long[S + 1];
        for (int i = 0; i < N; i++) {
            dp[0] += 1;
            for (int j = S; j >= 0; j--) {
                long c1 = dp[j], c2 = 0;
                if (j >= A[i]) {
                    c2 = dp[j - A[i]];
                }
                dp[j] = c1 + c2;
                dp[j] %= mod;
            }
            res += dp[S];
            res %= mod;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 26092
from collections import defaultdict
import sys

def soinsuu(soinsuu_dic, num):
    for i in range(2, int(num ** 0.5) + 1):
        while num % i == 0:
            num //= i
            soinsuu_dic[i] += 1
    if num > 1:
        soinsuu_dic[num] += 1
    return soinsuu_dic

def main():
    a, b, c, d = map(int, input().split())
    print(max(a * b, c * d))




if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <cstdio>
#include <cstring>
const int MAXN = 1e5+5;
int A[MAXN];
char S[MAXN];
int N;

int main() {
  scanf("%s", S);
  N = strlen(S);
  for (int i = 0; i < N; ++i) {
    A[i] = 0;
  }
  for (int i = 0, j; i < N; i = j) {
    int p = i;
    while (S[i] == 'R') ++i;
    j = i;
    while ((j < N) && (S[j] == 'L')) ++j;
    int lhs = i-p;
    int rhs = j-i;
    A[i] = lhs / 2 + (rhs + 1) / 2;
    A[i-1] = (lhs + 1) / 2 + rhs / 2;
  }
  for (int i = 0; i < N; ++i) {
    printf("%d%c", A[i], (i+1 == N) ? '\n' : ' ');
  }
  return 0;
}

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

using namespace std;

#define EPS (1e-8)
#define INF 101010

struct Point {
    double x, y;
    
    Point () {}
    Point (double x, double y) : x(x), y(y) {}

    Point operator - (const Point &p) const {
        return Point(x - p.x, y - p.y);
    }
};

double cross(const Point &a, const Point &b)
{
    return a.x * b.y - a.y * b.x;
}

int ccw(const Point &p0, const Point &p1, const Point &p2)
{
    Point a = p1 - p0, b = p2 - p0;
    if (cross(a, b) > EPS)  return -1; // COUNTER CLOCK WISE
    return +0;
}

#define next(G,i) (G[(i+1)%G.size()])

double get_area(double l, double r, int W)
{
    vector<Point> pg(4);
    pg[0] = Point(0, 0);
    pg[1] = Point(W, 0);
    pg[2] = Point(W, r);
    pg[3] = Point(0, l);
    
    double res = 0;
    for (int i = 0; i < (int)pg.size(); i++) {
	res += cross(pg[i], next(pg, i));
    }
    return abs(res)/2.0;
}


int main()
{
    int N, M, W, H, S;
    while (cin >> N >> M >> W >> H >> S, N) {
        vector<double> l(M+1), r(M+1);
        l[0] = r[0] = 0;
        
        vector<int> s(M+1, 0);
        for (int i = 1; i <= M; i++) {
            cin >> l[i] >> r[i];
            s[i] = get_area(l[i], r[i], W);
        }        

        vector<int> choco(M+1, 0);
        
        Point p;
        for (int i = 0; i < N; i++) {
            cin >> p.x >> p.y;
            int lb = 0, ub = M+1;
            while (ub - lb > 1) {
                int mid = (lb + ub) / 2;
                if (ccw(Point(0, l[mid]), Point(W, r[mid]), p) == -1) {
                    lb = mid;
                } else {
                    ub = mid;
                }
            }
            choco[ub]++;
        }

        for (int i = 1; i <= M; i++) {
            choco[i] += choco[i-1];
        }
        int res = INF;
        for (int i = 0; i <= M; i++) {
            int lb = i, ub = M+1;
            int ns = s[i];
            while (ub - lb > 1) {
                int mid = (lb + ub) / 2;
                if (ns + (s[M] - s[mid]) < S) {
                    ub = mid;
                } else {
                    lb = mid;
                }
            }

            if (ns + (s[M] - s[lb]) >= S) {
                res = min(res, choco[M] - (choco[lb] - choco[i]));
            }
        }
        cout << res << endl;
    }        
    return 0;
}

Measured memory_bytes: 3684
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b = LI()

    return a*b

print(main())





Measured memory_bytes: 10972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n; cin >> n;
    vector<ll> limit(5);
    for(int i = 0; i <5; i++)
    {
        cin >> limit[i];
    }
    ll lmin = limit[0];
    for(int i = 0; i<5; i++)
    {
        if(lmin > limit[i])
        {
            lmin = limit[i];
        }
    }
    if(n%lmin == 0){
        cout << 5 + n/lmin - 1<< endl;
    }
    else{
        cout << 5 + n/lmin << endl;
    }
}

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

using namespace std;

typedef long long ll;

const int N = 200010;

int n;
ll a[N], b[N], tmp;
ll cnt[10][10][10][10];

int main() {
  cin >> n;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    long double x;
    scanf("%Lf", &x);
    b[i] = 1000000000LL;
    a[i] = floor(x * b[i] + 0.1) + 0.1;
    ll g = __gcd(a[i], b[i]);
    a[i] /= g, b[i] /= g;
    int a2 = 0, a5 = 0, b2 = 0, b5 = 0;
    tmp = a[i]; 
    while (tmp % 2 == 0) tmp /= 2, ++a2;
    while (tmp % 5 == 0) tmp /= 5, ++a5;
    tmp = b[i];
    while (tmp % 2 == 0) tmp /= 2, ++b2;
    while (tmp % 5 == 0) tmp /= 5, ++b5;
    assert(tmp == 1);
    a2 = min(a2, 9), a5 = min(a5, 9);
    for (int j = 0; j <= a2; ++j) {
      for (int k = 0; k <= a5; ++k) {
        ans += cnt[j][k][b2][b5];
      }
    }
    for (int j = 0; j <= a2; ++j) {
      for (int k = 0; k <= a5; ++k) {
        ++cnt[b2][b5][j][k];
      }
    }
  }
  cout << ans << '\n';
  return 0;
}



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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    ll a[n]; f(i,0,n-1) cin >> a[i];
    ll F[100001];
    f(i,0,100000) F[i] = 0;
    f(i,0,n-1) F[a[i]]++;
    ll sum = 0;
    f(i,0,n-1) sum += a[i];
    int n_testcases; cin>>n_testcases;
    for(int n_testcase = 1; n_testcase <= n_testcases; n_testcase++)
    {
    	ll bi, ci; cin >> bi >> ci;
    	sum -= F[bi] * bi;
    	sum += F[bi] * ci;
    	ll temp = F[bi];
    	F[bi] = 0;
    	F[ci] += temp;
    	cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 5184
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		String s = Integer.toString(in.readInt());
		String rev = new StringBuilder(s).reverse().toString();
		if(s.equals(rev)) {
			System.out.println("Yes");
		}
		else System.out.println("No"); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <tuple>
#include <vector>
#include <map>


using namespace std;


const string march = "MARCH";


vector<tuple<char, char, char>> combinations;
void create_combinations(int depth, vector<char> now = {}) {
    if (now.size() == 3) {
        combinations.push_back(make_tuple(now[0], now[1], now[2]));
        return;
    }
    if (depth == march.length())
        return;

    create_combinations(depth + 1, now);
    vector<char> tmp = now;
    tmp.push_back(march[depth]);
    create_combinations(depth + 1, tmp);
}


int main()
{
    create_combinations(0);

    map<char, unsigned long long> cnt;
    for (char ch = 'A'; ch <= 'Z'; ++ch)
        cnt[ch] = 0;


    long long N;
    cin >> N;
    for (long long i = 0; i < N; i++) {
        string tmp;
        cin >> tmp;
        cnt[tmp[0]]++;
    }

    unsigned long long ans = 0;
    for (auto e : combinations) {
        ans += cnt[get<0>(e)] * cnt[get<1>(e)] * cnt[get<2>(e)];
    }
    cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            num++;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));

    return res;
}

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

    vector<pair<ll, ll>> primes = prime_factorize(N);
    ll ans = 0;
    for (auto p: primes) {
        int count = p.second;
        int n = 1;
        while (count >= n) {
            ans++;
            count -= n;
            n++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3632
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), k = next(), c = next();
  var s = next(1);
  var l = xArray(0,n), t = 1;
  for(var i = 0; i < n; i++){
    if(s[i] === "o")l[i] = t++, i += c;
  }
  t = k;
  var r = xArray(0,n);
  for(var i = n; i-- > 0;){
    if(s[i] === "o")r[i] = t--, i -= c;
  }
  var ans = [];
  for(var i = 0; i < n; i++){
    if(l[i] && l[i] === r[i])ans.push(i+1);
  }
  if(ans.length)return ans.join("\n")
}

Measured memory_bytes: 35716
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

int dh[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dw[] = {-1, 0, 1, -1, 1, -1, 0, 1};

void dfs(const vector<vector<int>>& c, vector<vector<bool>>& visited, int h, int w) {
  visited[h][w] = true;
  rep(i, 8) {
    int nh = h + dh[i];
    int nw = w + dw[i];
    if (nh < 0 || nh >= c.size() || nw < 0 || nw >= c[0].size()) continue;
    if (visited[nh][nw]) continue;
    if (c[nh][nw] == 0) continue;
    dfs(c, visited, nh, nw);
  }
}

bool solve() {
  int w, h; cin >> w >> h;
  if (w == 0 && h == 0) return false;
  vector<vector<int>> c(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> c[i][j];
  vector<vector<bool>> visited(h, vector<bool>(w, false));

  int ans = 0;
  rep(i, h) rep(j, w) {
    if (visited[i][j]) continue;
    if (c[i][j] == 0) continue;
    dfs(c, visited, i, j);
    ans++;
  }
  cout << ans << endl;
  return true;
}

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

  while (solve()) {}

  return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
int ans=0;
int n;
int a[114514];
int count(int &f){
    int re=0;
    int i=f;
    while(1){
        if(i>=n)break;
        if(a[i]==a[f])re++;
        else break;
        i++;
    }
    f=i;
    if(re%2==1)return 1;
    else return 0;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int i=0;
    while(i<n){
        ans+=count(i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
package main

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

const MOD = 1000000007

/* input */
var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
    return n
}

/* fact */
func fact(x int, factMem map[int]int) int {
    if x == 0 {
        return 1
    }
    value, ok := factMem[x]
    if ok {
        return value
    }
    factMem[x] = x * fact(x - 1, factMem) % MOD
    return factMem[x]
}

/* inverse */
func inverse(x int, factMem map[int]int, inverseMem map[int]int) int {
    value, ok := inverseMem[x]
    if ok {
        return value
    }
    inverseMem[x] = power(fact(x, factMem), MOD - 2, MOD)
    return inverseMem[x]
}

/* power */
func power(x, y, z int) int {
    if y == 0 {
        return 1
    }
    if y % 2 == 0 {
        return power(x * x % z, y / 2, z)
    } else {
        return x * power(x, y - 1, z) % z
    }
    return 0
}

/* comb */
func comb(x int, y int, factMem map[int]int, inverseMem map[int]int) int {
    if x < y || y < 0 {
        return 0
    }
    return fact(x, factMem) * inverse(y, factMem, inverseMem) % MOD * inverse(x - y, factMem, inverseMem) % MOD
}

func main() {
    sc.Split(bufio.ScanWords)
    n := readInt()
    dic := make(map[int]int)
    left, right := 0, 0
    for i := 0; i < n + 1; i++ {
        a := readInt()
        index, ok := dic[a]
        if ok {
            left = index
            right = i
            break
        } else {
            dic[a] = i
        }

    }

    rem := n - right + left
    factMem := make(map[int]int)
    inverseMem := make(map[int]int)
    for i := 0; i < n + 1; i++ {
        fact(i, factMem)
    }

    for i := 0; i < n + 1; i++ {
        fmt.Println((MOD + comb(n + 1, i + 1, factMem, inverseMem) - comb(rem, i, factMem, inverseMem)) % MOD)
    }
}

Measured memory_bytes: 14976
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

bool check(string &cur, vector<int> &s, vector<char> &c, int M) {
	for (int i=0; i<M; i++)
		if(cur[s[i]-1]!=c[i])
			return false;
	return true;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M; cin>>N>>M;
	vector<int> s(M);
	vector<char> c(M);
	for (int i=0; i<M; i++)
		cin>>s[i]>>c[i];

	if(N==1) {
		for (char ch='0'; ch<='9'; ch++) {
			string cur; cur+=ch;
			if(check(cur,s,c,M)) {
				cout<<cur<<"\n";
				return 0;
			}
		}
	}
	else if(N==2) {
		for (char ch='1'; ch<='9'; ch++)
			for (char ch2='0'; ch2<='9'; ch2++) {
				string cur; cur+=ch; cur+=ch2;
				if(check(cur,s,c,M)) {
					cout<<cur<<"\n";
					return 0;
				}
			}
	}
	else if(N==3) {
		for (char ch='1'; ch<='9'; ch++) 
			for (char ch2='0'; ch2<='9'; ch2++)
				for (char ch3='0'; ch3<='9'; ch3++) {
					string cur; cur+=ch; cur+=ch2; cur+=ch3;
					if(check(cur,s,c,M)) {
						cout<<cur<<"\n";
						return 0;
					}
				}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
#9 900 90000..
buf = 0

if len(str(N)) % 2 != 0 : #Nが奇数桁
    buf += N - 10**(len(str(N))-1) +1
    for i in range((len(str(N))-1)//2) :
        buf += 9 * (100**(i))

else : #Nが偶数桁
    for i in range(len(str(N))//2) :
        buf += 9*(100**i)

print(buf)

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
def main():
    N, M, *a = map(int, open(0).read().split())
    div = 1000000007
    broken = set(a)

    comb_list = [0] * (N + 1)
    comb_list[0] = 1
    if 1 not in broken:
        comb_list[1] = 1

    for i in range(2, N + 1):
        if i in broken:
            continue
        comb_list[i] = (comb_list[i - 1] + comb_list[i - 2]) % div

    print(comb_list[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 14180
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: int):
    print(N**2-A)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(N, A)


if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  string str;

getline(cin,str);

 for(int i=0;i<(int)str.size();i++){
  if( islower(str[i]) ){
    str[i]=toupper(str[i]);
  }else if( isupper(str[i]) ){
    str[i]=tolower(str[i]);
  }
}
cout<<str<<endl;
}
   


Measured memory_bytes: 3140
#include<iostream>
using namespace std;
int a,b,c;
int main(int argc, char const *argv[])
{
    cin>>a>>b;
    for(int i = 1;i <= 3;i++){
        if((a*b*i)%2 == 0){
            cout<<"No"<<endl;
            break;
        }
        else cout<<"Yes"<<endl;
        break;
    }
    return 0;
}


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

int main(){
    int a, b;
    int h, m;
    cin >> a >> b >> h >> m;
    long double theta;

   
    theta = 2.0*M_PI*((long double)h/12.0 + ((long double)m/60.0)/12.0 - (long double)m/60.0);
    
    long double c = sqrtl((long double)(a*a + b*b) - (long double)(2.0*a*b)*cosl(theta));

    printf("%20.20Lf\n", c);

    return 0;

}

Measured memory_bytes: 4128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a, b, c;
	cin >> a >> b >> c;

	int ans = 0;

	ans += 2 * min(b, c);

	int x = b - min(b, c);
	int y = c - min(b, c);

	int j = 0;
	int k = 0;

	if (y == 0 && x > 0) {
		ans += x;
	}
	else {
		j = a - min(a, y);
		k = y - min(a, y);
		ans += min(a, y);
	}


	if (k > 0) {
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<functional>
#include<iostream>
#define rep(i,a) for(i=0;i<a;i++)
using namespace std;
int glid[91][91];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int m,n,mx,cnt;
void func(int,int);
int main(void)
{
	int i,j,k;
	while(cin>>m>>n && m && n ) {
		mx=-1;
		rep(i,n)rep(j,m) cin>>glid[i][j];
		rep(i,n)rep(j,m) if(glid[i][j]==1) {cnt=0;func(i,j);}
		cout<<mx<<endl;
	}
	return 0;
}
void func(int x,int y)
{
	int i,j,k,xx,yy;
	rep(i,4) {
		xx=dx[i]+x; yy=dy[i]+y;
		if(xx<=m && xx>=0 && yy<=n && yy>=0 && glid[yy][xx]==1) {
			cnt++;
			mx=max(mx,cnt);
			glid[yy][xx]=0;
			func(xx,yy);
			cnt--;
			glid[yy][xx]=1;
		}
	}
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    ll res=1e9;
    for(int i=-200;i<=200;i++){
        ll buf=0;
        rep(j,n)buf+=(i-a[j])*(i-a[j]);
        chmin(res,buf);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];

void Solve() {
	double t, x;
	cin >> t >> x;
	double res = t / x;
	cout << std::setprecision(20) << res << endl;
}


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



Measured memory_bytes: 6400
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		StringBuffer aString = new StringBuffer();
		StringBuffer bString = new StringBuffer();
		for(int i = 0; i < b; i++) {
			aString.append(a);
		}
		for(int i = 0; i < a; i++) {
			bString.append(b);
		}
		
		if(a < b) {
			System.out.println(aString);
		}else {
			System.out.println(bString);
		}
		sc.close();
	}
}

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

int main()
{
  bool is_prime[100000];
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<100000; i++){
    is_prime[i] = true;
  }

  for(int i=2; i*i<100000; i++){
    if(is_prime[i]){
      for(int j=i*i; j<100000; j+=i){
        is_prime[j] = false;
      }
    }
  }

  while(1){
    int n;
    cin >> n;

    if(n == 0)
      break;

    int cnt=0;

    for(int i=0; i<=n/2; i++){
      if(is_prime[i] && is_prime[n-i])
        if(i+(n-i) == n) cnt++;
    }

    cout << cnt << endl;
  }
}



Measured memory_bytes: 3096
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
#include <cstdio>
#include <iostream>
#include <iomanip>
using namespace std;

int no[10] = {};

bool isOK(int n) {
	while (n > 0) {
		if (no[n % 10] == 1) {
			return false;
		}
		n /= 10;
	}
	return true;
}

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

	int t;
	for (int i = 0; i < k; i++) {
		cin >> t;
		no[t] = 1;
	}

	int i = n;
	while (1) {
		if (isOK(i)) {
			cout << i << endl;
			return 0;
		}
		else {
			i++;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
#define endl '\n'

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n >> m){
        if (m == 1) cout << 0 << endl;
        else {
            cout << n - m << endl;
        }
        int ans;
    }
    return 0;
}


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

using namespace std;

typedef long long LL;
#define N 101010

vector<pair<int, int>> e[N];
int ans[N];

void dfs(int v, int par=-1)
{
    for (auto p: e[v]) {
        int u = p.first, w = p.second%2;
        if (p.first != par) {
            ans[u] = ans[v] ^ w;
            dfs(u, v);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    for (int i=0; i<n-1;++i) {
        int u, v;
        long long w;
        cin >> u >> v >> w;
        e[u].emplace_back(v, w);
        e[v].emplace_back(u, w);
    }

    dfs(1);

    for (int i=1; i<=n; ++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 8448
#include <iostream>

using namespace std;

int main() {
    int n, v, l, h = -1e9;
    cin >> n >> l;
    for (int i = 0; i < n - 1; ++i) {
        cin >> v;
        h = max(h, v - l);
        l = min(l, v);
    }
    cout << h << endl;

    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
db ans=100.0,r=0.01;
ll n;
int main(){
    cin>>n;
    for(int i=1;;i++){
        ans=ans*(1.00+r);
        ans=floor(ans);
        if(ans>=(db)n){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3676
#include <stdio.h>

#define N 110000

char s[N];

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


Measured memory_bytes: 128
/*#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;*/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);   cout.tie(NULL);
#define mod (ll)1e18
#define pb push_back
#define N 100000 + 5
#define N 100000 + 5
# define deb(x) cout<<#x<<" "<<x<<endl;
//   cout << fixed << setprecision(12);
#define forab(i, a, b, c) for (ll(i) = a; (i) <= (b); (i) += (c))
#define forabr(i, a, b, c) for (ll(i) = a; (i) >= (b); (i) -= (c))
void arrinitialize(ll n,ll a[],ll x){
    forab(i,0,n-1,1){
        a[i]=x;
    }
}
void arrinput(ll n,ll a[]){
    forab(i,0,n-1,1)cin>>a[i];
}
void start(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int main(){
    fastio;
   // start();
    ll n;cin>>n;ll a[n][3];ll dp[n+1][3]={0};
    forab(i,0,n-1,1){
        forab(j,0,2,1){
            cin>>a[i][j];
        }
    }
    forab(i,1,n,1){
        forab(j,0,2,1){
            if(j==0){
                dp[i][j]=a[i-1][j]+max(dp[i-1][1],dp[i-1][2]);
            }
            if(j==1){
                dp[i][j]=a[i-1][j]+max(dp[i-1][0],dp[i-1][2]);
            }
            if(j==2){
                dp[i][j]=a[i-1][j]+max(dp[i-1][1],dp[i-1][0]);
            }
        }
        
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}
    

Measured memory_bytes: 4992
def mygets():
    return [int(v) for v in input().split(' ')]

n, x = mygets()
a = mygets()

b1 = a

ans = sum(a)
xt = 0
for i in range(1, n):
    xt += x
    b1 = [u if u < b1[k - 1] else b1[k - 1] for k, u in enumerate(a)]
    bsum = sum(b1) + xt
    if bsum < ans:
        ans = bsum
    else:
        break

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=998244353;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b,c;
  cin >> a >> b >> c;
  int d=max({a,b,c});
  int f=min({a,b,c});
  int e=a+b+c-d-f;
  int ans=0;
  ans+=d-e;
  f+=ans;
  ans+=(d-f)/2;
  if(f%2!=d%2)ans+=2;
  
  cout << ans << endl;
  
  return 0;     
}


Measured memory_bytes: 256