akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll ans = A[0];
  rep(i, N - 1) { ans = gcd(ans, A[i + 1]); }
  cout << ans << endl;
}

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

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

ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

int main(){

    ll a,b,c,d;
    cin>> a >> b >> c >> d;

    ll cc=b/c;
    ll dd=b/d;
    ll cd=lcm(c,d);
    ll ccdd=b/cd;
    a--;
    ll ccs=a/c;
    ll dds=a/d;
    ll ccdds=a/cd;

    ll ans=(b-a-(cc-ccs))+(b-a-(dd-dds))-(b-a-(ccdd-ccdds));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[300010];
int b[100010], c[100010], mi, sum;
signed main() {
	cin >> n;
	rep(i, 3 * n)cin >> a[i];
	prique<int,vector<int>,greater<int>> q;
	rep(i, n) {
		q.push(a[i]);
		sum += a[i];
	}
	b[0] = sum;
	for (int i = n; i < 2 * n; i++) {
		if (a[i] > q.top()) {
			sum -= q.top();
			sum += a[i];
			q.pop();
			q.push(a[i]);
		}
		b[i - n + 1] = sum;
	}
	prique<int> que;
	sum = 0;
	rep(i, n) {
		que.push(a[2 * n + i]);
		sum += a[2 * n + i];
	}
	c[n] = sum;
	for (int i = 2 * n - 1; i >= n; i--) {
		if (a[i] < que.top()) {
			sum -= que.top();
			sum += a[i];
			que.pop();
			que.push(a[i]);
		}
		c[i - n] = sum;
	}
	int ans = -INF;
	rep(i, n + 1) {
		ans = max(ans, b[i] - c[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5876
fun main(args: Array<String>){
    val X = readLine()!!.toLong()
    var i_sum: Long = 0
    for(i in 1..X){
        if(i % 5 == 0L && i % 3 == 0L){
            continue
        }else if(i % 3 == 0L){
            continue
        }else if(i % 5 == 0L){
            continue
        }else{
            i_sum += i
        }
    }
    
    

    println(i_sum)
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  cin >> N;
  set<int> s;
  REP(i,N){
    int a;
    cin >> a;
    s.insert(a);
  }

  if(s.size()&1){
    cout << s.size() << endl;
  }else{
    cout << s.size()-1 << endl;
  }
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using T = tuple<int,int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;

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

    vector<ll> P(A), Q(B), R(C);
    rep(i, A)cin>>P.at(i);
    rep(i, B)cin>>Q.at(i);
    rep(i, C)cin>>R.at(i);

    sort(P.begin(), P.end());
    sort(Q.begin(), Q.end());
    reverse(P.begin(), P.end());
    reverse(Q.begin(), Q.end());

    priority_queue<ll> pq_R; //大きい順に出てくるpriority_queue
    rep(i, C)pq_R.push(R.at(i));

    priority_queue<ll, vector<ll>, greater<ll>> pq_P; 
    rep(i, X)pq_P.push(P.at(i));

    priority_queue<ll, vector<ll>, greater<ll>> pq_Q; 
    rep(i, Y)pq_Q.push(Q.at(i));

    ll P_sum = 0;
    ll Q_sum = 0;
    rep(i,X)P_sum+=P.at(i);
    rep(i,Y)Q_sum+=Q.at(i);

    while(!pq_R.empty()){
        ll P_min = pq_P.top();
        ll Q_min = pq_Q.top();
        ll R_max = pq_R.top();
        if(R_max<=P_min && R_max<=Q_min){
            break;
        }
        if(P_min<Q_min){
            pq_P.pop();
            pq_P.push(R_max);
            P_sum = P_sum-P_min+R_max;
        }else{
            pq_Q.pop();
            pq_Q.push(R_max);
            Q_sum = Q_sum-Q_min+R_max;
        }
        pq_R.pop();

    }

    cout << P_sum + Q_sum <<endl;








    
 

}

Measured memory_bytes: 8748
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	ans += min(k,a);
	k -= (a+b);
	if(k > 0)ans -= k;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3624
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();
		if(a<=5){
			System.out.println(0);
		}else if(a>=6 && a<=12){
			System.out.println(b/2);
		}else{
			System.out.println(b);
		}
	}
}


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


int main(int argc, char** argv) {
    
    int length;
    
    scanf("%d", &length );
    
    int A[100];
    int i;
    
    for(i=0;i<length;i++)
    {
        scanf("%d", &A[i]);
    }

    int j;
    int t;
    int p = 0;
    
    for(i=0;i<length-1;i++)
    {
        int min=i;
        for(j=i+1;j<length;j++)
            if(A[min]>A[j])
                min=j;
                
        if(min!=i)
        {
            t=A[min];
            A[min]=A[i];
            A[i]=t;
            p = p + 1;
        }
    }
    
    for(int n=0; n<length; n++){
        printf("%d", A[n]);
        if(n!=length-1)
            printf(" ");
        else
        {
            printf("\n");
        }     
    }
    printf("%d\n", p);

    return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

pii cnt[MAXN];

void solve(){
	int n, k;
	scanf("%d%d", &n, &k);
	REP(i, 0, n) {
		int a;
		scanf("%d", &a);
		cnt[a]._1++;
	}
	REPN(i, 1, n) {
		cnt[i]._2 = i;
	}
	sort(cnt + 1, cnt + n + 1);
	reverse(cnt + 1, cnt + n + 1);
	int cur = 0;
	REPN(i, 1, k) {
		cur += cnt[i]._1;
	}
	cout << n - cur << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int total = r + g + b;
	int mx = max(r, max(g, b));
	int mn = min(r, min(g, b));
	int mid = total - mx - mn;
	int mxu = n / mx;
	int count = 0;
	for(int i = 0; i <= mxu; i++) {
		int rval = n - (i * mx);
		int rvalu = rval / mid;
		for(int j = 0; j <= rvalu; j++) {
			int rval2 = rval - (j * mid);
			if(rval2 % mn == 0) {
				count++;
			//	cout << (rval2 / mn) << " " << rvalu << " " << mxu << endl;
			}
		}
	}
	cout << count;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A[4],L[10];
  cin>>A[0]>>A[1]>>A[2]>>A[3];
  REP(i,10) L[i]=0;
  for(int i=0; i<4; ++i){
    if(A[i]==1) L[1]++;
    if(A[i]==4) L[4]++;
    if(A[i]==7) L[7]++;
    if(A[i]==9) L[9]++;
  }
  if(L[1]==1 && L[4]==1 && L[7]==1 && L[9]==1) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(void) {
    char c;
    int count[26] = {0}, i;
    while (1) {
        if (scanf("%c", &c) == EOF)
            break;
        if ('a' <= c && c <= 'z')
            count[c-'a']++;
        else if ('A' <= c && c <= 'Z')
            count[c-'A']++;
    }
    for (i = 0; i < 26; i++) {
        cout << (char)(i + 'a') << " : " << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define ll long long int

using namespace std;


int main(){

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
string s1;
string s2;
cin>>s1>>s2;
int n = s1.size();
int m = s2.size();
int dp[n+1][m+1];
for(int i=0;i<=n;i++)
	dp[i][0] =0;
for(int i=0;i<=m;i++)
	dp[0][i] = 0;
for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
		if(s1[i-1]==s2[j-1])
			dp[i][j] = 1+dp[i-1][j-1];
		else
			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
	}
}
int i=n,j=m;
string ans = "";
	while(i!=0&&j!=0){
		if(s1[i-1]==s2[j-1]){
			ans+=s1[i-1];
			i--;
			j--;
		}
		else {
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<endl;
}
		

Measured memory_bytes: 38732
# -*- coding: utf-8 -*-

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
edges = []
for i in range(M):
    a, b = MAP()
    a -= 1; b -= 1
    edges.append((a, b))

def check(x):
    nodes = [[] for i in range(N)]
    for i in range(M):
        # 辺x以外でグラフを構築する
        if i == x:
            continue
        a, b = edges[i]
        nodes[a].append(b)
        nodes[b].append(a)
    # BFSで到達確認
    que = deque([0])
    visited = [0] * N
    while que:
        u = que.popleft()
        if visited[u]:
            continue
        visited[u] = 1
        for v in nodes[u]:
               que.append(v)
    # 全ての辺に到達できたか
    return sum(visited) != N

ans = 0
for x in range(M):
    # 辺xを除いて、到達できなくなる場所があればこの辺は橋
    if check(x):
        ans += 1
print(ans)


Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

string S,C[200000];
int Q,T[200000],F[200000],t;
int main(){
  cin>>S>>Q;
  REP(i,0,Q){
    cin>>T[i];
    if(T[i]==2){
      cin>>F[i]>>C[i];
    }
  }
  bool rev=false;
  REP(q,0,Q){
    if(T[q]==1){
      rev=!rev;
    }
    if(T[q]==2){
      if(F[q]==1){
        if(rev)S.insert(S.size(),C[q]);
        else S.insert(0,C[q]);
      }
      if(F[q]==2){
        if(rev)S.insert(0,C[q]);
        else S.insert(S.size(),C[q]);
      }
    }
  }
  if(rev){
    reverse(S.begin(),S.end());
  }
  print(S)

}


Measured memory_bytes: 13440
def aa(n)
    a = []
    0.upto(10) do |i|
        a << i if n & 2**i == 2**i
    end
    a
end

d,g = gets.chomp.split.map(&:to_i)
p = []
c = []
pc = []
d.times do |i|
    pp,cc = gets.chomp.split.map(&:to_i)
    p << pp
    c << cc
    pc << (i+1) * 100 * pp + cc
end

ans = 0
0.upto(2**d-1) do |i|
    t = aa(i)
    tt = ((0..(d-1)).to_a - t)[-1]
    score = 0
    prob = 0
    t.each do |j|
        score += pc[j]
        prob += p[j]
    end
    if g <= score
        ans = prob if ans == 0 || ans > prob
    elsif g <= score + p[tt] * 100 * (tt+1)
        prob += ((g - score - 1) / (100 * (tt+1)) + 1)
        ans = prob if ans == 0 || ans > prob
    end
end
puts ans

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    vint lis={1};
    int a=1;
    while(true){
        a*=6;
        if(a>N)break;
        lis.pb(a);
    }
    a=1;
    while(true){
        a*=9;
        if(a>N)break;
        lis.pb(a);
    }

    vint dp(N+1,INT_MAX);
    dp[0]=0;
    rep(i,N){
        for(auto u:lis){
            if(u+i<=N)chmin(dp[i+u],dp[i]+1);
        }
    }
    cout<<dp[N]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 1000000000
using namespace std;

int main(){

    int a,b,ans=0; cin>>a>>b;

for(int i=0; i<N; i++){
        if(abs(a-i) == abs(b-i)) {
            ans = i;

            break;
        } 

    }

    if(ans == 0)  cout<<"IMPOSSIBLE"<<endl;

    else if(ans != 0) cout<<ans<<endl;

    return 0; 

    
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((int)1e5+5)

int d[MAXN];
int dp[MAXN];
	
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);

	int n,k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;

	for (int i = 0; i < n-1; ++i)
	{
		if(dp[i] == INT_MAX) continue;
		for (int j = 1; j <= k; ++j)
			dp[i+j] = min(dp[i+j] , dp[i] + abs(d[i] - d[i+j]));
	}

	cout << dp[n-1] << endl;
	return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> t;

  bool flag = false;
  int i = 1;
  while (true) {
    int m = (a * i) % b;
    if (m == c) {
      flag = true;
      break;
    }

    if (find(t.begin(), t.end(), m) == t.end()) {
      t.push_back(m);
    } else {
      break;
    }
    i++;
  }

  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 5005;

int dp[MAX_N][MAX_N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	int n;
	cin >> n;
	vpi test[n];
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		for(int j = 0; j < x; j++){
			int z, y;
			cin >> z >> y;
			test[i].push_back({--z, y});
		}
	}
	int maxi = 0;
	for(int bit = 0; bit < (1 << n); bit++){
		bool possible = true;
		for(int i = 0; i < n; i++){
			//don't care if "i" is unkind
			if(bit & (1 << i)){
				for(pi p: test[i]){
					int about = p.first, kind = p.second;
					if(kind == 1){
						//the person must be kind
						if(bit & (1 << about)){

						}
						else{
							possible = false;
							break;
						}
					}
					else{
						//kind = 0
						if(bit & (1 << about)){
							possible = false;
							break;
						}
					}
				}
			}
		}
		if(possible){
			maxi = max(maxi, __builtin_popcount(bit));
		}
	}
	cout << maxi << endl;
}

Measured memory_bytes: 256
def main():
    limit = int(input())
    result = 0
    for i in range(1, limit + 1, 2):
        divisor = 2
        j = 2
        while j * j <= i:
            if i % j == 0:
                if i * i == j:
                    divisor += 1
                else:
                    divisor += 2
            j += 1
        if divisor == 8:
            result += 1
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <algorithm>
#include <cstring>
#include <cstdio>
int dp[100005], seq[100005], deg[100005], lst[100005], to[200005], pre[200005], tot; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u];
	deg[v]++; 
	lst[u] = tot++;
}
bool dfs(int u, int lim, int fa = -1)
{
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] != fa && !dfs(to[i], lim, u))
			return false; 
	}
	int len = 0; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] != fa)
			seq[len++] = dp[to[i]] + 1; 
	}
	if (len & 1 ^ (fa != -1))
		seq[len++] = 0; 
	std::sort(seq, seq + len); 
	if (~fa)
	{
		int l = 0, r = len - 2; 
		while (l < r)
		{
			if (seq[l++] + seq[r--] > lim)
				return false; 
		}
		int idx = len - 1; 
		while (idx && seq[idx] + seq[len - 1 - idx + (idx << 1 < len)] <= lim)
			idx--; 
		dp[u] = seq[idx]; 
	}
	else
	{
		int l = 0, r = len - 1; 
		while (l < r)
		{
			if (seq[l++] + seq[r--] > lim)
				return false; 
		}
	}
	return true; 
}
int main()
{
	// freopen("ARC088-F.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	int n; 
	scanf("%d", &n); 
	for (int i = 1; i < n; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		add_edge(--u, --v);
		add_edge(v, u); 
	}
	int a = 0, l = 0, r = n - 1, ans; 
	for (int i = 0; i < n; i++)
		a += deg[i] & 1; 
	while (l <= r)
	{
		int m = l + r >> 1; 
		if (dfs(0, m))
		{
			ans = m; 
			r = m - 1; 
		}
		else
			l = m + 1;
	}
	printf("%d %d\n", a + 1 >> 1, ans);
	return 0; 
}


Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	int m;
	cin >> m;
	REP(i, m) {
		set<string> ptn;
		string input;
		cin >> input;
		FOR(j, 1, input.size()) {
			string t1 = input.substr(0, j);
			string t2 = input.substr(j);
			string t1r = input.substr(0, j);
			string t2r = input.substr(j);
			reverse(t1r.begin(), t1r.end());
			reverse(t2r.begin(), t2r.end());

			ptn.insert(t1 + t2);
			ptn.insert(t2 + t1);
			ptn.insert(t1r + t2);
			ptn.insert(t2 + t1r);
			ptn.insert(t1 + t2r);
			ptn.insert(t2r + t1);
			ptn.insert(t1r + t2r);
			ptn.insert(t2r + t1r);
		}

//		for(auto it = ptn.begin(); it != ptn.end(); it++)
//			cout << *it << endl;
		cout << ptn.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int main() {
    int n,m; cin >> n >> m;
    print(n-m+1);
}

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

double sum;
int n;

int main() {
	int i; double x;
	scanf("%d",&n);
	for (i=1;i<=n;i++) {
		scanf("%lf",&x);
		sum+=1/x;
	}
	printf("%.6lf\n",1/sum);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
		long answer = 0;

    if(nums[0] % 2 == 1 && nums[3] % 2 == 1 && nums[4] >= 1 ||
      nums[3] % 2 == 1 && nums[4] % 2 == 1 && nums[0] >= 1 ||
      nums[4] % 2 == 1 && nums[0] % 2 == 1 && nums[3] >= 1)
    {
      answer += 3;
      nums[0]--;
      nums[3]--;
      nums[4]--;
    }
    answer += (nums[0]/2)*2;
    answer += nums[1];
    answer += (nums[3]/2)*2;
    answer += (nums[4]/2)*2;

		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ll m;
    cin>>m;
    ve <ll> adj[n+1];
    ve <ll> val(n+1,0);
    rep (i,1,n+1)
    {
        cin>>val[i];
    }
    rep (i,0,m)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    ll ans=0;
    rep (i,1,n+1)
    {
        bool flag=true;
        for (auto x: adj[i])
        {
            if (val[x]>=val[i])
            {
                flag=false;
            }
        }
        if (flag)
        {
            ans++;
        }
    }
    cout<<ans<<"\n";
}


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

int main(){
    int N;
    cin >> N;
    
    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            if(i * j == N) { cout << "Yes"; return 0; }
       }
    }

    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n; scanf("%d", &n);
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += 1ll * i * (n - i + 1);
	}
	for (int i = 1; i < n; i++) {
		int x, y; scanf("%d%d", &x, &y);
		if (x > y) swap(x, y);
		ans -= 1ll * x * (n - y + 1);
	}
	printf("%lld\n", ans);
	return 0;
}


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

int N;
vector<int> B;

void input_init(void) {
	cin >> N;
	B.resize(N - 1);
	for (int i = 0; i < N - 1; ++i)
		cin >> B[i];
}

int solve(void) {
	int sum = B[0];
	sum += B[N - 2];
	for (int i = 1; i <= N - 2; ++i)
		sum += min(B[i], B[i - 1]);
	return sum;
}

int main(void) {
	input_init();
	int ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
N = input()
ss = []
for i in range(N):
    ss.append(input())
ans = 0
for s in ss:
    ans += s
if ans%10 != 0:
    print ans
else:
    ss.sort()
    for s in ss:
        if s%10 != 0:
            ans -= s
            print ans
            break
    if ans%10==0:
        print 0


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

using namespace std;

int main() {
    ios::sync_with_stdio();
    cin.tie(0);
    int n;
    cin >> n;
    string a,b;
    cin >> a>> b;
    for (int i=0;i<n;i++) {
        cout << a[i] << b[i];
    }
    //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s. \n";
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using P = pair<ll, ll>;
const int INF = 1001001001;

const int mod = 1000000007;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

int main(void){
  ll n, m;
  cin >> n >> m;
  vector<P> factor;
  ll t = m;
  for(ll i = 2; i*i <= t; i++){
    if(t%i) continue;
    ll c = 0;
    while(t%i == 0){
      t /= i;
      c++;
    }
    factor.emplace_back(P(i, c));
  }
  if(t != 1) factor.emplace_back(P(t, 1));

  mint ans = 1;
  comb c(200000);
  for(P p : factor){
    ll k = p.second;
    ans *= c(k+n-1, k);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> x(n);
  vector<ll> y(n);
  vector<ll> h(n);
  int f = -1;
  rep(i, n) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0) f = i;
  }
  ll ansx = -1, ansy = -1, ansh = -1;
  //中心座標を全探索
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      ll H = h[f] + abs(i - x[f]) + abs(j - y[f]);
      bool tf = true;
      for (int k = 0; k < n; k++) {
        if (h[k] > 0 && H - h[k] != abs(i - x[k]) + abs(j - y[k])) tf = false;
        if (h[k] == 0 && H > abs(i - x[k]) + abs(j - y[k])) tf = false;
      }
      if (tf) ansx = i, ansy = j, ansh = H;
    }
  }
  cout << ansx << " " << ansy << " " << ansh << endl;
  return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i;
	cin >> n;
	vl a(n), b(n);
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	ll put = 0;
	for (i = n - 1; i >= 0; i--) {
		a[i] += put;
		if (a[i] % b[i] == 0) {
			continue;
		}
		else {
			put += b[i] - (a[i] - b[i] * (a[i] / b[i]));
		}
	}
	cout << put << endl;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            var ans = (ab[0]+ab[1])%24;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#include<cstring> 
#include<algorithm>
using namespace std;
long long a[200010];
int main(){
	long long n,p;
	char s[200010];
	long long ans=0;
	scanf("%lld%lld%s",&n,&p,s);
	memset(a,0,sizeof(a));
	if(p==2||p==5){
		for(int i=0;i<n;i++){
			if((s[i]-'0')%p==0){
				ans+=i+1;
			}
		}
	}
	else{
		long long base=1,now=0;
		a[0]=1;
		for(int i=n-1;i>=0;i--){
			now=(((s[i]-'0')*base)%p+now)%p;
			base=(base*10)%p;
			ans+=a[now];
			a[now]++;
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define sz(a) (int)a.size()
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
// ===================== MANASH =================== //

void test() {

    int n;
    cin >> n;
    map<int,int> m;
    vi v(n);
    fo(i,n) {
        int t;
        cin >> t;
        v[i] = t;
        m[t]++;
    }
    int s = 0;
    for( pi p : m ) {
        int y = p.second;
        s += max(0LL,y*(y-1)/2);
    }
    for( int i = 0; i < n; i++) {
        int y = m[v[i]];
        cout << max(0LL,(s - y + 1)) << '\n';
    }
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 12672
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

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

object Problem {
    fun pow(a: Int, p: Int): Long = pow(a.toLong(), p)
    fun pow(a: Long, p: Int): Long = when {
        p == 0 -> 1L
        p % 2 == 1 -> a * pow(a, p - 1)
        else -> {
            val half = pow(a, p / 2)
            half * half
        }
    }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val K = sc.next().toLong()
        val A = Array(N) { sc.next().toInt() - 1 }
        val m = mutableMapOf<Int, Long>()
        var k = K
        var i = 0
        while (k > 0) {
//            println("$k: ${i + 1}")
            if (m.containsKey(i)) {
                val d = (K - k) - m[i]!!
                k %= d
//                println("d=$d, k=$k")
                if (k == 0L) break
            }
            m[i] = (K - k)
            i = A[i]
            k--
        }
        pw.println(i + 1)
    }
}


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

int main()
{
  string str;
  int n;

  cin >> str >> n;

  int cnt = 0;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    s += s;
    if (s.find(str) != -1) cnt++;
  }
  cout << cnt << endl;
}

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

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] s = str.split(" ",0);
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			int c = Integer.parseInt(s[2]);
			if(b - a == c - b) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a[3][3],n,b;
    bool ans = false;
    
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> a[i][j];
        }
    }
    
    cin >> n;
    
    for(int i = 1; i <= n;i++){
        cin >> b;
        
        for(int j = 0; j < 3;j++){
            for(int k = 0;k < 3;k++){
                if(a[j][k] == b) a[j][k] = 0;
            }
        }
    }
    
    for(int i = 0;i<3;i++){
        if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) ans = true;
        if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) ans = true;
        if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) ans = true;
        if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) ans = true;
    }
    
    if(ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
import sys
idCards, gates = input().split(" ")
idCards = int(idCards)
gates = int(gates)
minNum = []
maxNum = []

if idCards > 1000000 or gates > 1000000:
    sys.exit()

for count in range(0, gates, 1):
    num1, num2 = input().split(" ")
    minNum.append(int(num1))
    maxNum.append(int(num2))

minId = max(minNum)
maxId = min(maxNum)
if minId > maxId:
    print("0")
else:
    print((maxId - minId) + 1)

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c;
int x, y;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> a >> b >> c;
  pr(min(a*b,c));
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
void solve(int N, std::vector<std::string> u, std::vector<std::string> x) {
  double BTCrate = 380000.0;
  double paytotal = 0.0;
  for(int i=0;i<N;i++){
    if (u[i]=="JPY"){
      paytotal += std::stod(x[i]);
    }
    if (u[i]=="BTC"){
      paytotal += BTCrate * std::stod(x[i]);
    }
  }
  std::cout << paytotal << std::endl;
}
int main(void) {
  int N;
  std::cin >> N;
  std::vector<std::string> u(N);
  std::vector<std::string> x(N);
  for(auto i0 = 0; i0 < N; ++i0)
  {
    std::cin >> x[i0];
    std::cin >> u[i0];
  }
  solve(N,u,x);
  return 0;
}


Measured memory_bytes: 256
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array


void solve(){
   string s,t;
   cin >> s >> t;
   int n = s.size();
   int nt = t.size();
   int req = 1e8;
   for(int i = 0;i <= (n-nt); i++){
   		int ans = 0;
  		for(int j = i,var=0;j < n && var<nt;j++){
  			if(s[j]!=t[var++]) ++ans;
  		}
  		req=min(req,ans);
    }
    cout << req << "\n";

}

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

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}


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

int main() {

  int64_t H, W;
  cin >> H >> W;
  
  if(H==1 || W==1) {
    cout << 1 << endl;
  }
  
  else {
    cout << (H*W+1)/2 << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#include <stdio.h>

#define buf_size 5000
char Input[buf_size];
char* ptr = Input;

inline int getint(void){
    int res = 0; char c; while((c = *ptr++ - '0') >= 0) res = 10 * res + c;
    return res;
}
inline long long int getlong(void){
    long long int res = 0; char c; while((c = *ptr++ - '0') >= 0) res = 10 * res + c;
    return res;
}

char Out[20];

inline void println(long long int a){
    if(a){
      char* t = Out;
      while(a) *t++ = a % 10, a /= 10;
      while(t != Out) putchar_unlocked(*(--t) | '0');
    }
    else putchar_unlocked('0');
    putchar_unlocked('\n');
}

int main(void){
    fread_unlocked(Input, 1, buf_size, stdin);
    int n = getint() - 2; 
    const long long int a = getlong(), b = getlong();
    long long int B = 0; while(n--) B ^= getlong();
    const long long int A = a + b - B;
    const long long int C = A >> 1;
    if((A < 0) || (A & 1) || (B & C) || (a < C)){ puts("-1"); return 0; }
    long long int res = C;
    for(long long int x = 1LL << 40; x ; x >>= 1) if(B & x) if((res | x) <= a) res |= x; 
    if(res){
      res = a - res;
        if(res){
            char* t = Out;
            while(res) *t++ = res % 10, res /= 10;
            while(t != Out) putchar_unlocked(*(--t) | '0');
        }
        else putchar_unlocked('0');
        putchar_unlocked('\n');
    }
    else puts("-1");
    return 0;
}

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

using namespace std;

int main(void){
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> a;
	unsigned long long sum=0;
	for(int i=0 ; i < 3*N ; i++){
		int x;
		cin >> x;
		a.push_back(x); 
	}
	sort(a.begin(),a.end(),greater<int>());
	for(int i=1;i<N*2;i+=2){
		//cout<< a[i]<<endl;
		sum+=a[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>
int main()
{
    int n,j2, j=0,count = 0;
    scanf("%d",&n);

    while(n != 0)
    {
        j2=n%10;
        if(j2==7)
        {
            count++;
            break;
        }
        else
        {
            count += 0;
        }
        n /= 10;
    }
    if(count >0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 1728
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pddd(n, m, z) printf("%d %d %d\n", n, m, z)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define plddd(n, m, z) printf("%lld %lld %lld\n", n, m, z)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ce i == n ? '\n' : ' '
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int ret = 0, sgn = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			sgn = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		ret = ret * 10 + ch - '0';
		ch = getchar();
	}
	return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
	if (a > 9)
		Out(a / 10);
	putchar(a % 10 + '0');
}

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

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

vector<ll> ans;
ll Q[10000005];
int l = 1, r = 0;
void init()
{
	rep(i, 1, 9)
		Q[++r] = i;
	while (r > l)
	{
		ll cur = Q[l++];
		if (cur > 1e11)
			return;
		ans.pb(cur);
		int back = cur % 10;
		Q[++r] = cur * 10ll + back;
		if (back != 0)
			Q[++r] = cur * 10ll + back - 1;
		if (back != 9)
			Q[++r] = cur * 10ll + back + 1;
	}
}

int main()
{
	init();
	int k;
	sd(k);
	sort(ans.begin(), ans.end());
	pld(ans[k - 1]);
	return 0;
}

Measured memory_bytes: 22892
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 5005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int H, W;
	scanf("%d %d", &H, &W);
	int h, w;
	scanf("%d %d", &h, &w);
	printf("%d\n", (H - h) * (W - w));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<unordered_set>
using namespace std;
bool S[1000006];
int main( ) {
	int s , ans = 0 ;cin >> s; 
	while( !S[s] ) 
		S[s] = true , ++ans , s = ( s & 1 ? 3*s+1 : s/2 );
	cout << ans + 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
int a[100][26];
int b[100][26];
int main() {
	int N; cin >> N;
	string s; cin >> s;
	for (int i = 0; i < N - 1; i++) {
		int tmp = s[i] - 'a';
		for (int j = i; j < 100; j++) a[j][tmp] = 1;
	}
	for (int i = 0; i < N - 1; i++) {
		int tmp = s[N-1-i] - 'a';
		for (int j = i; j < 100; j++) b[j][tmp] = 1;
	}
	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		int cnt = 0;
		rep(j, 26) {
			if (a[i][j] == 1 && b[N-2-i][j] == 1) {
				cnt++;
			}
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620