akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        if (s.length() != a + b + 1) {
            System.out.println("No");
            return;
        }
        if (!"-".equals(String.valueOf(s.charAt(a)))) {
            System.out.println("No");
            return;
        }
        for (int i = 0; i < s.length(); i++) {
            if (i == a) {
                continue;
            }
            int num = Character.getNumericValue(s.charAt(i));
            if (!(num >= 0 && num < 10)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back
#define inf 1000000000000000000

							
									//nestedcode
									
ll binpow(ll a, ll b) {
    a %= M;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % M;
        a = (a * a)% M;
        b >>= 1;
    }
    return res;
}



bool is_composite[10000005];
ll lp[10000005];
vector<ll> prime;
void sieve (int n) {
	std::fill (is_composite, is_composite + n, false);
	for (int i = 2; i < n; ++i) {
		if (!is_composite[i]) {
			prime.push_back (i);
			lp[i] = i;
		}	for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
			is_composite[i * prime[j]] = true;
			lp[i * prime[j]] = prime[j];
			if (i % prime[j] == 0) break;
		}
	}
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    sieve(10000005);
    ll n,i,k,ans,fans;
    cin>>n;
    fans = 0;
    for(i=1;i<=n;i++){
    	k = i;
    	map<ll,ll> m;
    	while(k>1){
    		m[lp[k]]++;
    		k/=lp[k];
		}
		ans = 1;
		for(auto x: m){
			ans = (ans * (1+x.ss));
		}
		fans += i*ans;
	}
	cout<<fans;
    
}

Measured memory_bytes: 99412
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
using namespace std;

const double PI=acos(-1);

double rad(int d){
    return (double)d/360*2*PI;
}

int main(){
    int n;
    double p[1000];
    fill(p, p, 0);

    while(cin >> n, n != 0){
        double s = 0, t = 0;
        for(int i = 0; i < n; i++){
            cin >> p[i];
            s += p[i];
        }
        double ave = s / n;
        for(int i = 0; i < n; i++){
            t += pow(p[i] - ave, 2);
        }
        //printf("%.4f %.4f %.4f %d\n", s, ave, t, n);
        printf("%.4f\n", sqrt(t/n));
    }
    return 0;
}


Measured memory_bytes: 3220
# -*- coding: utf-8 -*-
import collections

N = int(input())
D = list(map(int,input().split()))

set_D = set(D)
c = collections.Counter(D)

sum = 1
if D[0] != 0 or D.count(0) > 1:
  print(0)
elif len(set_D)-1 == max(set_D):
  for i in range(len(set_D)):
    if i >= 1:
      sum *= c[i-1]**c[i]
  q, mod = divmod(sum, 998244353)
  print(mod)
else:
  print(0)

Measured memory_bytes: 25568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
ll a[maxn],sum[maxn];
map<ll,int>vis;
map<ll,ll>exist;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		sum[i] = sum[i-1]+a[i];
		exist[sum[i]]++; 
	}
	

	ll cnt = 0;
	for(int i=1;i<=n;i++)
	{
	
		if(sum[i]==0)
		{
			cnt++;
		
		}
			if(!vis[sum[i]])
			{
				vis[sum[i]] = 1;
				cnt+= exist[sum[i]]*(exist[sum[i]]-1)/2;
			}
	}
	
	cout<<cnt<<endl;
	
	return 0;
} 

Measured memory_bytes: 28416
#include <iostream>
using namespace std;
int main(){
 int a, b;
    cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
    } else if (6 <= a && a <= 12) {
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 110, INF = 1 << 15;
struct edge {
  int la,b,cap;
} con[N * N * 10];
int tot = 1,fir[N * N * 4],cnt,cur[N * N * 4];
void add(int from,int to,int cap) {
  con[++tot] = (edge) {fir[from],to,cap};
  fir[from] = tot;
  con[++tot] = (edge) {fir[to],from,0};
  fir[to] = tot;
}
int st,en,flo,dis[N * N * 4];
int dfs(int pos,int imp) {
  if (pos == en || !imp) return imp;
  int expo = 0, tmp;
  for (int& i = cur[pos] ; i ; i = con[i].la) {
    if (dis[con[i].b] == dis[pos] + 1) {
      tmp = dfs(con[i].b,min(imp,con[i].cap));
      con[i].cap -= tmp;
      con[i^1].cap += tmp;
      expo += tmp;
      imp -= tmp;
      if (!imp) break;
    }
  }
  return expo;
}
queue<int> q;
bool bfs() {
  while (!q.empty()) q.pop();
  memset(dis,0,sizeof dis);
  q.push(st);
  dis[st] = 1;
  for (int pos ; !q.empty() ; q.pop()) {
    pos = q.front();
    for (int i = fir[pos] ; i ; i = con[i].la)
      if (con[i].cap && !dis[con[i].b]) {
        dis[con[i].b] = dis[pos] + 1;
        q.push(con[i].b);
      }
  }
  for (int i = 1 ; i <= cnt ; ++ i)
    cur[i] = fir[i];
  return dis[en] != 0;
}
int sta[N][N],h,w,sx,sy,tx,ty,num[N][N][2],row[N],col[N];
int main() {
  char tmp;
  scanf("%d%d",&h,&w);
  for (int i = 1 ; i <= h ; ++ i)
    for (int j = 1 ; j <= w ; ++ j) {
      #define gc() getchar()
      for (tmp = gc() ; tmp != '.' && tmp != 'o' && tmp != 'S' && tmp != 'T' ; tmp = gc());
      if (tmp == '.');
      else sta[i][j] = 1, num[i][j][0] = ++cnt, num[i][j][1] = ++cnt;
      if (tmp == 'S') sx = i, sy = j;
      if (tmp == 'T') tx = i, ty = j;
    }
  if (sx == tx || sy == ty) return 0 * printf("-1\n");
  for (int i = 1 ; i <= h ; ++ i)
    row[i] = ++cnt;
  for (int i = 1 ; i <= w ; ++ i)
    col[i] = ++cnt;
  for (int i = 1 ; i <= h ; ++ i)
    for (int j = 1 ; j <= w ; ++ j)
      if (sta[i][j]) {
        add(row[i],num[i][j][0],INF);
        add(col[j],num[i][j][0],INF);
        add(num[i][j][0],num[i][j][1],1);
        add(num[i][j][1],row[i],INF);
        add(num[i][j][1],col[j],INF);
      }
  st = num[sx][sy][1];
  en = num[tx][ty][0];
  while (bfs()) {
    flo += dfs(st,INF);
  }
  printf("%d\n",flo);
  return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		char[][] room = new char[h][w];
		
		for (int i = 0; i < h; i++) {
			String s = sc.next();
			for (int j = 0; j < w; j++) {
				room[i][j] = s.charAt(j);
			}
		}
		
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				char c = room[i][j];
				if (c == '#') {
					int area = computeArea(room, i, j);
					if (area == 1) {
						System.out.println("No");
						System.exit(0);
					}
				}
			}
		}
		System.out.println("Yes");
	}
	private static int computeArea(char[][] room, int x, int y) {
		int res = 0;
		if ((0 <= x) && (x < room.length) && (0 <= y) && (y < room[0].length)) {
			if (room[x][y] == '.') { return res; }
			room[x][y] = '.';
			res += 1;
			res += computeArea(room, x - 1, y);
			res += computeArea(room, x + 1, y);
			res += computeArea(room, x, y - 1);
			res += computeArea(room, x, y + 1);
			return res;
		}
		return res;
	}
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22484
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        String S = sc.nextToken();
        int N = S.length();

        String prev = "";
        int ans = 0;
        int i = 0;

        int n = 1;
        while (i+n <= N) {
            String s = S.substring(i, i+n);
            if (s.equals(prev) == false) {
                prev = s;
                ans++;
                i = i + n;
                n = 1;
            } else {
                n++;
            }
        }


        out.println(ans);
        out.flush();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int N) {
            int a[] = new int[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextInt();
            }

            return a;
        }

        long[] nextLongArray(int N) {
            long a[] = new long[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextLong();
            }

            return a;
        }

        double[] nextDoubleArray(int N) {
            double a[] = new double[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextDouble();
            }

            return a;
        }

        String[] nextTokenArray(int N) {
            String a[] = new String[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextToken();
            }

            return a;
        }
    }
}

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

int main(){
    int n, i, h, hm = 0, c = 0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> h;
        if(h >= hm){
            c++;
            hm = h;
        }
    }
    cout << c << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int n, m, k = 0;
	char str[5];
	scanf("%s", str);

	if (str[0] == '9') { k++; }


	if (str[1] == '9') { k++; }


	if (k != 0){printf("Yes");
	}
	else { printf("No"); }
}

Measured memory_bytes: 128
from collections import *
from functools import *
from itertools import *

def main():
    #n = int(input())
    a, p = map(int, input().split())
    #xs = list(map(int, input().split()))
    print((3 * a + p) // 2)
    pass


if __name__ == "__main__":
    main()
    pass


Measured memory_bytes: 3820
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

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

typedef pair<int ,int> P;


int main()
{

// N A B C X
// Y1 Y2 ... YN
    int N,A,B,C,X;
    while(cin >> N >> A >> B >> C >> X )
    {
        if( N == 0 && A==0 && B==0 && C==0 && X==0 ) { break;}
        deque<int> deq;
        int tmp;
        rep(i,N) { cin >> tmp; deq.push_back(tmp); }

        int count = 0;

        int x = X;
        while ( !( deq.empty() ) )
        {
            if( x == deq.front() )
            {
                deq.pop_front();
            }
            x = (A*x + B)%C;
            count++;
            if(count > 10001){break;}
        }
        if(count >10001 ){ cout << -1 <<endl;}
        else { cout << count-1 << endl; }
    }
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    if(a[0] == b[2] and a[1] == b[1] and a[2] == b[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
    int n;
    cin>>n;
    //int arr[n];
    long ans=0;
    for(int i=0;i<n;i++)
    {
        long x;
        cin>>x;
        ans+=x-1;

    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n,m,p=0;
        cin>>n;
        while(n>0){
            m=n%10;
            if(m==7){
                    cout<<"Yes";
            p=1;
                break;
            }
            n=n/10;
        }
        if(p==1){
            p=0;
        }
        else{
            cout<<"No";
        }
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input;
		int n = Integer.parseInt(reader.readLine());
		long[] arr = new long[n + 1];
		input = reader.readLine().split(" ");
		for(int i = 0; i <= n; i++) {
			arr[i] = Integer.parseInt(input[i]);
		}
//		if(n > 0 && (arr[0] != 0 || arr[n] == 0)) {
//			System.out.println(-1);
//			return;
//		}
		long[][] up = new long[n + 1][2];
		up[0][0] = 1;
		for(int i = 1; i <= n; i++) {
			up[i][0] = ((up[i - 1][0]) * 2) - arr[i];
			if(up[i - 1][0] > Math.pow(10, 18)) {
				up[i][0] = Long.MAX_VALUE;
			}
			if(up[i][0] < 0) {
				System.out.println(-1);
				return;
			}
//			System.out.println(up[i][0] + " ");
		}
		up[n][1] = 0;
		for(int i = n - 1; i >= 0; i--) {
			up[i][1] = arr[i + 1] + up[i + 1][1];
		}
		BigInteger ans = new BigInteger("0");
		long[] temp = new long[n + 1];
		for(int i = 0; i <= n; i++) {
			ans = ans.add(new BigInteger((Math.min(up[i][0], up[i][1]) + arr[i]) + ""));
			temp[i] = Math.min(up[i][0], up[i][1]);
			if(temp[i] < 0) {
				System.out.println(-1);
				return;
			}
		}
		if(Long.parseLong(ans.toString()) > 1 && arr[0] != 0) {
			System.out.println(-1);
			return;
		}
		out.print(ans.toString());
		out.flush();
	}

}


Measured memory_bytes: 65012
#include <bits/stdc++.h>
#define MAXN 2550
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> id(N+1);

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

    multiset<int> st;
    ll ans = 0;
    st.insert(0);
    st.insert(0);
    st.insert(N+1);
    st.insert(N+1);


    for (int n = N; n >=1; n--){
        int i = id[n];
        auto l = st.upper_bound(i);
        auto r = l;
        ll x = *(--l), y = *(--l), w = *(r), z = *(++r);

        ans += n*((x - y)*(w - i) + (i - x)*(z - w));
        st.insert(i);
    }

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

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


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

    vector<int> a(n);
    int atmp;
    for(int in=0;in<n-1;in++) {
        cin >> atmp;
        a.at(atmp-1)++;
    }

    for(int in=0;in<n;in++) {
        cout << a.at(in) << endl;
    }

    return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ul unsigned long long
#define pi pair<ul,ul>
using namespace std;
const ul p=19260817;
int n,m,la,lb,lc;
char str[50],a[50],b[50],c[50];
map<pi,int>cnt;
int main()
{
    int n;
    scanf("%d",&n);
    m=(1<<n);
    scanf("%s",str);
    for(int s=0;s<m;++s)
    {
        ul fi=0,se=0;
        for(int i=0;i<n;++i)
            if(s>>i&1) fi=fi*p+str[i];
            else se=se*p+str[i];
        cnt[pi(fi,se)]++;
    }
    long long ans=0;
    for(int s=0;s<m;++s)
    {
        la=lb=lc=0;
        for(int i=0;i<n;++i)
            if(s>>i&1) a[la++]=str[i+n];
            else b[lb++]=str[i+n];
        ul fi=0,se=0;
        for(int i=0;i<lb;++i) fi=fi*p+b[lb-1-i];
        for(int i=0;i<la;++i) se=se*p+a[la-1-i];
        ans+=cnt[pi(fi,se)];
    }
    printf("%lld\n",ans);

    return 0;
}


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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;



int main() {
  int n;
  double x[20];
  string u[20];
  cin >> n;
  rep(i, n) {
    cin >> x[i] >> u[i];
  }

  double ans = 0.0;
  rep(i, n) {
    if (u[i] == "JPY") {
      ans += x[i];
    } else {
      ans += x[i] * 380000.0;
    }
  }

  cout << ans << endl;
}


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

#define pb push_back

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int m1, d1, m2, d2; 
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    cout << (m2 == m1 + 1);
}

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

int main(){
  int n, d, ans;
  cin >> n >> d;
  if(n % (2*d+1) == 0) ans = n/(2*d+1);
  else ans = n/(2*d+1) + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll H, N; cin >> H >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    cout << (accumulate(A.begin(), A.end(), 0LL) >= H ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1024
object Main {
  def main (args: Array[String]) {
    var count:Int = 0
    for(line <- scala.io.Source.stdin.getLines()){
      val Array(min, max, o) = line.split(" ").map(_.toInt)
      var list: List[Int] = List()
      for( i <- min to max if ((o % i)  == 0) ) list = i::list
      println(list.length)
    }
  }
}

Measured memory_bytes: 44464
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N;
  string s[100];
  cin>>N;
  rep(i,N) cin>>s[i];
  int l[100][30] = {0};
  rep(i,N){
    for (int j(0);j<int(s[i].size());j++){
      l[i][s[i][j]-'a']++;
    }
  }
  int ans[30] = {0};
  rep(i,30){
    int mini(100);
    for (int j(0);j<N;j++){
      mini = min(mini,l[j][i]);
    }
    ans[i] = mini;
  }
  //rep(i,30) cout << ans[i] <<" ";
  for(int i(0);i<30;i++){
    cout << string(ans[i],'a'+i);
  }
  cout << 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);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		int wa = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			wa += A[i];
		}
		sc.close();
		// Arrays.sort(A);
		int ok = 0;
		for(int i = N - 1; i >= 0; i--) {
			ok += A[i] * (4 * M) >= wa ? 1 : 0;
			// System.out.println(ok + " " + A[i] + " " + nov);
		}
		System.out.println(ok >= M ? "Yes" : "No");
	}
}


Measured memory_bytes: 23124
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n;cin>>n;
    ll a[n+1];
    for(ll i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    ll ans=0;
    if(n<3)
    {
        cout<<0<<endl;
        return;
    }
    for(ll i=n;i>=3;i--)
    {
        for(ll j=i-1;j>=2;j--)
        {
            ll c=a[i]-a[j]+1;
            if(c<0)continue;
            ll pos=lower_bound(a+1,a+n+1,c)-a;
            if(pos>=1 and pos<j)
                ans+=(j-pos);
//            cout<<"a= "<<a[i]<<" b= "<<a[j]<<" c= "<<c<<" ";
//            cout<<"i= "<<i<<" j= "<<j<<" pos= "<<pos<<endl;
        }
    }
    cout<<ans<<endl;
}
/*
9
9 7 7 6 6 5 4 3 2
*/
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct edge{
   int to, cost;
   edge(int to, int cost):to(to), cost(cost){}
};

template< typename G >
struct Dijkstra{
    const G &g;
    vector<int> d;

    Dijkstra(const G &g) : g(g), d(g.size(), INF) {}

    void build(int s){
        d[s] = 0;
        priority_queue<P, vector<P>, greater<P> > q;
        q.push({d[s], s});
        while(!q.empty()){
            P p = q.top(); q.pop();
            int from = p.second;
            int cost = p.first;
            if(d[from] < cost) continue;
            for(int i = 0; i < g[from].size(); i++){
                int next = g[from][i].to;
                int newCost = cost + g[from][i].cost;
                if(d[next] > newCost){
                    d[next] = newCost;
                    q.push({newCost, next});
                }
            }
        }
    }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    vector<vector<edge> > Gy(n), Gs(n);
    rep(i, 0, m){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        Gy[u].push_back({v, a});
        Gy[v].push_back({u, a});
        Gs[u].push_back({v, b});
        Gs[v].push_back({u, b});
    }
    Dijkstra<vector<vector<edge> > > Dy(Gy), Ds(Gs);
    Dy.build(s);
    Ds.build(t);
    vector<int> a(n);
    rep(i, 0, n){
        a[i] = 1e15 - Dy.d[i] - Ds.d[i];
    }
    vector<int> ans(n);
    int MAX = 0;
    for(int i = n - 1; i >= 0; i--){
        MAX = max(MAX, a[i]);
        ans[i] = MAX;
    }
    for(int ii = 0; ii < ans.size(); ii++){
        cout << ans[ii] << endl;
    }
}

Measured memory_bytes: 19784
//int -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define REP(i,sss,eee) for(int i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<int> inp;
int main(){
	int n,k;cin>>n>>k;
	inp.resize(n);
	REP(i,0,n-1){cin>>inp[i];}
	std::vector<int> dp(n,0);
	for(int i=1;i<n;++i)
	{
		int ans=INT_MAX;
		for(int sub=1;(sub<=k)&&((i-sub)>=0);++sub)
		{
			int si=(i-sub);
			ans=MIN(ans,(dp[si]+MOD(inp[i]-inp[si])));
		}
		dp[i]=ans;
	}
	cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> //AtCoder
#include <atcoder/all> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;
using namespace atcoder;

/*int gcd(int a,int b){return b?gcd(b,a%b):a;}//最大公約数
int lcm(int a,int b){return a/gcd(a,b)*b;}//最小公倍数*/

/****************************** START ******************************/

signed main(){
  int N,Q;
  cin >> N >> Q;
  dsu d(N);
  int t,u,v;
  rep(i,0,Q){
    cin >> t >> u >> v;
    if (t){
      if (d.same(u,v)){
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    } else {
      d.merge(u,v);
    }
  }
}      

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define ppi pair<Sint,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}


int main()
{
    IOS

    ll n;
    cin>>n;

    vector<ld> v(n+1);

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

    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            dp[i][j]=0;

    dp[0][0]=1;
    for(int i=1;i<=n;i++)
        dp[i][0]=dp[i-1][0]*(1-v[i]);
    
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            dp[i][j]=dp[i-1][j]*(1-v[i]) + dp[i-1][j-1]*v[i];
        }
    }
    ld sum=0;
    for(int i=n/2+1;i<=n;i++)
        sum+=dp[n][i];
        
    cout<<fixed<<setprecision(10)<<sum;
    return 0;
}

Measured memory_bytes: 140928
import java.util.*;

import static java.lang.Math.pow;
import static sun.swing.MenuItemLayoutHelper.max;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int k = scan.nextInt();
        int tmp = max(a, b, c);
        int ans = a + b + c - tmp;
        ans += tmp * Math.pow(2.0, (double) k);
        System.out.println(ans);
    }

}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[200005];
ll S[200005];

int main()
{
    ll N;
    cin >> N;
    memset(S, 0, sizeof(S));
    REP(i, N)
    {
        cin >> A[i];
        S[i + 1] += S[i] + A[i];
    }

    ll min = INF;
    REP(i, N)
    {
        ll m = abs(S[N] - 2 * S[i + 1]);
        min = std::min(m, min);
    }
    cout << min << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    string S;
    cin >> S;

    map<char, int> m;
    for (int i = 0; i < S.size(); i++) {
        m[S[i]] += 1;
    }

    bool ok(true);
    if (m.size() == 2) {
        for (auto& var: m) {
            if (var.second == 2) {
            } else {
                ok = false;
            }
        }
    } else {
        ok = false;
    }

    cout << ((ok) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
"use strict";
function Main(input) {
    let Nums = input.split(/\s/).map((v) => v - 0);
    Nums.sort((a, b) => b - a);
    let max = Nums[0] * 10 + Nums[1] + Nums[2];
    console.log(max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int mini = INT_MAX;
    forn(i,n){
        int x;
        cin>>x;
        int cnt=0;
        while(x%2==0){
            cnt++;
            x /=2;
        }
        mini = min(mini,cnt);
    }
    cout<<mini<<endl;
    return 0;
}



Measured memory_bytes: 3556
var
  t,x:array[0..300005]of int64;
  n,i:longint;
  l,z,c0,c1,c2:int64;
  f,g:boolean;
begin
  readln(n,l);
  for i:=1 to n do
    read(x[i]);
  readln;
  z:=1;
  for i:=1 to n do
  begin
    read(t[i]);
    z:=z+t[i] div (2*l);
    t[i]:=t[i] mod (2*l);
    if t[i]>0 then
    begin
      inc(z);
      f:=false;
      g:=false;
      if t[i]<=(l-x[i])*2 then
        f:=true;
      if t[i]<=x[i]*2 then
        g:=true;
      if i=n then
      begin
        if f then
          dec(z);
        break;
      end;
      if g then
      begin
        inc(c0);
        if f then
          inc(c2);
      end else
      if f then 
        inc(c1);
      while c0-c2<c1+c2 do
      begin
        if c2>0 then
          dec(c2) else
          dec(c1);
      end;
    end;
  end;
  z:=z-c1-c2;
  writeln(z*2*l);
end.


Measured memory_bytes: 4736
#!/usr/bin/env python
# -*- coding:utf-8 -*-

str = raw_input()
str = str.replace(',',' ')
str = str.replace('.',' ')
strs = str.split()
ans = ""
for out in strs:
	if(len(out) > 2 and len(out) < 7 ):
		ans += out + " "
ans = ans.rstrip(" ")
print ans

Measured memory_bytes: 6272
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

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

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

const ll N=1e4+5;

ll vis[N];

vpll arr[N];

ll d[N];


struct cmp{

bool operator()(pll a,pll b)const{
return a.ff>b.ff;

}
};





int main()
{ 

IOS;

ll t;cin>>t;

while(t--){

ll n;cin>>n;

vl profit[n+1],loss[n+2];

vl k(n+1),l(n+1),r(n+1);

vl allot(n+1);

for(int i=1;i<=n;i++){
  cin>>k[i]>>l[i]>>r[i];
  profit[k[i]].pb(i);
  loss[k[i]+1].pb(i);
}

set<pll>s;

for(int i=n;i>=1;i--){
for(auto ind:profit[i]){
  s.insert({l[ind]-r[ind],ind});
  // kisi i ke liye we are inserting all the 
  //positions(from [i,n]) for which l>r and
  // in increasing order of (l-r).
  // agar set is not empty ,then we can place the 
  // last element in the set(currently) at the
  // i'th postion.  
}
if(!s.empty()){
  auto it=s.rbegin();
  if((*it).ff>0){
    allot[(*it).ss]=1;
    s.erase(*it);
  } 
}

}

s.clear();

for(int i=2;i<=n;i++){
  for(auto ind:loss[i]){
    s.insert({r[ind]-l[ind],ind});
  }

if(!s.empty()){
  auto it=s.rbegin();
  if((*it).ff>0){
    allot[(*it).ss]=1;
    s.erase(*it);
  }
}

}

ll ans=0;

for(int i=1;i<=n;i++){
  if(!allot[i])ans+=min(l[i],r[i]);
  else ans+=max(l[i],r[i]);
}

cout<<ans<<endl;


}



return 0;
 
}


Measured memory_bytes: 33480
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String S = in.next();
        out.println(S.substring(0, 3));
        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 32676
import heapq
from heapq import heapify, heappush, heappop

global G

def input_graph(M, uvab):
  global G
  for i in range(M):
    u, v, a, b = uvab[i]
    G[u-1] += [[v-1, (a, b)]]
    G[v-1] += [[u-1, (a, b)]]
  
def dijkstra(N, S, flag):
  global G
  dist = [float('inf') for _ in range(N)]
  dist[S] = 0
  Q = [(0, S)]
  while Q:
    c, v = heappop(Q)
    if dist[v] < c:
      continue
    for t, cost in G[v]:
      yen, snuuk = cost
      if flag:
        if dist[v] + yen < dist[t]:
          dist[t] = dist[v] + yen
          heappush(Q, (dist[t], t))
      else:
        if dist[v] + snuuk < dist[t]:
          dist[t] = dist[v] + snuuk
          heappush(Q, (dist[t], t))
  return dist

def main():
  global G
  N, M, S, T = map(int, input().split())
  S -= 1
  T -= 1
  uvab = [list(map(int, input().split())) for _ in range(M)]
  G = [[] for _ in range(N)]
  input_graph(M, uvab)
  yen_dist = dijkstra(N, S, True)
  snuuk_dist = dijkstra(N, T, False)
  dist = [yen_dist[i]+snuuk_dist[i] for i in range(N)]
  for i in range(N-2, -1, -1):
    dist[i] = min(dist[i+1], dist[i])
  for i in range(N):
    print(10**15-dist[i])

if __name__ == "__main__":
  main()

Measured memory_bytes: 95868
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll dp[1010][1010];
int main(){
    int n,m;
    cin>>n>>m;
    string s[n];
    rep(i,n)cin>>s[i];
    dp[0][0]=1;
    rep(i,n)rep(j,m){
        dp[i][j]%=mod;
        if(s[i][j]=='#')continue;
        dp[i+1][j]+=dp[i][j];
        dp[i][j+1]+=dp[i][j];
    }
    cout<<dp[n-1][m-1]<<endl;
    return 0;
}

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

int main(){
  int K,A,B;
  cin>>K>>A>>B;
  
  if(K==1) cout<<"OK\n";
  else if(A%K==0 || B%K==0) cout<<"OK\n";
  else if(B/K - A/K >= 1) cout<<"OK\n";
  else cout<<"NG\n";
}

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

int main(void) {

    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 <= 21) cout << "win" << endl;
    else cout << "bust" << endl;

    return 0;
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;
 
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(c,l,r) for(int c=(l);c<=(r);c++)
 
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
 
using ll = long long;
//#define int ll
 
const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int  dx[]  = {-1,   0,   1,   0,  1, -1, -1,  1};
const int  dy[]  = { 0,   1,   0,  -1,  1, -1,  1, -1};
const char dt[] = {'U', 'R', 'D', 'L'};

map <int, int> mp;

int ok(int n) {
	while (n) {
		if (mp[n % 10]) return false;
		n /= 10;
	} return true;
}
void solve() {	
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; i ++) {
		int x;
		cin >> x;
		mp[x] = 1;
 	}
	while (!ok(n)) {
		n ++;
	}
	cout << n;	
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
   	//cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}



Measured memory_bytes: 3592
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 200005;
const int MAXM = 1000005;
const int MOD = 1000000007;
const int MAMOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double EPS = 1e-8;
#define endl "\n"
#define de(x) cout<<#x<<"="<<x<<endl

int main()
{
    string s;
    cin >> s;
    if (s.length() == 6 && s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    cin>>n;
    ll ans=0;
    for(ll k=1;k<=sqrtl(n);k++){
        if(k!=0) {
            ll nn = n - k;
            if (nn % k == 0) {
                //cout<<nn/k<<endl;
                ll j = nn / k;
               if(j!=0) {
                   if ((n % j) == (n / j)) {
                       ans += j;
                   }
               }
            }
        }
    }

    cout<<ans<<endl;



    return 0;
}


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

int main() {
    int H,W;
    int c[10][10];
    int A[200][200];
    cin >> H >> W;
    for(int i=0; i<10; ++i) {
        for(int j=0; j<10; ++j) cin >> c[i][j];
    }
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) cin >> A[i][j];
    }

    for(int k=0; k<10; ++k) {
        for(int i=0; i<10; ++i) {
            for(int j=0; j<10; ++j) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    long long ans = 0;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            if(A[i][j] < 0) continue;
            ans += c[A[i][j]][1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

namespace SCC{
    void visit(const vector<vector<int>>&G,vector<int>&vs,vector<int>&used,int v){
        used[v]=true;
        for(auto u:G[v]){
            if(!used[u])visit(G,vs,used,u);
        }
        vs.push_back(v);
    }

    void visit2(const vector<vector<int>>&T,vector<int>&used,vector<int>&comp,vector<int>&vec,int k,int v){
        comp[v]=k;
        used[v]=true;
        vec.push_back(v);

        for(auto u:T[v]){
            if(!used[u])visit2(T,used,comp,vec,k,u);
        }
    }

    //G:?????£?????????????§£???????????°??????
    //H:?????£??????????????°??????1???????????????????´?????????°??????
    //comp:G????????????????????????H?????????????±????????????????
    void decompose(const vector<vector<int>>&G,vector<vector<int>>&H,vector<int>&comp){
        vector<vector<int>>T(G.size());
        for(int i=0;i<G.size();i++){
            for(auto v:G[i]){
                T[v].push_back(i);
            }
        }
        comp.resize(G.size());

        vector<int>vs(G.size());
        vector<int>used(G.size());
        for(int i=0;i<G.size();i++){
            if(!used[i])visit(G,vs,used,i);
        }
        reverse(vs.begin(),vs.end());
        fill(used.begin(),used.end(),0);

        int K=0;
        vector<vector<int>>S;
        for(auto v:vs){
            if(!used[v]){
                S.push_back(vector<int>());
                visit2(T,used,comp,S.back(),K++,v);
            }
        }

        H.resize(K);
        fill(used.begin(),used.end(),0);
        for(int i=0;i<K;i++){
            for(auto v:S[i]){
                for(auto u:G[v]){
                    if(used[comp[u]]||comp[v]==comp[u])continue;
                    used[comp[u]]=true;
                    H[comp[v]].push_back(comp[u]);
                }
            }
            for(auto v:H[i])used[v]=true;
        }

    }
}

int N,M;
vector<vector<int>>H;
const int mod=1000000007;

int dp[1000];
void dfs(int v){
    dp[v]=1;
    for(auto u:H[v]){
        dfs(u);
        dp[v]=dp[v]*(dp[u]+1)%mod;
    }
}

signed main(){
    scanf("%lld%lld",&N,&M);
    vector<vector<int>>G(N);
    rep(i,M){
        int a,b;
        scanf("%lld%lld",&a,&b);
        a--;b--;
        G[b].push_back(a);
    }

    vector<int>comp;

    SCC::decompose(G,H,comp);
    int ans=1;
    int deg[1000]={};
    rep(i,H.size())for(auto v:H[i])deg[v]++;
    rep(i,H.size()){
        if(deg[i]==0){
            dfs(i);
            ans=ans*(dp[i]+1)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3476