akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	s := []byte(readString())
	leftB := make([]int, n)
	rightW := make([]int, n)

	for i := 0; i < n; i++ {
		if s[i] == '#' {
			leftB[i]++
		}
		if i > 0 {
			leftB[i] += leftB[i-1]
		}
	}
	for i := n - 1; i >= 0; i-- {
		if s[i] == '.' {
			rightW[i]++
		}
		if i < n-1 {
			rightW[i] += rightW[i+1]
		}
	}

	ans := min(leftB[n-1], rightW[0])
	for i := 0; i < n; i++ {
		var x int
		if i > 0 {
			x += leftB[i-1]
		}
		if i < n-1 {
			x += rightW[i+1]
		}
		ans = min(ans, x)
	}
	println(ans)
}

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


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N,A;
    cin>>N>>A;
    cout<<N*N-A<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from math import *
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = [n for i in range(n + 1)]
DP[0] = 0
for cost in c:
	for i in range(cost, n + 1):
		DP[i] = min(DP[i], DP[i - cost] + 1)
print(DP[n])



Measured memory_bytes: 7696
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);

    REP(i, n)
    {
        cin >> v.at(i);
    }

    int cnt = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (v.at(i - 1) < v.at(i) && v.at(i) < v.at(i + 1))
            cnt++;
        else if (v.at(i - 1) > v.at(i) && v.at(i) > v.at(i + 1))
            cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;
typedef long long ll;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vec<T>>;

int main(){
    int N,M;
    cin >> N >> M;
    vec<ll> L(M),R(M),C(M);
    vvec<int> lid(N+1),rid(N+1);
    for(int i=0;i<M;i++){
        cin >> L[i] >> R[i] >> C[i];
        lid[L[i]].push_back(i);
        rid[R[i]].push_back(i);
    }
    const ll inf = 1e18;
    vec<ll> dp(N+1,inf);
    vec<ll> val(M+1,inf);
    dp[1] = 0;
    map<ll,int> m;
    m[0] = 1;
    auto dec = [&](ll x){
        assert(m.count(x));
        m[x]--;
        if(m[x]==0) m.erase(x);
    };
    for(int i=1;i<=N;i++){
        if(m.empty()){
            cout << -1 << endl;
            return 0;
        }
        dp[i] = m.begin()->first;
        for(auto& id:rid[i]){
            if(val[id]==inf) continue;
            dec(val[id]);
        }
        for(auto& id:lid[i]){
//            cerr << i << " " << dp[i]+C[id] << endl;
            m[dp[i]+C[id]]++;
            val[id] = dp[i]+C[id];
        }
        if(i==1) dec(0);
    }
    cout << (dp[N]!=inf? dp[N]:-1) << endl;
}

Measured memory_bytes: 14976
if __name__ == '__main__':
    b, c = map(int, input().split())
    s = input()
    flag=True
    list = [str(i) for i in range(10)]
    for i in range(b+c+1):
        s1= s[i]
        if i < b:
            if s1 not in list:
                flag=False
        elif i > b:
            if s1 not in list:
                flag=False
        else:
            if s1!="-":
                flag=False

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

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  int l=0, r= 999999999 /b +1;
  while(l < r-1){
    int mid = (l+r)/2;
    ll cnt = 0;
    for(int i=0; i<n; ++i){
      if(mid *b >= an[i]) continue;
      int x = an[i] - mid*b;
      cnt += (x-1) /(a-b) +1;
    }
    if(cnt > mid) l = mid;
    else r = mid;
  }
  cout << r << endl;
}

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

const int MX =  1000000007;

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(int n, int a){
    mint x = 1, y=1; //分子x 分母y

    rep(i,a) {
        y*=(i+1);
        x*=(n-i);
    }
    return x/y;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    cout << ans.x << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

int r,c;
int a[80][80],b[80][80];
int dp[80][80][160*80+1];


int f(int i,int j,int diff){
    if(i>=r || j>=c){
        if(abs(r-i)+abs(c-j)==1)return diff;
        return INF;
    }
    int &ans=dp[i][j][diff];
    if(ans!=-INF)return ans;
    ans=INF;
    
    int p,q;
    
    //a
    p=a[i][j]-b[i][j];
    if(diff+p<0)p=-(diff+p);
    else p=p+diff;
    
    //b
    q=b[i][j]-a[i][j];
    if(diff+q<0)q=-(diff+q);
    else q=q+diff;
    
    ans=min(ans,f(i+1,j,p));
    ans=min(ans,f(i,j+1,p));
    ans=min(ans,f(i+1,j,q));
    ans=min(ans,f(i,j+1,q));
    
    return ans;
}

signed main(){
    FASTER;
    cin>>r>>c;
    for(int i=0;i<r;i++)for(int j=0;j<c;j++)cin>>a[i][j];
    for(int i=0;i<r;i++)for(int j=0;j<c;j++)cin>>b[i][j];
    
    for(int i=0;i<80;i++)
        for(int j=0;j<80;j++)
            for(int k=0;k<160*80+1;k++)
                    dp[i][j][k]=-INF;
    
    cout<<f(0,0,0);
}



Measured memory_bytes: 643792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a[500010],b[500010],c[500010],n,q0,now,last[500010],ans[500010];
struct query
{
    int l,r,id,ans;
}q[500010];
bool cmp(const query &x,const query &y)
{
     return x.r<y.r;
}
struct node
{
          int s[2];
          int val,rd;
          int sz,cnt;
}t[500010];
int root,num;
int op,x;
void maintain(int rt)
{
     t[rt].sz=t[t[rt].s[0]].sz+t[t[rt].s[1]].sz+t[rt].cnt;
}
void rotate(int&rt,int d)
{
     int k=t[rt].s[d^1];
     t[rt].s[d^1]=t[k].s[d];
     t[k].s[d]=rt;
     maintain(rt);
     maintain(k);
     rt=k;
} 
void insert(int &rt,int v)
{
     if(rt==0)
     {
         rt=++num;
         t[rt].val=v;
         t[rt].s[0]=t[rt].s[1]=0;
         t[rt].rd=rand();
         t[rt].sz=t[rt].cnt=1;
         return;
     }
     if(t[rt].val==v)
     {
         t[rt].sz++;
         t[rt].cnt++;
         return;
     }
     if(v<t[rt].val) insert(t[rt].s[0],v);
     else insert(t[rt].s[1],v);
     if(t[t[rt].s[0]].rd>t[rt].rd) rotate(rt,1);
     if(t[t[rt].s[1]].rd>t[rt].rd) rotate(rt,0);
     maintain(rt);
}
void remove(int &rt,int v)
{
     if(t[rt].val==v)
     {
          if(t[rt].cnt>1)
          {
              t[rt].sz--;
              t[rt].cnt--;
              return;
          } 
          if(t[rt].s[0]*t[rt].s[1]==0)
          {
              rt=t[rt].s[0]+t[rt].s[1];
              return;
          }
          if(t[t[rt].s[0]].rd>t[t[rt].s[1]].rd)
          {
              rotate(rt,1);
              remove(t[rt].s[1],v);
              maintain(rt);
              return;
          }
          else
          {
              rotate(rt,0);
              remove(t[rt].s[0],v);
              maintain(rt);
              return;
          }
     }
     if(v<t[rt].val) remove(t[rt].s[0],v);
     else remove(t[rt].s[1],v);
     maintain(rt);
}
int rankl(int rt,int v)
{
    if(rt==0) return 0;
    if(t[rt].val==v) return t[t[rt].s[0]].sz+t[rt].cnt;
    if(v<t[rt].val) return rankl(t[rt].s[0],v);
    else return rankl(t[rt].s[1],v)+t[t[rt].s[0]].sz+t[rt].cnt;
}
int main()
{
    int i;
    srand(0);
    cin>>n>>q0;
    for(i=1;i<=n;i++) 
    {
        scanf("%d",&a[i]);
        c[i]=c[i-1];
        if(b[a[i]]==0) c[i]++;
        b[a[i]]++;
    }
    for(i=1;i<=q0;i++) 
    {
        scanf("%d%d",&q[i].l,&q[i].r);
        q[i].id=i;
    }
    sort(q+1,q+q0+1,cmp);
    //for(i=1;i<=n;i++) cout<<c[i]<<endl;
    for(i=1;i<=q0;i++)
    {
        while(now<q[i].r)
        {
            now++;
            if(last[a[now]]!=0) remove(root,last[a[now]]);
            last[a[now]]=now;
            insert(root,now);
        }
        ans[q[i].id]=c[q[i].r]-rankl(root,q[i].l-1);
    }
    for(i=1;i<=q0;i++) printf("%d\n",ans[i]);
    system("pause");
}


Measured memory_bytes: 33340
n,m=map(int, input().split())
alist=[]
blist=[]
for i in range(m):
  a,b=map(int, input().split())
  alist.append(a)
  blist.append(b)
maxa=max(alist)
minb=min(blist)
if minb>=maxa:
  print(minb-maxa+1)
else:
  print(0)

Measured memory_bytes: 16688
n=int(input())
a= list(map(int, input().split()))
b=[0]*100001

for i in range(n):
    b[a[i]]+=1
ans=0
for i in range(99999):
    count=b[i]+b[i+1]+b[i+2]
    ans=max(count,ans)
print(ans)

Measured memory_bytes: 52908
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n,m = readInts()

print(comb(n,2)+comb(m,2))

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
# define ll long long int



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,i,ans;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		if(i==0){
			ans=a;
			continue;
		}
		ans=__gcd(ans,a);
	}cout<<ans;
}


Measured memory_bytes: 256
N,X,Y=map(int,input().split())

dp=[[0]*N for i in range(N)]
dist=[0]*N
X-=1
Y-=1
for i in range(N):
  for j in range(N):
    if not i<j:continue
    dp[i][j]=min(j-i,abs(j-Y)+1+abs(X-i))
    dist[dp[i][j]]+=1

for i in dist[1:]:
  print(i)

Measured memory_bytes: 88960
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>

using namespace std;
int n,a[500][500];
long long sol;
string s;
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)scanf("%d",&a[i][j]);

    for (int i=1;i<=n;i++)
    {
        for (int j=i+1;j<=n;j++)
        {
            bool o = true;
            for (int z = 1;z<=n;z++)
            {
                if (z==i||z==j)continue;
               if (a[i][z]+a[z][j]<a[i][j]){cout<<-1<<endl;return 0;}
               if (a[i][z]+a[z][j]==a[i][j])o = false;
            }

            if (o)sol+=1LL*a[i][j];
        }
    }
    cout<<sol<<endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int n, x, t; cin >> n >> x >> t;
    int ans = (n + (x-1))/x;
    cout << ans*t << endl;
    return 0;
}

Measured memory_bytes: 3608
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int q,l,r,a[100005]={};
  bool f[100005]={};
  scanf("%d",&q);
  for(int i=2; i<=100000; i++) {
    if(!f[i]) {
      for(int j=i*2; j<=100000; j+=i) {
        f[j]=true;
      }
    }
  }
  for(int i=3; i<=100000; i+=2) {
    if(!f[i]&&!f[(i+1)/2]) {
      a[i]++;
    }
  }
  for(int i=3; i<=100000; i++) {
    a[i]+=a[i-1];
  }
  while(q--) {
    scanf("%d%d",&l,&r);
    printf("%d\n",a[r]-a[l-1]);    
  }
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {

    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int num = Integer.parseInt(sc.next());
      String str = sc.next();
      
      int res = 0;
      for (int len = num; len > 0; len--) {
        int[] dp = new int[num];
        for (int i = num - len - 1; i >= 0; i--) {
          if (str.charAt(i) == str.charAt(i + len)) {
          	dp[i] = Math.min(dp[i + 1] + 1, len);
            res = Math.max(res, dp[i]);
          } else {
          	dp[i] = 0;
          }
        }
      }
      
      System.out.println(res);
    }
}

Measured memory_bytes: 63800
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) { 
                System.out.printf("%d %d %d\n", a, c, b);
            } else { 
                System.out.printf("%d %d %d\n", c, a, b);
            }
        }
        else{
            if(a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c){
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
    }
}


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

void change(int *x, int *y)
{
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

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

	if(a > b)	change(&a, &b);
	if(b > c)	change(&b, &c);
	if(a > b)	change(&a, &b);

	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 1164
l,r = gets.split.map(&:to_i)

if r-l >= 2019
  puts 0
  exit
end

r%=2019
l%=2019

ans = 2500

l.upto r do |i|
  (i+1).upto r do |j|
    ans = [ans, i*j%2019].min
  end
end

puts ans

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int n;
int w[302];
bool can[302][302];
int main() {
    //cout.precision(10);
    while(true) {
        cin >> n;
        if(n == 0) break;
        for(int i = 1; i <= n; i++) {
            cin >> w[i];
        }
        for(int i = 0; i <= n + 1; i++) {
            for(int j = 0; j <= n + 1; j++) {
                can[i][j] = false;
            }
            can[i][i] = true;
        }
        for(int delta = 2; delta <= n; delta++) {
            for(int from = 1; from + delta <= n + 1; from++) {
                int to = from + delta;
                for(int mid = from; mid <= to; mid++) {
                    if(can[from][mid] && can[mid][to]) can[from][to] = true;
                }
                if(can[from + 1][to - 1]) {
                    if(abs(w[from] - w[to - 1]) <= 1) can[from][to] = true;
                }
                //if(can[from][to]) cout << from << " " << to << endl;
            }
        }
        int dp[305];
        for(int i = 0; i <= 304; i++) {
            dp[i] = 0;
        }
        for(int now = 1; now <= n; now++) {
            dp[now] = dp[now - 1];
            for(int from = 1; from <= now; from++) {
                if(can[from][now + 1]) {
                    dp[now] = max(dp[now], dp[from - 1] + (now + 1 - from));
                }
            }
            //cout << now << " " << dp[now] << endl;
        }
        cout << max(dp[n], dp[n - 1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
#1_7_D
y = []
c = 0
n , m , l = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [list(map(int,input().split())) for i in range(m)]

for t in range(n):
    for u in range(l):
        x = 0

        for s in range(m):
            x += a[t][s] * b[s][u]
        c += 1
        if c%l == 0:
            print(x)
        else:
            print(x,'',end='')


Measured memory_bytes: 6560
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;

double K;

double re(double i){
  double k=0;
  while(i<K){
    i=i*2.0;
    k+=1.0;
  }
  return k;
}

int main(){
  double N;
  double sum=0;
  cin>>N>>K;
  double a;
  for(double i=1.0;i<=N;i+=1.0){
    a=1/N;
    if(re(i)!=0)a=a*pow(0.5,re(i));
    sum+=a;
  }
  printf("%.16f", sum);
}


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

using namespace std;

bool isPrime(int x) {
	if (x <= 1) return false;
	if (x == 2) return true;
	if (x % 2 == 0) return false;
	for (int i = 3; i*i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return true;
}

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

	int ans = 0;
	while (N--) {
		int x;
		cin >> x;
		ans += isPrime(x);
	}

	cout << ans << endl;
}


Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top=0,ope[100];

int pop(void);
void push(int);

int main(){
  int num1,num2,result;
  char data[1000000];

  while(1){
    if(scanf("%s",data)==EOF) break;
    
    if(data[0]=='+'){
      num1=pop();
      num2=pop();
      result=num1+num2;
      push(result);
    }

    else if(data[0]=='-'){
      num2=pop();
      num1=pop();
      result=num1-num2;
      push(result);
    }

    else if(data[0]=='*'){
      num1=pop();
      num2=pop();
      result=num1*num2;
      push(result);
    }

    else{
      num1=atoi(data);
      push(num1);
    }

  }
  printf("%d\n",pop());
  
  return 0;

}
  
int pop(){
  top--;
  return ope[top+1];
}

void push(int x){
  top++;
  ope[top]=x;
}



Measured memory_bytes: 2104
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] arr = new int [n];
		for(int i=0;i<n;i++)
			arr[i]=sc.nextInt();
		Arrays.sort(arr);
		int x = n/2;
		int y = n/2-1;
		x = arr[x];
		y=arr[y];
		
		System.out.println(x-y);
		

	}

}


Measured memory_bytes: 52480
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, int n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7
const double PI = 3.1415926535897932384626;

/*********** variables ************/
int X;
/**********************************/


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

    int x = 0;
    for(int i=0; ; i++) {
        if(x >= X) {
            cout << i << endl;
            return 0;
        }
        x += i+1;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long ans=0;
    cin>>s;
    for(long long i=0;i<s.length();i++)
    {
        ans+=(s[i]-'0');
    }
    int m = stoi(s); 
  if(m%ans==0)
  {
      cout<<"Yes"<<"\n";
  }
  else
  {
      cout<<"No"<<"\n";
  }
    return 0;
}


Measured memory_bytes: 3624
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
usize n;
cin >> n;
vector<i64> a(n);
rep(i,n)cin >> a[i];
sort(all(a));
i64 ans = a[n - 1] - a[0];
for(i32 i = 0,j = n - 2; i + 1 < j; i++,j--)ans += a[j] - a[i];
for(i32 i = 1,j = n - 1; i + 1 < j; i++,j--)ans += a[j] - a[i];
if(n & 1) ans += max(a[n / 2 + 1] - a[n / 2], a[n / 2] - a[n / 2 - 1]);
cout << ans << endl;
}

Measured memory_bytes: 3972
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    int32_t Q;
    bool rev = false;
    std::list<char> S;
    std::string tmp;
    in >> tmp;
    S.assign(all_range(tmp));
    in >> Q;
    while (Q--)
    {
        int type;
        in >> type;
        if (type == 1) {
            rev = !rev;
        }
        else
        {
            in >> type >> tmp;
            if ((type == 1) == rev) {
                S.push_back(tmp[0]);
            }
            else {
                S.push_front(tmp[0]);
            }
        }
    }
    tmp.assign(all_range(S));
    if (rev) {
        std::reverse(all_range(tmp));
    }
    out << tmp << endl;

    return 0;
}
#endif


Measured memory_bytes: 10304
A, B, N = map(int,input().split())

if N >= B:
    x = B -1
else:
    x = N
MAX = 0
# for i in range(1,N+1):
#     MAX = max(MAX, (A*i)//B - A*(i//B))
# print(MAX)


ans = (A*x)//B - A*(x//B)
print(ans)

Measured memory_bytes: 9076
#include<iostream>

using namespace std;

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

    for (int i = 0; i < 3;i++){
        if(s[i]=='1'){
            s[i] = '9';
        }else{
            s[i] = '1';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000
int n,m[101][101],p[101];
void dp();

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i-1]>>p[i];
  dp();
  cout<<m[1][n]<<endl;
  return 0;
}
void dp(){
  for(int i=0;i<n-1;i++)
    for(int j=1;j<n-i;j++){
     int a=j+i+1;
     m[j][a]=INF;
     for(int k=j;k<a;k++){
       int b=m[j][k]+m[k+1][a]+p[j-2]*p[k-1]*p[a-1];
       if(m[j][a]>b)m[j][a]=b;
     }
    } 
}



Measured memory_bytes: 3140
//#include <bits/stdc++.h>
#include <iostream>
#include <cstring>

using namespace std;
int a,b;
string s;

int main(){
    cin>>a>>s>>b;

    if(s=="+"){
      cout<<a+b<<endl;
    }else{
      cout<<a-b<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define X first
#define Y second

const int maxn=131072+233;

int n,fa[maxn],lc[maxn],rc[maxn],w[maxn];
LL mid;
vector<pair<LL,LL> > S[maxn],t1,t2;

void dfs(int u)
{
	if (!lc[u])
	{
		S[u].push_back(make_pair(w[u],w[u]));
		return;
	}
	dfs(lc[u]); dfs(rc[u]);

	int i,j=-1,m=S[rc[u]].size()-1;
	LL last;
	t1.clear(); t2.clear();
	for (i=0;i<(int)S[lc[u]].size();i++)
	{
		bool flag=0;
		while (j<m&&S[lc[u]][i].Y+S[rc[u]][j+1].X<=mid) j++,flag=1;
		if (flag)
		{
			t1.push_back(make_pair(S[lc[u]][i].X+w[u],S[rc[u]][j].Y+w[u]));
			t2.push_back(make_pair(S[rc[u]][j].Y+w[u],S[lc[u]][i].X+w[u]));
		}
	}
	for (last=1e18,m=t1.size(),i=0,j=m-1;i<m||j>=0;)
	{
		bool flag=i==m?0:j==-1?1:t1[i]<t2[j];
		pair<LL,LL> pr=flag?t1[i++]:t2[j--];
		if (last>pr.Y) last=pr.Y,S[u].push_back(pr);
	}
}

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i;
	LL L=0,R=0;
	scanf("%d",&n);
	for (i=2;i<=n;i++)
	{
		scanf("%d%d",&fa[i],&w[i]);
		if (lc[fa[i]]) rc[fa[i]]=i;
		else lc[fa[i]]=i;
		R+=w[i];
	}
	while (L<=R)
	{
		mid=(L+R)>>1;
		for (i=1;i<=n;i++) S[i].clear();
		dfs(1);
		S[1].size()?R=mid-1:L=mid+1;
	}
	printf("%lld\n",L);
}


Measured memory_bytes: 29144
# C
N, A, B, C = map(int, input().split())
l_list = [0]*N
for i in range(N):
    l_list[i] = int(input())
    
res = 10000000

for i in range(4**N):
    r = 0
    r_list = [0]*4
    c_list = [0]*4
    
    for j in range(N):
        k = (i // (4**j)) % 4
        r_list[k] += l_list[j]
        c_list[k] += 1
        
    if c_list[0]*c_list[1]*c_list[2] != 0:
        r += 10*(c_list[0] - 1)
        r += 10*(c_list[1] - 1)
        r += 10*(c_list[2] - 1)
        CC, BB, AA = sorted(r_list[:3])
        r += abs(CC-C)
        r += abs(BB-B)
        r += abs(AA-A)
        res = min(res, r)
    
print(res)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 21:41:22 2019

@author: avina
"""


d = 380000.0 
sums = 0
n = int(input())
for i in range(n):
  a,b = input().strip().split()
  if b == 'JPY':
    sums += float(a)
  else:
    sums += d*float(a)
print(sums)

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

int a[N];
vi g[1000];

signed main() {
   #ifdef Flash
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   string s;
   cin >> s;
   for (int i = 0; i < s.size(); i++) {
        a[s[i]]++;
        g[s[i]].pb(i);
   }
   int ans = INF;
   for (char c  = 'a'; c <= 'z'; c++) {
        if (g[c].size() == 0) continue;
        g[c].pb(s.size());
        reverse(g[c].begin(), g[c].end());
        g[c].pb(-1);
        int kol = 0;
        while (g[c].size() > 1) {
              int k = g[c].back();
              g[c].pop_back();
              kol = max(g[c].back() - k - 1, kol);
        }
        ans = min(ans, kol);
   }
   cout << ans;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var X int
	fmt.Sscanf(scanner.Text(), "%d", &X)

	if X == 1 {
		fmt.Println("Hello World")
	} else {
		arr := make([]int, 2)
		for i := 0; i < 2; i++ {
			scanner.Scan()
			fmt.Sscanf(scanner.Text(), "%d", &arr[i])
		}
		fmt.Println(arr[0] + arr[1])
	}

}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main(){
  int n;
  int cnt=0;
  int max=0;
  cin >> n;
  
  int h[n];
  for(int i =0; i < n; i++) cin >> h[i];
 
  for(int j = 0; j < n-1; j++)
  {
    if(h[j] >= h[j+1]) ++cnt;
    else cnt = 0;
    
    if(cnt > max) max = cnt;
  }
 
  cout << max << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	if (n==m)
		cout<<"Yes\n";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int H,W;
int h[1500],w[1500];
 
void solve(){
    for(int i=0;i<H;i++)scanf("%d",&h[i]);
    for(int i=0;i<W;i++)scanf("%d",&w[i]);
 
    int mxh=accumulate(h,h+H,0);
    int mxw=accumulate(w,w+W,0);
 
    vector<int>th(mxh+1,0),tw(mxw+1,0);
 
    for(int i=0;i<H;i++){
        int sum=0;
        for(int j=i;j<H;j++){
            sum+=h[j];
            th[sum]++;
        }
    }
    for(int i=0;i<W;i++){
        int sum=0;
        for(int j=i;j<W;j++){
            sum+=w[j];
            tw[sum]++;
        }
    }
    long long ans=0;
    for(int i=1;i<=min(mxh,mxw);i++){
        ans+=(long long)th[i]*tw[i];
    }
 
    printf("%d\n",ans);
}
int main(){
    while(scanf("%d%d",&H,&W),H||W)solve();
}


Measured memory_bytes: 7008
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


int main(){
    LL a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

// intは極力使わない
// vectorのboundary checkに注意
// 同名のローカルスコープ変数に注意


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,digit,count = 0;
    back:
    while(~scanf("%d %d",&a,&b)){
        count = a + b;
        for(int i=0; ; i++){
            count = count/10;
            digit = i;
            if(count < 1){
                printf("%d\n",digit+1);
                goto back;
            }
        }
    }
    return 0;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    ll n, m;
    cin >> n >> m;

    ll sum = 0;
    if(2 <= m && 1 <= n){
        ll c_n = n;
        sum += min(c_n, m / 2);
        n -= min(c_n, m / 2);
        m -= min(c_n, m / 2) * 2;
    }
    sum += m / 4;

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n, x, i, r, z, num, tmp = 0;
    for(;scanf("%d%d", &n, &x); tmp = 0){
        if( n == 0 && x == 0 ){
            break;}
        for( i = 1; i <= n; i++ ){
            for( r = i+1 ; r <= n; r++ ){
                for( z = r+1; z <= n; z++ ){
                    num = i + r + z;
                    if( num == x ){
                        tmp += 1;
}}}}
        printf("%d\n",tmp);}
return 0;}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int A, B, C;

void solve() {
	
	cin >> A >> B >> C;

	ll ans = B;

	if (C <= B) ans += C;
	else {
		ans += B;
		C -= B;
		if (C <= A) ans += C;
		else {
			ans += A + 1;
		}
	}

	cout << ans << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

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

int main()
{
	long long a,b,c,d;
  	cin>>a>>b>>c>>d;
  	while(a>0 && c>0)
    {
      	c-=b;
      	if(c<=0)
        {
          cout<<"Yes\n";
          return 0;
        }
 		a-=d;
      	if(a<=0)
        {
          cout<<"No\n";
          return 0;
        }
    }  
return 0;  
}  

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

class Combination {
public:
    const int MAX = 2010000;
    const int MOD = 1000000007;
    vector<long long> fac, finv, inv;
    Combination();
    long long operator()(int n, int k);
} nck;

inline Combination::Combination() {
    fac.resize(MAX);
    finv.resize(MAX);
    inv.resize(MAX);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

inline long long Combination::operator()(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int64 r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    r1++, r2++;
    c1--;
    int64 a = 0, b = 0;
    for(int64 i = r1; i <= r2; ++i) {
        a += nck(c2 + i, c2);
        b += nck(c1 + i, c1);
        a %= MOD;
        b %= MOD;
    }
    a = (a - b) + MOD;
    a %= MOD;
    cout << a << '\n';
    return 0;
}


Measured memory_bytes: 47360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll N = 3e5+5;
vector<int>adj[N],adj1[N];
vector<pair<int,int>>v;
map<pair<int,int>,int>mp;
bool visited[N];
int height[N],val[N],grid[55][55];



void solve(){
 string s,t;
 cin>>s>>t;
 int c=INT_MAX;
 for(int i=0;i<=s.size()-t.size();i++){
    int ans=0;
    for(int j=0;j<t.size();j++){
        if(s[i+j]!=t[j])ans++;
    }
    c=min(c,ans);
 }
 cout<<c;
}
int main(){
    int t=1;
    //cin>>t;
   while(t--)solve();
}


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(a >= k){
        ans = k;
        k = 0;
    }
    else{
        ans += a;
        k -= a;
    }
    k -= b;
    if(k >= 0){
        ans -= k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define maxn 10005
#define maxm 120005
typedef long long ll;
using namespace std; 

int x, y, z;
multiset<string> Q;

inline int read(){
	int x = 0, f = 1;char ch = getchar();
	while(ch > '9' || ch < '0'){if(ch == '-') f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch -'0';ch = getchar();}
	return x * f;
}

int main(){
	int i,j,u,v,f;
	x = read(), y = read(), z = read();
	for(i = 1;i <= x;i++) Q.insert("a");
	for(i = 1;i <= y;i++) Q.insert("b");
	for(i = 1;i <= z;i++) Q.insert("c");
	while(Q.size() > 1){
		string a = *Q.begin(), b = *Q.rbegin();
		Q.erase(Q.begin()), Q.erase(Q.find(b));
		Q.insert(a + b);
	}
	cout<<*Q.begin();
}

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

int a[100000][3];

int f[100000][3];

int main()
{
    int n;
    cin>>n;
    for(int i = 0; i < n ; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cin>>a[i][j];
        }
    }

    f[0][0] = a[0][0];
    f[0][1] = a[0][1];
    f[0][2] = a[0][2];

    for(int day = 1; day < n ;day++)
    {
        f[day][0] = a[day][0] + max(f[day - 1][1],f[day-1][2]);
        f[day][1] = a[day][1] + max(f[day - 1][0],f[day-1][2]);
        f[day][2] = a[day][2] + max(f[day - 1][0],f[day-1][1]);
    }

    int answer = max({f[n - 1][0],f[n - 1][1],f[n - 1][2]});
    cout<<answer<<endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n, m;
        cin >> n >> m;
        map<ll, ll> mp;
        rep(i, n) {
            ll a = inl();
            mp[a]++;
        }
        rep(i, m) {
            ll b, c;
            cin >> b >> c;
            mp[c] += b;
        }

        ll ans = 0;
        for (auto i = mp.rbegin(); i != mp.rend(); ++i) {
            ans += min(n, i->second) * i->first;
            n -= min(n, i->second);
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 12800
n = int(input())

num = []
max = -9999999999999
minv = 10000000000

for i in range(n):
    num.append(int(input()))

    if i >= 1:
        if max <= num[i] - minv:
            max = num[i] - minv

    if num[i] <= minv:
         minv = num[i]

print(max)


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

int main() {
    
    int R,G,B,N;
    cin>>R>>G>>B>>N;
    int count=0;
    for(int i=0;i<=N/R;i++){
        for(int j=0;j<=(N-i*R)/G;j++){
            if(((N-i*R-j*G)%B)==0) count++;
        }
    }
    cout<<count<<endl;
}
   


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

void main() {
	auto limit = readln.chomp.split(' ').map!(to!long).array[2];
	auto booksA = readln.chomp.split(' ').map!(to!long).array;
	auto booksB = readln.chomp.split(' ').map!(to!long).array;

	long count;
	long time;
	size_t endA = booksA.length;

	foreach (size_t i, e;booksA) {
		if (time + e <= limit) {
			time += e;
			++count;
		} else {
			endA = i;
			break;
		}
	}

	size_t endB = booksB.length;

	foreach (size_t i, e;booksB) {
		if (time + e <= limit) {
			time += e;
			++count;
		} else {
			endB = i;
			break;
		}
	}

	auto answer = count;

	foreach_reverse (i;0..endA) {
		--count;
		time -= booksA[i];

		while (endB < booksB.length && time + booksB[endB] <= limit) {
			time += booksB[endB];
			++endB;
			++count;
		}
		if (count > answer) {
			answer = count;
		}
	}

	answer.writeln;
}


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

    using namespace std;
    #define ll long long
    #define rep(i,a,n) for(int i=a;i<n;i++)
    #define pb push_back
    #define in insert
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db  double
    #define sc scanf
    #define pf printf
    const ll MAX=10e5+8;
    //ll d[MAX],h[MAX];
    const double pi=3.14159265358979323846;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
   
      bool isPrime(ll n) 
{  
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6){ 
        if (n % i == 0 || n % (i + 2) == 0){ 
            return false; 
        }
    }
    return true; 
} 
bool pdrome(string s){
    ll n = s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll t,ans=0;
vector<ll>v;

  
  
  
    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
      int n,a;
      cin>>n>>a;
      cout<<n*a;
    return 0;
}
    	

Measured memory_bytes: 3652
class Stack:
    def __init__(self):
        self.top = 0
        self.length = 0
        self.S = []
        
    def initialize(self):
        self.top = 0
        
    def isEmpty(self):
        return self.top == 0
        
    def push(self, x):

        #self.S[self.top] = x
        #self.S.append(x)
        #self.S.insert(self.top, x)
        if self.length > self.top:
            self.S[self.top] = x
        else:
            self.S.append(x)
        self.top += 1      
        self.length = len(self.S)     
            
    def pop(self):
        if self.isEmpty():
            print("error")
            return
        self.top -= 1
        return self.S[self.top] 
        
        
        
"""
stack = Stack()
stack.push(1)
stack.push(2)
stack.push(3)
result = stack.pop()
"""

result = 0
a = 0
b = 0
stack = Stack()
A = list(input().split())
N = len(A)
for i in range(N):
    if A[i] == "+": 
        a = stack.pop()
        b = stack.pop()
        stack.push(a + b)
        
    elif A[i] == "-": 
        a = stack.pop()
        b = stack.pop()
        stack.push(-a + b)
        
    elif A[i] == "*": 
        a = stack.pop()
        b = stack.pop()
        stack.push(a * b)
    
    else:
        stack.push(int(A[i]))
    
    

print(stack.S[stack.top-1])








Measured memory_bytes: 5624