akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

import java.util.HashSet;

public class Main {
	
	int N;
	char[] B = {'a','i','u','e','o'};
	public void solve() {
		while(true){
			N = nextInt();
			if(N == 0)break;
			String[] S = new String[N];
			for(int i = 0;i < N;i++){
				String s = next();
				StringBuilder sb = new StringBuilder();
				boolean preB = false;
				for(int j = 0;j < s.length();j++){
					if(j == 0 || preB){
						if(preB)preB = false;
						sb.append(s.charAt(j));
					}
					
					for(int k = 0;k < B.length;k++){
						if(B[k] == s.charAt(j)){
							preB = true;
						}
					}
				}
				
				S[i] = sb.toString();
			}
			
			
			boolean isAns = false;
			for(int i = 1;i <= 50;i++){
				HashSet<String> set = new HashSet<String>();
				boolean ok = true;
				for(int j = 0;j < N;j++){
					if(set.contains(S[j].substring(0,Math.min(S[j].length(),i)))){
						ok = false;
						break;
					}else{
						set.add(S[j].substring(0,Math.min(S[j].length(),i)));
					}
				}
				
				if(ok){
					out.println(i);
					isAns = true;
					break;
				}
			}
			
			if(!isAns){
				out.println(-1);
			}
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 29652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define max(a, b) a>b?a:b;
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int>a;
int solve(int k, int n){
  int maxValue=0;
  for(int i=1;i<n;i++){
      int diff=a[i]-a[i-1];
      maxValue=max(maxValue,diff);
  }
  maxValue=max(maxValue,k-(a[n-1]-a[0]));
  return k-maxValue;
}

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

int k;
int n;

cin>>k;
cin>>n;
a.resize(n);
rep(i,n){
    cin>>a[i];
}

sort(a.begin(),a.end());

cout<<solve(k,n)<<endl;
return 0;
}

Measured memory_bytes: 1024
l, r = map(int, input().split())

ans = 10 ** 8

if r - l >= 2019:
    ans = 0
else:
    r_mod = r % 2019
    l_mod = l % 2019
    if r_mod < l_mod:
        ans = 0
    else:
        for i in range(l_mod, r_mod+1):
            for j in range(i+1, r_mod+1):
                ans = min(ans, (i * j) % 2019)

print(ans)


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

int main() {
	string s;
	cin >> s;
	string res = "";
	for (auto num: s) {
		if (num == '1') {
			res += '9';
		} else if (num == '9') {
			res += '1';
		} else {
			res += num;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
void dice(){
 int d1,d2,d3,d4,d5,d6;
 cin>>d1>>d2>>d3>>d4>>d5>>d6;

 char dir;
 int tmp;
 while(true){
     cin>>dir;
     if(cin.eof()) break;
     if(dir=='E'){
         tmp=d1;d1=d4;d4=d6;d6=d3;d3=tmp;
     }else if(dir=='N'){
         tmp=d1;d1=d2;d2=d6;d6=d5;d5=tmp;
     }else if(dir=='S'){
         tmp=d1;d1=d5;d5=d6;d6=d2;d2=tmp;
     }else if(dir=='W'){
         tmp=d1;d1=d3;d3=d6;d6=d4;d4=tmp;
     }
 }
 cout<<d1<<endl;
}
int main(){
 dice();
 return 0;
}


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

  int c = 0;
  int max = 0;
  for (int i=0; i<3;i++) {
    if (W.at(i) == 'R') {
      c++;
    }else {
      if (c > max) {
        max = c;
      }
      c=0;
    }
  }
  
  if (c > max) {
    max = c;
  }
  cout << max << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,k;

int main(){
    read2i(n,k);
    double ans = 0;
    lp(i,1,n){
        double p = 1;
        int j = i;
        while(j < k) p /= 2, j *= 2;
        ans += p;
    }
    printf("%.9f", ans / n);
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	real n = to!real(chomp(s));
	real sum=0;
	for(int i=0;i<10;i++){
	    sum += n;
	    if(i%2==0)	n *= 2;
	    else n /= 3;
	}
	writef("%.6f\n",sum);
    }
}

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

int main(){
    int MINnum = INT_MAX;
    string S;
    cin >> S;
    int tmp;

   
    for(int i = 0; S[i + 2]!='\0'; i++){
        tmp = atoi(S.substr(i, 3).c_str());
        tmp = abs(tmp - 753);
        MINnum = min(tmp, MINnum);
        
    }

    cout << MINnum << endl;


}

Measured memory_bytes: 256
def main():
    from collections import Counter
    s = input()

    n = 2019
    l = [0]
    t = 1
    for i, x in enumerate(s[::-1]):
        t = t * 10 % n
        y = (l[-1] + int(x) * t) % n
        l.append(y)

    c = Counter(l)
    ans = sum([v * (v - 1) // 2 for v in c.values()])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
		
	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		String[] inputs = reader.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]);
		int k = Integer.parseInt(inputs[1]);
		
		int[] weights = new int[n];
		int capacity = 0;
		for (int i = 0; i < n; i++) {
			int weight = Integer.parseInt(reader.readLine());
			weights[i] = weight;
			capacity += weight;
		}

		capacity /= k;
		
		while (true) {			
			boolean canAllocate = checkAllocation(weights, k, capacity);
			if (canAllocate) {
				break;
			}
			capacity++;			
		}		
		System.out.println(capacity);		
	}

	private static boolean checkAllocation(int[] weights, int k, int capacity) {
		
		int num = 1;
		int current = 0;
		
		for (int i = 0; i < weights.length; i++) {
			int weight = weights[i];
			if (current + weight > capacity) {
				current = weight;
				num++;
				if (num > k || current > capacity) {
					return false;
				}
			} else {
				current += weight;
			}
		}		
		return true;
	}
}


Measured memory_bytes: 34828
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List                   hiding (insert)
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce


main :: IO ()
main = do
    [n, a, b] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getContents
    print $ solve a b $ U.toList xs

solve a b xs = lowerBound 0 1000000000 predicate
  where
      !d = a - b
      predicate i = go i xs
        where
          go !rest (x:xs)
            | rest < 0 = False
            | otherwise = go (rest - y) xs
            where
              y = (d - 1 + max 0 (x - i * b)) `quot` d
          go rest [] = rest >= 0

-------------------------------------------------------------------------------

lowerBound :: (Integral i) => i -> i -> (i -> Bool) -> i
lowerBound low high p = go low high
  where
    go !low !high
        | high <= low = high
        | p mid       = go low       mid
        | otherwise   = go (mid + 1) high
      where
        mid = (low + high) `quot` 2

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

int main () {
  
  int maxr = 0;
  
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s.at(i);
  
  int M;
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) cin >> t.at(i);
  
  for (int i = 0; i < N; i++) {
    int r = 0;
    for (int j = 0; j < N; j++) {
      if (s.at(i) == s.at(j)) r++;
    }
    for (int k = 0; k < M; k++) {
      if (s.at(i) == t.at(k)) r--;
    }
    if (maxr < r) maxr = r;
  }
  cout << maxr << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

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

//10^9 + 7
const ll MOD = 1000000007;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;

	cout << (N / (A + B)) * A + min(N % (A + B), A)<< endl;
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    double sum = 0;
    vector<double> ep(10001);
    for (double i = 1; i <= 10000; i++) {
        ep[i] = (sum + i) / i;
        sum += i;
    }

    int n, k;
    cin >> n >> k;
    int x;
    vector<int> arr;
    for (int i = 0; i < n; i++) {
        cin >> x;
        arr.push_back(x);
    }

    double res = 0, best;
    for (int i = 0; i < k; i++) {
        res += ep[arr[i]];
    }
    best = res;
    for (int i = k; i < n; i++) {
        res = res - ep[arr[i - k]] + ep[arr[i]];
        best = max(res, best);
    }
    pout << best << endl;


    cerr << "TIME => " << now() - start << endl;
    return 0;
}

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

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	long long k;
	cin >> k;
	
	for(int i=1;i<=k;i++)
	{
		if(s[i-1]!='1')
		{
			cout << s[i-1] << endl;
			return 0;
		}
	}
	cout << '1' << endl;
}
	

Measured memory_bytes: 256
use std::fs::File;
use std::io::{stdout, BufWriter, Read, Write};
use std::thread;

fn run() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let input = read_input();
    let mut input = input.split_whitespace();

    let n: i64 = input.next().unwrap().parse().unwrap();
    let k: i64 = input.next().unwrap().parse().unwrap();
    writeln!(out, "{}", n - k + 1);
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}


Measured memory_bytes: 8572
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
long long calc[2][90][90];
bool dp[80][80][30000];
int main(){
	iostream::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	REP(t, 2) {
		REP(i, h) {
			REP(q, w) {
				cin >> calc[t][i][q];
			}
		}
	}
	dp[0][0][16000 + calc[0][0][0] - calc[1][0][0]] = 1;
	dp[0][0][16000 + calc[1][0][0] - calc[0][0][0]] = 1;
	REP(i, h) {
		REP(q, w) {
			REP(j, 30000) {
				if (dp[i][q][j] == 0) continue;
				REP(t, 2) {
					if (q != w - 1) {
						dp[i][q + 1][j + calc[t][i][q + 1] - calc[(t+1)%2][i][q+1]] = 1;
					}
					if (i != h - 1) {
						dp[i + 1][q][j + calc[t][i + 1][q] - calc[(t+1)%2][i+1][q]] = 1;
					}
				}
			}
		}
	}
	long long ans = 100000;
	REP(i, 30000) {
		if (dp[h - 1][w - 1][i] == 1) {
			ans = min(ans, llabs(i - 16000));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 186368
fun main(args: Array<String>) {
    var x = readLine()!!
    var xl = mutableListOf<String>()
    var e = x.count()
    for (i in 0 until e){
        xl.add(x)
        x = x.substring(1, e) + x[0]
    }
    var y = readLine()!!
    var a = if(xl.contains(y)) "Yes" else "No"
    println(a)
}


Measured memory_bytes: 33764
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+7;

const int mod = 1e9+7;

long long inv[N];
long long fac[N];
long long finv[N];

void cominit(){
    fac[0] = fac[1] =1;
    finv[0] = finv[1] =1;
    inv[1] = 1;
    for(int i = 2; i < N; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i]= mod - inv[mod%i] * (mod / i) %mod;
        finv[i]= finv[i-1] * inv[i] % mod;
    }
}

long long nCr(long long n , long long r){
    if(n < r)
        return 0;
    if(n < 0 || r < 0)
        return 0;
    return fac[n] * (finv[r] * finv[n-r] % mod) %mod;
}

int n;
int k;
int ar[N];

void add_self(int & sum , long long add){
    sum += add;
    sum %= mod;
}

int main(){
    cominit();
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &ar[i]);
    }
    int ans = 0;
    sort(ar + 1 , ar + n + 1);
    //select the minimum number
    for(int i = 1; i <= n; i++){
        if(n - i < k - 1)
            break;
        long long nve = ((1ll * -ar[i] * nCr(n - i , k - 1) % mod) + mod) % mod;
        add_self(ans , nve);
    }
    //select the maximum number
    for(int i = n; i >= 1; i--){
        int r = n - i + 1;
        if(n - r < k - 1)
            break;
        long long pos = ((1ll * ar[i] * nCr(n - r , k - 1) % mod) + mod) % mod;
        add_self(ans , pos);
    }
    printf("%d\n" , ans);
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int K;
    int t[3333] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    Scd(K);
    printf ("%d\n", t[K-1] );
    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<cstdlib>
#include<algorithm>
using namespace std;
 
pair<int, int> dx[900000];
int sum[100000];
 
int transport(int a, int b){
    return abs(dx[b].second - dx[a].second) + abs(dx[b].first - dx[a].first);
}
 
int main(){
    int h, w, d;
    int a[301][301];
    int q, l, r;
    int magic;
    //int l[100000], r[100000];
    scanf("%d%d%d", &h, &w, &d);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            scanf("%d", &a[i][j]);
            dx[a[i][j]].first = i;
            dx[a[i][j]].second = j;
        }
    }
    for(int i = d+1; i <= w*h; i++)
        sum[i] = sum[i-d] + transport(i-d, i);
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%d%d", &l, &r);
        /*magic = 0;
        while(l != r){
            magic += transport(l, l+d);
            l += d;
        }
        printf("%d\n", magic);
        */
        printf("%d\n", sum[r] - sum[l]);
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,ans=0,count[111111]={0};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    count[a]++; count[a+1]++; count[a+2]++;
  }
  for(int i=0;i<=100001;i++) ans=max(ans,count[i]);
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

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

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main() {

	int a, b, k,y[100],yay = 0;
	cin >> a >> b >> k;
	for (int i = 1; i <= 100; i++) {
		if (a % i == 0 && b % i == 0) {
			y[yay] = i;
			yay++;
		}
		
	}

	cout << y[yay - k] << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        if(a%2==1&&b%2==1){
            System.out.println("Odd");
        }else{
            System.out.println("Even");
        }


    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <cmath>



int main(){

    //文字列の種類を数え上げ
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i < n;i++) cin >> s[i];
    map<string,int> mp;
    int cnt = 0;
    for(int i =0;i < n;i++){
        mp[s[i]] = 1;
    }

    for(auto m:mp){
        cnt += m.second;
    }

    cout << cnt << endl;



    return 0;
}

Measured memory_bytes: 25176
void main()
{
    int n = readln.chomp.to!int;
    dchar[] a = readln.chomp.to!(dchar[]);
    dchar[] b = readln.chomp.to!(dchar[]);
    dchar[] c = readln.chomp.to!(dchar[]);

    int cnt;
    foreach (i; 0 .. n)
    {
        cnt += [a[i], b[i], c[i]].sort!"a < b".uniq.array.length - 1;
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

const LL INF = (LL)1e9 + 7;
int main(){
	while (1){
		int N, M;
		cin >> N >> M;
		if (N + M == 0)return 0;
		VVLL umi(N + 1, VLL(N + 1, INF)), riku(N + 1, VLL(N + 1, INF));
		for (int i = 1; i < N+1; i++){
			umi[i][i] = riku[i][i] = 0;
		}
		for (int i = 0; i < M; i++){
			LL x, y, t; char c;
			cin >> x >> y >> t >> c;
			if (c == 'L')riku[x][y] = riku[y][x] = min(riku[x][y], t);
			else umi[x][y] = umi[y][x] = min(umi[x][y], t);
		}
		for (int k = 1; k < N + 1; k++)for (int i = 1; i < N + 1; i++)for (int j = 1; j < N + 1; j++){
			riku[i][j] = min(riku[i][j], riku[i][k] + riku[k][j]);
			umi[i][j] = min(umi[i][j], umi[i][k] + umi[k][j]);
		}
		int R;
		cin >> R;
		VLL pos(R + 1);
		for (int i = 1; i < R+1; i++){
			cin >> pos[i];
		}
		VVLL dp(R + 1, VLL(N + 1, INF));
		dp[1][pos[1]] = 0;
		for (int i = 2; i < R+1; i++){
			for (int x = 1; x < N+1; x++){
				dp[i][x] = dp[i - 1][x] + riku[pos[i - 1]][pos[i]];
				for (int y = 1; y < N+1; y++){
					dp[i][x] = min(dp[i][x],dp[i-1][y] + riku[pos[i-1]][y] + umi[y][x] + riku[x][pos[i]]);
				}
			}
		}
		LL res = INF;
		for (int i = 1; i < N + 1; i++)
			res = min(dp[R][i], res);
		cout << res << endl;
	}
	return 0;

}

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

typedef long long ll;

int main() {
    bitset<64> bs(0);
    
    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int query; cin >> query;
        
        if(query==0){
            int i; cin >> i;
            cout << bs.test(i) << endl;
        }
        else if(query==1){
            int i; cin >> i;
            bs.set(i);
        }
        else if(query==2){
            int i; cin >> i;
            bs.reset(i);
        }
        else if(query==3){
            int i; cin >> i;
            bs.flip(i);
        }
        else if(query==4){
            cout << bs.all() << endl;
        }
        else if(query==5){
            cout << bs.any() << endl;
        }
        else if(query==6){
            cout << bs.none() << endl;
        }
        else if(query==7){
            cout << bs.count() << endl;
        }
        else if(query==8){
            cout << bs.to_ullong() << endl;
        }
    }

}



Measured memory_bytes: 3076
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := range A {
		fmt.Scan(&A[i])
	}
	a := maxi(A)
	c := A[a]
	A[a] = 0
	b := maxi(A)
	A[a] = c

	for i := 0; i < N; i++ {
		if i == a {
			fmt.Println(A[b])
		} else {
			fmt.Println(A[a])
		}
	}
}

func maxi(a []int) int {
	var i int
	max := 0
	for i = 1; i < len(a); i++ {
		if a[max] < a[i] {
			max = i
		}
	}
	return max
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int maxb = 35;
const ll inf = 1e9 + 10;
struct Node
{
	ll k, c;
}a[maxn];
int n, T, ans;
ll dp[maxb];
vector<Node> lin, ex;
bool cmplin(const Node & i, const Node & j) { return i.c < j.c;}
bool cmpex(const Node & i, const Node & j) { return j.k * i.c + j.c < i.k * j.c + i.c;}
int main()
{
	scanf("%d%d", &n, &T);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%lld%lld", &a[i].k, &a[i].c);
		++a[i].k;
		a[i].c += a[i].k;
		if(a[i].k == 1) lin.push_back(a[i]);
		else ex.push_back(a[i]);
	}
	sort(ex.begin(), ex.end(), cmpex);
	sort(lin.begin(), lin.end(), cmplin);
	for(int j = 1; j < maxb; ++j) dp[j] = inf;
	for(auto v : ex)
		for(int j = maxb - 1; j; --j)
			dp[j] = min(dp[j], v.k * dp[j - 1] + v.c);
	for(int i = 1; i < lin.size(); ++i) lin[i].c += lin[i - 1].c;
	for(int j = 0; j < maxb; ++j)
		if(dp[j] <= T)
		{
			int cur = upper_bound(lin.begin(), lin.end(), Node{1, T - dp[j]}, cmplin) - lin.begin();
			ans = max(ans, j + cur);
		}
	printf("%d\n", ans);
	return 0;
}
			 

Measured memory_bytes: 8304
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true){
            String x = input.next();
            if (x.equals("0")){
                break;
            }
            int result = 0;
            for (int i = 0; i < x.length(); i++){
                char c = x.charAt(i);
                result += (int)c-48;
            }
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 26040
L = int(input())
B = bin(L)
N = len(B)-2
Lines = []
for i in range(1,N):
    Lines.append((i,i+1,0))
    Lines.append((i,i+1,2**(i-1)))

for i in range(N-1):
    if B[N+1-i] == '1':
        Lines.append((i+1,N,L-2**i))
        L -= 2**i

print(N,len(Lines))
for Line in Lines:
    print("{} {} {}".format(Line[0],Line[1],Line[2]))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <queue> //C++
using namespace std; //C++



int main(void) {
	
	int x, n, i,j;
	int count = 0;
	int p[101];
	cin >> x >> n;
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (i = 0; i < n; i++) {
		if (p[i] == x) {
			count++;
			break;
		}
	}
	if (count == 0) {
		cout << x;
		return 0;
	}
	
	int mai=x, pul=x;

	for (;;) {
		count = 0;
		mai--;
		pul++;
		for (i = 0; i < n; i++) {
			if (p[i] == mai) {
				count++;
				break;
			}
		}
		if (count == 0) {
			cout << mai;
			return 0;
		}
		count = 0;
		for (i = 0; i < n; i++) {
			if (p[i] == pul) {
				count++;
				break;
			}
		}
		if (count == 0) {
			cout << pul;
			return 0;
		}
	}



}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

vector<bool> IsPrime;
vector<int> primes;

void sieve(int max) {
    IsPrime.resize(max + 1, true);
    IsPrime[0] = IsPrime[1] = false;
    for (int i = 2; i * i <= max; ++i){
        if (IsPrime[i]){
            for (int j = i * i; j <= max; j += i) IsPrime[j] = false;
        }
    }
    for(int i = 0; i <= max; ++i)if(IsPrime[i])primes.push_back(i);
}

int main() {
    sieve(1e5);
    int q, cum[MAX_N]{};
    for(auto p : primes){
        if(IsPrime[(p+1)/2]) cum[p]++;
    }
    REP(i,1e5){
        cum[i+1] += cum[i];
    }
    cin >> q;
    REP(i,q){
        int l ,r;
        cin >> l >> r;
        cout << cum[r] - cum[l-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

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

    vector<P> ans;
    if (N % 2 == 0) {
        int sum = 1 + N;
        for (int i = 1; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (i + j == sum) continue;
                ans.emplace_back(P(i, j));
            }
        }
    } else {
        int sum = N;
        for (int i = 1; i <= N - 1; i++) {
            for (int j = i + 1; j <= N - 1; j++) {
                if (i + j == sum) continue;
                ans.emplace_back(P(i, j));
            }
        }

        for (int i = 1; i <= N - 1; i++) ans.emplace_back(i, N);
    }

    cout << ans.size() << endl;
    for (P a : ans) cout << a.first << " " << a.second << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n; cin >> n;
    ll ans = 0;
    for(int i = 1; i <= sqrt(n); i++){
        if(n % i == 0){
            if(n/i-1 > i) ans += n/i - 1;
            if(i-1 > n/i) ans += i-1;
        }
    }
    cout << ans << endl;
}

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

ll solve(ll n)
{
    ll ans = 1;
    if(n == 1) return 1;
    ans += solve(n/2)*2;
    return ans ;
}

int main()
{
    ll h;
    cin >> h;
    cout << solve(h) << endl;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()
    K = I()

    l = [[] for _ in range(26)]
    for i in range(len(s)):
        l[ord(s[i])-ord('a')].append(i)

    for i in l:
        tmp = set()
        for j in i:
            for k in range(5):
                if j + k <= len(s) - 1:
                    tmp.add(s[j:j+k+1])
        tmp = list(tmp)
        tmp.sort()
        if len(tmp) >= K:
            print(tmp[K-1])
            break
        else:
            K -= len(tmp)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10140
from operator import mul
from functools import reduce

def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 3 * 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
    
    
r1, c1, r2, c2 = [int(i) for i in input().split()]
 
def calc(r, c):
    a = comb(r + c + 2, r + 1, mod) - r - c - 2
    b = r * (r + 3) / 2
 
    if c == 1:
        return b
    else:
        return a
 
result = calc(r2, c2) - calc(r2, c1 - 1) - calc(r1 - 1, c2) + calc(r1 - 1, c1 - 1)
result %= mod
if result < 0:
  result += mod
print(result)

Measured memory_bytes: 171956
n, k = map(int, input().split())
a = [0]+list(map(int, input().split()))+[0]

for loop in range(k):
    s = [0 for _ in range(n+2)]
    for i in range(1, n+1):
        s[max(0, i-a[i])] += 1
        s[min(n+1, i+1+a[i])] -= 1
    a[0]=0
    for i in range(1, n+1):
        s[i] += s[i-1]
    s[0] = 0
    s[-1] = 0
    a = s
    if sum(a) == n**2:
        break

print(*a[1:n+1])

Measured memory_bytes: 170496
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    i, o, t, j, l, s, z = map(int, input().split())
    ans = o
    ans += (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
    #ans += 3*min(i % 2, min(j % 2, l % 2))

      

    ans2 = o
    mi = min(i, min(l, j))
    if mi > 0:
        mi = 1
    else:
        print(ans)
        exit()
    ans2 += mi * 3
    ans2 += ((i - mi) // 2) * 2 + ((j - mi) // 2) * 2 + ((l - mi) // 2) * 2

    ans = max(ans, ans2)

    print(ans)



    


    


if __name__ == '__main__':
    main()


Measured memory_bytes: 64204
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);

    cout << a[2] * 10 + a[1] + a[0] << endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
alf = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']*2
ans = []

for i in range(len(S)):
    num = alf.index(S[i])
    ans.append(alf[num + N])


print(''.join(ans))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
const double eps = 1e-6;

double a[N];

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	
	a[0] = 0.0;
	double p;
	for(int i = 1;i <= n;++i){
		scanf("%lf",&p);
		a[i] = a[i-1]+p;
	}
	
	for(int i = 2;i+k-1 <= n;++i){
		int pos = i+k-1;
		double l = a[pos-1] - a[i-2];
		double r = a[pos] - a[i-1];
		
		if(r-l > eps) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 5280
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int sum1 = 0, sum2 = 0, sum3 = 0;

    sum1 = A * X + B * Y;

    int c = min(X, Y);
    sum2 += 2 * c * C;
    int diff = X - Y;
    if (diff > 0) {
        sum2 += diff * A;
    } else {
        sum2 -= diff * B;
    }

    sum3 = 2 * C * max(X, Y);

    int ans = min(sum1, min(sum2, sum3));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
a = [input() for _ in range(H)]

ans = []
tate = []
yoko = []

for i in range(H):
	if a[i].count("#") >= 1:
		yoko.append(i)

for i in range(W):
	for j in range(H):
		if a[j][i] == "#":
			tate.append(i)
			break

for y in yoko:
	tmp = ""
	for t in tate:
		tmp += a[y][t]
	ans.append(tmp)

print(*ans, sep="\n")


Measured memory_bytes: 5396
from sys import exit
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()

three = ['357', '375', '537', '573', '735', '753']
cand = ['3' , '5' , '7']
ans = 0
s = set()
def rladd(cur):
    global ans,N,s
    if(int(cur) > N) or cur in s: return False
    s.add(cur)
    ans+=1
    for i in range(len(cur)):
        for c in cand:
            temp = list(cur)
            temp.insert(i,c)
            rladd("".join(temp))
for th in three:
    rladd(th)

print(ans)


Measured memory_bytes: 6968
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	int ans = 0;
	int can;
	char[] s;

	void dfs(int even, int odd, int sum) {
		if (even == 0 && odd == 0) {
			if (sum % 10 == 0) {
				ans++;
			}
			return;
		}

		if (even > 0) {
			for (int i = 0; i <= 9; i++) {
				if ((can >> i & 1) == 1) {
					dfs(even - 1, odd, sum + i);
				}
			}
		} else {
			for (int i = 0; i <= 9; i++) {
				if ((can >> i & 1) == 1) {
					int a = i * 2;
					if (a >= 10) a = 1 + a - 10;
					dfs(even, odd - 1, sum + a);
				}
			}
		}
	}
	void solve() {
		int n = sc.nextInt();
		s = new char[n];
		String str = sc.next();
		for (int i = 0; i < n; i++) {
			s[n - 1 - i] = str.charAt(i);
		}
		int m = sc.nextInt();
		can = 0;
		for (int i = 0; i < m; i++) {
			int x = sc.nextInt();
			can |= (1 << x);
		}
		int sum = 0;
		int even = 0, odd = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] != '*') {
				int a = s[i] - '0';
				if (i % 2 == 1) a <<= 1;
				if (a >= 10) a = 1 + a - 10;
				sum += a;
			} else {
				if (i % 2 == 0) even++; else odd++;
			}
		}
		ans = 0;
		dfs(even, odd, sum % 10);
		out.println(ans);
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

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

int main()
{
	int a[4];

	cin >> a[0] >> a[1] >> a[2] >> a[3];

	sort(a, a + 4);

	if (a[0] == a[1] && a[2] == a[3])
		cout << "yes" << endl;
	else
		cout << "no" << endl;

	return 0;
}



Measured memory_bytes: 3160
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while(n) n /= k, ans++;
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
# D
from math import isinf
N,M = map(int, input().split())
e = []
for _ in range(M):
    a,b,c = map(int, input().split())
    e.append((a-1,b-1,-c))

dists = [float('inf')] * N # 到達不能はinf
def bellman_ford(edges:list, start:int)->bool:
    """O(|V|*|E|)
    param v:
    param edges:
    return (exist negative loop)
    """
    global dists
    dists[start] = 0
    V = len(dists)
    for i in range(V):
        for (s,t,w) in edges:
            if isinf(dists[s]): continue
            if dists[t] > dists[s]+w:
                dists[t] = dists[s]+w
                if i==V-1 and t==V-1:
                    return True
        #print(dists)
    return False

negativeLoop = bellman_ford(e, 0)
if negativeLoop:
    print('inf')
else:
    print(-dists[-1])

Measured memory_bytes: 3312
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define ll long long int
#define rep(i,a,b) for(int i=ll(a);i<ll(b);i++)
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};
int main() {
	int n;
	cin>>n;
	double ans=0;
	for(int i=0;i<n;i++){
		double a;
		string s;
		cin>>a>>s;
		if(s=="JPY")ans+=a;
		else ans+=a*380000.0000;
	}
  cout<<ans;
	return 0;
}



Measured memory_bytes: 256