akhauriyash/Code-Regression huggingface dataset:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

if __name__ == "__main__":
    A,B,C,D = map(int,input().split())
    ac = A%C
    E = int(C*D/gcd(C,D))
    if ac == 0:
        modc = B//C - A//C + 1
    else:
        modc = B//C - A//C
    ad = A%D
    if ad == 0:
        modd = B//D - A//D + 1
    else:
        modd = B//D - A//D
    ae = A%E
    if ae == 0:
        mode = B//E - A//E + 1
    else:
        mode = B//E - A//E
    print(int(B-A+1-modc-modd+mode))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fastIO                        \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 10002
#define MOD 1000000007
#define PI 3.14159265358979323846
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> pr_int;


int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int&x:a) cin >> x;
	int s = k+1;
	for (int i = 1; i < n; ++i)
		s = min(s, k-a[i]+a[i-1]);
	cout << min(s, k - (a[0]+k-a[n-1]));
	
	
	cout << "\n";
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	int n[26];
	for(int i=0;i<26;i++) n[i] = 0;
	char str[100];
	scanf("%s",str);
	for(int i=0;i<strlen(str);i++){
		int t = str[i] - 'a';
		n[t]++;
		if(n[t]>1){
			printf("no\n");
			return 0;
		}
	}
	printf("yes\n");
	return 0;
}


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

int main(){
  std::vector<int> ring(3);
  std::cin >> ring[0] >> ring[1] >> ring[2];
  sort(ring.begin(), ring.end());
  int ans = ring[0] + ring[1];
  std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    int ball[N];
    for(int i = 0; i < N; i++){
        cin >> ball[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += min(ball[i], K - ball[i]) * 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php



fscanf(STDIN,"%d",$N);
$staffs = explode(" ",trim(fgets(STDIN)));
$uper_class = array();

foreach($staffs as $staff){
    $uper_class[$staff]++;
}

for($i=1;$i<=$N;$i++){
    if(array_key_exists($i,$uper_class)){
        echo $uper_class[$i]."\n";
    }
    else{
        echo "0\n";
    }
}


Measured memory_bytes: 39860
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	int N;
	cin >> N;
	vector<int> As(N);
	vector<ll> NumberList(N + 1, 0);
	for (int i = 0; i < N; i++) {
		cin >> As[i];
		NumberList[As[i]]++;
	}

	ll total = 0;
	for (int k = 1; k <= N; k++) {
		total += NumberList[k] * (NumberList[k] - 1) / 2;
	}
	for (int k = 1; k <= N; k++) {
		int nk = NumberList[As[k-1]];
		if (nk == 0){
			print(total);
		}
		else {
			print(total - nk * (nk - 1) / 2 + (nk - 1) * (nk - 2) / 2);
		}
	}
}



Measured memory_bytes: 5560
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <tuple>
#include <functional>

using namespace std;

#define ll long long

ll a[200050] = {};
ll b[200050] = {};

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

	if (c - (a - b) < 0) {
		cout << 0 << endl;
	}
	else {
		cout << c - (a - b) << endl;

	}


	
}


Measured memory_bytes: 256
import sys
from functools import reduce
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	# t = [ for i in range(x+1,mn(n,x+k+1))]
	t = map(lambda i:ab(ar[x]-ar[i])+solve(n,k,ar,dp,i), range(x+1,mn(n,x+k+1)))
	dp[x] = reduce(lambda a,b : a if a < b else b,t)
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()

Measured memory_bytes: 565636
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        ans = a + b
    elif op == '-':
        ans = a - b
    elif op == '*':
        ans = a * b
    elif op == '/':
        ans = a // b
    print(ans)
    


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int n;
int qus[1000005];
int beg,las,midd;
int big,sma;
int fro,tai,ans;
bool ups(int x,int y){
	return x<y;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>qus[i];
	}
	sort(qus,qus+n,ups);
	if(qus[n/2]==qus[n/2-1]){
		cout<<"0"<<endl;
	}
	else cout<<qus[n/2]-qus[n/2-1];
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int lim = 31;

int H, W, N;
char ori[lim][lim], b[lim][lim];
int v[lim][lim], h[lim][lim];

void init(){
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            v[i][j] = 0;
            h[i][j] = 0;
        }
    }
    return;
}

void input(){
    for(int i=H-1; i>=0; i--){
        for(int j=0; j<W; j++) cin >> ori[i][j];
    }
    return;
}

void var(){
    for(int x=0; x<W; x++){
        for(int y=0; y<H; y++){
            if(b[y][x] != '.'){
                char c = b[y][x];
                int start = y;
                while(b[y][x] == c && y < H) y++;
                for(int i=start; i < y; i++) v[i][x] = y - start;
                y--;
            }
        }
    }
    return;
}

void hor(){
    for(int y=0; y<H; y++){
        for(int x=0; x<W; x++){
            if(b[y][x] != '.'){
                char c = b[y][x];
                int start = x;
                while(b[y][x] == c && x < W) x++;
                for(int i=start; i < x; i++) h[y][i] = x - start;
                x--;
            }
        }
    }
    return;
}

bool del(){
    bool done_del = false;
    for(int y=0; y<H; y++){
        for(int x=0; x<W; x++){
            if(v[y][x] >= N || h[y][x] >= N){
                b[y][x] = '.';
                done_del = true;
            }
        }
    }
    return done_del;
}

void drop(){
    for(int x=0; x<W; x++){
        int cur = -1;
        for(int y=0; y<H; y++){
            if(cur == -1 && b[y][x] == '.') cur = y;
            else if(cur != -1 && b[y][x] != '.'){
                b[cur][x] = b[y][x];
                b[y][x] = '.';
                cur++;
            }
        }
    }
}

bool check(){
    for(int y=0; y<H; y++){
        for(int x=0; x<W; x++){
            if(b[y][x] != '.') return false;
        }
    }
    return true;
}

bool solve(int fy, int fx, int sy, int sx){
    init();
    for(int i=0; i<lim; i++) for(int j=0; j<lim; j++) b[i][j] = ' ';
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            b[i][j] = ori[i][j];
        }
    }
    char tmp = b[fy][fx];
    b[fy][fx] = b[sy][sx];
    b[sy][sx] = tmp;
    drop();
    var();
    hor();
    while(del()){
        drop();
        if(check()) return true;
        init();
        hor();
        var();
    }
    return false;
}

int main(){
    bool flag = false;
    cin >> H >> W >> N;
    input();
    for(int y=0; y<H; y++){
        for(int x=0; x<W-1; x++){
            if(solve(y, x, y, x+1)) flag = true;
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>

using namespace std;

int main() {

  vector<vector<int>> vs( 9, vector<int>() );
  vs[ 0 ] = {1, 3};
  vs[ 1 ] = {0, 2, 4};
  vs[ 2 ] = {1, 5};
  vs[ 3 ] = {0, 4, 6};
  vs[ 4 ] = {1, 3, 5, 7};
  vs[ 5 ] = {2, 4, 8};
  vs[ 6 ] = {3, 7};
  vs[ 7 ] = {4, 6, 8};
  vs[ 8 ] = {5, 7};
  
  for ( int i = 0; i < 1000; i++ )
  {
	string input;
	getline( cin, input );
	int state = input[ 0 ] - 'A';
	bool success = true;
	for ( int i = 1; i < input.length(); i++ )
	{
	  int next = input[ i ] - 'A';
	  if ( find( vs[ state ].begin(), vs[ state ].end(), next ) == vs[ state ].end() )
	  {
		success = false;
		break;
	  }
	  state = next;
	}
	if ( success )
	{
	  cout << input << endl;
	}
  }
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int N,M;
  cin >> N >> M;
  Graph G(N);
  bool ok = false;
  for (int i = 0;i < M;i++) {
      int a,b;
      cin >> a >> b;
      G[a-1].push_back(b-1);
      G[b-1].push_back(a-1);
  }
  for (auto i : G[0]) {
    for (auto j : G[i]) {
        if (j == N-1) ok = true;
      
    }
  }
  
  


    if (ok) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 12016
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B, C, K;


int main()
{
  std::cin >> A >> B >> C >> K;

  ll ans = std::min( A, K );

  if( K > A+B )
    ans -= std::min( C, K-A-B );

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		boolean ans = false;
		for(int i = 0; i < s.length(); i++) {
			if(s.equals(t)) {
				ans = true;
				break;
			}
			s += s.charAt(0);
			s = s.substring(1);
		}
		if(ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22996
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Map as MP
import Data.List
import Data.Tuple
import Control.Monad

type Distance = VUM.IOVector Int
type Table = VUM.IOVector Int

bfs :: Distance -> MP.Map Int [Int] -> [Int] -> IO Distance
bfs distance graph [] = return distance
bfs distance graph (x:xs) = do
  VUM.read distance x >>= \rx -> do
    let Just ys = sort <$> MP.lookup x graph
    ys' <- flip filterM ys $ \y -> do
      VUM.read distance y >>= \ry ->
        if (ry /= 10^9)
           then return False
           else (VUM.write distance y $ rx+1) >> return True
    bfs distance graph (xs ++ ys')

main = do
  [n,a,b] <- map read . words <$> getLine :: IO [Int]
  let vs = let xs = zip [1..n] [2..n] in [(a,b),(b,a)] ++ (map swap xs) ++ xs :: [(Int, Int)]
  let graph = foldl (\m k -> MP.insert k [] m) MP.empty [1..n]
  let graph' = foldl (\m (f,t) -> MP.adjust (t:) f m) graph vs
  
  table <- VUM.replicate (n+1) 0 :: IO Table

  forM_ [1..n] $ \i -> do
    distance <- VUM.replicate (n+1) (10^9) :: IO Distance
    VUM.write distance i 0    
    bfs distance graph' [i]
    distance' <- VU.tail . VU.zip (VU.fromList [0..n]) <$> VU.unsafeFreeze distance

    VU.forM_ distance' $ \(j,d) -> do
      when (j > i) $ do
        VUM.modify table (+1) d

  table' <- VU.tail . VU.init <$> VU.unsafeFreeze table    
  VU.mapM_ print table'


Measured memory_bytes: 2428
import sys

input = sys.stdin.readline
MOD = 1000000007

N,M = map(int,input().split())

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

x  = [1]*N

for _ in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if H[a] > H[b]:
        x[b] = 0
    elif H[a] == H[b]:
        x[a] = 0
        x[b] = 0
    else:
        x[a] = 0


print(x.count(1))


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

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	long long ans = 0, t = a[0];
	for (int i = 1; i < n; i++) {
		ans += max(0LL, t - a[i]);
		t = max(t, a[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4780
n = int(input())
nums = list(map(int, input().split()))

cnt = 0
for i in range(n-2):
	if (nums[i] < nums[i + 1] < nums[i + 2]) or (nums[i] > nums[i + 1] > nums[i + 2]):
		cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;
int main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int &i : h)
        cin >> i;
    vector<int> dp(n, 1e9+9);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= i + 2; ++j) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 3992
import copy
import queue
import numpy as np

H,W=map(int,input().split())
c=np.array([list(input()) for _ in range(H)])







#import queue
def bfs(array,start,goal,height,width):
    v=[[-1]*width for _ in range(height)]

    q=queue.Queue()
    q.put([start[0],start[1]])
    move=[[0,1],[0,-1],[1,0],[-1,0]]
    v[start[0]][start[1]]=0
    while not q.empty():
        pos=q.get()
        if pos[0]==goal[0] and pos[1]==goal[1]:          
            break
        
        for m in move:
            y=pos[0]+m[0]
            x=pos[1]+m[1]
            if y>=0 and y<height and x>=0 and x<width and array[y][x]=="." and v[y][x]==-1 :
                v[y][x]=v[pos[0]][pos[1]]+1
                q.put([y,x])
    return v[goal[0]][goal[1]]


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

d=bfs(c,[0,0],[H-1,W-1],H,W)
if d==-1:
    print(-1)
else:
    print(H*W-1-d-cnt)

Measured memory_bytes: 21680
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp(const void*p,const void*q){return strcmp(p,q);}
char s[200010][11];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	qsort(s,n,11,cmp);
	int ans=0;
	for(int i=0;i<n;i++)if(strcmp(s[i],s[i+1]))ans++;
	printf("%d",ans);
}

Measured memory_bytes: 5732
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;

int a[(int)1e5];
int rui[(int)1e5+1];

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

	int n,m;
	cin >> n >> m;

	int tmp;
	for(int i=0;i<n;i++){
		cin >> tmp;
		a[i] = tmp % m;
	}

	for(int i=1;i<=n;i++){
		rui[i] = (rui[i-1]+a[i-1]) % m;
	}

	sort(rui,rui+n+1);
//	cout << "\n";
//	for(int i=0;i<n+1;i++){
//		cout << rui[i] << "\n";
//	}
//	cout << "\n";

	long long ans = 0;
	for(int i=0;i<n+1;i++){
		auto up = upper_bound(rui+i,rui+n+1,rui[i]);
		ans += up - (rui+i) - 1;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int E = C/B;
    int F = A/D;
    if(C%B!=0) E++;
    if(A%D!=0) F++;
    
    if(E<=F){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3640
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> p;

const int inf = 1e15;
const int mod = 1e9+7;

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        cout << 0 << endl;
        return 0;
    }

    vector<int> ans;
    ans.push_back(a * b);
    ans.push_back(b * c);
    ans.push_back(c * a);
    cout << *min_element(ans.begin(), ans.end()) << endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int a;
long long ans;
int main(){
    cin>>a;
    for(long long i=1;i<=a;++i){
        if(i%3!=0&&i%5!=0){
            ans=ans+i;
        }
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#define ll long long int
#include<bits/stdc++.h>
#include<cmath>
#define MOD 1000000009
using namespace std;
int main()
{
ll n;ll k;
cin>>n>>k;ll s=0;
vector<ll> v;
for(ll i=0;i<n;i++)
{ll x;
	cin>>x;
	v.push_back(x);
}
sort(v.begin(),v.end());
for(ll i=0;i<k;i++)
s+=v[i];
cout<<s<<endl;
return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 1000*101;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()


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

	string s;
	cin >> s;
	if(s == "AAA" or s == "BBB") {
		cout << "No";
	}
	else cout << "Yes";
	cout << endl;
}		


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	b := make([]int, n)
	suma, sumb := 0, 0
	for i := range a {
		fmt.Scan(&a[i])
		suma += a[i]
	}
	for i := range a {
		fmt.Scan(&b[i])
		sumb += b[i]
	}

	if suma > sumb {
		fmt.Println("No")
		return
	}

	d := sumb - suma
	ca, cb := 0, 0
	for i := 0; i < n; i++ {
		x := a[i] - b[i]
		if x > 0 {
			cb += x
		} else {
			ca += (-x + 1) / 2
			cb += -x % 2
		}
	}

	if suma+ca*2 == sumb+cb && ca <= d && cb <= d {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

void solver(){
	char *s = new char[100010];
	scanf("%s",s);
	int L = strlen(s);
	s[L] = 'R';
	int I = 0;
	int sta = 0 , end = 0;
	int cntl = 0 , posl = -1;
	vector<int> v(L,0);
	for(int i = 1 ; i <= L ; ++i){
		end = i;
		if(s[i] == 'L'){
			cntl++;
			if(posl == -1){
				posl = i;
			}
		}else if(s[i] == 'R' && cntl > 0){
			if((end - sta) % 2 == 0){
				v[posl] = v[posl-1] = (end - sta) / 2;
			}else{
				int sm = (end - sta)/2;
				int lm = end - sta - sm;
				if(cntl > end - sta - cntl){
					if(cntl & 1){
						v[posl] = lm;
						v[posl-1] = sm;
					}else{
						v[posl] = sm;
						v[posl-1] = lm;
					}
				}else{
					if(cntl % 2 == 0){
						v[posl-1] = lm;
						v[posl] = sm;
					}else{
						v[posl-1] = sm;
						v[posl] = lm;
					}
				}
			}
			sta = i;
			posl = -1;
			cntl = 0;
		}
	}
	for(auto i:v)printf("%d ",i);
	printf("\n");
	return;
}

int main(){
	int q = 1;
	//scanf("%d",&q);
	while(q--){
		solver();
	}
	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int h, k, cnt = 0;
	cin >> h >> k;
	if (h < k) cout << "1" << "\n";
	else if (k == 1) cout << h << "\n";
	else {
		while (1) {
			h -= k;
			cnt++;
			if (h <= 0) break;
		}	
		cout << cnt << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
char s[1000000+10];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n-8;i++)
		putchar(s[i]);
	putchar('\n');

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int ins;
    for(;;){
        int sum=-1;
        scanf("%d",&sum);
        if(sum==0)break;
        for(int i=0;i<9;i++){
            scanf("%d",&ins);
            sum-=ins;
        }
        printf("%d\n",sum);
    }
}

Measured memory_bytes: 0
n, k, q = map(int, input().split())
point = {}
tmp = 0

for i in range(q):
    tmp = int(input())
    if tmp in point:
        point[tmp] += 1

    else:
        point[tmp] = 1

total = sum(point.values())

for b in range(1, n + 1):
    if b in point:
        if total - point[b] >= k:
            print("No")
        else:
            print("Yes")

    else:
        if total >= k:
            print("No")

        else:
            print("Yes")


Measured memory_bytes: 9064
#include <stdio.h>
#include<string.h>
#include<limits.h>
#include<queue>
#include <cmath>
#include<stack>


using namespace std;

int main()
{
    char a;
    int v[3]={0};

    scanf("%c",&a);
    int k=(int)(a-'a');
    v[k]=1;
      scanf("%c",&a);
    k=(int)(a-'a');
    v[k]=1;
      scanf("%c",&a);
    k=(int)(a-'a');
    v[k]=1;
    bool b=true;
    for(int i=0;i<3;i++){
        if(v[i]==0){
            b=false;}
    }
    if(b){
        printf("Yes\n");
    }else{
    printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char s[1024];

int Number(int l, int r)
{
	int n = 0;
	for (int i = l; i <= r; i++){
		n = n * 10 + s[i] - '0';
	}
	
	return (n);
}

int main()
{
	int N;
	scanf("%d", &N);
	
	for (int c = 0; c < N; c++){
		scanf("%s", s);
		
		int cnt = 0;
		while (s[1] != '\0'){
			int ma = 0;
			
			int len = strlen(s);
			for (int m = 0; m < len - 1; m++){
				ma = max(ma, Number(0, m) * Number(m + 1, len - 1));
			}
			
			sprintf(s, "%d", ma);
			
			cnt++;
		}
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, X, T; cin >> N >> X >> T;
    int num = (N+(X-1))/X;
    cout << T*num << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, const char * argv[]) {
  // insert code here...
  string s;
  cin>>s;
  if (s.length() <4) {cout<<"No";return 0;}
  if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {cout<<"Yes";}
  else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
n,t = map(int, input().split())
a = list(map(int, input().split()))
MAX = []
now = 0
for i in a[::-1]:
  now = max(i,now)
  MAX.append(now)
MAX.reverse()
max_margin = 0
ans = 0
for i,j in zip(a[:-1],MAX[1:]):
  margin = j-i
  if margin > max_margin:
    ans = 1
    max_margin = margin
  elif margin == max_margin:
    ans += 1
print(ans)

Measured memory_bytes: 14252
A,B,H,M = map(float, input().split())
 
import math
 
degreeA = float((H * 60 + M) / 2)
degreeB = float(M * 6)
 
degreeAB = abs(degreeA - degreeB)
if degreeAB == 180:
    print(A + B)
elif degreeAB > 180:
    degreeAB = 360 - degreeAB
    C = float(A ** 2 + B ** 2 - 2 * A * B * float(math.cos(float(degreeAB * math.pi / 180))))
    print(math.sqrt(C))
else:
    C = float(A ** 2 + B ** 2 - 2 * A * B * float(math.cos(float(degreeAB * math.pi / 180))))
    print(math.sqrt(C))

Measured memory_bytes: 9368
s=input()
K=int(input())
S=list(ord(s[i]) for i in range(len(s)))

for i in range(len(s)):
    if i!=len(s)-1:
        if S[i]!=97 and 123-S[i]<=K:
            K-=123-S[i]
            S[i]=97
    if i==len(s)-1:
        S[i]+=K%26
        if S[i]>=123:
            S[i]=S[i]-123+97
T=""
for i in range(len(s)):
    T+=chr(S[i])
print(T)

Measured memory_bytes: 4340
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	int a,b,x;
	cin >> a >> b >> x;
	if(x>=a && x<=b+a)cout << "YES" << endl;
	else cout << "NO" << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
const ll MOD = 1e9+7;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,k; cin >> n >> k;
    int sz=sqrt(n);
    sz*=2;
    vector<ll> v(sz);
    for(int i=1;2*i<=sz;i++){
        v[i-1]=1;
        v[sz-i]=n/i;
    }
    for(int i=sz;i>sz/2+1;i--){
        v[i-1]-=v[i-2];
    }
    v[sz/2]=n/(sz/2)-(sz/2);
    
    //rep(i,sz)cout<<v[i]<<endl;
    vector<ll> sum(sz);
    sum[0]=v[0];
    rep(i,sz-1)sum[i+1]=sum[i]+v[i+1];
    
    vector<ll> r=v;
    rep(i,k-1){
        vector<ll> a=r;
        r[sz-1]=a[0];
        for(int j=sz-2;j>=0;j--){
            r[j]=r[j+1]+a[sz-j-1];
            r[j]%=MOD;
        }
        rep(j,sz){
            r[j]*=v[j];
        }
    }
    //rep(i,sz)cout<<r[i]<<endl;
    ll res=0;
    rep(i,sz){
        res+=r[i];
        res%=MOD;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 5264
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define deb(x) cout<<#x<<" "<<x<<el;
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n==1) return x;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                              //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

template<typename T>
T maxx(T a,T b)
{
  if(a<b) re b;
  re b;
}
template<typename T, typename... Args>
T maxx(T a,T b, Args... args)
{
    re(maxx(maxx(a,b),args...));
}

template<typename T>
T minn(T a,T b)
{
  if(a<b) re a;
  re b;
}
template<typename T, typename... Args>
T minn(T a,T b, Args... args)
{
    re(minn(minn(a,b),args...));
}

template<typename T>
void read(T& a)
{
  cin>>a;
}
template<typename T, typename... Args>
void read(T& a,Args&... args)
{
  cin>>a; read(args...);
}

template<typename T>
void write(T a)
{
  cout<<a<<' ';
}
template<typename T, typename... Args>
void write(T a,Args... args)
{
  cout<<a<<' '; write(args...);
}

inline ll min(ll a,ll b)
{
  if(a<b) re a;
  else re b;
}
inline ll max(ll a,ll b)
{
  if(a<b) re b;
  else re a;
}

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

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=((ans*((n-i)%N))%N*modInverse(i+1,N))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    ll a,b;
    read(a,b,n);
    if((b-1)<=n)
    {
      k=b-1;
      cout<<max(0,(a*k)/b-a*(k/b));
    }
    else cout<<max(0,(a*n)/b-a*(n/b));

  }


  return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iostream>
#define maxn 109
using namespace std;
int cnt[maxn][30];
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		string s;
		cin >> s;
		for(int j = 0 ; j < (int)s.size(); j++)
			cnt[i][s[j] - 'a']++;
	}
	for(int i = 0 ; i < 26; i++){
		for(int j = 2; j <= n; j++)
			cnt[1][i] = min(cnt[1][i], cnt[j][i]);
	}
	for(int i = 0 ; i< 26; i++){
		for(int j = 0; j < cnt[1][i]; j++)
			printf("%c", 'a' + i);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

string S;

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

    cin >> S;

    if (S == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;
    
    return 0;
}

Measured memory_bytes: 3540
import Data.List

main = do
 _ <- getLine
 s <- lines<$>getContents
 putStr $ solve s

solve s = if (s == nub s) && check s then "Yes" else "No"

check :: [[Char]] -> Bool
check [] = True
check [a] = True
check (a:b:x) = (last a == head b) && check (b:x)

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



int main(){
  int a,b;
  cin >> a >> b;
  int c = max(a,b);
  int d = min(a,b);
  int ans = c;
  int e = max(c-1,d);
  ans += e;
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>
using namespace std;
 
int main() {
    string a,s,c,all;
    cin >> a >> s >> c;
    cout << a.at(0) << s.at(0)<<c.at(0)<<endl;
}

Measured memory_bytes: 256
x,y,z,k = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
 
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
 
cakes = []
for x, a in enumerate(A):
    if x+1 > k: break
        
    for y, b in enumerate(B):
        if (x+1)*(y+1) > k: break
            
        for z, c in enumerate(C):
            if (x+1)*(y+1)*(z+1) > k: break
                
            cakes.append(a+b+c)
    
cakes.sort(reverse=True)      
for cake in cakes[:k]:
    print(cake)

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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str = in.readLine();
		short size = (short) str.length();
		char[] charStr = str.toCharArray();
		for (int i = 0; i < size; i += 1) {
			if (Character.isLowerCase(charStr[i])) {
				charStr[i] = Character.toUpperCase(charStr[i]);
			} else if (Character.isUpperCase(charStr[i])) {
				charStr[i] = Character.toLowerCase(charStr[i]);
			}
		}
		System.out.println(charStr);
	}
}

Measured memory_bytes: 17028
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int X = sc.nextInt();
		List<Integer> dp = new ArrayList<Integer>();
		dp.add(2);
		int i = 2;
		do {		
			boolean f = true;
			for(int j=0;j<dp.size();j++) {
				if(i%dp.get(j)==0) {
					f=false;
					break;
				}
			}
			if(f) dp.add(i);
			i++;
		} while (i<X);
		int ans = 0;
		for(i=X;i<2*X;i++) {
			boolean f=true;
			for(int j=0;j<dp.size();j++){
				if(i%dp.get(j)==0) {
					f=false;
					break;
				}
			}
			if(f) {
				ans=i;
				break;
			}
		}
		System.out.println(X==2?2:ans);
	}
}

Measured memory_bytes: 23636
main :: IO ()
main = do
  a <- getLine
  let n = read a
  let m = (n `div` 11) * 2
  let tmp = n `mod` 11
  let l = if (tmp == 0)
        then -1
        else if (tmp `mod` 6 == 0)
             then 0
             else tmp `div` 6
  putStrLn . show $ m + l + 1


Measured memory_bytes: 508
// Bismillahirrahmanirrahim
// AgriCoder IPB
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <clocale>
#include <ctime>
#include <climits>
#include <cassert>
//#include <unordered_map>
using namespace std;

#define FOR(i, agri, coder) for (int i = (int)agri; i <= (int)coder; i++)
#define REP(agri,coder) for (int agri = 0; agri < (int)coder; agri++)
#define FOREACH(i,agricoder) for (typeof((agricoder).end()) i = (agricoder).begin(); i != (agricoder).end(); ++i)
//for (auto& it: agricoder)
#define RESET(agri,coder) memset(agri, coder, sizeof(agri))
#define pb push_back
#define mp make_pair
#define NL printf("==========================\n")
#define getchar_unlocked getchar // for codeforces

int arahbar[8] = {0,1,0,-1,1,1,-1,-1};
int arahkol[8] = {1,0,-1,0,1,-1,-1,1};
int kudabar[8] = {-2,-1,1,2, 2,1 , -1 ,-2};
int kudakol[8] = {1 ,2 ,2,1,-1,-2 , -2,-1};

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned int UNi;

template<typename T>
T getNum() {
   T res=0;
   char c;
   while(1)
   {
      c=getchar_unlocked();
      if(c==' ' || c=='\n') continue;
      else break;
   }
   bool negatif;
   if (c=='-') {
       negatif = true;
       res = 0;
   }
   else {
       res=c-'0';
       negatif = false;
   }
   while(1)
   {
      c=getchar_unlocked();
      if('0'<=c && c<='9') res=res*10 + c-'0';
      else break;
   }
   if (negatif) res*=-1;
   return res;
}

inline void boost() { //dont use with cstdio, dont use in interactives
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
}
//freopen("badmilk.in", "r", stdin);
//freopen("badmilk.out", "w", stdout);
//fclose(stdin);
//fclose(stdout);
#define INF 1000000000
#define EPS 1e-9
#define MAX_N 100005
// ================================  TEMPLATE ENDS HERE ================================================== //

int main() {
	int n;
	LL T;
	LL ans = 0LL;
	cin >> n >> T;
	
	LL x;
	cin >> x;	
	
	LL kiri = 0,kanan = T;
	
	REP(i,n-1) {
		cin >> x;
		if (x<=kanan) kanan = x+T;
		else {
			ans += kanan-kiri;
			kiri = x; kanan = x+T;
		}
	}
	ans += kanan-kiri;
	cout << ans << endl;
	return 0;
}
//Alhamdulillahirabbilalamin


Measured memory_bytes: 256
n,x,y=map(int, input().split())
count=[0]*n

def push(a,b,q,distance):
    if distance[a-1]==-1:
        distance[a-1]=b
        q.append(a)

    return (q,distance)

for i in range (1,n+1):
    distance=[-1]*n
    q=[]
    q.append(i)
    distance[i-1]=0
    while len(q) > 0:
        a=q.pop(0)
        if a>=2:
            q,distance=push(a-1,distance[a-1]+1,q,distance)
        if a<=n-1:
            q, distance = push(a + 1, distance[a-1] + 1, q, distance)
        if a==x:
            q, distance = push(y, distance[a-1] + 1, q, distance)
        if a==y:
            q, distance = push(x, distance[a-1] + 1, q, distance)

    for i in range(n):
        count[distance[i]]+=1

for i in range (1,n):
    print(count[i]//2)

Measured memory_bytes: 49500
import java.util.Scanner;

public class Main {
	
	void doIt(){
		Scanner sc = new Scanner(System.in);
		int i, cnt = 0;
		int N = sc.nextInt();
		String name = sc.next();
		String[] board = new String[N];
		for(i=0; i<N; i++)board[i] = sc.next();
		
		for(i=0; i<N; i++){
			cnt += Main.Check(name, board[i]);
		}
		System.out.println(cnt);
	}
	
	public static int Check(String name, String board){
		int i, j, k, space, next;
		boolean flag = false;
		char[] nameC = name.toCharArray();
		char[] boardC = board.toCharArray();
		
		for(i=0; i<board.length(); i++){
			if(nameC[0] == boardC[i]){
				for(j=i; j<board.length(); j++){
					if(nameC[1] == boardC[j]){
						space = j - i;
						for(k=2, next=j+space; next<board.length(); next+=space, k++){
							flag = false;
							if(nameC[k] == boardC[next]){
								flag = true;
								if(k==name.length()-1)return 1;
							}
							if(flag == false)break;
						}		
					}
				}
			}
		}
		return 0;
	}
	
	
	public static void main(String[] args){
		new Main().doIt();
		
	}
	
	

}

Measured memory_bytes: 27688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

char maze[444][444];
ll visited[444][444];


bool is_in_field(ll h, ll w, pll now){
    if(now.first < 0 || now.first >= h){return false;}
    if(now.second < 0 || now.second >= w){return false;}
    return true;
}

ll bfs(ll h, ll w, ll sh,ll sw){
    queue<pll> q;
    pll start = {sh,sw};
    pll d[4] = {{1,0},{-1,0},{0,1},{0,-1}};
    q.push(start);
    visited[start.first][start.second] = 1;
    ll black = 0;
    ll white = 0;
    while(!q.empty()){
        pll now = q.front();
        q.pop();
        if(maze[now.first][now.second]=='.'){white++;}
        else if(maze[now.first][now.second]=='#'){black++;}
        for(ll i = 0; i < 4; i++){
            pll next = {now.first + d[i].first, now.second + d[i].second};
            if(maze[next.first][next.second] == maze[now.first][now.second]){continue;}

            if(is_in_field(h, w, next)){
                if(visited[next.first][next.second] == -1){
                    q.push(next);
                    visited[next.first][next.second] = 1;
                }
            }
        }
    }
    return white*black;
}

int main(){
    ll h, w;
    cin >> h >> w;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            cin >> maze[i][j];
            visited[i][j] = -1;
        }
    }
    ll ans = 0;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(visited[i][j] == -1){
                ans += bfs(h,w,i,j);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////


int main() {

    int n;
    I(n);

    int a[n+2], b[n+2], c[n+2];

    ll x = 0,y =0 ,z =0;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
        if(c[i]) x=a[i], y= b[i], z= c[i];
    }
    
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            bool fl = 0;
            set<int>st;
            ll v = abs(i-x) + abs(j-y) +z;
            for(int k=1;k<=n;k++){
               ll k1 = max(0ll, v- abs(i-a[k]) - abs(j-b[k]));
               if(k1!=c[k])fl = 1;
            }
            if(!fl){
                
                cout<<i<<" "<<j<<" "<<v<<endl;
                return 0;
            }
        }
    }
    cout<<"0 0 0"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#include <map>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<int,int>;
const ll M = 1e9+7, mx = 301;
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; void chmax(ll& x, ll y) {if (x<y) x=y;}; void chmin(ll& x, ll y) {if (x>y) x=y;};

int main() {
  int n,m; cin>>n>>m;
  ll a[m],b[m],c[m];
  for(int i=0;i<m;i++) {
    cin>>a[i]>>b[i]>>c[i];
    a[i]--; b[i]--;
  }

  ll score[n]; fill(score,score+n,-LINF);
  score[0]=0;
  bool update = true;
  bool update_n = false;
  int ii = 0;
  while(update) {
    update = false; update_n = false;
    for(int i=0;i<m;i++) {
      if(score[b[i]]<score[a[i]]+c[i]){
        score[b[i]]=score[a[i]]+c[i];
        update = true;
        if (b[i]==n-1) update_n = true;
      }
    }
    if (ii >= n && update_n) {
      cout<<"inf"<<endl;
      return 0;
    } else if (ii >= 2*n) {
      break;
    }
    ii++;
  }
  cout<<score[n-1]<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
 
int main()
{
    // 入力
    map<int, int> mp1;
    map<int, int> mp2;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if(i % 2 == 0) mp1[a]++;
        else mp2[a]++;
    }

    int max1 = 0;
    int key = 0;
    for(pair<int, int> m: mp1)
    {
        if(m.second > max1)
        {
            max1 = m.second;
            key = m.first;
        }
    }
    int max2 = 0;
    for(pair<int, int> m: mp2)
    {
        if(m.second > max2 && m.first != key) max2 = m.second;
    }
    int ans1 = (N/2 - max1) + (N/2 - max2);

    // 最頻値から答えを求める２
    max1 = 0;
    key = 0;
    for(pair<int, int> m: mp2)
    {
        if(m.second > max1)
        {
            max1 = m.second;
            key = m.first;
        }
    }
    max2 = 0;
    for(pair<int, int> m: mp1)
    {
        if(m.second > max2 && m.first != key) max2 = m.second;
    }
    int ans2 = (N/2 - max1) + (N/2 - max2);
    int ans = min(ans1, ans2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992