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

public class Main {

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

        int n = sc.nextInt();
        String s = sc.next();
        String[] numbers = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};

        int count = 0;
        for (int i=0; i<10; i++) {
            if (!s.contains(numbers[i])) continue;
            int index1 = s.indexOf(numbers[i]);
            for (int j=0; j<10; j++) {
                String s2 = s.substring(index1+1, n);
                if (!s2.contains(numbers[j])) continue;
                int index2 = s2.indexOf(numbers[j]);
                int l2 = s2.length();
                for (int k=0; k<10; k++) {
                    String s3 = s2.substring(index2+1, l2);
                    if (!s3.contains(numbers[k])) continue;
                    count ++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 59220
import itertools

H,W,K = map(int,input().split())
field = [list(input()) for i in range(H)]

if K == H*W:
    print(1)
    exit()

b = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == "#":
            b += 1

r = [i for i in range(H)]
c = [i for i in range(W)]

r_comb = []
for h in range(H):
    for v in itertools.combinations(r,h):
        r_comb.append(v)
c_comb = []
for w in range(W):
    for v in itertools.combinations(c,w):
        c_comb.append(v)      

ans = 0
for R in r_comb:
    for C in c_comb:
        tmp = b

        #選んだ行に対する処理
        for h in range(H):
            if h in R:
                tmp -= field[h].count("#")

        #選んだ列に対する処理
        for h in range(H):
            if h not in R:
                for w in range(W):
                    if w in C and field[h][w] == "#":
                        tmp -= 1
    
        if tmp == K:
            ans += 1

print(ans)





Measured memory_bytes: 9268
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	UL dp[1001][10001];

	void Solve() {
		UL H; cin >> H;
		UL N; cin >> N;
		pair<UL, UL> AB[1000]; rep(i, N) cin >> AB[i].first >> AB[i].second;
		rep(i, N + 1)rep(j, H + 1) dp[i][j] = 1000000000;
		dp[0][H] = 0;
		for (UL i = 0; i < N; i++) {
			for (UL j = 0; j <= H; j++) {
				UL jx = H - j;
				UL buf = min(dp[i + 1][jx], dp[i][jx]);
				if(jx + AB[i].first <= H) buf = min(buf, dp[i + 1][jx + AB[i].first] + AB[i].second);
				else buf = min(buf, dp[i + 1][H] + AB[i].second);
				dp[i + 1][jx] = buf;
			}
			for (UL j = 0; j < H; j++) {
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i + 1][j]);
			}
		}
		cout << dp[N][0] << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 39424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//main definations
#define endl "\n"
#define UI unsigned int
#define LLI long long int
#define ULLI unsigned long long int
#define PI 3.14159258

//codechef only
#define TC for(UI defined_i=1;defined_i<=t;defined_i++)
//int b_s(int arr[], int n, int find);
using namespace std;
int main(){
	LLI a[4], quan[4]={1,2,4,8},score[4];
	LLI tp=0;
	for(int i=0;i<4;i++){
		cin>>a[i];
	}
	LLI n;
	cin>>n;
	n=n*4;
	score[0]=a[0]*8;
	score[1]=a[1]*4;
	score[2]=a[2]*2;
	score[3]=a[3]*1;
	
	LLI small;
	LLI x;
	LLI temp;
	for(int i=0;i<4 && n>0;i++){
		small=score[0];
		for(int j=0;j<4;j++){
			if(score[j]<=small){
				small=score[j];
				x=j;
			}
		}
		
		temp=n/quan[x];
		n=n-(temp*quan[x]);
		tp=tp+(a[x]*temp);
		score[x]=2147483647;
	}
	cout<<tp<<endl;
	
	return 0;
}
/*
int b_s(int arr[], int n, int find){
	int start=0, end=n-1, mid=(start+end)/2;
	while(start<=end){
		if(arr[mid]==find){
			return mid;
		}
		else if(arr[mid]<find){
			start=mid+1;
			mid=(start+end)/2;
		}
		else{
			end=mid-1;
			mid=(start+end)/2;
		}
	}
	return -1;
}*/

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define MAX_C 1000000001

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

  printf("%lf", 2 * 3.141592653589 * r);
}


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

const int MOD = 1e9 + 7 ;

map<int,int> PF( int n ){
    map<int,int> ret ;
    for(int i = 2 ; i*i <= n ; i++ ){
        if(n%i) continue ;
        while(n%i==0) {
            ret[i]++ ;
            n /= i ; 
        }
    }
    if( n != 1 ) ret[n] = 1 ;
    return ret ;
}

int main(){
    int n ;
    cin >> n ;
    map<int,int> mp ;
    for(int i = 1 ; i <= n ; i++ ){
        map<int,int> count = PF(i) ;
        for(auto p : count){
            int a = p.first  ;
            int b = p.second ;
            mp[a] += b ; 
        }
    }
    ll ans = 1 ;
    for(auto p : mp ){
            int a = p.first  ;
            int b = p.second ;
            ans *= mp[a] + 1 ;
            ans %= MOD ; 
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 256
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

A,B,C = map(int,input().split())
cap = A-B
if cap > C:
    print(0)
else:
    print(C-cap)


Measured memory_bytes: 4328
import java.io.*;
public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader mBufferedReader=new BufferedReader(new InputStreamReader(System.in));
   try{
     String str=mBufferedReader.readLine();
     String[] arr=str.split(" ");
     int a=Integer.parseInt(arr[0]);
     int b=Integer.parseInt(arr[1]);
     int c=Integer.parseInt(arr[2]);
     int x;
     if(a>b){
       x=b;
       b=a;
       a=x;
     }if(b>c){
       x=c;
       c=b;
       b=x;
     }if(a>b){
       x=b;
       b=a;
       a=x;
     }
       System.out.println(a+" "+b+" "+c);
    }catch(IOException e){
      System.out.println("Error");
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n;
    cin >> n;
    vi v(n);
    for(auto &z : v)cin >> z;

    ll resenje = (ll)n * (n-1LL) * (n-2LL) / 6LL;

    sort(all(v));

    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; ++j)
        {
            auto it = lower_bound(all(v), v[i]+v[j]);
            resenje -= n - (it-v.begin());
        }
    }

    cout << resenje << '\n';

    return 0;
}


Measured memory_bytes: 256
N = int(input())

oa = list(map(int,input().split()))

maxi = max(oa)

keta = 1

while 2 ** keta < maxi:

    keta += 1


a = []
dic = {}

for i in oa:

    new = format(i,"b")
    new = new.zfill(keta)
    a.append(new)

    if new not in dic:
        dic[new] = 1
    else:
        dic[new] += 1

if len(dic) > 3:
    print ("No")

elif len(dic) == 1:

    flag = True

    for i in dic:

        if "1" in i:
            flag = False

    if flag:
        print ("Yes")
    else:
        print ("No")

elif len(dic) == 2:

    flag1 = -1
    flag2 = -1
    cnt = 0

    for i in dic:
        
        if cnt == 0:

            if "0" in i and "1" not in i:
                flag1 = 0
                
            key1 = i
            cnt += 1

        if cnt == 1:

            if "0" in i and "1" not in i:
                flag2 = 0

            key2 = i

    if flag1 != 0 and flag2 != 0:
        print ("No")
    elif flag1 == 0 and dic[key1] == dic[key2] * 2:
        print ("Yes")
    elif flag2 == 0 and dic[key2] == dic[key1] * 2:
        print ("Yes")
    else:
        print ("No")

elif len(dic) == 3:

    key = []
    for i in dic:
        key.append(i)

    if dic[key[0]] == dic[key[1]] and dic[key[1]] == dic[key[2]]:

        Flag = True


        for i in range(len(key[0])):

            ndic = {}
            ndic["0"] = 0
            ndic["1"] = 0

            for j in range(3):
                
                if key[j][i] == "0":
                    ndic["0"] += 1
                else:
                    ndic["1"] += 1

            if ndic["1"] == 1 or ndic["1"] == 3:
                Flag = False
                break

        if Flag:
            print ("Yes")
        else:
            print ("No")
                

    else:
        print ("No")
    #print (a)


Measured memory_bytes: 16296
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break
    h = "#" * W
    a = "#"+"."*(W-2) + "#"
    print(h)
    for i in range(H-2):
      print(a)    
    print(h)
    print()

Measured memory_bytes: 7676
#include <cstdio>
#define Min(_A, _B) (_A < _B ? _A : _B)
int n, A[100010], B[100010], rA, rB;
int Point[200010], Next[800010], To[800010], q = 1, deg[200010], dir[400010], X[100010];
void Add(int u, int v)
{
	Next[++q] = Point[u]; Point[u] = q; To[q] = v;
	Next[++q] = Point[v]; Point[v] = q; To[q] = u;
	++deg[u]; ++deg[v];
}
void dfs(int u)
{
	for(int &j = Point[u]; j;) 
	{
		int v = To[j];
		if(!dir[j >> 1])
		{
			dir[j >> 1] = j & 1 ? -1 : 1;
			j = Next[j];
			dfs(v);
		}
		else j = Next[j];
	}
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &A[i]);
	for(int i = 1; i <= n; ++i) scanf("%d", &B[i]);
	for(int i = 1; i <= n; ++i) if(~A[i]) Add(A[i], i); else rA = i;
	for(int i = 1; i <= n; ++i) if(~B[i]) Add(B[i] + n, i + n); else rB = i;
	Add(rA, rB + n); int tmp = q >> 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 1, lim = Min(deg[i], deg[i + n]); j <= lim; ++j)
			Add(i, i + n);
	for(int i = 1; i <= n; ++i) if(deg[i] & 1){ puts("IMPOSSIBLE"); return 0; } 
	for(int i = 1; i <= n; ++i) if(deg[i + n] & 1){ puts("IMPOSSIBLE"); return 0; }
	dfs(rA);
	for(int i = 1; i < n; ++i){ X[To[i << 1]] += dir[i]; X[To[i << 1 | 1]] -= dir[i]; }
	X[To[tmp << 1 | 1]] -= dir[tmp];
	puts("POSSIBLE");
	for(int i = 1; i <= n; ++i) printf("%d ", X[i]); puts("");
	return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int k;
  cin >> k;
  int ans = -1;
  int acc = 0;
  for (int i = 1; i <= k; i++) {
    acc = (10 * acc + 7);
    acc %= k;
    if (acc == 0) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


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

int main()
{
    string a;
    cin >> a;

    int m = a.size();
    for (int i = 0; i < m; i ++ )
    {
        for (int j = i+1; j < m; j ++ )
        {
            if(a[i] == a[j])
            {
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;

    return 0;
}


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

int main() {
  int m, f, r;

  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    } 
    if (m == -1 || f == -1) {
      cout << "F" << endl;
    }
    else if (m + f >= 80) {
      cout << "A" << endl;
    }
    else if (m + f >= 65) {
      cout << "B" << endl;
    }
    else if (m + f >= 50) {
      cout << "C" << endl;
    }
    else if (m + f >= 30) {
      if (r >= 50) {
        cout << "C" << endl;
      }
      else {
        cout << "D" << endl;
      }
    }
    else{
      cout << "F" << endl;
    }
  }
}


Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c;
  cin >> a;
  
  if(a==7||a==5||a==3){
    cout << "YES" <<endl;
  }else{
	cout << "NO" <<endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	ans := 1
	for i := 0; i < n; i++ {
		if ans < k {
			ans *= 2
		} else { // ans >= k
			ans += k
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){
int H,W ;


while(1){

cin >> H >> W;
if(H == 0 && W == 0){
    break;
}
for(int j = 0; j< H; j++){
for(int i = 0; i< W; i++){
cout << '#';
}
cout << endl;
}
cout << endl;

}
return 0;
}


Measured memory_bytes: 3080
N,T=map(int,input().split())
c=[]
mn=1001
for i in range(N):
    cost,time=map(int,input().split())
    if time<=T:
        c.append(cost)
for i in c:
    if i<=mn:
        mn=i
if len(c)==0:
    print('TLE')
else:
    print(mn)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S[3];
	cin >> S[0] >> S[1] >> S[2];
	cout << S[0][0] << S[1][0] << S[2][0] << endl;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

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

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

//↑template↑





int main() {
	int a, b;
	cin >> a >> b;
	if (a == 0) {
		if (1868 <= b && b <= 1911) { cout << "M" << b - 1868 + 1 << endl; }
		else if (1912 <= b && b <= 1925) { cout << "T" << b - 1912 + 1 << endl; }
		else if (1926 <= b && b <= 1988) { cout << "S" << b - 1926 + 1 << endl; }
		else { cout << "H" << b - 1989 + 1 << endl; }
	}
	else {
		switch (a) {
		case 1:
			cout << 1868 + b - 1 << endl;
			break;
		case 2:
			cout << 1912 + b - 1 << endl;
			break;
		case 3:
			cout << 1926 + b - 1 << endl;
			break;
		case 4:
			cout << 1989 + b - 1 << endl;
			break;
		}
	}
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
struct point {
  int i;
  double x;
  double y;
};
double argu(point a, point b) {
  return atan2(b.y - a.y, b.x - a.x);
}
signed main() {
  int n; cin >> n;
  point holes[n];
  for (int i = 0; i < n; i++) {
    holes[i].i = i;
    cin >> holes[i].x >> holes[i].y;
  }
  sort(holes, holes + n, [](point a, point b) { return a.x < b.x or a.x == b.x and a.y < b.y; });
  vector<int> v;
  int s = 0;
  v.push_back(holes[s].i);
  double theta = M_PI;
  while (true) {
    int i_m;
    double m = 100.0;
    for (int i = (s + 1) % n; i != s; i = (i + 1) % n) {
      double tmp = fmod(argu(holes[s], holes[i]) - theta + 4 * M_PI, 2 * M_PI);
      if (tmp < m) {
        i_m = i;
        m = tmp;
      }
    }
    if (s != 0 and abs(argu(holes[s], holes[i_m]) - argu(holes[s], holes[0])) < eps) {
      break;
    }
    theta = argu(holes[s], holes[i_m]);
    s = i_m;
    v.push_back(holes[s].i);
  }
  double res[n]; fill(res, res + n, 0.0);
  sort(holes, holes + n, [](point a, point b) { return a.i < b.i; });
  for (int i = 0; i < v.size(); i++) {
    res[v[i]] = fmod(argu(holes[v[i]], holes[v[(i + 1) % v.size()]]) - argu(holes[v[(i + v.size() - 1) % v.size()]], holes[v[i]]) + 8 * M_PI, 2 * M_PI) / (2 * M_PI);
  }
  for (int i = 0; i < n; i++) printf("%.20f\n", res[i]);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int d,t,s,sum;
    while(scanf("%d%d%d",&d,&t,&s)==3)
    {
        sum=t*s;
        if(d<=sum)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0; 
}


Measured memory_bytes: 1664
#include <stdio.h>
int main(void)
{
   int S,h,m,s;
   scanf("%d",&S);
   h=S/3600;
   m=(S%3600)/60;
   s=S-h*3600-m*60;
   printf("%d:%d:%d\n",h,m,s);
   return 0;
}

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

int main(void)
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;

    int sum = 0;
    while(k > 0 && a > 0){
        sum++;
        k--;
        a--;
    }
    while(k > 0 && b > 0){
        k--;
        b--;
    }
    while(k > 0 && c > 0){
        sum--;
        k--;
        c--;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int N;

int main() {
	cin >> N;
	vector<long long int> d(N);
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]
#print(S)
a_cnt = 0
b_cnt = 0
ab_cnt = 0
b_a_cnt = 0
for i,s in enumerate(S):
    ab_cnt += s.count("AB")
    if s[-1] == "A":
        a_cnt += 1
    if s[0] == "B":
        b_cnt += 1
    if s[0] == "B" and s[-1] == "A":
        b_a_cnt += 1
if a_cnt == b_cnt == b_a_cnt and b_a_cnt != 0:
    ab_cnt += min(a_cnt, b_cnt) - 1
else:
    ab_cnt += min(a_cnt, b_cnt)

print(ab_cnt)


Measured memory_bytes: 3700
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
signed main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[21][21]={},dp[1<<22]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      cin >> a[i][j];
    }
  }
  dp[0]=1;
  for(int i=0; i<(1<<n); i++) {
    int cnt=__builtin_popcount(i);
    for(int j=0; j<n; j++) {
      if((i&(1<<j))&&a[cnt-1][j]) {
        (dp[i]+=dp[i^(1<<j)])%=MOD;
      }
    }
  }
  cout << dp[(1<<n)-1] << endl;
}

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

const int N=2010;
int C[N][N],n;
const int mod=1000000007;

int main(){
	scanf("%d",&n);
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=C[i-1][j]+C[i-1][j-1],C[i][j]%=mod;
	}
	int ans=0;
	for(int i=1;i<=n/3;i++){
		ans+=C[n-i*3+i-1][i-1];
		ans%=mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 17516
from collections import Counter

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
ans = 0
pre = [0] * k
d = Counter(t)
for i in range(0, n+(k-1)//k, k):
    L = list(t[i:i+k])
    for j in range(len(L)):
        if pre[j] == L[j]:
            d[L[j]] -= 1
            L[j] = 'x'
    pre = L
ans = d['r'] * p + d['s'] * r + d['p'] * s
print(ans)


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int64_t n;
  cin >> n;
  priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pq;
  rep(i,5) {
    int64_t p;
    cin >> p;
    pq.push(p);
  }
  int64_t ans;
  if(n % pq.top() != 0)
     ans = n / pq.top() + 5;
  else
     ans = n / pq.top() + 4;
  cout << ans;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			int sum = 0;
			int cnt = 0;
			if(a % b == 0) {
				System.out.println(0);
				continue;
			}
			if(a > b) {
				a -= (a / b) * b;
			}
			while(cnt < n) {
				if(a % b == 0) {
					break;
				}else {
					cnt++;
					if(10 * a < b) {
						a *= 10;
					}else {
						sum += (10 * a) / b;
						a = (10 * a) % b;
					}
				}
			}
			System.out.println(sum);
		}
		sc.close();
	}
}


Measured memory_bytes: 26160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int main()
{
	ll n;cin>>n;ll i=0;
	for(i=1;i*i<=n;i++);
	while(n%i!=0) i--;
	if(i<10&&n/i<10) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

#define LIM 10000000001LL

using namespace std;

int n, pr[2005], p, ans;
LL s[100005], pal[100005];

map<LL, LL> M, M_pal;

bool isp(int x){
	FI(i, 1, p) if(x % pr[i] == 0) return false;
	return true;
}

int main(){
	FI(i, 2, 2200) if(isp(i)) pr[++p] = i;
	scanf("%d", &n);
	FI(i, 1, n){
		scanf("%lld", &s[i]);
		FI(j, 1, p){
			LL u = 1LL * pr[j] * pr[j] * pr[j];
			while(s[i] % u == 0) s[i] /= u;
		}
		//Now s[i] is p^3-free
		LL tmp = s[i];
		pal[i] = 1;
		FI(j, 1, p){
			if(tmp % pr[j] == 0){
				LL u = 1LL * pr[j] * pr[j] * pr[j];
				while(tmp % pr[j] == 0){
					tmp /= pr[j];
					u /= pr[j];
				}
				if(pal[i] <= LIM / u) pal[i] *= u;
				else pal[i] = LIM;
			}
		}
		if(tmp > 1){
			LL rt = sqrt(tmp);
			if(rt * rt == tmp && pal[i] <= LIM / rt) pal[i] *= rt;
			else if(pal[i] <= LIM / tmp / tmp) pal[i] *= tmp * tmp;
			else pal[i] = LIM;
		}
	}
	FI(i, 1, n){
		if(!M.count(s[i])) M[s[i]] = 1, M_pal[s[i]] = pal[i];
		else M[s[i]]++;
	}
	
	for(auto pi: M){
		LL u = pi.fi, cnt = pi.se;
		LL pa = M_pal[u];
		if(pa == u) ans++; //only if u == 1
		else if(!M.count(pa)) ans += cnt;
		else if(u > pa) ans += max(cnt, (LL)M[pa]);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cin.ignore();
    for(int i=0; i<n; i++){
        char a[128], b[128], c[128];
        int al, bl;
        cin.getline(a, 128);
        al=cin.gcount()-1;
        cin.getline(b, 128);
        bl=cin.gcount()-1;
        int j=al, k=bl, carry=0, l=0;
        while(true){
            j--, k--;
            if(j<0||k<0) break;
            c[l]=a[j]+b[k]+carry-'0';
            if(c[l]>'9'){
                c[l]-=10;
                carry=1;
            } else {
                carry=0;
            }
            ++l;
        }

        if(j<0){
            ++k;
            while(--k>=0){
                c[l]=b[k]+carry;
                if(c[l]>'9'){
                    c[l]-=10;
                    carry=1;
                } else {
                    carry=0;
                }
                ++l;
            }
        }else{
            ++j;
            while(--j>=0){
                c[l]=a[j]+carry;
                if(c[l]>'9'){
                    c[l]-=10;
                    carry=1;
                } else {
                    carry=0;
                }
                ++l;
            }
        }
        if(carry==1) c[l++]='1';
        if(l>80) cout<<"overflow\n";
        else{
            while(--l>=0) cout<<c[l];
            cout<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n;cin >> n;
  int ans = 0;
  int a[n];
  for(int i = 0;i<n;i++){
    cin >> a[i];
  }
  int i = 0;
  while(i<n){
    if(a[i]==i+1){
      ans += 1;i++;
    }
    i++;
  }
  cout << ans << endl;
}

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

int main(){
	int n;
	cin >> n;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(i*j == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
void solve()
{
   int n,k; cin>>n>>k;
   int h[n];
   rep(i,0,n) cin>>h[i];
   int dp[n+1];
   dp[0]=0;
   rep(i,1,n)
   {
     dp[i]=lul;
     rep(j,max(0,i-k),i) dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
   }
   cout<<dp[n-1];
}
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
S=input()
w,e='W','E'
if e not in S or w not in S:print(0);exit()
ecnt=len([1 for i in list(S) if i==e])
p0,p1=0,ecnt-int(S[0]==e)
ans=p0+p1
for i in range(1,n):
  p0,p1=(p0+int(S[i-1]==w),p1-int(S[i]==e))
  #(l and gyaku,r and gyaku)
  ans=min(ans,p0+p1)
print(ans)

Measured memory_bytes: 8088
X, N = map(int, input().split())
P = list(map(int, input().split()))

def Main(X, N, P):
    if N == 0:
        return X
    anss = []
    for i in range(102):
        if i in P:
            continue
        else:
            ab = 1000
            for e in P:
                ab = min(ab, abs(i-e))
            anss.append((i, ab))
    anss.sort(key = lambda x: x[1])
    ans = []
    mi = anss[0][1]
    for el in anss:
        if el[1] == mi:
            ell = (abs(X-el[0]), el[0])
            ans.append(ell)
        else:
            break
    ans.sort()
    return ans[0][1]
            
        
                    
out = Main(X, N, P)
print(out)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  string b;
  cin >> a >> b;
  int x = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != b[a.size()-i-1]) {
      x++;
      break;
    }
  }
  if (x == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int>adj[20002];
int vis[200003];
int dis[200003];
int cnt[200005];
ll n;
void bfs(ll s)
{
 memset(vis,0,sizeof(vis));
 memset(dis,0,sizeof(dis));

 queue<ll>q;

 q.push(s);
 vis[s]=1;
 dis[s]=0;

 while(!q.empty())
 {
  ll u=q.front();
  q.pop();
  for(int i=0; i<adj[u].size(); i++)
  {
    ll v=adj[u][i];

    if(vis[v]==0)
    {
      vis[v]=1;
      dis[v]=dis[u]+1;
      q.push(v);
    }
  }
 }

 for(int i=1; i<=n; i++)
 {
  cnt[dis[i]]++;
  //cout<<cnt[dis[i]]<<" k "<<dis[i]<<endl;
 }

}
void add(ll u , ll v)
{
  adj[u].push_back(v);
  adj[v].push_back(u);
}

int main()
{
  ll x, y, i, ans, c=0;

  cin>>n>>x>>y;

  for(i=1; i<n; i++)
  {
    add(i,i+1);
  }
  add(x,y);

  for(i=1; i<=n; i++)
  {
    bfs(i);
  }
  //cout<<c<<" ch"<<endl;
  for(i=1; i<n; i++)
  {
    cout<<cnt[i]/2<<endl;
  } 
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define int long long

string s;
int p;
bool is_first;

int dfs() {
  vector<int> v;
  while (p < s.size()) {
    if (s[p] == '[') {
      is_first = true;
      p++;
      int tmp = dfs();
      v.push_back(tmp);
    } else if (s[p] == ']') {
      p++;
      sort(v.begin(), v.end());
      int res = 0;
      if (is_first) {
        for (int i = 0; i < v.size() / 2 + 1; i++) {
          res += v[i] / 2 + 1;
        }
      } else {
        for (int i = 0; i < v.size() / 2 + 1; i++) {
          res += v[i];
        }
      }
      is_first = false;
      return res;
    } else {
      int figure = 0;
      while (s[p] != ']') {
        figure *= 10;
        figure += s[p] - '0';
        p++;
      }
      p++;
      return figure;
    }
  }
  return v[0];
}

signed main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    p = 0;
    cout << dfs() << endl;
  }
  return 0;
}



Measured memory_bytes: 3248
#include <stdio.h>

int main(){
  int a[3];
  int i,tmp_max=0;
  int i_max;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    if(tmp_max<a[i]){
      tmp_max=a[i];
      i_max=i;
    }
  }
  if(i_max==0)printf("%d\n",a[1]*a[2]/2);
  else if(i_max==1)printf("%d\n",a[0]*a[2]/2);
  else if(i_max==2)printf("%d\n",a[1]*a[0]/2);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int x;
  cin >> x;
  vector<int> primes(911111);
  for (int i = 2; i < 911111; ++i) primes[i] = i;
  for (int i = 2; i * i < 911111; ++i)
    if (primes[i])
      for (int j = i * i; j < 911111; j += i) primes[j] = 0;

  int ans = 0;
  for (int i = x; i < 911111; i++) {
    if (primes[i] != 0) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3840
// AOJ 2249: Road Construction
// 2017.11.15 bal4u@uu
// 2017.12.9

#include <stdio.h>
#include <string.h>

#define MAX 16010
typedef struct { int t, node, c; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].c < que[i].c)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].c < que[min].c)) min = r;
	if (min != i) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t, int c)
{
	int i, min;
	QUE qt;
	i = qsize++;
	que[i].node = n, que[i].t = t, que[i].c = c;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		   que[min].t == que[i].t && que[min].c > que[i].c)) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		i = min;
	}
}

typedef struct { int to[100], d[100], c[100]; } TBL;
TBL tbl[10003];
int len[10003];
char visited[10003];

int dijkstra(int start)
{
	int i, s, e, c, d, ans = 0;
	TBL *tp;

	qsize = 0;
	memset(visited, 0, sizeof(visited));
	enq(start, 0, 0);
	while(qsize) {
		s = que[0].node, d = que[0].t, c = que[0].c, deq();
		if (visited[s]) continue;
		visited[s] = 1;
		ans += c;
		for (tp = tbl+s, i = 0; i < len[s]; i++) {
			e = tp->to[i];
			if (visited[e]) continue;
			enq(e, d + tp->d[i], tp->c[i]);
		}
	}
	return ans;
}

char buf[40], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int n, m, i, k, u, v, d, c;
	TBL *tp;

	while (fgets(p=buf, 40, stdin) && *p != '0') {
		n = getint(), m = getint();
		memset(len, 0, sizeof(len));
		while (m--) {
			fgets(p=buf, 40, stdin);
			u = getint()-1, v = getint()-1, d = getint(), c = getint();
			tp = tbl+u,	k = len[u]++;
			tp->to[k] = v, tp->d[k] = d, tp->c[k] = c;
			tp = tbl+v, k = len[v]++;
			tp->to[k] = u, tp->d[k] = d, tp->c[k] = c;
		}
		printf("%d\n", dijkstra(0));
	}
	return 0;
}

Measured memory_bytes: 12684
#include<stdio.h>
 #include<string.h>
 int main(void)
 {
     int K,i;
     char S[100];

     scanf("%d",&K);
     scanf("%s",S);

     if(strlen(S)<=K) printf("%s\n",S);
     else{
       for(i=0;i<K;i++)
         printf("%c",S[i]);
           printf("...\n");
     }

     return 0;
 }



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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

const int MOD = 1'000'000'007;

int main() {
  int n;
  string s;
  cin >> n >> s;
  map<char, int> mp;
  for (char c : s) {
    mp[c]++;
  }
  ll res = 1;
  for (auto x : mp) {
    res *= (x.second + 1);
    res %= MOD;
  }
  res--;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using namespace std;
 
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair


int main() 

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,m;
    cin>>n>>m;
    ll a[10000];
    ll sum=0;
    f(i,0,m){
        ll x;
        cin>>x;
        sum+=x;
    }
    if(sum>n){
        cout<<"-1"<<endl;
    }
    else{
        cout<<n-sum<<endl;
    }


}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 0, now = 0;
    rep(i, 0, n){
        ans += min(t, a[i] + t - now);
        now = a[i] + t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 10 == 3) {
            System.out.println("bon");

        } else if (n % 10 == 0 ||n % 10 == 1 ||n % 10 == 6 ||n % 10 == 8) {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }

    }

}

Measured memory_bytes: 35848
a1= list(map(int, input().split()))
a2= list(map(int, input().split()))
a3= list(map(int, input().split()))
a = a1+a2+a3

n = int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            a[j] = 0

if a[0]==a[1]==a[2] or a[3]==a[4]==a[5] or a[6]==a[7]==a[8] or a[0]==a[3]==a[6]\
or a[1]==a[4]==a[7] or a[2]==a[5]==a[8] or a[0]==a[4]==a[8] or a[2]==a[4]==a[6]:
    print("Yes")
else:
    print("No")

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

int main () {
    int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y; cin >> x >> y;
    cout << (a[x] == a[y] ? "Yes " : "No ") << endl;
}

Measured memory_bytes: 256
"""
E.
"""
from functools import reduce
from collections import deque


def prod(x, y):
    return x * y % MOD

    
N, K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
# abs_a_list = sorted(a_list, key=abs, reverse=True)
MOD = 10**9 + 7

if K%2 == 1:
    flg = True
    for a in a_list:
        if a >= 0:
            flg = False
            break
    if flg:
        print(reduce(prod, a_list[:K]))
        exit()

S = []
a_list = deque(a_list)
i = 0
while i < K:
    if len(a_list)>=2:
        if a_list[0]*a_list[1] > a_list[-1]*a_list[-2]:
            S.append(a_list.popleft())
            i += 1
        elif a_list[0]*a_list[1] <= a_list[-1]*a_list[-2] and i <= K-2:
            S.append(a_list.pop())
            S.append(a_list.pop())
            i += 2
        else:
            S.append(a_list.popleft())
            i += 1
    else:
        S.append(a_list.popleft())
        i += 1
        
ans = reduce(prod, S)
print(ans)

Measured memory_bytes: 32244
n=int(input())
a=[list(input())for i in range(3)]
cnt=0
for i in range(n):
    tmp=[]
    tmp.append(a[0][i])
    tmp.append(a[1][i])
    tmp.append(a[2][i])
    cnt+=len(list(set(tmp)))-1
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define forn for(int i=0;i<n;i++)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
vector<bool> taken;
int score[(int)1e6];
bool cmp(int a,int b)
{
	return score[a]>score[b];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    forn
    cin>>a[i];
    int ans=INT_MAX,sum=0;
    for(int x=0;x<=100;x++)
    {
    	sum=0;
    	forn
    	sum+=(a[i]-x)*(a[i]-x);
    	ans=min(ans,sum);
	}
    cout<<ans;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,M,x;
  int max=0;
  cin>>N;
  vector<string> s(N);
  for(int i=0;i<N;i++)
  {
    cin>>s.at(i);
  }
  cin>>M;
  vector<string> t(M);
  for(int j=0;j<M;j++)
  {
    cin>>t.at(j);
  }
  for(int k=0;k<N;k++)
  {
    x=0;
    for(int l=0;l<N;l++)
    {
      if(s.at(k)==s.at(l))
      {
        x++;
      }
    }
    for(int m=0;m<M;m++)
    {
      if(s.at(k)==t.at(m))
      {
        x--;
      }
    }
    if(max<x)
    {
      max=x;
    }
  }
  cout<<max<<endl;
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	vb seats(100030);
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		for (int j = l; j <= r; j++) {
			seats[j] = true;
		}
	}

	int res = 0;
	for (auto seat : seats) {
		if (seat == true) {
			res++;
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

W = list(map(int, input().split()))

S1 = 0
S2 = sum(W)
diff = S2-S1
for i in range(N):
    newdiff = abs(S2-S1)
    S1 += W[i]
    S2 -= W[i]
    if(newdiff < diff):
        diff = newdiff

print(diff)


Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

const ll p = 1000000007;

int main(){
  string k;
  cin >> k;
  ll d;
  cin >> d;
  int k_sep[k.length()];
  REP(i,k.length()) k_sep[i] = k[i]-'0';
  ll n = k.length();//kの桁数
  ll dp[n][d];
  fill(dp[0],dp[n],0);
  REP(j,10){
    dp[0][j%d]++;
  }
  REP(i,n-1) REP(j,d) REP(l,10){
    dp[i+1][(j+l)%d] += dp[i][j];
    dp[i+1][(j+l)%d] %= p;
  }
  ll ans = 0;
  ll sum = 0;
  REP(i,n-1){
    REP(j,k_sep[i]){
      ans += dp[n-2-i][(2*d-sum-j)%d];
      ans %= p;
    }
    sum += k_sep[i];
    sum %= d;
  }
  REP(j,k_sep[n-1]+1){
    if((sum+j)%d==0) ans++;
  }
  cout << (ans+p-1)%p << endl;
  return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read(), cnt = 0, cnt2 = 0, _n = n;
  REP(i, n) {
    int tmp = read();
    if (tmp % 4 == 0)
      cnt++;
    else if (tmp % 2 == 0) {
      if (cnt2) {
        _n--;
      } else
        cnt2++;
    }
  }
  if (_n / 2 <= cnt)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
//#include<sstream>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, b) for (ll i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
int main()
{
    int x, y;
    cin >> x >> y;
    //int a, b;
    bool cnt = 0;
    for (int i = 0; i < x+1; i++)
    {
        for (int j = 0; j < x - i+1; j++)
        {
            if ((10 * i + 5 * j + (x - i - j)) == y / 1000)
            {
                cout <<i<< " " <<j<< " " << (x - i - j)<<endl;
                cnt = 1;
                break;
            }
            
        }
        if(cnt) break;
    }
    if (!cnt)
    {
        cout << "-1 -1 -1";
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))


sum_value = 0
for i in range(len(A)-1):
  if A[i] >= A[i+1]:
    x =  A[i] - A[i+1]
    A[i+1] = x + A[i+1]
    sum_value += x

print(sum_value)

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

int main()
{
    long long int n,i,j;
    cin>>n;
    long long int a[n];
    long long int fre[2] = {0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=n-1,j=0;i>=0,j<2;i--)
    {
        if(a[i+1]==a[i])
            fre[j++] = a[i--];
    }
    cout<<fre[0]*fre[1]<<endl;
}


Measured memory_bytes: 4384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define TEMP int
#define ordered_set tree<TEMP, null_type, less<TEMP>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 100005;

ll cnt[N];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    ROF(i,k,1){
        cnt[i] = mexp(k/i,n,MOD);
        for(int j = 2; i * j <= k; j++){
            cnt[i] = (cnt[i] - cnt[i*j] + MOD) % MOD;
        }
        ans = (ans + (i * cnt[i]) % MOD) % MOD;
    }
    cout << ans;
    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

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

using ll = long long;

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

    ll x; cin >>x;

    ll ans = 0;
    ans += x/11 * 2;
    ll rest = x%11;
    if (rest >= 1)
        ans++;
    if (rest >= 7)
        ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256