akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
  int n, u, k, v;
  bool G[100][100] = {0};

  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
        cin >> v;
        G[u-1][v-1] = true;
    }
  }

  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      cout << G[i][j];
      if(j != n-1) cout << ' ';
    }

    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<vector>
using namespace std;
string make(string s,string a,string b){
	string x;
	for(int i=0;i<s.size();i++){
		bool flag =true;
		for(int j=0;j<a.size();j++){
			if(i+j>=s.size()||s[i+j]!=a[j]){
				flag=false;
				break;
			}
		}
		if(flag){
			i+=a.size()-1;
			x+=b;
		}else{
			x+=s[i];
		}
	}
	return x;
}

int dfs(string s,string ans,int t,int n,vector<string> a,vector<string>b){
if(s.size()>ans.size()||t>10)return 11;
string w;
int l=11;
for(int i=0;i<n;i++){
w=make(s,a[i],b[i]);
if(w==ans){
	return t+1;
}
if(s!=w){
	l=min(l,dfs(w,ans,t+1,n,a,b));
}
}

return l;
}

int main(void){
	int n;
	while(1){
		cin>>n;
		if(n==0)break;
		vector<string> a(n),b(n);
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
string s,ans;
cin>>s>>ans;
int k=dfs(s,ans,0,n,a,b);
if(k==11){
	cout<<-1<<endl;
}else{
	cout<<k<<endl;
}
	}

	return 0;
}

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

int main() {
int N;
cin>>N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
    cin >> A[i];
}
vector<int> rev(N);
for (int i = 0; i < N; i++) {
    rev[A[i]-1]=i+1;
}
for (int i = 0; i < N; i++) {
   cout << rev[i] << endl;
}
return 0;
}

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

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

int main(){
  long a,b,c,d;
  cin >> a >> b >> c >> d;
  long numc = b/c - (a-1)/c;
  long numd = b/d - (a-1)/d;
  //cout << gcd(c,d) << endl;
  long cd = c * d / gcd(c,d);
  long numcd = b/cd - (a-1)/cd;
  cout << b - a + 1 - (numc + numd - numcd) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>

int main(){
    double x1,y1,x2,y2;
    double d;
    std::cin >> x1 >> y1 >> x2 >> y2;
    d = std::sqrt((x1 - x2) * ( x1 - x2) + ( y1- y2) * (y1 - y2));
    std::cout << std::setprecision(20) << d << std::endl;
    return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    string str;
    cin>>str;
    int n=str.size();
    if(n%2==1)
    {
        cout<<"No";
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        if(i%2==0 && str[i]!='h')
        {
            cout<<"No";
            return 0;
        }
        else if(i%2==1 && str[i]!='i')
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 998244353;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};

int main() {
    int n; string s;
    cin >> n >> s;
    ll ans = 1;
    Factorial<ll> f(n, MOD);
    vector<ll> v(8);
    v[0] = n;
    for (int i = 0; i < n*3; ++i) {
        int x = 0;
        if(s[i] == 'R') x = 1;
        else if(s[i] == 'G') x = 2;
        else x = 4;
        for (int j = 6; j >= 0; --j) {
            if(!(j&x) && v[j]){
                (ans *= v[j]) %= MOD;
                v[j]--;
                v[j|x]++;
                break;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define MXN 300000
int a[100005];
int go(int n){
    LL tot=0;
    vector<int> v;
    for(int i = 0;i<n;i++){
        tot+=a[i];
        if(a[i]&1)v.pb(i);
    }
    if((tot-n)&1){
        return 1;
    }
    if(v.size()!=1||a[v[0]]==1){
        return 0;
    }
    a[v[0]]--;
    int gcd=0;
    for(int i = 0;i<n;i++)
        gcd=__gcd(a[i],gcd);
    for(int i = 0;i<n;i++)
        a[i]/=gcd;
    return 1-go(n);
}
int main(){
    int n;
    scanf("%d",&n);

    LL tot=0;
    vector<int> v;
    for(int i = 0;i<n;i++){
        scanf("%d",&a[i]);
       // if(a[i]&1)v.pb(i);
      //  tot+=a[i];
    }
    if(go(n)){
        printf("First\n");
    }
    else{
        printf("Second\n");
    }
}
/*
5 4
8 1 0 3 0
0 0 1 3 8
1
*/

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

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(b)   sort(b.begin(), b.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    ll height = 0;
    while(n > 1) {
        n /= 2;
        height++;
    }

    ll ans = pow(2, height + 1) - 1;

    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long K, long long X){
  ll tmp=max((ll)-1000000,X-K+1);
  repf(i,tmp,X+K){
    cout<<i;
    if(i==1000000||i==X+K-1)break;
    cout<<" ";
  }cout<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    solve(K, X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, a, b, c, d);
    ll e = c/gcd(c, d)*d;
    Cout((b-a+1) - (b/c - (a-1)/c) - ((b/d) - (a-1)/d) + (b/e - (a-1)/e));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
using namespace std;
int main(){
	ll n,k,q;
	cin>>n>>k>>q;
	ll a[n+1];
	for(int i=1;i<=n;i++)a[i]=k-q;
	ll x;
	for(int i=1;i<=q;i++){
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++){
		if(a[i]>0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}return 0;
} 

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

int main()
{
  int n;

  cin >> n;

  bool flag = true;

  vector<int> a(n);
  rep(i, n){
    cin >> a.at(i);
    if(a.at(i) %2 == 0){
      if(a.at(i) %3 != 0 && a.at(i) % 5 !=0){
        flag = false;
      }
    }
  }

  if(flag)
    cout << "APPROVED";
  else
  {
    cout << "DENIED ";
  }

}


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

int main()
{
	int a;
	int b;
	int C;

	cin >> a >> b;

	if(2 == a || 2 == b) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
D=int(input())
c = [int(i) for i in input().split()]
s=[]
for i in range(D):
    s.append([int(j) for j in input().split()])
t=[0] * D
for i in range(D):
    t[i] = int(input())

tst = [0] * 26
last = [0] * 26
for i,j in enumerate(t):
    tst[j-1] += s[i][j-1]
    last[j-1] = i+1
    for k in range(26):
        if k != j-1:
            tst[k] -= (i+1 - last[k])*c[k] 
    print(sum(tst))



Measured memory_bytes: 9404
import datetime
y,m,d = input().split('/')
y = int(y)
m = int(m)
d = int(d)
a = datetime.date(y,m,d)
b = datetime.date(2019,4,30)
c = (a - b).days
if c <= 0:
  print('Heisei')
else:
  print('TBD')

Measured memory_bytes: 3312
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=in.nextInt();
		}
		Arrays.sort(a);
		System.out.println(Math.abs(a[0]-a[n-1]));
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll test[12345678];
signed main() {
	ll n, k, cnt = 1; cin >> n >> k; vector<ll> sei, hu;
	rep(i, n) {
		cin >> test[i]; cnt *= abs(test[i]); cnt %= mod;
		if (test[i] >= 0) { sei.push_back(test[i]); }
		else { hu.push_back(abs(test[i])); }
	}
	if (n == k) {
		if (hu.size() % 2 == 1) { cout << mod - cnt << endl; }
		else { cout << cnt << endl; }
		return 0;
	}
	ll a = 0, b = 0, ans = 1;
	if (k % 2 == 1 && sei.size() == 0) {//負
		sort(all(hu));
		rep(i, k) {
			ans *= hu[i]; ans %= mod;
		}
		cout << mod - ans << endl;
		return 0;
	}
	sort(all(sei)); reverse(all(sei)); sort(all(hu)); reverse(all(hu));
	ll z = 0, q1 = sei.size(), w2 = hu.size(); q1--; w2--;
	while ((a + b) != k) {
		if ((a + b) == k - 1) { ans *= sei[a]; a++; }
		else if (a >= q1) {
			ans *= ((hu[b] * hu[b + 1]) % mod); b += 2;
		}
		else if (b >= w2) {
			ans *= (sei[a] % mod); a++;
		}
		else {
			if ((sei[a] * sei[a + 1]) > (hu[b] * hu[b + 1])) {
				ans *= sei[a]; a++;
			}
			else { ans *= (hu[b] * hu[b + 1] % mod); b += 2; }
		}
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6552
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;

int cnt[MAXN];
ll dp[MAXN], tab[MAXN], h[MAXN];
bool vis[MAXN], used[MAXN];

vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

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

    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n] << "\n";
}


Measured memory_bytes: 28928
#include <iostream>
#include <deque>
#define KMAX 100001
using namespace std;
deque <int> DEQ;
int dist[KMAX],k;
int bfs01(int st)
{
    int nod,v;
    DEQ.push_front(1);
    while(!DEQ.empty())
    {
        nod=DEQ.front();
        DEQ.pop_front();
        v=nod*10%k;
        if(dist[v]==0||dist[nod]<dist[v])
            { dist[v]=dist[nod]; DEQ.push_front(v);}
        v=(nod+1)%k;
        if(dist[v]==0||dist[nod]+1<dist[v])
            {dist[v]=dist[nod]+1; DEQ.push_back(v); }
    }
    return dist[0];
}
int main()
{
    cin>>k;
    dist[1]=1;
    cout<<bfs01(1);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

int main() {
    long long c, a, b, ans = 0;
    cin >> a >> b >> c;
    for (int i = 1; i < 100000; i++) {
        if ((i * a) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <map>
using namespace std;


const int maxn = 3e2+1;
int n, m, a[maxn][maxn];
bool vis[maxn];
int cnt[maxn];
inline int solve()
{
  memset(cnt, 0, m*sizeof(int));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (vis[a[i][j]])
	{
	  cnt[a[i][j]] += 1;
	  break;
	}

  int pick = 0;
  for (int i = 0; i < m; ++i)
    if (cnt[i] > cnt[pick])
      pick = i;
  vis[pick] = false;
  return cnt[pick];
}
int main()
{
  scanf("%d %d", &n, &m);
  memset(vis, true, m*sizeof(bool));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      {
	scanf("%d", &a[i][j]);
	a[i][j] -= 1;
      }
  int ans = 300;
  for (int i = 0; i < m; ++i)
    {
      int ret = solve();
      ans = min(ans, ret);
    }
  printf("%d\n", ans);
}


Measured memory_bytes: 640
def modinv(a,m):
    b, u, v = m, 1, 0
    while b:
        t = a//b
        a -= t*b
        a,b = b,a
        u -= t * v
        u,v = v,u
    u %= m
    return u

s=input()
all_hatena = s.count('?')

a_cnt = 0
ab_cnt = 0
hatena_cnt = 0
ans = 0

MOD = 10**9+7
for si in s:
    if si == 'A':
        a_cnt += 1
    elif si == 'B':
        ab_cnt += a_cnt*pow(3,all_hatena,MOD)
        if all_hatena >= 1:
            ab_cnt += hatena_cnt*pow(3,all_hatena-1,MOD)
    elif si == 'C':
        ans += ab_cnt
    else:
        ans += ab_cnt*modinv(3,MOD)
        ab_cnt += a_cnt*pow(3,all_hatena-1,MOD)
        if all_hatena >= 2:
            ab_cnt += hatena_cnt*pow(3,all_hatena-2,MOD)
        hatena_cnt += 1
    ab_cnt%=MOD
    ans%=MOD
    # print(a_cnt,ab_cnt,ans)
print(ans)

Measured memory_bytes: 74208
import sys
from itertools import combinations
N, *S = open(0).read().split()

T = [0]*5

for s in S:
    i = s[0]
    if i == 'M':
        T[0] += 1
    elif i == 'A':
        T[1] += 1
    elif i == 'R':
        T[2] += 1
    elif i == 'C':
        T[3] += 1
    elif i == 'H':
        T[4] += 1

T.sort(reverse=True)

k = 0
for t in T:
    if t:
        k += 1

ans = 0
for a, b, c in combinations(range(k), 3):
    ans += T[a] * T[b] * T[c]
print(ans)


Measured memory_bytes: 10864
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int main()
{
	//97:a        122:z
	int lena,lenb,i,j,flag;
	char a[120],b[120];
	scanf("%s",a);
	scanf("%s",b);
	lena=strlen(a);
	lenb=strlen(b);
	for(i=1;i<=lena;i++)
	{
		flag=0;
		for(j=i;j<=lenb+i-1;j++)
			if(a[j%lena]!=b[j-i])
			{
				flag=1;
				break;
			}
		if(flag==0)
			break;
	}
	if(flag==0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 2120
#include <iostream>
using namespace std;
int p, q, a, n;
int solve(int p1, int a1, int r, int depth) {
	if (p1 * q == a1 * p) return 1;
	if (depth == n) return 0;
	int ret = 0;
	for (int i = r; a1 * i <= a; i++) {
		ret += solve(p1 * i + a1, a1 * i, i, depth + 1);
	}
	return ret;
}
int main() {
	while (cin >> p >> q >> a >> n, p | q | a | n) {
		cout << solve(0, 1, 1, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
import sys
readline = sys.stdin.readline
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def main():
    N = int(readline())
    ans = 1
    for _ in range(N):
        t = int(readline())
        ans = lcm_base(ans, t)
    
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 5048
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

int main()
{
	int n,m,X,Y;
	cin >> n >> m >> X >> Y;
	vector<int> x(n),y(m);

	REP(i,n)
	cin >> x[i];

	REP(i,m)
	cin >> y[i];

	sort(x.begin(),x.end(),greater<int>());
	sort(y.begin(),y.end());

	if(x[0] < Y && y[0] > X && x[0] < y[0])cout << "No War" << endl;
	else cout << "War" << endl;

	return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 998244353
#define inf -2e9
#define N (int) 3e5
using namespace std;
int n;
struct Node {
	int x, d;
} node[N];

struct Sgtree {
	int mx[N<<2];
	void build (int id, int l, int r) {
		mx[id] = inf;
		if (l == r) return ;
		int mid = l + r >> 1;
		build (id<<1, l, mid);
		build (id<<1|1, mid+1, r);
	}
	void update (int id, int l, int r, int pos, int val) {
		if (pos == l && l == r) {
			mx[id] = val;
			return ;
		}
		int mid = l + r >> 1;
		if (pos <= mid) update (id<<1, l, mid, pos, val);
		else update (id<<1|1, mid+1, r, pos, val);
		mx[id] = max (mx[id<<1], mx[id<<1|1]);
	}
	int query (int id, int l, int r, int L, int R) {
		if (L <= l && r <= R) return mx[id];
		int mid = l + r >> 1;
		int ret = inf;
		if (L <= mid) ret = max (ret, query (id<<1, l, mid, L, R));
		if (mid < R) ret = max (ret, query (id<<1|1, mid+1, r, L, R));
		return ret;
	}
} sgtree;

int b[N];
int dp[N];

bool cmp (const Node & x, const Node & y) {
	return x.x < y.x;
}

int main () {
	cin >> n;
	for (int i = 1; i <= n; i ++) cin >> node[i].x >> node[i].d, b[i] = node[i].x;
	
	sort (node+1, node+n+1, cmp);
	sort (b+1, b+n+1);
	
	sgtree.build (1, 1, n);
	
	dp[n+1] = 1;
	for (int i = n; i >= 1; i --) {
		int pos = upper_bound (b+1, b+n+1, node[i].x+node[i].d-1) - b - 1;
		int tmp = sgtree.query (1, 1, n, i, pos);
		int j = upper_bound (b+1, b+n+1, max (tmp, node[i].x+node[i].d-1)) - b;
		sgtree.update (1, 1, n, i, max (tmp, node[i].x+node[i].d-1));
//		cout << j << " " << tmp << " " << pos << endl;
		dp[i] = (dp[i+1] + dp[j]) % MOD;
	}
	
	cout << dp[1] << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll INF=1000000000000000;

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

int main(){
	ll N,W; cin>>N>>W;
	vector<ll> w(N);
	vector<ll> v(N);
	rep(i,N) cin>>w[i]>>v[i];

	//dp[i][j]:i番目まで選んで価値がちょうどjとなるときの重さの最小値
	ll dp[105][100010];
	rep(i,105)rep(j,100010) dp[i][j]=INF;
	dp[0][v[0]]=w[0];
	dp[0][0]=0;
	rep1(i,N-1){
		rep(j,100001){
			//i番目選ぶとする
			if(j-v[i]>=0) chmin(dp[i][j],dp[i-1][j-v[i]]+w[i]);
			//i番目選ばない
			chmin(dp[i][j],dp[i-1][j]);
		}
	}

	//答はWを超えないような価値の最大値
	for(int i=100000;i>=0;i--){
		if(dp[N-1][i]<=W){
			cout<<i;
			return 0;
		}
	}
}

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


int main() {
  int a[9],b[9]={0};
  r(i,9)cin >> a[i];
  int n;
  cin >> n;
  r(i,n){
    int c;
    cin >> c;
    r(j,9)if(a[j]==c)b[j]=1;
  }
  if(b[0]==1&&b[1]==1&&b[2]==1)cout<<"Yes"<<endl;
  else if(b[4]==1&&b[3]==1&&b[5]==1)cout<<"Yes"<<endl;
  else if(b[6]==1&&b[7]==1&&b[8]==1)cout<<"Yes"<<endl;
  else if(b[0]==1&&b[3]==1&&b[6]==1)cout<<"Yes"<<endl;
  else if(b[1]==1&&b[4]==1&&b[7]==1)cout<<"Yes"<<endl;
  else if(b[2]==1&&b[5]==1&&b[8]==1)cout<<"Yes"<<endl;
  else if(b[0]==1&&b[4]==1&&b[8]==1)cout<<"Yes"<<endl;
  else if(b[2]==1&&b[4]==1&&b[6]==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


/*   3
 * 0   2
 *   1
 */

public class Main {

	static int[] v1 ={-1, 0, 1, 0};
	static int[] v2 ={0, 1, 0, -1};
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			if(n==0){
				break;
			}
			int[][] a = new int[n*2+2][n*2+2];
			
			int[][] pair = new int[n][2];
			pair[0][0]=n/2+1;
			pair[0][1]=n/2+1;
			a[n/2][n/2]=1;
			
			int minx=n/2+1,maxx=n/2+1,miny=n/2+1,maxy=n/2+1;
			for(int i = 1; i < n;i++){
				int ni=cin.nextInt();
				int d=cin.nextInt();
				int x = pair[ni][0]+v1[d];
				int y = pair[ni][1]+v2[d];
				pair[i][0]=x;
				pair[i][1]=y;
				//System.out.println(x + " " + y);
				//a[x][y]=1;
				if(minx > x){
					minx = x;
				}
				if(maxx < x){
					maxx = x;
				}
				if(miny > y){
					miny = y;
				}
				if(maxy < y){
					maxy = y;
				}
			}
			for(int i = 0; i < n*2+2;i++){
				for(int j = 0; j < n*2+2;j++){
					//System.out.print(a[i][j] + " " );
				}
				//System.out.println();
			}
			System.out.println((maxx-minx+1) +" "+(maxy-miny+1));
		}
	}
}

Measured memory_bytes: 13000
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n,m;
  scanf("%d%d",&n,&m);

  int x[m];
  for(int i = 0; i < m; ++i){
    scanf("%d",x+i);
  }

  qsort(x,m,sizeof(int),sort);

  int dif[m-1];
  for(int i = 0; i < m-1; ++i){
    dif[i] = abs(x[i+1] - x[i]);
  }

  qsort(dif,m-1,sizeof(int),sort);

  int ans = 0;
  for(int i = 0; i < m-n; ++i){
    ans += dif[i];
  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 1396
//abc049_a.cpp
//Fri Oct 19 22:45:44 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	char s;
	cin >> s;

	if (s == 'a' || s == 'i' ||s == 'u' ||s == 'e' ||s == 'o'){
		cout << "vowel" << endl;
	}else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
s = gets.chomp
a = [1]
m = 1
for i in 1..n-1
    if s[i] == s[i-1]
        a[-1] += 1
    else
        a << 1
    end
end
a.unshift(0) if s[0] == "0"
a.push(0) if s[-1] == "0"
t = a.size
sums = Array.new(t+1,0)
ans = 0
t.times do |i|
    sums[i+1] = sums[i]+a[i]
    # ans = a[i] if i%2 == 0 && ans < a[i]
end
for i in 0..t
    r = i*2+k*2+1
    r = t if r > t
    ret = sums[r]-sums[i*2]
    ans = ret if ans < ret
    break if r == t
end
puts ans

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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	string s1, s2;
	cin >> s1 >> s2;
	int ans = 0;
	REP(i,3) ans+=(s1[i]==s2[i]);
	cout << ans << endl;
	return 0;
} 


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

using namespace std;

#define ll long long
#define vi vector<int>

string S;
ll ans = 0;

bool isEvenStr(){
    bool flag = true;
    int N = S.size();

    if(N%2 != 0) flag = false;
    else{
        for(int i = 0; i < N/2; i++){
            if(S[i] != S[i+N/2]){
                flag = false;
                break;
            }
        }
    }

    return flag;
}

void solve(){
    while(!S.empty()){
        if(isEvenStr()){
            ans = S.size();
            break;
        }
        S.pop_back();
    }

    cout << ans << endl;
}

int main(){
    cin >> S;
    
    S.pop_back();

    solve();
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int res = 0, p = 0;
  vector<bool> reached(N);
  do {
    if (reached[p]) {
      res = -1;
      break;
    }
    reached[p] = true;
    ++res;
    p = a[p] - 1;
  } while (p != 1);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1e9+7;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
int f[5010][2],g[5010][2];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),a=read(),b=read();
	if(a>b)swap(a,b);
	g[1][1]=1;
	for(int i=2;i<b;i++)
	{
		g[i][1]=ad(g[i-1][0]+g[i-1][1]);
		for(int j=a;j<i;j++)g[i][0]=ad(g[i][0]+g[i-j][1]);
	}
	f[0][0]=f[0][1]=1;
	int tot=1;
	for(int i=1;i<=n;i++)
	{
		tot=ad(2*tot);
		for(int j=1;j<min(a,i+1);j++)f[i][0]=ad(f[i][0]+f[i-j][1]);
		for(int j=1;j<min(b,i+1);j++)
		{
			if(i==n)f[i][0]=ad(f[i][0]+1LL*f[i-j][0]*g[j][0]%mod);
			if(i==j)f[i][1]=ad(f[i][1]+ad(g[i][0]+g[i][1]));
			else f[i][1]=ad(f[i][1]+1LL*f[i-j][0]*g[j][1]%mod);
		}
	}pr2(dec(tot-ad(f[n][0]+f[n][1])));
	return 0;
}

Measured memory_bytes: 1576
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u8  = read();
    let b: u8  = read();
    let c: u8  = std::cmp::min(a, b);
    let d: u8  = std::cmp::max(a, b);
    for _ in 0..d {
        print!("{}", c);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int> >v;
  REP(i,N){
    int A,B;
    cin>>A>>B;
    v.push_back(make_pair(B,A));
  }
  sort(ALL(v));
  int t=0;
  bool f=true;
  for(auto e:v){
    int A=e.second;
    int B=e.first;
    // cerr<<A<<" "<<B<<endl;
    t+=A;
    if(t>B)f=false;
  }
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <cmath>

using namespace std;

long long max(vector<long long> A){
    long long ret=0;
    for(int i=0; i<A.size(); i++){
        if(A[i]>ret){
            ret= A[i];
        }
    }
    return ret;
}

long long N,K;

void search_(long long num, vector<long long> &vec, int cnt, int flag, priority_queue<long long> &que){
    long long sum_0;
    long long sum_1;
    for(int i=cnt; i>=0; i--){
        sum_0=0;
        sum_1=0;
        long long tmp=num+(long long) pow(2,i);
        if(tmp>K)continue;

        for(int j=0; j<N; j++){
            sum_0+=vec[j]^num;
            sum_1+=vec[j]^tmp;
        }
        if(sum_0<sum_1){
            if(flag)search_(num, vec, i-1, 0, que);
            num=tmp;
        }else{
            flag=0;
        }
    }

    if(sum_0 == 0){
        for(int i=0; i<N; i++){
            sum_0+=vec[i]^num;
        }
    }
    que.push(max(sum_0,sum_1));
}

int main(){
    cin >> N >> K;
    vector<long long> A(N,0);

    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    /*
    long long num=0;
    for(int i=40; i>=0; i--){
        long long sum_0=0;
        long long sum_1=0;
        long long tmp=num+(long long) pow(2,i);
        if(tmp>K)continue;

        for(int j=0; j<N; j++){
            sum_0+=A[j]^num;
            sum_1+=A[j]^tmp;
        }
        if(sum_0<sum_1){
            num=tmp;
        }
    }
    long long ans=0;
    for(int i=0; i<N; i++){
        ans+=A[i]^num;
    }
    */
    priority_queue<long long> que;
    search_(0, A, 40, 1, que);
    cout << que.top() << endl;

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

    long long ans=0;
    for(int i=0; i<=K; i++){
        long long tmp =0;
        for(int j=0; j<N; j++){
            tmp+=i^A[j];
        }
        if(tmp>ans){
            ans=tmp;
        }
    }
    cout <<  ans << endl;
    */

}

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

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    cout << t/a*b << endl;
    return 0;
}


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

    int a, b, d, r;
    double f;

    cin >> a >> b;

    d = a/b;
    r = a%b;

    cout << d << " " << r << " ";
    printf("%05f\n",(double)a / b);

    return 0;

}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
	cin>>a>>b;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<char>());
    if(a<b){
    	cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int n,f[100005][13],j,p=1,i,k,len;
char c[100005];
int main()
{
    scanf("%s",c+1);
    f[0][0]=1;
    len=strlen(c+1);
    for(i=1;i*2<=len;i++)
        std::swap(c[i],c[len-i+1]);
    for(i=1;c[i];i++)
    {
        if(c[i]=='?')
            for(j=0;j<=9;j++)
                for(k=0;k<13;k++)
                    f[i][k]=(f[i][k]+f[i-1][((k-j*p%13)%13+13)%13])%1000000007;
        else
            for(k=0;k<13;k++)
                f[i][k]=(f[i][k]+f[i-1][((k-(c[i]-'0')*p%13)%13+13)%13])%1000000007;
        p=p*10%13;
    }
    std::cout<<f[i-1][5];
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int x;
    cin >> x;

    vec goods = {100, 101, 102, 103, 104, 105};
    For(i, 0, 5) {
        For(j, i + 1, 5) {
            if (x >= goods[i] * goods[j]) {
                print(1);
                return 0;
            }

            for (int cnt = 0; goods[i] * cnt <= x; cnt++) {
                if ((x - goods[i] * cnt) % goods[j] == 0) {
                    print(1);
                    return 0;
                }
            }
        }
    }
    print(0);

    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=input()
Q=int(input())
K=[int(i) for i in input().split()]
def f(k):
    num=0
    L=[0,0,0]
    for i in range(N):
        if i-k>=0:
            if S[i-k]=='D':
                L[0]-=1
                L[2]-=L[1]
            elif S[i-k]=='M':
                L[1]-=1
        if S[i]=='D':
            L[0]+=1
        elif S[i]=='M':
            L[1]+=1
            L[2]+=L[0]
        elif S[i]=='C':
            num+=L[2]
        #print(i,':',L,':',num)
    return num
for k in K:
    print(f(k))

Measured memory_bytes: 62064
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        s: String,
        t: String,
    }

    let s_chars: Vec<char> = s.chars().collect();
    let t_chars: Vec<char> = t.chars().collect();

    let mut min = t_chars.len();

    for i in 0..s.len()-t.len()+1 {
        let tmp = s_chars[i..i+t_chars.len()].iter().map(|x| *x).collect::<Vec<char>>();
        // dbg!(&tmp);
        let mut cnt = 0;
        for i in 0..t.len() {
            if tmp[i] != t_chars[i] { cnt += 1 }
        }
        // dbg!(&tmp);
        min = std::cmp::min(min, cnt);
    } 

    println!("{}", min);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2212
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int n;
int main() {
  while (cin >> n) {
	if (n < 1200) puts("ABC");
	else if (n < 2800) puts("ARC");
	else puts("AGC");
  }
}


























Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

inline int getint()
{
/*	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;*/

	int x;
	cin >> x;

	return x;
}

const int MaxN = 100000;
const int MaxNV = MaxN * 2 + 1;
const int MaxNE = MaxNV + MaxN;

int n;
int r1, r2;

int parity[MaxNV + 1];

struct halfEdge
{
	int v;
	bool used;
	halfEdge *next;
};
halfEdge adj_pool[MaxNE * 2], *adj_tail = adj_pool;
halfEdge *adj[MaxNV + 1];

inline halfEdge *oppo(const halfEdge *e)
{
	return adj_pool + ((e - adj_pool) ^ 1);
}

inline void addEdge(const int &u, const int &v)
{
	adj_tail->v = v, adj_tail->next = adj[u];
	adj[u] = adj_tail++;
}

inline void build(int &root, int d)
{
	for (int u = 1; u <= n; ++u)
	{
		int v = getint();
		if (v == -1)
			root = u + d;
		else
		{
			int p = u + d, q = v + d;
			addEdge(p, q);
			addEdge(q, p);
		}
	}
}

void dfs(const int &u, const int &fa)
{
	parity[u] = 1;
	for (halfEdge *e = adj[u]; e; e = e->next)
		if (e->v != fa)
		{
			dfs(e->v, u);
			parity[u] ^= 1;
		}
}

int tour_n = 0;
int tour[MaxNE * 2 + 1];

void euler(const int &u)
{
	halfEdge *&e = adj[u];
	while (e)
	{
		if (e->used)
			e = e->next;
		else
		{
			e->used = oppo(e)->used = true;
			euler(e->v);
		}
	}

	tour[++tour_n] = u;
}

int lab[MaxN + 1];

int main()
{
	cin >> n;
	build(r1, 0), dfs(r1, 0);
	build(r2, n), dfs(r2, 0);

	for (int u = 1; u <= n; ++u)
		if (parity[u] != parity[u + n])
		{
			puts("IMPOSSIBLE");
			return 0;
		}

	puts("POSSIBLE");

	int sv = n * 2 + 1;
	addEdge(r1, sv), addEdge(sv, r1);
	addEdge(r2, sv), addEdge(sv, r2);
	for (int u = 1; u <= n; ++u)
		if (parity[u])
		{
			addEdge(u, u + n);
			addEdge(u + n, u);
		}

	euler(sv);

	for (int u = 1; u <= n; ++u)
		if (parity[u])
			lab[u] = -1;
	for (int i = 1; i < tour_n; ++i)
	{
		int u = tour[i];
		if (u <= n && tour[i + 1] == u + n)
			lab[u] = 1;
	}

	for (int u = 1; u <= n; ++u)
		printf("%d ", lab[u]);
	puts("");

	return 0;
}

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

/**
|||||||||||||       |||||     |||||    ||||||||||
||||||||||||||      |||||     |||||  |||||
|||||     |||||     |||||     |||||  |||||
||||||||||||||||    |||||||||||||||    ||||||||||
|||||||||||||||||   |||||||||||||||           |||||
|||||        |||||  |||||     |||||           |||||
|||||         ||||| |||||     |||||    ||||||||||
AHMED;HASSAN;SAEED;
*/

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<10;i++){
        if(n%i==0){
            for(int j=1;j<10;j++){
                if((n/i)==j){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main() {
	char a,b,c,d,e,f,g,h,i,j,k,l;
	cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j>>k>>l;
	cout<<a<<b<<c<<d<<" "<<e<<f<<g<<h<<i<<j<<k<<l<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define sz(a) (int)a.size()
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    #define REVERSE(v) reverse(ALL(v))
    #define display(x) trav(a,x) cout<<a<<" ";cout<<endl
    #define debug cerr<<"bhau"<<endl
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        std::cerr << name << " : " << arg1 << 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...);
    }
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}
    void amax(int &a,int b){a=max(a,b)%M; }
    void amin(int &a,int b){ a=min(a,b)%M;}
    void inc(int &a,int b){a=(a+b)%M;}
    void dec(int &a,int b){a=(a-b+M)%M;}


    
     int solve()
     {  
     	string s;cin>>s;
     	int n=s.size();int ans=0;
     	for(int i=0;2*i<n;i++){
     		if(s[i]!=s[n-i-1]) ans++;
     	}
     	cout<<ans;

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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

int main(){
  string S;
  cin >> S;
  long long ans = 0;
  long long Slen = S.size();
  long long Bpos = Slen-1;
  for (int i=Slen-1; i>=0; i--){
    if (S[i] == 'B'){
      ans += Bpos-i;
      Bpos--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640