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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define INF 1e15
struct edge{ll to; double cost;};
typedef pair<ll,ll> P;
typedef pair<double,ll> PDL;
typedef pair<PDL,int> State;
struct graph{
  ll V;
  vector<vector<edge> > G;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
  }

  void add_edge(ll s, ll t, double cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  double dijkstra(ll s, ll g,VI& t){
    vector<vector<double>> dp(V,vector<double>(1<<t.size(),INF));
    dp[s][0] = 0.;
    priority_queue<State,vector<State>, greater<State> > que;
    que.push(State(PDL(0.,0),s));
    while(!que.empty()){
      State p = que.top(); que.pop();
      double current_dist = p.first.first;
      int current_node = p.second;
      ll current_thicket = p.first.second;

      if(dp[current_node][current_thicket]< current_dist) continue;
      for(auto e : G[current_node]){
        rep(i,t.size()){
          if( !!(current_thicket & (1<<i)) ) continue;
          if(current_dist + (e.cost/(double)t[i]) < (dp[e.to][current_thicket + (1<<i)]) ) {
            dp[e.to][current_thicket + (1<<i)] = current_dist + (e.cost/(double)t[i]);
            que.push( State(PDL(dp[e.to][current_thicket + (1<<i)],current_thicket+(1<<i)),e.to) );
          }
        }
      }
    }
    double dist = INF;
    rep(i,(1<<t.size())){
      dist = min(dist,dp[g][i]);
    }
    return dist;
  }
};

int main(){

  ll n,m,p,a,b;
  while(true){
    cin >> n >> m >> p >> a >> b;
    if(n==0 && m == 0 && p == 0 && a == 0 && b== 0){
      break;
    }
    a--,b--;
    VI t(n);
    rep(i,n){
      cin >> t[i];
    }
    graph g(m);
    rep(w,p){
      ll x,y;
      double  z;
      cin >> x >> y >> z;
      x--;
      y--;
      g.add_edge(x,y,z);
      g.add_edge(y,x,z);
    }

    double dist = g.dijkstra(a,b,t);

    if(dist == INF){
      cout << "Impossible" << "\n";
    }else{
      printf("%0.10lf\n",dist);
    }
  }

  return 0;
}



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

bool graph[8][8];
int N,M;

int dfs(int v, int N,bool visited[8] ) {
  bool all_visited = true;

  for ( int i = 0; i < N; i++ ) {
    if ( visited[i] == false ) all_visited = false;
  }

  if ( all_visited ) return 1;

  int ret = 0;

  for ( int i = 0; i < N; i++ ) {
    if ( graph[v][i] == false ) continue;
    if ( visited[i] ) continue;
    visited[i] = true;
    ret += dfs(i,N,visited);
    visited[i] = false;
  }
  return ret;
}

int main() {
  cin >> N >> M;
  for ( int i = 0; i < M; i++ ) {
    int a,b;
    cin >> a >> b;
    a--,b--;
    graph[a][b] = graph[b][a] = true;
  }

  bool visited[8];
  for ( int i = 0; i < N; i++ ) visited[i] = false;
  visited[0] = true;
  cout << dfs(0,N,visited) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n; cin >> n;
	string s, t;
	cin >> s >> t;
	int ans = 2 * n;
	bool flag = true;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (s[j] != t[j - i]) {
				flag = false;
				break;
			}
		}
		if (flag == true) {
			ans -= n - i;
			break;
		}
		flag = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int all = 0, overseas = 0;
    REP(i,n){
        if(s[i] == 'a'){
            if(all < a + b){
                cout << "Yes" << endl;
                all++;
            }else{
                cout << "No" << endl;
            }
        }else if(s[i] == 'b'){
            if(all < a + b && overseas < b){
                cout << "Yes" << endl;
                all++;
                overseas++;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N, Y; cin >> N >> Y;

    int a = -1, b = -1, c = -1;
    REP(i,N+1) {
        REP(j,N+1) {
            int k = N - i - j;
            if (k>=0 && 10000*i+5000*j+1000*k==Y) {
                a = i; b = j; c = k;
                break;
            }
        }
    }

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


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_10_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            string[] x = Console.ReadLine().Split(' ');
            string[] y = Console.ReadLine().Split(' ');
            double[] X = new double[D];
            double[] Y = new double[D];
            double p1 = 0;
            double p2 = 0;
            double p3 = 0;
            double p0 = 0;
            double[] array = new double[D];
            for (int i = 0; i < D; i++)
            {
                X[i] = double.Parse(x[i]);
            }
            for (int i = 0; i < D; i++)
            {
                Y[i] = double.Parse(y[i]);
            }
            for (int i = 0; i < D; i++)
            {
                p1 += Math.Abs(X[i] - Y[i]);
                array[i] = Math.Abs(X[i] - Y[i]);
            }
            for (int i = 0; i < D; i++)
            {
                p2 += Math.Pow(Math.Abs(X[i] - Y[i]), 2.0);
            }
            p2 = Math.Sqrt(p2);
            for (int i = 0; i < D; i++)
            {
                p3 += Math.Pow(Math.Abs(X[i] - Y[i]), 3.0);
            }
            p3 = Math.Pow(p3, 1.0 / 3.0);
            p0 = array.Max();

            Console.WriteLine(p1);
            Console.WriteLine(p2);
            Console.WriteLine(p3);
            Console.WriteLine(p0);
        }
    }
}



Measured memory_bytes: 20288
N = gets.to_i
A = gets.split.map(&:to_i)

sb = 2.times.map{ Array.new(N + 1, 0) }
dp = 2.times.map{ Array.new(N + 1, 0) }
(1 .. N).each do |n|
  a = A[n - 1]
  2.times do |k|
    if (k + n).odd?
      if sb[k][n-1] + a > 0
        dp[k][n] = dp[k][n-1]
        sb[k][n] = sb[k][n-1] + a
      else
        dp[k][n] = dp[k][n-1] + (sb[k][n-1] + a).abs + 1
        sb[k][n] = 1
      end
    else
      if sb[k][n-1] + a < 0
        dp[k][n] = dp[k][n-1]
        sb[k][n] = sb[k][n-1] + a
      else
        dp[k][n] = dp[k][n-1] + (sb[k][n-1] + a).abs + 1
        sb[k][n] = -1
      end
    end
  end
end
puts [dp[0][N], dp[1][N]].min

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    bool ok = true;
    ll ans = 0;
    while(ok){
        for(int i = 0; i < n; i++){
            if(a[i]%2 == 0){
                a[i] /= 2;
            }
            else{
                ok = false;
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3572
def main():
    minu = 0
    S = input()
    N = len(S)
    S = int(S, 2)
    f01 = int('01' * (N//2) + '0' * (N%2), 2)
    f10 = int('10' * (N//2) + '1' * (N%2), 2)
    minu = min(str(bin(f01 ^ S)).count('1'), str(bin(f10 ^ S)).count('1'))
    print(minu)


main()

Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
struct BIT {
    BIT(int n) : b(n + 1), n(n) {}
    void add(int i, T v) {
        for (int k = i + 1; k <= n; k += k & -k) b[k] += v;
    }
    T sum(int k) {
        T s = 0;
        for (; k > 0; k -= k & -k) s += b[k];
        return s;
    }
    vector<T> b;
    int n;
};

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

    int n, q;
    cin >> n >> q;

    BIT<int> bt[2] = { n, n };
    auto f = [&](int h, int k, int v) {
        bt[h].add(0, v);
        bt[h].add(k, -v);
    };
    for (int h = 0; h < 2; h++) {
        f(h, n - 2, n - 2);
    }

    ll s = 0;
    for (int i = 0; i < q; i++) {
        int t, x;
        cin >> t >> x;
        t--; x -= 2;

        int k = bt[t ^ 1].sum(x + 1);
        if (k > 0) {
            s += k;
            int y = bt[t].sum(k - 1 + 1);
            if (x < y) {
                f(t, k, x - y);
            }
        }
    }

    s = (ll)(n - 2) * (n - 2) - s;
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    const int m = 4280;
    while(true){
	int n;
	cin >> n;
	if(n==-1) break;
	int a = max(115*n,1150);
	n -= 10;
	if(n>0) a += n * 10;
	n -= 10;
	if(n>0) a += n * 15;
	n -= 10;
	if(n>0) a += n * 20;
	cout << m - a << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <vector>
using namespace std;
const int MAXN = 1e5 + 7;
int col = 1;
int idx[MAXN];
vector<int> G[MAXN];
void dfs(int cur) {
	idx[cur] = col;
	for (int i = 0; i < G[cur].size(); i++) {
		if (!idx[G[cur][i]]) dfs(G[cur][i]);
	}
}
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    while (m--) {
    	int s, t;
    	scanf("%d%d", &s, &t);
    	G[s].push_back(t);
    	G[t].push_back(s);
	}
	for (int i = 0; i < n; i++) {
		if (!idx[i]) {
			dfs(i);
			col++;
		}
	}
	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int s, t;
		scanf("%d%d", &s, &t);
		if (idx[s] == idx[t]) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 11556
import sys
n, m = map(int, input().split())

if m > 0:
  As = set(map(int, sys.stdin))
else:
  As = set()

nums = [0] * (n + 1)
nums[0] = 1
if 1 in As:
  pass
else:
  nums[1] = 1
  
for i in range(2, n + 1):
  if i in As:
    continue
  else:
    nums[i] = (nums[i-1] + nums[i-2]) % 1000000007
    
print(nums[-1])

Measured memory_bytes: 11884
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
r=sum(A[0:K])
re=r
for i in range(N-K):
    r=r+A[K+i]-A[i]
    if r > re:
        re=r
        
print((re+K)/2)

Measured memory_bytes: 33728
package main

import(
      "fmt"
)

func main(){
  var a,b,c string
  fmt.Scan(&a,&b,&c)
  if a[len(a)-1]==b[0] {
    if b[len(b)-1]==c[0] {
      fmt.Println("YES")
    }else{
      fmt.Println("NO")
    }
  }else{
    fmt.Println("NO")
  }
}

//====  ↓↓↓ template functions ↓↓↓  ==============

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(x int) int{
  if x < 0 {
    return -x
  }
  return x
}

Measured memory_bytes: 512
N, Y = map(int, input().split())
z = -1
for i in range(N+1):
    if z == -1:
        x = N - i
    else:
        break
    for j in range(N-x+1):
        y = N - x - j
        if 10000*x + 5000*y + 1000*(N-x-y) == Y:
            z = N - x - y
            break

if z == -1:
    print(-1, -1, -1)
else:
    print(x, y, z)


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




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

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include <stdio.h>
 
int hantei(double,double,double,double,double,double);
 
main(){
  double xa,ya,xb,yb,xc,yc,xd,yd;
  double xac,yac,xbd,ybd;
  double xab,yab,xad,yad,xcb,ycb;
  int f;
  while(1){
    if(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)==EOF) break;
    xac=xa-xc;
    yac=ya-yc;
    xbd=xb-xd;
    ybd=yb-yd;
    xab=xa-xb;
    yab=ya-yb;
    xad=xa-xd;
    yad=ya-yd;
    xcb=xc-xb;
    ycb=yc-yb;
     
    f=0;
     
    if(hantei(xab,yab,xad,yad,xac,yac)==1) f=1;
    if(hantei(xab,yab,xcb,ycb,xbd,ybd)==1) f=1;
     
    if(f==0) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}
 
int hantei(double a,double b,double c,double d,double e,double f){
  double t1,t2;
 
  t1=a*f-b*e;
  t2=c*f-d*e;
 
  if((t1*t2)<0) return 0;
  else return 1;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int g;
	cin >> g;
	int MA = g;
    if (g == k) {
        cout << "POSSIBLE" << endl;
        return 0;
    }
    for (int i=1; i<n; i++) {
        int num; cin >> num;
        if (num == k) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
		g = __gcd(g, num);
		MA = max(MA, num);
    }
    int maxd = MA - g;
    if (maxd < k) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if (k%g != 0) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 256
<?php
  list($n, $k) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $ans = 0;
  for ($i=0; $i<$n; $i++) {
    if($a[$i] >= $k){
      $ans++;
    }
  }

  echo $ans;

Measured memory_bytes: 14836
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll a, b, x;
    cin >> a >> b >> x;

    ll cnta = a / x;
    if (a % x == 0) cnta--;

    ll cntb = b / x;

    cout << cntb - cnta << endl;

    return 0;
}

Measured memory_bytes: 3632
k = int(input())
s = list(input())
mod = 10 ** 9 + 7

nagasa = len(s)


ans = pow(26, k, mod)
bunbo = 1
bunshi = 1
for i in range(1, k + 1):
    bunbo *= nagasa - 1 + i
    bunshi *= pow(i, mod - 2, mod)
    bunbo %= mod
    bunshi %= mod
    temp = bunbo * bunshi
    temp %= mod
    temp *= pow(25, i, mod)
    temp %= mod
    temp *= pow(26, k - i, mod)
    temp %= mod
    ans += temp
    ans %= mod

print(ans)


Measured memory_bytes: 111712
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sst stringstream
#define sz size()
#define vc vector
typedef vc<int> vi;
typedef vc<ll> vl;
typedef vc<string> vs;

string s;
int n;

ll toLL(string s){
	if(s=="")return 0;
	iss is(s);
	ll x;
	is>>x;
	return x;
}

string toStr(ll x){
	sst ss;
	ss<<x;
	return ss.str();
}

int main(){
	while(cin>>s && s!="#"){
		ll ans=0;
		n=s.sz;
		int allzero=1;
		rep(i,n)if(s[i]!='0')allzero=0;
		if(allzero)s="1"+s,n++,ans++;
		
		ll firstnum=INF*INF,pos=-1;
		
		rep(a,16)rep2(b,1,n+1){
			if(a+b>16)continue;
			if(a==0 && s[0]=='0')continue;
			if(b<n && s[b]=='0')continue;
			string pref=s.substr(0,b);
			string rest=s.substr(b);
			if(rest.sz>=a){
				rep(i,2){
					ll head=toLL(rest.substr(0,a))-i;
					if(head<0)continue;
					int oneless=0;
					if(toStr(head).sz == a-1) oneless=1;
					ll num=toLL(toStr(head)+pref);
					ll num0=num;
					//cout<<a<<" "<<b<<" "<<i<<" "<<head<<" "<<num<<endl;
					while(rest.sz>0){
						num++;
						string t=toStr(num);
						rep(i,min(rest.sz,t.sz)){
							if(rest[i] != t[i]){
								goto out;
							}
						}
						if(rest.sz<t.sz)rest="";
						else rest=rest.substr(t.sz);
					}
					out:;
					//cout<<"["<<rest<<"]"<<endl;
					if(rest==""){
						if(num0 < firstnum || num0 == firstnum && a - oneless < pos){
							//cout<<a<<" "<<b<<" "<<i<<" "<<head<<" "<<num<<endl;
							firstnum=num0;
							pos=a - oneless;
						}
					}
				}
			}
		}
		//cout<<firstnum<<" "<<pos<<endl;
		ans+=pos;
		ll p10=10,dig=1;
		while(1){
			if(firstnum-1<=p10-1){
				ans+=dig*(firstnum-1 - p10/10+1);
				break;
			}
			ans+=dig*(p10-1 - p10/10+1);
			p10*=10;
			dig++;
		}
		cout<<ans+1<<endl;
	}
}

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

int main(){
    string s;
    cin >> s;
    int n = (s[0]-'0')*10000000+(s[1]-'0')*1000000+(s[2]-'0')*100000+(s[3]-'0')*10000+(s[5]-'0')*1000+(s[6]-'0')*100+(s[8]-'0')*10+s[9]-'0';
    if(n<20190431)cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
	int a;
	std::cin >> a;
	int b[a];

	for (int i = 0; i < a; i++) {
		std::cin >> b[i];
	}
	for (int i = 0; i < a; i++) {
		if ( i )std::cout << " ";
		std::cout << b[a-i-1];
	}
	std::cout << std::endl;

	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <math.h>

int main(void)
{
	double a, b, C, r;
	
	scanf("%lf%lf%lf", &a, &b, &C);
	r = C*M_PI/180;
	printf("%f\n", a*b*sin(r)/2);
	printf("%f\n", a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(r)));
	printf("%f\n", b*sin(r));
	
	return(0);
}



Measured memory_bytes: 2088
n,m = map(int, input().split())
a = [0,n]
for i in range(m):
  s,t = map(int, input().split())
  a[0] = max(a[0], s)
  a[1] = min(a[1], t)
print(max(a[1] - a[0] + 1, 0))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int a, b, x;
string s;
int main()
{
	cin >> a >> b >> x;
	if (a <= x && x <= a + b) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int t=0,n,k,m=0,cnt=0;
set<int>st;
set<int> :: iterator it;
int main()
{
    scanf("%lld",&t);
    while(t--)
    {
        scanf("%lld",&k);
        if(k==0)
        {
            scanf("%lld",&n);
            st.insert(n);
            cout<<st.size()<<endl;

        }
        if(k==1)
        {
            scanf("%lld",&n);
            if(st.count(n))
            {
                cout<<"1"<<endl;
            }
            else
            {
                cout<<"0"<<endl;
            }



        }
        if(k==2){
             scanf("%lld",&n);
             st.erase (n);
        }
    }
}




Measured memory_bytes: 12500
import collections

n = int(input())
graph = [[] for i in range(n + 1)]
edge = []
for i in range(n - 1):
    a, b = map(int, input().split())
    edge.append((a, b))
    graph[a].append(b)
    graph[b].append(a)
color = {}
queue = collections.deque([(1, 0)])
while queue:
    temp = queue.popleft()
    num = temp[0]
    prev = temp[1]
    if prev:
        col = color[(prev, num)]
    else:
        col = 0
    count = 1
    for i in graph[num]:
        a, b = min(i, num), max(i, num)
        if (a, b) in color.keys():
            continue
        else:
            if count == col:
                color[(a, b)] = count + 1
                count += 2
            else:
                color[(a, b)] = count
                count += 1
            queue.append((i, num))
print(max([len(graph[i]) for i in range(n + 1)]))
for i, j in edge:
    print(color[(i, j)])

Measured memory_bytes: 119112
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int inf = 999999;

struct P{
	int x;
	int y;
};

struct St{
	P tk;
	P kz;
	int cost;
};

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {1, 0, -1, 0};

int bfs(char a[51][51], int w, int h, P p, P q)
{
	int r = inf;
	bool vis[51][51][51][51];
	fill(&vis[0][0][0][0], &vis[50][50][50][50], true);
	St s, t;
	queue<St> que;
	s.tk = p;
	s.kz = q;
	s.cost = 0;
	que.push(s);
	
	while(!que.empty()){
		s = que.front();
		que.pop();
		if(s.tk.x == s.kz.x && s.tk.y == s.kz.y){
			r = s.cost;
			break;
		}
		if(s.cost >= 100){
			break;
		}
		
		for(int i = 0; i < 4; i++){
			int tx = s.tk.x+xdir[i], ty = s.tk.y+ydir[i];
			int kx = s.kz.x-xdir[i], ky = s.kz.y-ydir[i];
			if(!(0 <= tx && tx < w && 0 <= ty && ty < h && a[ty][tx] == '0')){
				tx = s.tk.x;
				ty = s.tk.y;
			}
			if(!(0 <= kx && kx < w && 0 <= ky && ky < h && a[ky][kx] == '0')){
				kx = s.kz.x;
				ky = s.kz.y;
			}
			if(vis[ty][tx][ky][kx]){
				vis[ty][tx][ky][kx] = false;
				t.tk.x = tx;
				t.tk.y = ty;
				t.kz.x = kx;
				t.kz.y = ky;
				t.cost = s.cost+1;
				que.push(t);
			}
		}
	}
	
	return r;
}

int main()
{
	int w, h, r;
	char a[51][51];
	P p, q;
	
	while(cin>>w>>h && (w+h)){
		cin >> p.x >> p.y;
		cin >> q.x >> q.y;
		p.x--;
		p.y--;
		q.x--;
		q.y--;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> a[i][j];
			}
		}
		
		r = bfs(a, w, h, p, q);
		if(r == inf){
			cout << "NA" << endl;
		} else {
			cout << r << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 7776
package main

import "fmt"

func main() {
	var (
		H1, M1, H2, M2, K int
	)
	fmt.Scan(&H1, &M1, &H2, &M2, &K)

	start := H1*60 + M1
	end := H2*60 + M2

	answer := end - K - start
	if answer < 0 {
		fmt.Println(0)
	} else {
		fmt.Println(answer)
	}
}


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

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

int main() {
  char str[4];
  scanf("%s", str);
  qsort(str , 3, sizeof(char), asc);
  if(strcmp(str, "abc") == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace c
{
    class Program
    {
        public static readonly long INF = 999999999999;
        public static readonly long MOD = 1000000007;

        static void Main(string[] args)
        {
            var nm = Scanner.IntScan();
            var a = new bool[nm[0]+10];
            for(var i = 0; i < nm[1]; i++)
            {
                var t = int.Parse(Console.ReadLine());
                a[t] = true;
            }

            var dp = new long[nm[0] + 10];
            for (var i = 0; i <= nm[0]; i++) dp[i] = 0;
            dp[0] = 1;
            for(var i = 0; i < nm[0]; i++)
            {
                for(var j = i + 1 ; j <= Math.Min(nm[0],i+2); j++)
                {
                    if (!a[i])
                    {
                        dp[j] += dp[i];
                        dp[j] %= MOD;
                    }
                }
            }
            Console.WriteLine(dp[nm[0]]);
            
        }
    }

    public class Scanner
    {
        public static string[] Scan() => Console.ReadLine().Split(' ');
        public static int[] IntScan() => Array.ConvertAll(Scan(), int.Parse);
        public static long[] LongScan() => Array.ConvertAll(Scan(), long.Parse);
        public static string[][] Scan(int n) => Enumerable.Repeat(0, n).Select(_ => Scan()).ToArray();
        public static int[][] IntScan(int n) => Enumerable.Repeat(0, n).Select(_ => IntScan()).ToArray();
        public static long[][] LongScan(int n) => Enumerable.Repeat(0, n).Select(_ => LongScan()).ToArray();

    }

    public class Ex
    {
        public static bool Chmin(ref int a, int b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmin(ref long a, long b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmax(ref int a, int b) { if (a < b) { a = b; return true; } return false; }
        public static bool Chmax(ref long a, long b) { if (a < b) { a = b; return true; } return false; }
        public static int[] SubArr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


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

char str[105];

int main()
{	
	cin >> str+1;
	int ans = strlen(str+1);
	int n = strlen(str+1);
	for (char i = 'a'; i <= 'z'; i++) {
		int last = 0, cur = 0;
		for (int j = 1; j <= n; j++)
			if (str[j] == i) {
				cur = max(cur, j-last-1);
				last = j;
			}
		cur = max(cur, n+1-last-1);
		ans = min(ans, cur);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	v := make([]float64, N)
	for i := 0; i < N; i++ {
		v[i] = float64(scanInt())
	}
	sort.Float64s(v)

	ans := (v[0] + v[1]) / 2
	for i := 2; i < N; i++ {
		ans = (ans + v[i]) / 2
	}
	fmt.Println(ans)
}


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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 5e5 + 10;
int n;
char S[MAXN];

const int MOD = (int) 1e9 + 7;
int E[MAXN];
int H[MAXN];
vector<int> D[MAXN];

bool fl[MAXN];
bool fr[MAXN];

int Hash(int l, int r) {
	return (H[r] - (LL) H[l - 1] * E[r - l + 1] + (LL) MOD * MOD) % MOD;
}

int main() {
	scanf("%s", S + 1);
	n = strlen(S + 1);

	E[0] = 1; H[0] = 0;
	for (int i = 1; i <= n; ++i) {
		E[i] = (E[i - 1] * 31ll) % MOD;
		H[i] = (H[i - 1] * 31ll + S[i] - 48) % MOD;
	}
	for (int i = 1; i <= n; ++i)
		for (int j = i * 2; j <= n; j += i)
			D[j].push_back(i);
	if (Hash(1, n - 1) == Hash(2, n)) {
		printf("%d\n", n);
		printf("1");
		return 0;
	}

	int flag = 1;
	for (int j = 0; j < (int) D[n].size(); ++j) {
		int len = D[n][j];
		if (Hash(1, n - len) == Hash(len + 1, n)) flag = 2;
	}
	if (flag == 1) {
		puts("1");
		puts("1");
		return 0;
	}

	for (int p = 1; p <= n; ++p) {
		fl[p] = true;
		fr[p] = true;
		for (int i = 0; i < (int) D[p].size(); ++i) {
			int len = D[p][i];
			if (Hash(1, p - len) == Hash(len + 1, p)) fl[p] = false;
		}
		for (int i = 0; i < (int) D[n - p + 1].size(); ++i) {
			int len = D[n - p + 1][i];
			if (Hash(p, n - len) == Hash(p + len, n)) fr[p] = false;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n - 1; ++i)
		if (fl[i] && fr[i + 1]) ans++;
	printf("%d\n", 2);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 63232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  string S; cin >> S;

  int ans = 0;
  
 
  
  rep(tmp, (1 << S.size()-1)) {
    bitset<9> bit(tmp);
    //cout << bit << endl;
    int n=0, k=0;
    while(n+k < S.size()-1) {
      //cout << n << " " << k << endl;
      if(bit.test(n+k)) {
        //if(stoi(S.substr(n, k+1)) != 0) cout << stoi(S.substr(n, k+1)) << endl;
        ans += stoi(S.substr(n, k+1));
        n += k+1;
        k = 0;
      } else {
        k++;
      }
    }
    ans += stoi(S.substr(n, k+1));
  }

  cout << ans << endl;

}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

#define INF (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long H;
    std::cin >> H;
    long long N;
    std::cin >> N;
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
        std::cin >> B[i];
    }

    V<ll> dp(H + 1, INF);
    dp[0] = 0;
    rep(i, N) {
        rep(j, H) {
            dp[min((ll)j + A[i], H)] =
                min(dp[min((ll)j + A[i], H)], dp[j] + B[i]);
        }
    }
    cout << dp[H] << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  long long n,m,a[100009][3],ans = -(1LL << 60);
  cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 0;j < 3;j++) cin >> a[i][j];
    }
      for(int i = 0; i < 8;i++){
      vector<long long>vec;
      for(int j = 1; j <= n;j++){
        long long v = 0;
         for(int k = 0;k < 3;k++){
	   if((i / (1 << k)) % 2 ==  0 ) v += a[j][k];else v -= a[j][k];
          }
          vec.push_back(v);
    }
      sort(vec.begin(),vec.end());
      reverse(vec.begin(),vec.end());
      long long sum = 0;
      for(int j = 0;j < m;j++) sum += vec[j];
      ans = max(ans,sum);
	}
  cout << ans << endl;
  return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    static bool is_comp[200000];
    vector<int> primes;
    for(int i=2;;++i){
        if(is_comp[i]) continue;
        primes.emplace_back(i);
        for(int j=2;i*j<200000;++j) is_comp[i*j] = true;
        if(i > 100000) break;
    }
    int x;
    cin >> x;
    cout << *lower_bound(primes.begin(), primes.end(), x) << endl;

    return 0;
}

Measured memory_bytes: 512
//2018.9.22 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
namespace MAIN{
    int A,B;
    inline void MAIN(){
        A=read(),B=read();
        if((LL)A*B<=0)puts("Zero");
        else if(A>0&&B>0)puts("Positive");
        else if((B-A)&1)puts("Positive");
        else puts("Negative");
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

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

int main(){
    long long A,V,B,W,T;
    cin>>A>>V>>B>>W>>T;
    int flag=0;
    if(A==B){
        cout<<"YES"<<endl; 
        flag = 1;
    } 
    else if(A<B){
        if(A+V*T >= B+W*T){
            cout<<"YES"<<endl; 
            flag = 1;
        }
    }
    else if(A>B){
        if(A-V*T <= B-W*T){
            cout<<"YES"<<endl; 
            flag = 1;
        }
    }
    if(flag==0)cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3624
<?php
/*dskhbfjkhs*/
$server = "php://stdin";
$handle = fopen($server, "r");
$t = trim(fgets($handle));
$s = trim(fgets($handle));
$m=[];
$m[$t]=1;
$m[$s]=1;
if(isset($m[1]) && isset($m[2]))
{
    echo '3'."\n";
}else if(isset($m[1]) && isset($m[3]))
{
    echo '2'."\n";
}else
{
    echo '1'."\n";
}


?>

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

int main()
{
  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a < 3200)
  {
    cout << "red" << endl;
  }
  else
  {
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long xN = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    long long ans=1;

    //nのほうが大きい
    if(n<m)swap(n,m);
    if(n==m){
        for (int i=1; i<=m; i++) ans = ans*i%xN;
        ans = ans*ans%xN;
      	ans = ans*2%xN;      
    }else if(n-1==m){
        for (int i=1; i<=m; i++) ans = ans*i%xN;
        ans = ans*ans%xN;
      	ans = ans*n%xN;
    }else ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c=gets.split.map &:to_i
s=[]
100.times do|i|
  x=a*(i+1)%b
  if x==c
    puts :YES
    exit
  elsif s.count(x)==0
    s[s.size]=a*(i+1)%b
  else
    puts :NO
    exit
  end
end


Measured memory_bytes: 1788
gets.to_i
array = gets.split.map(&:to_i)
sorted = array.sort

diff_count = 0

array.each_with_index do |n, i|
  diff_count += 1 if n != sorted[i]
end

if diff_count == 0 || diff_count == 2
  puts 'YES'
else
  puts 'NO'
end

Measured memory_bytes: 3836
s = gets.chomp
Q = gets.to_i


flg = false
l = []
r = []
$<.each{|t|
  q, f, c = t.split
  case q.to_i
  when 1
    flg = !flg
  when 2
    if flg ^ (f == "1")
      l.unshift  c
    else
      r << c
    end
  end
}

ans = l*"" + s + r*""
puts flg ? ans.reverse : ans

Measured memory_bytes: 17276
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100

int main(void) {
    int num = get_int();
    int arr[NUM_MAX];
    fget_array(arr, num);
    int ans = 0;
    while(1) {
#ifdef DEBUG
        int i;
        printf("ans: %d: ", ans);
        for(i = 0; i < num; i++) printf(" %d", arr[i]);
        putchar('\n');
#endif
        int left, right;
        int cnt = 0;
        for(left = 0; left < num;) {
            if(!arr[left]) { left++; continue; }
            for(right = left; right < num; right++) {
                if(!arr[right]) break;
                arr[right]--; // watering
            }
            // [left, right)
            cnt++;
            // update left
            left = right+1;
        }
        if(!cnt) break;
        ans += cnt;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
N = gets.to_i
as = gets.split.map(&:to_i)
#N = 10**2
#as = N.times.map{|i| N}

cand = [0]
max = as[0]

(1...N).each do |i|
    if as[i] > max
        cand.push(i)
        max = as[i]
    end
end

ans = Array.new(N, 0)
assort = as.sort
prev = 0
N.times do |i|
    a = assort[i]
    if a != as[cand[0]]
        ans[cand[0]] += a - prev
        next
    end
    ans[cand[0]] += (a - prev) * (N - i)
    prev = a
    cand.shift
    break if cand.length == 0
end

puts ans.join("\n")

Measured memory_bytes: 15232
#include<stdio.h>

int main(void)
{
  int a,b,price;
  scanf("%d %d",&a,&b);
  if(a>=6 && 12>=a){
    price=b/2;
  }else if(a<=5){
    price=0;
  }else{
    price=b;
  }
  
  printf("%d",price);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int a,b,c,i,j;

  for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      c=i*j;
      printf("%dx%d=%d\n",i,j,c);
    }
  }
  return 0;
}

Measured memory_bytes: 524
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

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

  int ans = INF;
  rep(i, s.size() - t.size() + 1) {
    int cnt = 0;
    int j = 0;
    while (j < t.size()) {
      if (s[i + j] == t[j]) {
        j++;
        // cout << "OK";
      } else {
        cnt++;
        j++;
        // cout << "NO" << endl;
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

struct Edge{
    int u, v;
    int64_t cost;
    
    Edge() = default;
    Edge(int u, int v, int64_t cost) : u(u), v(v), cost(cost) {}

    bool operator<(const Edge& other) const{
        return cost < other.cost;
    }
};

struct UnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;

    UnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else    return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y])   par[x] = y;
        else{
            par[y] = x;
            if(rank[x] == rank[y])  ++rank[x];
        }
    }
};

// クラスカル法を適用してグラフの最小全域木を求める
int64_t Kruskal(vector<Edge> &es){
    int64_t res = 0;    
    sort(es.begin(), es.end());
    int sz = es.size();
    UnionFind tree(sz);
    for(int i = 0; i < sz; ++i){
        if(!tree.same(es[i].u, es[i].v)){
            tree.unite(es[i].u, es[i].v);
            res += es[i].cost;
        }
    }
    return res;
}

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

    int n;
    cin >> n;
    vector<P> xorder(n), yorder(n);
    for(int i = 0; i < n; ++i){
        int x, y;
        cin >> x >> y;
        xorder[i] = P(x, i);
        yorder[i] = P(y, i);
    }
    sort(xorder.begin(), xorder.end());
    sort(yorder.begin(), yorder.end());
    vector<Edge> es;
    for(int i = 0; i + 1 < n; ++i){
        int u = xorder[i].second, v = xorder[i + 1].second;
        int64_t costu = xorder[i].first, costv = xorder[i + 1].first;
        es.push_back(Edge(u, v, costv - costu));
        u = yorder[i].second, v = yorder[i + 1].second;
        costu = yorder[i].first, costv = yorder[i + 1].first;
        es.push_back(Edge(u, v, costv - costu));
    }
    int64_t ans = Kruskal(es);
    cout << ans << endl;
}

Measured memory_bytes: 8048
#include<bits/stdc++.h>
#define N 300050
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
using namespace std;
int ar[N],n,fr[N];
int cal(int x){
    x*=x-1;
    x/=2;
    return x;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>ar[i];
        fr[ar[i]]++;
    }
    int sum = 0;
    for(int i=0;i<N;i++){
        sum += cal(fr[i]);
    }
  
    for(int i=0;i<n;i++){
        cout<<sum-fr[ar[i]]+1<<" ";
    }
        return 0;
}


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> A(M);

    rep(i,M) {
        int k;
        cin >> k;
        rep(j,k) {
            int s;
            cin >> s;
            s--;
            A[i].push_back(s);
        }
    }

    vector<int> P;
    rep(i,M) {
        int p;
        cin >> p;
        P.push_back(p);
    }

    int ans = 0;
    for(int bit=0; bit<(1<<N); bit++) {
        vector<int> C(M,0);
        rep(m,M) {
            rep(i,A[m].size()) {
                if (bit & (1<<A[m][i])) {
                    C[m]++;
                }
            }
        }
        bool t = true;
        rep(i,M) {
            if (C[i]%2 != P[i]) t = false;
        }
        if (t) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n<105){
        cout << 0 << endl;
    }else if(n<135){
        cout << 1 << endl;
    }else if(n<165){
        cout << 2 << endl;
    }else if(n<189){
        cout << 3 << endl;
    }else if(n<195){
        cout << 4 << endl;
    }else{
        cout << 5 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<iterator>
#include<algorithm>
#include<bitset>

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);
#define sci(x) scanf("%d", &x)
#define sci2(x,y) scanf("%d%d", &x,&y)
#define scll2(x,y) scanf("%lld%lld",&x,&y)
#define scll(x) scanf("%lld",&x)
#define scd(x) scanf("%lf", &x)
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", x)
#define pfll(x) printf("%lld", x)
#define pfd(x) printf("%f", x)
#define pfstr(x) printf("%s", x)
#define ps printf(" ")
#define pn printf("\n")
#define pfdt printf("..")

#define For(i,a,n) for(int i=a; i<=n;i++)
#define rFor(i,n,a) for(int i=n; i>=a; i--)
#define TestCase int testcase, cs=1; cin>>testcase;while(testcase--)

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second

#define px(x) cout<<"X -> "<<x<<endl;
#define py(x) cout<<"Y = "<<x<<endl;
#define pz(x) cout<<"Z >> "<<x<<endl;
#define pstr(x) printf("%s\n",x);

using namespace std;
using ll = long long;
using vi = vector <int>;
using mpii = map<int,int>;
using si = set<int>;
using sll = set<ll>;
using vll= vector<ll>;

#define INF 1000000000
#define LINF 4000000000000000000
#define pi  (2*acos(0))
#define Mod 1000000007

 int main(){

 int c=0,n;

 For(i,1,5){
    sci(n);
    if(n==0) c= i;
 }


 pfi(c); 



    return 0;
}







Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>

using namespace std;

int main(){
	int n;
	double a[101],ans;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> a[i];
		
		ans += 1/a[i];
	}
	
	cout << setprecision(10) << 1/ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	input := scanIntNum()
	fmt.Println(check(input))
}

func check(num int) string {
	if num > 81 {
		return "No"
	}
	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			if i*j == num {
				return "Yes"
			}
		}
	}
	return "No"

}

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}

Measured memory_bytes: 640