akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long mod = 1000000007LL;

long long modInverse(long long a, long long m)
{
    long long m0 = m;
    long long y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        long long q = a / m;
        long long t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}

int main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin >> n;
	long long arr[n];
	for(int i = 0;i < n;i++) cin >> arr[i];
	
	long long fact = 1;
	for(long long i = 1;i < n;i++){
		fact *= i;
		fact %= mod;
	}
	long long ans = 0;
	
	long long accfact = 0;
	for(long long i = 1;i < n;i++){
		
		long long L = (i);
		L = modInverse(L, mod);
		L %= mod;
		L *= fact;
		L %= mod;
		accfact += L;
		accfact %= mod;
		
		ans += accfact * (arr[i]-arr[i-1]);
		ans %= mod;
	}
	
	cout << ans;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long K = scan.nextLong();
        if (K == 0) {
            System.out.println(2);
            System.out.println("1 1");
            return;
        }
        if (K == 1) {
            System.out.println(2);
            System.out.println("3 0");
            return;
        }
        long[] a = new long[50];
        for (int i = 0; i < 50; i++) {
            a[i] = Math.floorDiv(K, 50) + i;
        }
        long remain = K - Math.floorDiv(K, 50) * 50;
        for (long i = 0; i < remain; i++) {
            for (int j = 0; j < 50; j++) {
                if (j == 0) {
                    a[j] += 50;
                    continue;
                }
                a[j] -= 1;
            }
            Arrays.sort(a);
        }
        System.out.println(50);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 50; i++) {
            sb.append(a[i]);
            sb.append(" ");
        }
        System.out.println(sb.substring(0, sb.length()-1));
        return;
    }
}


Measured memory_bytes: 23252
from collections import deque

H, W = (int(x) for x in input().split())
C = [list(input()) for i in range(H)]
walk = [[1,0],[0,1],[-1,0],[0,-1]]
que = deque()
ans = -1
for sx in range(W):
    for sy in range(H):
        if C[sy][sx] == "#":
            continue
        dist = [[-1 for _ in range(W)] for _ in range(H)]
        
        que.append((sy,sx))
        dist[sy][sx] = 0
        while que:
            y,x = que.popleft()
            for tmp in walk:
                nx = x + tmp[0]
                ny = y + tmp[1]
                if 0 <= nx < W and 0 <= ny < H and C[ny][nx] == ".":
                    if dist[ny][nx] == -1:
                        dist[ny][nx] = dist[y][x] + 1
                        que.append((ny,nx))
        for tmp in dist:
            t = max(tmp)
            ans = max(ans,t)
print(ans)

Measured memory_bytes: 3316
dxys = [(-1,0), (1,0), (0,-1), (0,1)]

H, W = map(int, input().split())
Sss = ['#'*(W+2)] + ['#'+input()+'#' for _ in range(H)] + ['#'*(W+2)]

N = H*W
adjL = [[] for _ in range(N)]
for x in range(1, H+1):
    for y in range(1, W+1):
        if Sss[x][y] != '.': continue
        for dx, dy in dxys:
            x2, y2 = x+dx, y+dy
            if Sss[x2][y2] != '.': continue
            z = (x-1)*W + y-1
            z2 = (x2-1)*W + y2-1
            adjL[z].append(z2)

# 重みなしグラフの直径を求める
def getDiameterOfUnweightedGraph(adjList):
    numV = len(adjList)
    def bfs(vSt):
        costs = [-1] * numV
        costs[vSt] = cost = 0
        vs = [vSt]
        while vs:
            cost += 1
            v2s = []
            for v in vs:
                for v2 in adjList[v]:
                    if costs[v2] == -1:
                        costs[v2] = cost
                        v2s.append(v2)
            vs = v2s
        return cost - 1
    return max([bfs(vSt) for vSt in range(numV)])

maxDist = getDiameterOfUnweightedGraph(adjL)
print(maxDist)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(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 fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main(){
	fast_io;
	ll x;
	cin>>x;
	ll k = 100;
	ll cnt = 0;
	// trace(x)
	// cout<<x;
	while(k<x){
		k = (ll)(k*1.01);
		// trace(k)
		cnt++;
	}
	cout<<cnt;

	
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

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

long long a, b, c;

int main() {
    scanf("%lld%lld%lld", &a, &b, &c);
    if(c > a + b && (c - a - b)*(c - a - b) > 4*a*b) printf("Yes");
    else printf("No");
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length();

  auto get = [&](int l, int r) {
    long long res = 0;
    for (int i = l; i <= r; i++) {
      res = 10 * res + (s[i] - '0');
    }
    return res;
  };

  long long ans = 0, l, r;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      l = max(0, i - 1);
      r = max(0, n - 2 - j);
      ans += get(i, j) * (1 << (l + r));
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main()
{
	int n, m;
	cin >> n >> m;

	vector<int> xv(m);
	for (auto& x : xv) {
		cin >> x;
	}

	if (m <= n) {
		cout << 0 << endl;
	}
	else {

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

		vector<int> lv(m - 1);
		for (int i = 1; i < m; ++i)
		{
			lv[i-1] = xv[i] - xv[i - 1];
		}

		sort(lv.begin(), lv.end());
		int ret = 0;
		for (int i = 0; i < m - n; ++i) {
			ret += lv[i];
		}

		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


signed main(){ 
    int a,b; cin>>a>>b;

    cout<<(a*b)<<endl;
}  

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        map<ll, ll> mp;
        rep(i, 0, 4) {
                ll x;
                cin >> x;
                mp[x]++;
        }

        if (mp[1] == 1 and mp[9] == 1 and mp[7] == 1 and mp[4] == 1) {
                cout << "YES" << endl;
        } else {
                cout << "NO" << endl;
        }
}


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

int main(){
  char S;
  cin>>S;
  char ans;
  if(S=='A'){
    ans='T';
  }else if(S=='T'){
    ans='A';
  }else if(S=='G'){
    ans='C';
  }else if(S=='C'){
    ans='G';
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define UL 100000007
#define ret return
#define f(dt,i,a,b) for(dt i=a;i<b;i++)
#define pb push_back
#define sq(a) (a)*(a)
#define PI 3.14159

typedef vector<long long int> vlli;
typedef vector<int> vi;
typedef long long int lli;  //  e-18 to e18

int main(){
    fastIO();
    int n,m,tmp;
    cin>>n>>m;
    lli s=0;
    for(int i=0;i<m;i++){
        cin>>tmp;
        s+=tmp;
    }
    if(s>n) cout<<"-1\n";
    else    cout<<n-s<<"\n";
    ret 0; 
}       

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

int n,m,num,x[1000007],y[1000007],head,tail,st[1000007];
char s[1007][1007];
bool vis[1007][1007];

inline void pd(int a,int b,int k){
	if((a<0)||(a>=n)||(b<0)||(b>=m)) return;
	if(vis[a][b]) return;
	if(s[a][b]=='#') return;
	++tail;
	x[tail]=a; y[tail]=b;
	st[tail]=k;
	vis[a][b]=1;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<n;++i){
		scanf("%s",s[i]);
		for(int j=0;j<m;++j)
			if(s[i][j]=='.')
				++num;
	}
	if(s[0][0]=='#'||s[n-1][m-1]=='#') {printf("-1"); return 0;}
	vis[0][0]=1; ++tail; x[1]=0; y[1]=0; st[1]=1;
	int a,b;
	while(head<tail){
		++head;
		a=x[head]; b=y[head];
		if(a==n-1&&b==m-1){
			printf("%d",num-st[head]);
			return 0;
		}
		pd(a,b-1,st[head]+1);
		pd(a,b+1,st[head]+1);
		pd(a-1,b,st[head]+1);
		pd(a+1,b,st[head]+1);
	}
	printf("-1");
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; ll k;
    cin >> n >> k;
    ll r; ll s; ll p;
    cin >> r >> s >> p;
    string t; cin >> t;
    ll score = 0;
    REP(begin, k){
        ll idx = begin;
        char mae = 'x';
        while (true){
            if (idx >= n){
                break;
            }
            if (t[idx] == mae){
                mae = 'x';
            } else {
                mae = t[idx];
                if (t[idx] == 's'){
                    score += r;
                } else if (t[idx] == 'r'){
                    score += p;
                } else {
                    score += s;
                }
            }
            idx += k;
        }
    }
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 512
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var p = []
var j = []
p[0] = Number(lines[0]);
p[1] = Number(lines[1]);
p[2] = Number(lines[2]);
j[0] = Number(lines[3]);
j[1] = Number(lines[4]);

console.log(Math.min.apply(null, p) + Math.min.apply(null, j) - 50)

Measured memory_bytes: 15524
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 1001001001
#define longinf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,b) for(lld i=a;i<b;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,b) for(lld i=b-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<":"; }

//prime sieve if needed 
//prime factors of number
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[i]==1)
           prime[j]=i; 
      }
}

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

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/
void contest(); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld t=1; 


    rec(i,t) 
    {
     //google(i+1); 
      contest(); 
      cout<<endl; 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest()
{ 
  lld n; 
  cin>>n; 
  lld a[n]; 
  rec(i,n) 
  cin>>a[i]; 
  
  lld max=a[0]; 
  lld ans=0; 
  for(lld i=1;i<n;i++) 
  { 
   if(a[i]<max) 
    ans=ans+max-a[i]; 
    else
    max=a[i]; 
  } 
  cout<<ans; 
}

Measured memory_bytes: 5108
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>

using namespace std;
using Integer = long long;

#define INFTY (Integer)100'000'000'000

Integer input () {
  Integer x;
  cin >> x;
  return x;
}

int main () {
  Integer A, B, Q;
  cin >> A >> B >> Q;

  vector<Integer> s;
  vector<Integer> t;

  for (Integer i = 0; i < A; i++) s.push_back(input());
  for (Integer i = 0; i < B; i++) t.push_back(input());

  auto f_plus = [&](Integer p) {
    if (p > s.back()) return INFTY;
    return *lower_bound(s.begin(), s.end(), p);
  };
  auto g_plus = [&](Integer p) {
    if (p > t.back()) return INFTY;
    return *lower_bound(t.begin(), t.end(), p);
  };
  auto f_minus = [&](Integer p) {
    if (p < s.front()) return -INFTY;
    return *--upper_bound(s.begin(), s.end(), p);
  };
  auto g_minus = [&](Integer p) {
    if (p < t.front()) return -INFTY;
    return *--upper_bound(t.begin(), t.end(), p);
  };

  for (Integer i = 0; i < Q; i++) {
    Integer p = input();
    Integer fp = f_plus(p);
    Integer fm = f_minus(p);
    Integer gp = g_plus(p);
    Integer gm = g_minus(p);
    Integer df = min(abs(fp - p), abs(fm - p));
    Integer dg = min(abs(gp - p), abs(gm - p));
    Integer d1 = max(abs(fp - p), abs(gp - p));
    Integer d2 = max(abs(fm - p), abs(gm - p));
    Integer d3 = 2 * min(df, dg) + max(df, dg);
    Integer d = min(min(d1, d2), d3);

    cout << d << endl;
  }
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> A(n); rep(i, n) cin >> A[i];
  map<int, int> mp;
  rep(i, n) mp[A[i]]++;
  if(mp.size() > 2) {
    cout << "No\n";
  } else if(mp.size() == 2) {
    ll a = mp.begin()->first;
    ll b = mp.rbegin()->first;
    if(a == b-1) {
      ll nCol = b;
      ll na = mp[a];
      ll m = nCol-na;
      if(m <= 0) cout << "No\n";
      else if(mp[b] < 2*m) cout << "No\n";
      else cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  } else {
    ll a = mp.begin()->first;
    if(a == n-1) cout << "Yes\n";
    else if(n >= 2*a) cout << "Yes\n";
    else cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 8128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll x;
    cin >> x;

    ll happy = 0;

    int a = 0,b = 0;

    a = x /500;
    x -= a*500;
    b = x/5;
    happy = a * 1000 + b * 5;

    cout << happy << endl;
}

Measured memory_bytes: 256
#include<iostream>
 #include<cstdio>
 #include<cmath>
 #include<algorithm>
 //#include<cstring>
 using namespace std;
 struct knife
 {
     int ai;
     bool f;
 }m[2000018];
 inline int read()
 {
   int p=0,f=1;char c=getchar();
   while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
   while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
   return f*p;}
 int N,H,ans;
 bool cmp(knife x,knife y)
 {
     return x.ai>y.ai;//返回伤害最大的刀 
 }
 int main()
 {
     N=read(),H=read();
     for(int i=1;i<=N;i++)
         m[i].ai=read(),
      m[i+N].ai=read(),
         m[i+N].f=true;
     //我们把每把刀看作是可以无限扔的和只能扔一次的两把刀，存进去 
     sort(m+1,m+1+N*2,cmp);//排序，便于取 
     int ans=0;           //ans最终答案
     for(int i=1;i<=2*N;i++)//枚举2*N把刀 
        {
          if(m[i].f)//接下来贪心，如果刀可以飞出去就废掉，同时加上伤害 
            {ans++;
             H-=m[i].ai;}
          else
             {
              int u=H%m[i].ai;
              //如果碰到第一把无限次飞而且伤害最高的就无限砍 
              ans+=H/m[i].ai;
              //一直砍到没血，记录ans+ 
              if(u)ans++;
            H=-1;
             }
           if(H<=0)
             {printf("%d",ans);
              return 0;}
             //如果怪物没血了就输出 
        }
 }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll a,b,k;
    cin >> a>>b>>k;
    if(a<k){
      k-=a;
        a=0;
    }else{
        a-=k;
        k=0;
    }
   
    b-=k;

    if(0>b){
        b=0;
    }
    cout << a <<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(a[n-1])


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,t; cin >> n >> t;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll mx = a[n-1];
    ll bmx = 0;
    vl b(n-1);
    for(ll i=n-2; i>=0; i--){
        b[i] = mx - a[i];
        mx = max(mx,a[i]);
        bmx = max(bmx,b[i]);
    }
    ll ans = 0;
    rep(i,n-1){
        if(b[i] == bmx) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	vector<int> p(6);
	for(int i = 0;i < 6;i++){
		cin >> p[i];
	}
	sort(p.begin(),p.end()-2);
	int s = 0;
	for(int i = 3;i > 0;i--){
		s += p[i];
	}
	if(p[4] < p[5]){
		s += p[5];
	}
	else{s+= p[4];}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
int n;
  cin>>n;
  vector<string> s(n);
  ll ans=0;
  ll ba=0,a=0,b=0;
  rep(i,0,n) {
    cin>>s[i];
    ll m=s[i].size();
    rep(j,0,m-1){
      if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
    }
    if(s[i][0]=='B'&&s[i][m-1]=='A') ba++;
    else if(s[i][m-1]=='A') a++;
    else if(s[i][0]=='B') b++;
    
    
  }
  //cout<<ans<<" "<<a<<b<<ba<<endl;
  if(ba>1)ans+=ba-1;
  if(ba==0) ans+=min(a,b);
  else{
   a++;
    b++;
    if(a==1&&b==1) {
     a--;b--; 
    }
    ans+=min(a,b);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
struct node{
	int x,t;
	bool operator < (const node &b)const{
		int u,v;
		if(t>31||(1<<t)>x)u=0;
		if(b.t>31||(1<<b.t)>b.x)v=0;
		u=1.0*x/(1<<t);
		v=1.0*b.x/(1<<b.t);
		return u<v;
	}
};
priority_queue<struct node> Q;
int n,m;
int main(){
	int i,q;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		scanf("%d",&q);
		Q.push((node){q,0});
	}
	node head; 
	for(i=1;i<=m;i++){
		head=Q.top();
		Q.pop();
		head.t++;
		Q.push(head);
	}
	long long ans=0;
	while(!Q.empty()){
		head=Q.top();
		Q.pop();
		if(head.t>31||(1<<head.t)>head.x)ans+=0;
		else ans+=(long long)(1.0*head.x/(1<<head.t));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	ll A,B,K;
	cin>>A>>B>>K;
	if(A>K){
		A-=K;
	}
	else if(A==K){
		A=0;
	}
	else{
		B-=K-A;
		A=0;
		if(B<0) B=0;
	}
	cout<<A<<endl;
	cout<<B<<endl;
	return 0;
}


Measured memory_bytes: 3624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

A, B, C, D, E, F = MAP()

water = set()
sugar = [0]*(F+1)

for a in range(F//(100*A)+1):
	for b in range((F-100*a*A)//(100*B)+1):
		water.add(100*(a*A+b*B))

f = F//2
for c in range(f//C+1):
	for d in range((f-c*C)//D+1):
		sugar[c*C+d*D] = 1

sugar_acc = [0]*(F+1)
tmp = 0
for i in range(F//2+1):
	if sugar[i] == 1:
		tmp = i
	sugar_acc[i] = tmp

#print(water)
#print(sugar_acc)

ans = 0
den = 0
water_ans = 0
sugar_ans = 0
water = sorted(list(water))

for water_tmp in water[1:]:
	if E == 100:
		t = min(water_tmp, F-water_tmp)
	else:
		t = min(E*water_tmp//100, F-water_tmp)

	sugar_tmp = sugar_acc[t]
	if F < sugar_tmp + water_tmp:
		continue

	if sugar_tmp == 0:
		den_tmp = 0
	else:
		den_tmp = sugar_tmp/(sugar_tmp+water_tmp)

	#print(water_tmp, sugar_tmp, den_tmp, E*water_tmp//(100-E), F-water_tmp, t)
	if den <= den_tmp:
		den = den_tmp
		water_ans = water_tmp
		sugar_ans = sugar_tmp

print(water_ans+sugar_ans, sugar_ans)


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

int main(void){
	int l[10];
	char c;
	double ls, x1, t, v1, v2;
	while(1){
		ls = 0;
		for(int i = 0; i < 10; i++){
			cin >> l[i] >> c;
			ls += l[i];
		}
		cin >> v1 >> c >> v2;
		if(cin.eof())break;
		x1 = t = 0.0;
		for(int i = 0; i < 10; i++){
			x1 += l[i];
			t = x1 / v1;
			if(x1 + t * v2 >=ls){
				cout << ++i << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main() {
 string S;
cin >> S;
  int A=S.size();
 bool X=true;
  for(int i=0;i<A/2;i++){
  if(S.at(i)!=S.at(A-i-1)) X=false;
  }
  for(int i=0;i<A/4;i++){
  if(S.at(i)!=S.at(A/2-1-i)) X=false;
  }

 if(X==true) cout << "Yes" << endl;
  else cout << "No" << endl;  

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int >v,vi;
    for(int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=1;i<v.size();i++)
    {
        vi.push_back(v[i]-v[i-1]);
    }
   int s=0;
    sort(vi.begin(),vi.end());
    reverse(vi.begin(),vi.end());
    for(int i=n-1;i<vi.size();i++)
    {
        s+=vi[i];
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1400
package main

import "fmt"

func solve() {
	var s string
	fmt.Scan(&s)

	ans := ""
	for i, c := range s {
		if i%2 == 0 {
			ans += string(c)
		}
	}
	fmt.Println(ans)
}

func main() {
	solve()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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


Measured memory_bytes: 7808
<?php
fscanf(STDIN, "%d %d", $n, $l);
$array = array();
for($i = 0; $i < $n; $i++){
    fscanf(STDIN, "%s", $array[$i]);
}
sort($array);
for($j = 0; $j < $n; $j++){
    print $array[$j];
}

Measured memory_bytes: 4728
#include<iostream>
#include<vector>

int main(){
  int n;
  std::cin>>n;
  std::vector<int> a(n);
  for(auto &e:a)std::cin>>e;
  int g=0;
  for(auto e:a)g^=e;
  for(auto e:a)std::cout<<(g^e)<<"\n";
}


Measured memory_bytes: 4044
import sys
from collections import deque
input = sys.stdin.readline

S = input()
N = len(S)
S = S.replace('RL', 'X')
#S = S.replace('LR', 'Y')
costR = deque()
costL = deque()
count = 0
for i in range(len(S)):
    if S[i] == 'X':
        costR.append(count)
        count = 0
    if S[i] == 'R':
        count += 1
for i in range(len(S)-1,-1,-1):
    if S[i] == 'X':
        costL.appendleft(count)
        count = 0
    if S[i] == 'L':
        count += 1

ans = [0] * (N-1)
i = 0
j = 0
while i < N - 1:
    if S[j] == 'L' or S[j] == 'R':
        i += 1
    if S[j] == 'X':
        numL = costL.popleft()
        numR = costR.popleft()
        ans[i] += (numL+1)//2 + numR//2 + 1
        ans[i+1] += numL//2 + 1 + (numR+1)//2
        i += 2
    j += 1
print(*ans)

Measured memory_bytes: 7376
#include <stdio.h>
#include <unistd.h>

#define L 6
#define putchar_buf(X) do{ buf[point] = X; point++; }while(0)
#define putlong_buf(X) \
    do{ \
        long n=X; \
        char c[L]; \
        long i=L-1; \
        do{ c[i]=n%10+'0'; n/=10; i--; }while(n>0); \
        for(i++;i<L;i++){ putchar_buf(c[i]); } \
    }while(0)
#define puts_buf(X) \
    do { \
        for(size_t i=0; X[i]!='\0'; i++){ \
            putchar_buf(X[i]); \
        } \
        putchar_buf('\n'); \
    }while(0)

int data[1<<17];
char buf[819200];

static void solve(long a, long b, const size_t sp, const size_t ep, long mask, long common){
    if(ep-sp<=2){
        data[sp+0] = common|a;
        data[sp+1] = common|b;
    }else{
        const long t = a^b;
        const long d = t&(-t);
        mask ^= d;
        const long ad = a&d;
        const long bd = b&d;
        a &= mask;
        const long ab = a ^ (mask&(-mask));
        const size_t mp = (sp+ep)/2;
        //printf("%ld %ld %ld\n", aa, ab, bb);
        solve( a,     ab, sp, mp, mask, common|ad);
        solve(ab, b&mask, mp, ep, mask, common|bd);
        //for(size_t i=sp; i<mp; i++){ data[i] |= ad; }
        //for(size_t i=mp; i<ep; i++){ data[i] |= bd; }
    }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_parity(a) == __builtin_parity(b)){
        puts("NO");
    }else{
        const size_t m = 1<<n;
        solve(a, b, 0, m, 0xFFFFFFFFFFFFFFFF, 0);
        size_t point=0;
        puts_buf("YES");
        for(size_t i=0; i<m-1; i++){
            putlong_buf(data[i]);
            putchar_buf(' ');
        }
        putlong_buf(data[m-1]);
        putchar_buf('\n');
        write(1, buf, point);
    }
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<pair<ll,ll>>v;
	for(ll i=0;i<a;i++)
	{
		ll t;
		cin>>t;
		v.push_back({t,1});
	}
	for(ll i=0;i<b;i++)
	{
		ll t;
		cin>>t;
		v.push_back({t,2});
	}
	for(ll i=0;i<c;i++)
	{
		ll t;
		cin>>t;
		v.push_back({t,3});
	}
	sort(v.begin(),v.end());
	ll j=v.size()-1,x1=0,y1=0,c1=0,sum=0;
	for(ll i=0;i<v.size();i++)
	{
		if(x1+y1+c1==x+y)
			break;
		else if(v[j].second==1&&x1<x)
		{
			sum+=v[j].first;
			x1++;
		}
		else if(v[j].second==2&&y1<y)
		{
			sum+=v[j].first;
			y1++;
		}
		else if(v[j].second==3)
		{
			sum+=v[j].first;
			c1++;
		}
		j--;
	}
	cout<<sum<<endl;	
}


Measured memory_bytes: 10604
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007


signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	REP(i,0,n){
		cin>>a[i];
		if(a[i]%2==1){
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;

	return 0;
}

Measured memory_bytes: 1024
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

template <class T>
struct RangeSum {
  vector<T> vec;
  RangeSum() {}
  RangeSum(vector<T> elems) : vec(elems) {
    for (int i = 1; i < vec.size(); i++) { vec[i] += vec[i - 1]; }
  }
  T sum(int l, int r) {
    if (l > r) return T(0);
    if (l == 0)
      return vec[r];
    else
      return vec[r] - vec[l - 1];
  }
};

void solve() {
  int N;
  string s;
  cin >> N >> s;
  vector<int> r(N), g(N), b(N);
  for (int i = 0; i < N; i++) {
    if (s[i] == 'R') r[i]++;
    if (s[i] == 'G') g[i]++;
    if (s[i] == 'B') b[i]++;
  }
  RangeSum<int> R(r), G(g), B(b);
  ll ans = 0ll;
  for (int i = 0; i < N; i++) {
    for (int k = i + 2; k < N; k++) {
      if (s[i] == s[k]) continue;
      if (s[i] != 'R' && s[k] != 'R') ans += R.sum(i, k);
      if (s[i] != 'G' && s[k] != 'G') ans += G.sum(i, k);
      if (s[i] != 'B' && s[k] != 'B') ans += B.sum(i, k);
      if ((i + k) % 2 == 0) {
        int mid = (i + k) / 2;
        if (s[i] != s[mid] && s[k] != s[mid]) ans--;
      }
    }
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


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

using namespace std;

const int N = 401;

int n, a[N]; long long f[N][N], p[N];

long long P(int l, int r)
{
    return p[r] - p[l-1];
}

long long F (int l, int r)
{
    if (l >= r)
        return 0;
    if (f[l][r])
        return f[l][r];
    if (l + 1 == r)
    {
        f[l][r] = a[l] + a[r];
    }
    else
    {
        long long ans = 1e16;
        for (int k=l; k<r; k++)
        {
            ans = min(ans, F(l, k) + F(k+1, r));
        }
        f[l][r] = ans + P(l,r);
    }
    return f[l][r];
}

int main()
{
    cin >> n;
    for (int i=1; i<=n; i++)
    {
        cin >> a[i];
        p[i] = p[i-1] + a[i];
    }
    cout << F(1,n);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll t;
	cin>>n>>t;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<ll> max;
	int min=a[0];
	for(int i=1;i<n;i++){
		if(min>a[i])min=a[i];
		if(min!=0)max.push_back(a[i]-min);
	}
	sort(max.begin(),max.end(),greater<ll>());
	int res=0;
	for(int i=0;i<max.size();i++){
		int dekai;
		if(i==0)dekai=max[i];
		if(dekai!=max[i])break;
		res++;
	}
	cout<<res<<endl;
	return 0;
}
	

Measured memory_bytes: 2168
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define debug(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define debug(...) 
#define end_time()
#endif
 
 
#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
inline int gcd(int a, int b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); } 
inline int power(int x, int n, int m = LLONG_MAX)
    {  int res=1; x = (x%m + m)%m;
       while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
    }
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

void solve(){
	string s,t;
	cin>>s>>t;
	int n = s.length();
	int m = t.length();
	int ans = mod;
	for(int i = 0; i<=(n-m); i++){
		int cnt = 0;
		for(int j = 0; j<m; j++){
			if(s[i+j]!=t[j]) cnt++;
		}
		ans = min(ans,cnt);
	}
	cout<<ans<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	end_time();
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int l=0;
	rep(i,n){
		cin >> a[i];
		if(a[i]%2==0) l++;
	}
	cout << pow(3,n)-pow(2,l) << endl;
	return 0;
}



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

typedef long long int ll;
#define T int t,q; scanf("%d",&t); for(q=1;q<=t;q++)

int main(){
	ll n;
	cin >> n;
	string s;
	std::map<string, ll> mp;
	for(int i=0;i<n;i++){
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
		cout << "WA x " << mp["WA"] << endl;
			cout << "TLE x " << mp["TLE"] << endl;
				cout << "RE x " << mp["RE"] << endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}
        static void myerr(Object t){System.err.println(t);}
        static String getStr(){return sc.next();}
        static int getInt(){return sc.nextInt();}
        static Long getLong(){return sc.nextLong();}
        static boolean isNext(){return sc.hasNext();}
        public static void main(String[] args){
          long A = getLong();
          long B = getLong();
          long K = getLong();
          long tmpA = A - K;
          if(tmpA <= 0){
            K = K - A;
            A = 0;
          }else{
            A = A - K;
            K = 0;
          }
          long tmpB = B - K;
          if(tmpB <= 0){
            B = 0;
          }else{
            B = tmpB;
          }
          myout(A + " " + B);
          
        }
        //便利メソッド追加枠ここから

        //便利メソッド追加枠ここまで
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool is_t(int n, vector<vector<int>> &edges, vector<int> &oe, int from, int prev, int depth) {
    int noe = depth % 2;
    if (oe[from] == -1) {
        oe[from] = noe;
        for (int to : edges[from]) {
            if (to == prev) continue;
            bool b = is_t(n, edges, oe, to, from, depth + 1);
            if (!b) return false;
        }
        return true;
    } else {
        return oe[from] == noe;
    }
}

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

    vector<vector<int>> edges(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> oe(n, -1);
    bool ok = is_t(n, edges, oe, 0, -1, 0);

    if (ok) {
        ll b = count(oe.begin(), oe.end(), 0);
        ll w = count(oe.begin(), oe.end(), 1);
        cout << b * w - m << endl;
    } else {
        cout << n * (n - 1) / 2 - m << endl;
    }

}




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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int n,m;cin>>n>>m;
  vi v;
  fori(i,n){
    int va;cin>>va;
    v.pb(va);
  }
  sort(all(v));
  //for(auto it:v)cout<<it<<" ";
  //cout<<endl;
  vii v2;
  fori(i,m){
    int b,c;cin>>b>>c;
    v2.pb({c,b});
  }
  sort(all(v2));
  reverse(all(v2));
  //for(auto it:v2)cout<<it.ff<<" "<<it.ss<<endl;
  //now come from back pick 
  int pos=0;
  int ans=0;
  for(int i=0;i<m && pos<n;++i){
    int b=v2[i].ss;
    int c=v2[i].ff;
    if(v[pos]>=c)continue;
    //need to add another condition 
    auto it=lower_bound(v.begin()+pos,v.end(),c);
    int vpos=it-v.begin();
    vpos--;
    if(it!=v.end() && vpos-pos+1<=b){
      //means not full
  //    cout<<"it entered\n";
    //  cout<<c<<" c\n";
      //vpos--;
//      cout<<vpos<<" vpos \n";
      ans+=(vpos-pos+1)*c;
      pos=vpos+1;
      break;
    }
    if(pos+b-1>=n){
      ans+=((n-1)-(pos)+1)*c;
      pos=n;
      break;
    }
    ans+=b*c;
    pos+=b;
  }
  while(pos<n)ans+=v[pos],pos++;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	ll a, b, c, k;

	cin >> a >> b >> c >> k;

	if (k == 0) {
		cout << a - b << endl;
	}
	else {
		ll sum = 0;

		/*for (int i = 0; i < k; i++) {
			ll aa = a, bb = b, cc = c;
			a = bb + cc;
			b = aa + cc;
			c = aa + bb;
			cout << "a->" << a << " b->" << b << " c->" << c << " a - b->" << a - b << endl;
		}
		cout << endl;*/

		for (int i = 0; i < 1; i++) {
			ll aa = a, bb = b, cc = c;
			a = bb + cc;
			b = aa + cc;
			c = aa + bb;
			//cout << "a->" << a << " b->" << b << " c->" << c << " a - b->" << a - b << endl;
			sum = a - b;
		}

		if (k % 2 == 1) {
			cout << sum << endl;
		}
		else {
			cout << -sum << endl;
		}

	}


	  
	return 0;
}

Measured memory_bytes: 256
N,P = map(int,input().split())
Odd = sum([int(i)%2 for i in input().split()])
Even = N-Odd

def f_C(x,y):
    ans = 1
    for i in range(y):  
        ans *= x-i
    for i in range(y):  
        ans //= i+1
    return(ans)

ans = 2**Even
tmp = 0
for i in range(P,Odd+1,2):
    tmp += f_C(Odd,i)
print(ans*tmp)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
    int N, W;   cin >> N >> W;
    int *v = new int[N], *w = new int[N];
    for (int i = 0; i < N; i++)
        cin >> v[i] >> w[i];

    int *dp = new int[W+1];
    for (int i = 0; i <= W; i++)
        dp[i] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = W; j >= 0; j--) {
            if (j >= w[i])
                dp[j] = max(dp[j-w[i]]+v[i], dp[j]);
        }
    }

    cout << dp[W] << endl;

    return 0;
}


Measured memory_bytes: 3144