akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	sort(a, a + n);
	
	int ans = a[0];
	inc(i, n - 1) { if(min(ans, a[n - 1] - ans) < min(a[i], a[n - 1] - a[i])) { ans = a[i]; } }
	
	cout << a[n - 1] << " " << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, a, b = 0, c = 0, d = 0;cin >> n;
	rep(i, n) {
		cin >> a;
		if (a % 2 == 0) {
			if (a % 4 == 0) d++;
			else c++;
		}
		else b++;
	}
	if (c == 0 && b  <= d + 1) cout << "Yes" << endl;
	else if (c == 0 && b > d + 1) cout << "No" << endl;
	else if (b <= d) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  int A[101];
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < M; i++){
    int idx = 0;
    while(1){
      if(idx == N-1) break;
      if(A[idx]%(i+1) > A[idx+1]%(i+1)) swap(A[idx], A[idx+1]);
      idx++;      
    }
  }
  for(int i = 0; i < N; i++) cout << A[i] << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

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

	int a, b, m;
	cin >> a >> b >> m;

	vector<int> v(a), w(b);
	int vmin = 101010, wmin = 101010;
	rep(i, a) {
		cin >> v[i];
		vmin = min(vmin, v[i]);
	}

	rep(i, b) {
		cin >> w[i];
		wmin = min(wmin, w[i]);
	}

	vector<int> x(m), y(m), c(m);
	rep(i, m) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--;
		y[i]--;
	}

	int ans = vmin + wmin;
	rep(i, m){
		int t = v[x[i]] + w[y[i]] - c[i];
		ans = min(ans, t);
	}

	cout << ans << endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const int D = 60;

int main(){
    int n; ll k;
    cin >> n >> k;
    vi a(n);
    vector<vi> to(D, vi(n));
    rep(i, n) {
        cin >> to[0][i];
        to[0][i]--;
    }
    rep(i, D-1) rep(j, n) {
        to[i+1][j] = to[i][to[i][j]];
    }
    int v = 0;
    repr(i, D) {
        ll l = 1ll<<i;
        if (l<=k) {
            v = to[i][v];
            k -= l;
        }
    }
    cout << v+1 << endl;
    return 0;
}


Measured memory_bytes: 51812
#include<stdio.h>
int main()
{
long long int A,B,c,d,e;
scanf("%lld %lld",&A,&B);
c=A+B;
d=A-B;
e=A*B;
if(c>=d && c>=e)
printf("%lld\n",c);
else if(d>=c && d>=e)
printf("%lld\n",d);
else if(e>=c && e>=d)
printf("%lld\n",e);
return 0;
}

Measured memory_bytes: 1688
def merge(A, left, mid, right):
    global cnt
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]
 
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
 
 
def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
 
 
n = int(input())
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, n)
 
print(' '.join(str(a) for a in A))
print(cnt)


Measured memory_bytes: 66584
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
mt19937 rnd(1337);
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define pNN pair <Node *, Node *>
#define SZ(x) (int)(x).size()
#define pii pair <int, int>
#define pb push_back
#define rev reverse
#define ins insert
#define ers erase
#define S second
#define F first
#define int ll
const int N = 1e5 + 10, INF = 1e9 + 10;

void solve() {
	int k;
	cin >> k;
	if (k <= 9) {
		cout << k;
		exit(0);
	}
	int cnt = 9;
	vector <string> vec;
	for (char i = '1'; i <= '9'; ++i) {
		string f;
		f += i;
		vec.pb(f);
	}
	while (true) {
		vector <string> vec1;
		for (auto x : vec) {
			char c = x.back();
			if (c > '0') {
				string f = x;
				f += (c - 1);
				vec1.pb(f);
				++cnt;
				if (cnt == k) {
					cout << f;
					exit(0);
				}
			}
			{
				string f = x;
				f += c;
				vec1.pb(f);
				++cnt;
				if (cnt == k) {
					cout << f;
					exit(0);
				}
			}
			if (c < '9') {
				string f = x;
				f += (c + 1);
				vec1.pb(f);
				++cnt;
				if (cnt == k) {
					cout << f;
					exit(0);
				}
			}
		}
		vec = vec1;
	}
}
 
signed main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    #ifdef Solenoid555
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1;
    //cin >> t;
    while(t--) solve();
    return 0;
}

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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n,d,x;
    cin>>n>>d>>x;
    rep(i,0,n){
        int a;
        cin>>a;
        for(int i=0;i*a+1<=d;i++)x++;
        
    }
    cout<<x<<endl;
    
    return 0;
}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll N,K;
v_ll A;
int main(){
  MOD=1000000007;
  cin >> N >> K;
  v_ll k1=mod_nck(K-1);
  v_ll nk1=mod_nck(N-K+1);
  for (ll i=1;i<=K;i++){
    if (N-K+1<i){
      cout << 0 << endl;
    }else{
      cout << mod(k1[i-1]*nk1[i]) << endl;
    }
  }
}


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

typedef long long ll;

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

    int L, R;
    cin>>L>>R;
    int a = L/2019, b = R/2019;

    if (L==0 || (b>=a+1) || (b==a && L%2019 == 0)){
        cout<<0<<endl;
    }
    else {
        int mini = 2019;
        for (int i=L;i<R;++i){
            for (int j=i+1;j<=R;++j){
                mini = min(mini, ((i%2019)*(j%2019))%2019);
            }
        }
        cout<<mini<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=2e5+3,du=1e9+7;
int m,n;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>m>>n;
	map<int,int> mp;
	multiset<int> s;
	for (int i=1;i<=n;i++) mp[i]=i,s.insert(0);
	for (int i=1;i<=m;i++)
    {
        int l,r;
        cin>>l>>r;
        auto it=mp.lower_bound(l);
        int mx=0;
        while(it!=mp.end()&&it->first<=r)
        {
            mx=max(mx,it->second);
            int dis=(it->first)-(it->second);
            s.erase(s.find(dis));
            mp.erase(it++);
        }
        if (mx!=0&&r<n&&mp.find(r+1)==mp.end())
        {
            mp[r+1]=mx;
            s.insert(r+1-mx);
        }
       // cout<<"DM";
        if (s.size()) cout<<(*s.begin())+i<<"\n";
        else cout<<-1<<"\n";
    }
	return 0;
}


Measured memory_bytes: 25480
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll uni[100005];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}

void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]<uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    int n,m,k;
    cin>>n>>m>>k;
    int a,b;
    vector<set<int> > fr(n),br(n);
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;b--;
        fr[a].insert(b);
        fr[b].insert(a);
        connect(a,b);
    }
    for(int i=0;i<k;i++){
        cin>>a>>b;
        a--;b--;
        br[a].insert(b);
        br[b].insert(a);
    }
    int ans[n];
    memset(ans,0,sizeof(ans));
    for(int i=0;i<n;i++){
        ans[i]=size(i)-fr[i].size()-1;
        for(auto& x:br[i]){
            if(root(i)==root(x))ans[i]--;
        }
        cout << ans[i]<<" ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 30976
# coding: utf-8
# Your code here!

n = int(input())
A = [int(e) for e in input().split()]
q = int(input())
M = [int(e) for e in input().split()]

def solve(i,m):
    if m == 0:
        return True
    if i >= n:
        return False
    if m > sum(A[i:]):
        return False
    res = solve(i + 1,m) or solve(i + 1,m - A[i])
    return res
    
for m in M:
    if(solve(0,m)):
        print("yes")
    else:
        print("no")


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

int main() {
    int N;
    cin >> N;
    int A[N+1];

    for (int i=1; i<=N; i++) {
        cin >> A[i];
    }

    unsigned long int currentMoney=1000,kabu=0;
    for (int i = 1 ; i<N ; i++) {
        if ( A[i] < A[i + 1] ) {
            kabu += currentMoney / A[i];
            currentMoney = currentMoney % A[i];
        } else if ( A[i] > A[i+1] ) {
            currentMoney += kabu * A[i];
            kabu = 0;
        }

        // cout << "currentMoney" << currentMoney << endl;
        // cout << "kabu" << kabu << endl;
    }

    if (kabu != 0){
        currentMoney += kabu * A[N];
    }

    cout << currentMoney << endl;


    return 0;
}


Measured memory_bytes: 3604
def main():
    n,m = map(int, input().split())
    stairs = [1]*(n+1)
    mod = 1000000007
    for _ in range(m):
        stairs[int(input())] = 0
    for i in range(2, n+1):
        stairs[i] = (stairs[i-2] + stairs[i-1]) * stairs[i]
    print(stairs[n] % mod)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 462708
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }

  map<int, int> m1;
  REP(i, N) m1[A[i]+i]++;

  map<int, int> m2;
  REP(i, N) m2[i-A[i]]++;

  int ans = 0;
  for(auto p : m1){
    ans += p.second*m2[p.first];
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 39076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin>>a>>b>>c;

    int sum1=0, sum2=0, sum3=0;
    sum1 = a+b;
    sum2=b+c;
    sum3 = a+c;
    int mn = min(sum1,sum2);
    int xy= min(mn,sum3);
    cout<<xy<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] tests1 = new int[4];
        int tests1_min = 101;
        int tests1_sum = 0;

        for (int i = 0; i < tests1.length; i++) {
            tests1[i] = sc.nextInt();
        }
        
        for (int i = 0; i < tests1.length; i++) {
            tests1_min = Math.min(tests1_min, tests1[i]);
        }
        
        for (int i = 0; i < tests1.length; i++) {
            tests1_sum += tests1[i];
        }
        
        int tests1_3max = tests1_sum - tests1_min;
        
        int rekisi = sc.nextInt();
        int tiri = sc.nextInt();
        int test2 = Math.max(rekisi, tiri);
        
        System.out.println(tests1_3max + test2);
    }
}


Measured memory_bytes: 26168
N,K = map(int,input().split())
p = list(map(int,input().split()))
S = [0]
s = 0
Max = 0
for i in range(N):
    s += (p[i]+1)/2
    S.append(s)
for i in range(N-K+1):
    s = S[i+K] - S[i]
    if s > Max:
        Max = s
print(Max)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int k;
    cin >> s >> k;

    set<string> ss;
    bool flag = false;
    for(int i = 1; i <= s.size(); i++)
    {
        for(int j = 0; j <= s.size() - i; j++)
        {
            string tmp = s.substr(j, i);
            ss.insert(tmp);
            if(tmp.size() >= 6)
            {
              flag = true;
              break;
            }
        }
        if(flag) break;
    }
    set<string>::iterator itr = ss.begin();
    for(int i = 1; i < k; i++)
    {
        itr++;
    }
    cout << *itr << endl;
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main() {
	int tate, yoko;
	cin >> tate >> yoko;
	while (tate != 0 || yoko != 0) {
		for (int i = 0; i < yoko; i++)cout << "#";
		cout << endl;
		for (int i = 1; i < tate-1; i++) {
			for (int j = 0; j < yoko; j++) {
				if (j == 0||j==yoko-1)cout << "#";
				else cout << '.';
			}
			cout << endl;
		}
		for (int i = 0; i < yoko; i++)cout << "#";
		cout << endl;
		cout << endl;
		cin >> tate >> yoko;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int A,B;
int main(){
	cin>>A>>B;
	int maxn=0;
	for(int i=0;i<2;i++){
		A>B?maxn+=A,A--:maxn+=B,B--;
	}
	cout<<maxn<<endl;
	return 0;
}

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

int8_t main(void) {
    uint8_t buffer;
    if ((buffer = fgetc(stdin))) {
        switch (buffer) {
            case 'A':
                printf("T");
                break;
            case 'C':
                printf("G");
                break;
            case 'G':
                printf("C");
                break;
            case 'T':
                printf("A");
                break;
            default:
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    int H , W ;
    cin>> H >> W;
    while ( H > 0 || W > 0) {
    	    	
    	// print H rows
    	for( int i=1; i<=H; i++) {
    		    		
    		// print W #/.
			for (int j=1; j<=W; j++ ) {
				if(j==1 || j==W || i==1 ||i ==H) { 	
					cout<< '#';
			    } else {
					cout<<'.';
				}
				
			}
			
			cout<< endl;
		}
			cout<< endl;
			
		cin >> H >> W ;
	}	
	return 0;	
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int n;
  cin >> n;
  vector<int> h;
  for(int i = 0; i < n; i++){
    int num;
    cin >> num;
    h.push_back(num);
  }
  
  int ans = 0;
  int step = 0;
  
  for(int i = 0; i < n-1; i++){
    if(h[i] >= h[i+1]){
      step++;
    }
    else if(h[i] < h[i+1]){
      step = 0; 
    } 
    if(ans < step){
      ans = step;
    }

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

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int c[300];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",c+i);
	int ans=0;
	rep(i,1,n-1)if(c[i-1]<c[i]^c[i]>c[i+1])ans++;
	printf("%d",ans);
}

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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

}

long long ans = 0;
void primeFactor(long long n){
    long long prev = 0, now = 0;
    while(n%2 == 0){
        n/=2;
        now++;
        if(now > prev){
            ans++;
            prev = now;
            now = 0;
        }
    }
    for(long long i=3;i*i<=n;i+=2){
        prev = 0, now = 0;
        while(n%i == 0){
            n/=i;
            now++;
            if(now > prev){
                ans++;
                prev = now;
                now = 0;
            }
        }
    }
    if(n >2)
        ans++;
}

int main()
{
    textIO();
    fastIO();

    long long n;
    cin >> n;
    
    primeFactor(n);
    cout << ans << '\n';

    return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    int res, res1, res2, res3;
    res1 = 10 * A + B + C;
    res2 = A + 10 * B + C;
    res3 = A + B + 10 * C;
    res = res1;
    if (res2 >= res) {
        res = res2;
    }
    if (res3 >= res) {
        res = res3;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		double me = sc.nextInt();
		int point = sc.nextInt();
		int count = 0;
		double anser = 0;
		//サイコロの目
			for(int i = 1; i <= me ; i++) {
				double sai = 1.0/me;
				int win = i;
				//コインの振った回数
				while(win<point) {
					win = win*2;
					sai = sai/2;
				}
				anser += sai;
			}
			System.out.println(anser);
		}
	}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

constexpr int INF = 1 << 25;
constexpr int MOD = 1000000007;

int main() {
  int n, q, t, cnt = 0;
  cin >> n;
  vector<int> S(n);
  REP(i, n) cin >> S[i];
  cin >> q;
  REP(i, q) {
    cin >> t;
    if (binary_search(ALL(S), t)) ++cnt;
  }

  cout << cnt << endl;
}



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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	
	int n;
	cin >> n;
	
	map<int , int> mp;
	rep(i , n){
		int x;
		cin >> x;
		++mp[x];
	}
	
	int m;
	cin >> m;
	
	rep(i , m){
		int x;
		cin >> x;
		if(mp.find(x) == mp.end())dier("NO");
		--mp[x];
		if(mp[x] < 0)dier("NO");
	}
	cout << "YES";

	return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>
int main(void){
    // Your code here!
    int n,h,m,s;
    scanf("%d",&n);
    s = n%60;
    m = n/60%60;
    h = n/3600;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<stdio.h>
int space(int,int);
int round(int,int);


using namespace std;

int main(){
    int a,b;
    cin >>a>>b;
    printf("%d %d\n",space(a,b),round(a,b));
    
    return 0;
}

int space(int a,int b){
    return a*b;
}
int round(int a,int b){
    return 2*(a+b);
}


Measured memory_bytes: 3232
#include <stdio.h>

int main(void) {
    int n, count = 0;
    scanf("%d", &n);
    int a[4] = {n/1000, n/100%10, n/10%10, n%10};
    for(int i = 0; i < 3; i++) {
        if(a[i] == a[i+1]) count++;
    }
    if(count > 0) printf("Bad\n");
    else printf("Good\n");
    return 0;
}


Measured memory_bytes: 128
import scala.io.StdIn._

object Main {
  def main(args: Array[String]) = {
    val x = readInt
    val h = x / 3600
    val m = (x - h * 3600) / 60
    val s = (x - h * 3600 - m * 60)
    println(h + ":" + m + ":" + s)
  }
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (b-a == c-b ? "YES\n" : "NO\n");
}


Measured memory_bytes: 256
package main

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

func main() {
	var x, y, a, b, c int
	fmt.Scan(&x, &y, &a, &b, &c)
	apples := make([]apple, 0, a+b+c)
  var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for a > 0 {
		a--
      		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		apples = append(apples, apple{k, 1})
	}
	for b > 0 {
		b--
      		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		apples = append(apples, apple{k, 2})
	}
	for c > 0 {
		c--
				sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		apples = append(apples, apple{k, 0})
	}
	sort.Sort(byDel(apples))
	eaten := 0
	var total int
	for _, a := range apples {
		switch a.color {
		case 0:
			eaten++
			total += a.del
		case 1:
			if x > 0 {
				x--
				total += a.del
			}
		case 2:
			if y > 0 {
				y--
				total += a.del
			}
		}
		if eaten == x+y {
			break
		}
	}
	fmt.Printf("%d\n", total)
}

type apple struct {
	del   int
	color int
}

type byDel []apple

func (a byDel) Len() int           { return len(a) }
func (a byDel) Less(i, j int) bool { return a[i].del > a[j].del }
func (a byDel) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }


Measured memory_bytes: 9728
#include<iostream>
#include<vector>

int main(){
	int n,m;
	while(std::cin>>n){
		if(n==0)break;
		std::vector<char>table_a(n);std::vector<char>table_b(n);
		for(int i=0;i<n;i++)std::cin>>table_a[i]>>table_b[i];
		std::cin>>m;
		std::vector<char>data(m);
		for(int i=0;i<m;i++)std::cin>>data[i];
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(table_a[j]==data[i]){
					data[i]=table_b[j];
					break;
				}
			}
		}
		for(int i=0;i<m;i++)std::cout<<data[i];
		std::cout<<std::endl;
	}	
	return 0;
}

Measured memory_bytes: 1292
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	cout << fixed << setprecision(2);
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector<vector<ld>>field(N+1, vector<ld>(N));
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				cin >> field[i][j];
			}
			
		}
		for (int j = 0; j < N; ++j) {
			field[N][j] = 1;
		}
		vector<vector<ld>>dp(M + 1, vector<ld>(N+1));
		dp[0][N] = 1;
		for (int t = 0; t < M; ++t) {
			for (int pre = 0; pre <= N; ++pre) {
				for (int next = 0; next < N; ++next) {
					dp[t + 1][next] = max(dp[t + 1][next], dp[t][pre] * field[pre][next]);
				}
			}
		}
		ld ans = 0;
		for (int i = 0; i < N; ++i) {
			ans = max(ans, dp[M][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

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


int main(void){
    int n;
    int ball;
    int B_last, C_last;
    bool flag;
    cin>>n;
    vector<int> B(1,0);
    vector<int> C(1,0);
    for(int i=0;i<n;i++){
        flag=true;

        for(int j=0;j<10;j++){
            cin>>ball;
            B_last=B[B.size()-1];
            C_last=C[C.size()-1];
            if(B_last>=C_last){
                if(ball>B_last){
                    B.push_back(ball);
                }
                else if(ball>C_last){
                    C.push_back(ball);
                }
                else{
                    flag=false;
                }
            }
            else{
                if(ball>C_last){
                    C.push_back(ball);
                }
                else if(ball>B_last){
                    B.push_back(ball);
                }
                else{
                    flag=false;
                }
            }
        }
        if(flag){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
        B.clear();
        C.clear();
        B.push_back(0);
        C.push_back(0);
    }
    return 0;
}



Measured memory_bytes: 3008
#include <iostream>
#include <vector>
#include <utility>
#include <string>

char next(char c,int cnt){
    if(cnt == 0) return c;
    if(c == 'z') return next('a',cnt-1);
    return next(c+1,cnt-1);
}

using namespace std;
int main(){
    while(true){
        int N;
        string message;
        cin >> N;
        if(N == 0) break;
        cin >> message;
        vector<pair<int,int> > input(N);
        for(int i=0;i<N;i++){
            cin >> input[i].first >> input[i].second;
        }
        for(int i=N-1;i>=0;i--){
            int a,b;
            a = input[i].first;
            b = input[i].second;
            a--;b--;
            int diff = b - a;
            swap(message[a],message[b]);
            message[a] = next(message[a],diff);
            message[b] = next(message[b],diff);
        }

        cout << message << endl;
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
using namespace std;


#define ll long long

int main() {
  int N;
  cin >> N;
  ll A[N];

  ll x = 0;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] <<= 1;
    x += (i % 2 == 0 ? A[i] : -A[i]);
  }
  x /= 2;

  ll B[N];
  B[0] = x;
  cout << x;
  for (int i = 1; i < N; i++) {
    B[i] = A[i - 1] - B[i - 1];
    cout << " " << B[i];
  }
  cout << endl;

  return 0;
}


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

int main ()
{
    int n;
    cin >> n;
    int k;
    cin >> k;
    
    vector <int> height(n);
    
    for (auto& i:height){
        cin >> i;
    }
    
    vector <int> dp(n, 1e9);
    dp[0] = 0;
    
    for (int i=0; i<n; i++){
        for (int j=i; j<=i+k; j++){
            if (j<n){
                dp[j] = min(dp[j], dp[i] + abs(height[j] - height[i]));
            }
        }
    }
    
    cout << dp[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N;i++){
        cin >> A[i];
    }
    sort(ALL(A));
    auto pos = lower_bound(ALL(A), 0);//0以上の最初の位置のiterator
    int idx;
    idx  = distance(A.begin(), pos);//iteratorを配列の位置に変換
    ll sum = 0;
    if(idx == N){
        int tmp = A[N-1];
        for(int i = 0; i < N-1; i++){
            sum -= A[i];
        }
        sum += A[N-1];
        cout << sum << endl;
        for(int i = N-2; i >= 0; i--){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
    }else if(idx == 0){
        int tmp = A[0];
        for(int i = 1; i < N; i++){
            sum += A[i];
        }
        sum -= A[0];
        cout << sum << endl;
        for(int i = 1; i <=  N-2; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
        cout << A[N-1] << " " << tmp << endl;
    }else{
        int tmp = A[idx-1];
        for(int i = 0; i < N; i++){
            sum += llabs(A[i]);
        }
        cout << sum << endl;
        for(int i = idx; i <= N-2; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
        cout << A[N-1] << " " << tmp  << endl; 
        tmp = A[N-1] - tmp;
        for(int i = 0; i <= idx-2; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
    }
}

Measured memory_bytes: 2688
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[3001][3001][2];
ll solve(vector<int>& v, int i, int j, bool turn)
{
    if(i > j)
        return 0;
    
    if(dp[i][j][turn] != -1)
        return dp[i][j][turn];
    
    if(turn == 1)
        return dp[i][j][turn] = max(v[i] + solve(v, i+1,j,0), v[j] + solve(v, i,j-1, 0));
    else return dp[i][j][turn] = min(solve(v, i+1,j,1)-v[i], solve(v, i,j-1, 1)-v[j]);
}

int main() {
   int n;
   cin >> n ;
   vector<int> v(n+1);
   memset(dp, -1, sizeof dp);
   ll sum = 0;
   for(int i = 1; i <= n; i++)
    {
        cin>>v[i];
        sum += v[i];
    }
   ll scoreX = solve(v, 1, n, 1);
   ll scoreY = (sum - scoreX);
   cout << scoreX;
   return 0;
}


Measured memory_bytes: 144620
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, M;
	cin >> N >> M;
	priority_queue<pair<ll, ll>> pq;
	REP(i, N) {
		ll A;
		cin >> A;
		pq.push({ A,A });
	}
	REP(i, M) {
		ll after, before;
		tie(after, before) = pq.top();
		pq.pop();
		if (after > 0) {
			int d = before / after * 2;
			after = before / d;
		}
		pq.push({ after, before });
	}

	ll res = 0;
	while (!pq.empty()) {
		ll after = pq.top().first;
		pq.pop();
		res += after;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

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

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

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

    ll cnt = 0;

    map<ll, ll> cnter;
    ll ans = 1;
    for (int i = 0; i < N; i++)
    {
        if (A[i] == 0)
        {
            cnt++;
        }
    }

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

        if (A[i] == 0)
        {
            ans = mulMod(ans, 3 - cnter[A[i]]);
        }
        else
        {
            ans = mulMod(ans, cnter[A[i] - 1] - cnter[A[i]]);
        }
        cnter[A[i]]++;
    }

    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 7296
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i

ans = Array.new(n+1, 0)
1.upto(100) do |i|
  num = i*i
  1.upto(100) do |j|
    num2 = num + j*j + i * j
    # break if num2 > n
    1.upto(100) do |k|
      num3 = num2 + k*k + i*k + j*k
      if num3 > n
        break
      else
        ans[num3] += 1
      end
    end
  end
end

ans.shift
ans.each do |e|
  puts e
end


Measured memory_bytes: 14516
N = int(input())
steps = list(map(int, input().split()))
sum_step = 0

for i in range(N-1):
  if steps[i] < steps[i+1]:
    continue
  else:
    step = steps[i] - steps[i+1]
    steps[i+1] += step
    sum_step += step
print(sum_step)

Measured memory_bytes: 32136
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    int max_num = *max_element(A.begin(), A.end());

    vector<bool> b_table(max_num+1, false);
    vector<bool> checked_table(max_num+1, false);
    for(int a : A) {
        b_table[a] = (true && !checked_table[a]);
        checked_table[a] = true;
        for(int i = a+a; i <= max_num; i += a) {
            b_table[i] = false;
            checked_table[i] = true;
        }
    }

    int res = 0;
    for (auto b : b_table) {
        if (b) { res ++; }
    }
    cout << res << endl;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	int dislike = 0;
	for (int i = 0; i < K; i++) {
		int D; cin >> D;
		dislike |= 1 << D;
	}

	auto is_good = [&](int x) -> bool {
		while (x) {
			if (dislike & (1 << (x%10))) return false;
			x /= 10;
		}
		return true;
	};

	int ans = N;
	while (!is_good(ans)) ans++;
	cout << ans << '\n';

	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        String s = sc.next();
        String t = sc.next();

        if (s.length()+1 != t.length()) {
            System.out.println("No");
            return;
        }

        boolean isAns = true;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                isAns = false;
                break;
            }
        }

        System.out.println(isAns ? "Yes" : "No");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 25428
#include<bits/stdc++.h>
using namespace std;
int n,i,s[105],j,k,l;
int d[1000005],td[1000005];
char c[1000005];
string p[1000005],tmp[1000005];
int main()
{
	scanf("%d",&n);
	s[0]=1;
	for(i=1;i<=n;++i)
		s[i]=s[i-1]*3;
	cin>>p[0];
	for(i=0;i<n;++i)
	{
		for(k=0;k<s[i];++k)
			tmp[k].clear();
		for(j=0;j<3;++j)
		{
			for(k=0;k<s[i];++k)
			{
				int u=j,w=0;
				for(l=0;l<p[k].size();++l)
					if(p[k][l]=='S')
					{
						if(u==1)
							u=2;
						else
							if(u==2)
								u=1;
						w^=1;
					}
					else
					{
						++u;
						if(u>=3)
						{
							if(w)
							{
								tmp[j*s[i]+k]+='S';
								w=0;
							}
							u=0;
							tmp[j*s[i]+k]+='R';
						}
					}
				if(w)
					tmp[j*s[i]+k]+='S';
				d[j*s[i]+k]=td[k]+u*s[i];
			}
		}
		for(k=0;k<s[i+1];++k)
		{
			td[k]=d[k];
			p[k]=tmp[k];
		}
	}
	for(i=0;i<s[n];++i)
		printf("%d ",d[i]);
}


Measured memory_bytes: 74988
// 2011/09/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int sum;
		cin >> sum;
		if(sum==0)
			break;

		for(int i=0; i<9; i++){
			int n;
			cin >> n;
			sum -= n;
		}

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long dp[1000010][2][2] = { 0 };
int main() {
	long long n;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				dp[i][j][k] = 0;
			}
		}
	}
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 9; j++) {
			if (j == 0) {
				dp[i][1][0] += dp[i - 1][0][0];
				dp[i][1][0] += dp[i - 1][1][0];
				dp[i][1][1] += dp[i - 1][0][1];
				dp[i][1][1] += dp[i - 1][1][1];
			}
			else if (j == 9) {
				dp[i][0][1] += dp[i - 1][0][0];
				dp[i][1][1] += dp[i - 1][1][0];
				dp[i][0][1] += dp[i - 1][0][1];
				dp[i][1][1] += dp[i - 1][1][1];
			}
			else {
				dp[i][0][0] += dp[i - 1][0][0];
				dp[i][1][0] += dp[i - 1][1][0];
				dp[i][0][1] += dp[i - 1][0][1];
				dp[i][1][1] += dp[i - 1][1][1];
			}
			dp[i][0][0] %= 1000000007;
			dp[i][1][0] %= 1000000007;
			dp[i][0][1] %= 1000000007;
			dp[i][1][1] %= 1000000007;
		}
		dp[i][0][0] %= 1000000007;
		dp[i][1][0] %= 1000000007;
		dp[i][0][1] %= 1000000007;
		dp[i][1][1] %= 1000000007;
	}
	cout << dp[n][1][1] << endl;
}


Measured memory_bytes: 34856
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1000000009;
const ll LINF = 1e18;

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int min = n / x;
  int remain = n % x;
  if (remain != 0) ++min;

  cout << min * t << endl;
}


Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        
        long prev = 0;
        int moves = 0;
        int maxMoves = 0;
        
        for (int i = 0; i < n; i ++) {
            long in = s.nextLong();
            if (in <= prev)
                moves ++;
            else {
                if (moves > maxMoves)
                    maxMoves = moves;
                moves = 0;
            }
            prev = in;
        }
        
        System.out.println(Math.max(moves, maxMoves));
    }
    
}


Measured memory_bytes: 48792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

vector<string>con(10);

int main(){
  con[0] = " ";
  con[1] = "',.!?";
  con[2] = "abcABC";
  con[3] = "defDEF";
  con[4] = "ghiGHI";
  con[5] = "jklJKL";
  con[6] = "mnoMNO";
  con[7] = "pqrsPQRS";
  con[8] = "tuvTUV";
  con[9] = "wxyzWXYZ";

  char in[1000000];
  while(~scanf("%s", in)){
    int now;
    string res = "";
    int c = 0;
    now = in[0]-'0'; c = -1;
    rep(i, strlen(in)){
      int buf = in[i]-'0';
      if(now != 0 && now != buf || buf == 0) cout << con[now][c%con[now].size()], c=0;
      else now?c++:c=0;
      now = buf;
    }
    cout << con[now][c%con[now].size()] << endl;
  }
  return 0;
}

Measured memory_bytes: 1208