akhauriyash/Code-Regression huggingface dataset:
import java.util.*
import java.math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private const val MOD = 1_000_000_007L


fun solveC(N:Int, M:Int, X:Int, C:Array<Int>, A:Array<Array<Int>>): Int {
    var res = Int.MAX_VALUE

    for(p in 0 until (0b01 shl N)) {
        var ptn = p
        var sk = Array<Int>(M){0}
        var cost = 0

        for (i in 0 until N) {
            if ((ptn and 0b01) == 1) {
                A[i].forEachIndexed{ j, v -> sk[j] += v }

                cost += C[i]
            }
            ptn = ptn shr 1
        }

        if (sk.count{it < X} == 0) {
            res = Math.min(res, cost)
        }
    }

    return if (res == Int.MAX_VALUE) -1 else res
}


fun main(args: Array<String>) {
    val (N,M,X) = readListInt()
    val C = Array<Int>(N){0}
    val A = Array(N){Array<Int>(M){0} }
    for(i in 0 until N) {
        val ca = readListInt()
        C[i] = ca[0]
        ca.drop(1).forEachIndexed{j,v -> A[i][j] = v}
    }

    val ans = solveC(N, M, X, C, A)

    println(ans)
}


Measured memory_bytes: 43820
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        
       List<Mgawa> list = new ArrayList<>();
       int x,y;
       
       while((x = sc.nextInt()) != 0 && (y =sc.nextInt()) != 0) list.add(new Mgawa(x,y));    
      
       for(Mgawa m : list){
           m.pie();
           System.out.println();
       }
      
       
    }
    
    
}

class Mgawa{
    int x,y;
    Mgawa(int x, int y){
        this.x = x;
        this.y = y;
    }
            

public void pie() {
    
    for(int i=0; i<this.x; i++){
        for(int j=0; j<this.y; j++){
            
        System.out.print("#");
        }
        
        System.out.println();
    }
    
    
}   
        
    
}
       

   




Measured memory_bytes: 35352
#include "bits/stdc++.h"

using namespace std;

void Main() {
    string S;
    cin >> S;
    set<char> alphabet;
    for (int i = 0; i < S.size(); ++i) {
        alphabet.insert(S[i]);
    }
    for (int i = 0; i < 26; ++i) {
        char x = 'a' + i;
        if (alphabet.count(x) == 0) {
            cout << x << endl;
            return;
        }
    }
    cout << "None" << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

#define MAX 1000000
#define XY_MAX 1002
pair<int,int> NIL(0,-1);

int caves[XY_MAX][XY_MAX];
bool nonprime[MAX+1];
pair<int,int> memo[XY_MAX][XY_MAX],inv[MAX+1];
int n,m;

void make_prime() {
	nonprime[0]=nonprime[1]=true;
	for(long long i=2;i*i<=MAX;++i)
		if(!nonprime[i])
			for(long long j=i*i;j<=MAX;j+=i) nonprime[j]=true;
}

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

void make_caves() {
	int x=500,y=500;
	caves[x][y]=1;
	inv[1]={x,y};
	int num=2;
	for(int i=2;;i+=2) {
		for(int d=0;d<4;++d) {
			if(!d) caves[x][++y]=num++;
			for(int j=(d?0:1);j<i;++j) {
				x+=dx[d],y+=dy[d];
				inv[num]={x,y};
				caves[x][y]=num++;
				if(num>MAX) goto en;
			}
		}
	}
en:;
}

pair<int,int> solve(int x,int y) {
	if(memo[x][y]!=NIL) return memo[x][y];
	pair<int,int> res(0,0);
	for(int yy=-1;yy<2;++yy)
		if(caves[x+1][y+yy]&&caves[x+1][y+yy]<=m)
			res=max(res,solve(x+1,y+yy));
	if(!nonprime[caves[x][y]]) {
		if(!res.first) res.second=caves[x][y];
		++res.first;
	}
	return memo[x][y]=res;
}

int main() {
	make_prime();
	make_caves();
	while(cin >> m >> n,m) {
		fill(memo[0],memo[XY_MAX],NIL);
		pair<int,int> res=solve(inv[n].first,inv[n].second);
		cout << res.first << " " << res.second << endl;
	}
	
	return 0;
}


Measured memory_bytes: 23740
S = input()
T = input()
assert 1 <= len(S) and len(S) <= 1000
assert 1 <= len(T) and len(T) <= 1000
assert len(T) <= len(S)
for s in S:
    assert s.islower()
for t in T:
    assert t.islower()
len_T = len(T)
max_count = 0
for i in range(len(S)-len_T+1):
    count = 0
    for j in range(len_T):
        count += int(T[j] == S[i+j]) 
    max_count = max(count, max_count)
print(len_T - max_count)

Measured memory_bytes: 8892
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, k: usize,
        mut pv: [usize; n]
    };

    pv.sort();
    let res = pv.into_iter().take(k).sum::<usize>();
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2276
tmp=raw_input().split(" ")
N=int(tmp[0])
T=int(tmp[1])
Cost=[]
for i in range(N):
  tmp=raw_input().split(" ")
  if int(tmp[1])<=T:
     Cost.append(int(tmp[0]))
if len(Cost)==0:
  print("TLE")
else:
  print(min(Cost)) 

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

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

typedef long long ll;
typedef pair<int, int> pii;

int a, b, c;


int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	cout << max(c - a + b, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
	s.append(input())

print('AC x {}'.format(s.count('AC')))
print('WA x {}'.format(s.count('WA')))
print('TLE x {}'.format(s.count('TLE')))
print('RE x {}'.format(s.count('RE')))

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

const int MOD = 1000000007;

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

    vector<vector<vector<vector<long long int>>>> 
    dp(n+1, 
        vector<vector<vector<long long int>>>(4, 
            vector<vector<long long int>>(4, 
                vector<long long int>(4)
            )
        )
    );
    //d[n][a1][a2][a3] = number of n letters ending with [a3 a2 a1]
    dp[0][0][0][0] = 1;
    for(int i=0; i<n; i++){
        for(int a1=0; a1<4; a1++){// 1 = A, 2 = C, 3 = G, 0 = T
            for(int a2=0; a2<4; a2++){
                for(int a3=0; a3<4; a3++){
                    for(int b=0; b<4; b++){
                        if(b == 2 && a1 == 3 && a2 == 1) continue;// ?AGC
                        if(b == 2 && a1 == 1 && a2 == 3) continue;// ?GAC
                        if(b == 3 && a1 == 2 && a2 == 1) continue;// ?ACG
                        if(b == 2 && a2 == 3 && a3 == 1) continue;// AG?C
                        if(b == 2 && a1 == 3 && a3 == 1) continue;// A?GC
                        dp[i+1][b][a1][a2] += dp[i][a1][a2][a3];
                        dp[i+1][b][a1][a2] %= MOD;
                    }
                }
            }
        }
    }
    long long int answer = 0;
    for(int a1=0; a1<4; a1++){
        for(int a2=0; a2<4; a2++){
            for(int a3=0; a3<4; a3++){
                answer += dp[n][a1][a2][a3];
                answer %= MOD;
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int d,n;
	scanf("%d %d",&d,&n);
	if(n==100) n+=1;
	if(d==0) printf("%d\n",n);
	if(d==1) printf("%d\n",n*100);
	if(d==2) printf("%d\n",n*100*100);
	return 0;
}

Measured memory_bytes: 1724
import java.util.Scanner

import scala.annotation.tailrec

object Util {
  @tailrec
  def loop(start: Int, end: Int)(f: Int => Unit) {
    if (start < end) {
      f(start)
      loop(start + 1, end)(f)
    }
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val a, b = sc.nextLong()
    if (a * b <= 0) {
      println("Zero")
    } else if (a + b > 0) {
      println("Positive")
    } else {
      if ((b - a) % 2 == 0) {
        println("Negative")
      } else {
        println("Positive")
      }
    }

  }
}


Measured memory_bytes: 25804
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int k, n;
    cin >> k >> n;
    vector<int> v(n);
    rep(i, n){
        cin >> v[i];
    }

    vector<int> d(n);
    rep(i, n-1) d[i] = v[i+1] - v[i];
    d[n-1] = v[0] + (k - v[n-1]);

    int maxv = 0, sum = 0;
    rep(i, n){
        sum += d[i];
        chmax(maxv, d[i]);
    }

    cout << sum - maxv << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define OO 0x3f3f3f3f
 
const double eps=(int)1e-9;
const int MOD=998244353;
const int N=998244353;
 
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

int32_t main() {
    IOS;
int n,x,g;
cin>>n>>x;
vi arr(n);
for (size_t i = 0; i < n; i++)
{
    cin>>arr[i];
    arr[i]=abs(arr[i]-x);
}
 g=arr[0];
for (size_t i = 0; i < n; i++)
{
    g=gcd(g,arr[i]);
}
cout<<g<<endl;


}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
	string str = "";

	while (getline (cin, str ) ){

		double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
		stringstream ss(str);

		ss >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2;

		bool inter = true; 

		if ( max (xa1, xa2 ) < min (xb1, xb2 ) 
 		  || min (xa1, xa2 ) > max (xb1, xb2 ) ){
			inter = false;
		}else 
		if ( max (ya1, ya2 ) < min (yb1, yb2 ) 
		  || min (ya1, ya2 ) > max (yb1, yb2 ) ){
			inter = false;
		} // end if

		if (inter){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if
	} //  end while
		
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

ll N,K;
vector<ll> h((ll)1e5+10,INF);
vector<ll> dp((ll)1e5+10,INF);

int main(){
    cin>>N>>K;
    for(ll i=0;i<N;i++) cin>>h[i];
    dp[0]=0;

    for(ll i=0;i<N;i++){
        for(ll j=1;j<=K;j++){
            chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }

    cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
int main()
{
	int N, M;
	cin >> N >> M;
	ll x[1100], y[1100], z[1100];

	for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> z[i];

	int sg[8][3] = {{1, 1, 1},
					  {1, 1, -1},
					  {1, -1, 1},
					  {1, -1, -1},
					  {-1, 1, 1},
					  {-1, 1, -1},
					  {-1, -1, 1},
					  {-1, -1, -1}};

	vector<ll> sum(8);
	for(int i = 0; i < 8; i++) {
		vector<ll> tsum;
		for(int j = 0; j < N; j++) {
			ll tmp = sg[i][0]*x[j] + sg[i][1]*y[j] + sg[i][2]*z[j];
			tsum.push_back(tmp);
		}
		sort(tsum.begin(), tsum.end(), greater<ll>());
		for(int j = 0; j < M; j++) sum[i] += tsum[j];
	}
	
	ll ans = -1;
	for(int i = 0; i < 8; i++){
		if(ans < sum[i]) ans = sum[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
 int n,m;
 while(1){
 cin>>n>>m;
 if(n==0||m==0)return 0;
 	 V<int> data(105,0);
 for(int i=0;i<n;i++){
	 int t;
	 cin>>t;
	 int d;
	 for(int j=0;j<t;j++){
		 cin>>d;
		 data[d]++;
	 }
 }
 int ans=0,ma=0;
 for(int i=0;i<105;i++){
	 if(data[i]>=m&&ma<data[i]){
		 ans=i;
		 ma=data[i];
	 }
 }
cout<<ans<<endl;
 }
}



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

int main() {
    string s;
    cin >> s;
    int p = 0;
    int cnt = 0;
    rep(i,s.size()) {
        if(s[i]=='S') p++;
        else{
            if(p){
                cnt++;
                p--;
            }
        }
    }
    int ans = s.size()-cnt*2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
from itertools import*
s,k=open(0)
k=int(k);x=y=0
g=[len(list(v))for _,v in groupby(s)]
for c in g:x+=c//2
if(s[0]==s[-2])*g[0]%2&g[-2]%2:y=k//2if-len(s)==~g[0]else k-1
print(x*k+y)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
  public  static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    double r = sc.nextDouble();
    double pi = Math.PI;
    double area = r * r * pi;
    double length = 2 * r * pi;
    System.out.printf("%f %f",area ,length);
    sc.close();
  }
}


Measured memory_bytes: 28068
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i <N; i++ ) cin >> A[i];
 
    map<int, int> mp;
    for(int i = 0; i < N; i++){
        mp[A[i]]++;
    }
    vector<int> B;
    for(auto p: mp){
        B.push_back(p.second);
    }
    //cout << "Yes"<<endl;
 
    sort(B.begin(), B.end());
    int sum = 0;
    int f = B.size();
    //cout << B.size() << "  " << K << endl;
    if((f- K) <= 0){
        cout << 0 <<endl;
        return 0;
    }
    else{
        for(int i = 0; i < B.size() - K; i++ ){
            sum += B[i];
        }
        cout << sum <<endl;
    }
}

Measured memory_bytes: 11516
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a),t(b);
    rep(i,a){
        cin>>s[i];
    }
    rep(i,b){
        cin>>t[i];
    }
    //え？lower_boundで死んでね？
    //あ、でもlower_boundしたとこの左右みなきゃだめだ
    sort(ALL(s));sort(ALL(t));
    vector<ll> ans;
    rep(i,q){
        ll x;cin>>x;
        ll tmp1=LINF,tmp2=LINF,tmp3=LINF,tmp4=LINF;
        ll inds=lower_bound(ALL(s),x)-s.begin();
        ll indt=lower_bound(ALL(t),x)-t.begin();
        if(inds<a&&indt<b)tmp1=min(abs(x-s[inds])+abs(s[inds]-t[indt]),abs(x-t[indt])+abs(t[indt]-s[inds]));
        if(inds>0&&indt<b) tmp2=min(abs(x-s[inds-1])+abs(s[inds-1]-t[indt]),abs(x-t[indt])+abs(t[indt]-s[inds-1]));
        if(indt>0&&inds<a) tmp3=min(abs(x-s[inds])+abs(s[inds]-t[indt-1]),abs(x-t[indt-1])+abs(t[indt-1]-s[inds]));
        if(inds>0&&indt>0) tmp4=min(abs(x-s[inds-1])+abs(s[inds-1]-t[indt-1]),abs(x-t[indt-1])+abs(t[indt-1]-s[inds-1]));
        ans.push_back(min({tmp1,tmp2,tmp3,tmp4}));
    }
    rep(i,q){
        cout<<ans[i]<<endl;
    }
    return 0;
}


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

int main() {
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    cin >> s.at(i);
  }
  int a=0;
  for(int i=0;i<s.size()/2;i++){
    if(s.at(i)!=s.at(s.size()-1-i)){
      a++;
    }
  }
       cout << a << endl;
}
       

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
using namespace std;
vector<int> e[110000];
int n,m,i,vis[110000],cnt[2],o,p;
void dfs(int x)
{
	for (int k=0;k<(int)e[x].size();k++)
	{
		int y=e[x][k];
		if (vis[y]==vis[x])
		{
			printf("%lld\n",(ll)n*(n-1)/2-m);
			exit(0);
		}
		if (vis[y]==-1)
		{
			vis[y]=vis[x]^1;
			cnt[vis[y]]++;
			dfs(y);
		}
	}
}
int main()
{
	scanf("%d %d",&n,&m);
	for (i=1;i<=m;i++)
	{
		scanf("%d %d",&o,&p);
		e[o].push_back(p);
		e[p].push_back(o);
	}
	for (i=1;i<=n;i++) vis[i]=-1;
	vis[1]=1;
	cnt[1]=1;
	dfs(1);
	printf("%lld\n",(ll)cnt[0]*cnt[1]-m);
	return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<cstdint>
using namespace std; // 575

const int MAX = 100001;
int main() {
	int N, Q;
	static int A[MAX], X;
	cin >> N >> Q;
	for (int i = 0;i < N;++ i) cin >> A[i];
	
	static int64_t sum = 0;
	static pair<int, int64_t> ans[MAX];
	for (int i = N / 2;i < N;++ i) sum += A[i];
	ans[0] = make_pair(0, sum);
	for (int i = 0, l = (N + 1) % 2, r = N / 2;r < N;++ i, l += 2, ++ r) { // 区間(l, r]ですね
		ans[i + 1] = make_pair(A[l] + (A[r] - A[l]) / 2, sum -= A[r] - A[l]);
	}
	
	for (int i = 0, min, mid, max, halfDiff;i < Q;++ i) {
		min = 0;
		max = (N + 3) / 2;
		cin >> X;
		while(halfDiff = max - min >> 1) (ans[mid = min + halfDiff].first < X ? min : max) = mid;
		cout << ans[min].second << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

O(N+QlogX)
*/

Measured memory_bytes: 2944
<?php
fscanf(STDIN, '%d', $N);
fscanf(STDIN, '%s', $S);
$a = str_split($S);
$c = array_count_values($a);
$ans = $t = $c["."] ?? 0;
for ($i = 0; $i < $N; $i++) {
    if ($a[$i] === '#') {
        $t++;
    } else {
        $t--;
        $ans = min($ans, $t);
    }
}
echo $ans;


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

void printArray(int *a,int n);
void insertSort(int *a,int n);

int main(void) {
    int i,n;
    int a[100];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    printArray(a,n);
    insertSort(a,n);
    
    return 0;
}

void insertSort(int *a,int n){
    int i,j,v;
    for(i=1;i<n;i++){
        v = *(a+i);
        j = i - 1;
        while(j>=0 && *(a+j)>v){
            *(a+j+1) = *(a+j);
            j--;
        }
        *(a+j+1) = v;
        printArray(a,n);
    }
}

void printArray(int *a,int n){
    int i;
    for(i=0;i<n-1;i++){
        printf("%d ",*(a+i));
    }
    printf("%d\n",*(a+n-1));
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> b(n);
  for(int i = 0; i < n; i++) cin >> b.at(i);
  
  vector<int> ans;
  for(int i = 0; i < n; i++){
    bool flag = false;
    for(int j = b.size() - 1; j >= 0; j--){
      if(b.at(j) == j + 1){
        ans.push_back(b.at(j));
        b.erase(b.begin() + j);
        flag = true;
        break;
      }
    }
    if(!flag){
      cout << -1 << '\n';
      return 0;
    }
  }
  
  for(int i = n - 1; i >= 0; i--) cout << ans.at(i) << '\n';
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader breader = getReader();

		int n = getInt(breader);
		int[] ary = getAry(breader);
		putAry(ary);
		for( int i = 1 ; i < ary.length ; i++) {
			int key = ary[i] ;
			int j = i - 1;
			while( j >= 0 && ary[j] > key ) {
				ary[j+1] = ary[j] ;
				j--;
			}
			ary[j+1] = key;
			putAry(ary);
		}
	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static int[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static void putAry(int[] ary) {
		for( int i = 0; i < ary.length ; i++ ) {
			System.out.print(ary[i]);
			if ( i < ary.length-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}

}

Measured memory_bytes: 25936
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



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

	vector<int> x(n), y(n);//ソートなし
	vector<int> xary, yary;//ソート

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		xary.push_back(x[i]);
		yary.push_back(y[i]);
	}

	sort(begin(xary), end(xary));//x、y別々で考えてよい。
	sort(begin(yary), end(yary));

	ll ans = 1LL * (xary[n - 1] - xary[0])*(yary[n - 1] - yary[0]);

	for (int xi = 0; xi < n; xi++) {
		for (int xj = xi + 1; xj < n; xj++) {
			for (int yi = 0; yi < n; yi++) {
				for (int yj = yi + 1; yj < n; yj++) {
					int num = 0;
					ll lx = xary[xi], rx = xary[xj];
					ll by = yary[yi], uy = yary[yj];

					for (int i = 0; i < n; i++) {
						if (lx <= x[i] && x[i] <= rx&&by <= y[i] && y[i] <= uy) {
							num++;
						}
					}

					if (num >= k)ans = min(ans, 1LL * (rx - lx)*(uy - by));

				}
			}
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    s = S()
    d = collections.defaultdict(int)
    for c in s:
        d[c] += 1
    l = d['(']
    r = d[')']

    if l > r:
        s += ')' * (l-r)
    elif r > l:
        s = '(' * (r-l) + s

    c = 0
    rc = 0
    i = 0
    while i < len(s):
        if s[i] == '(':
            c += 1
        else:
            c -= 1
        if c < 0:
            rc += 1
            c = 0
        i += 1
    s = '(' * rc + s + ')' * rc
    return s


print(main())


Measured memory_bytes: 5456
#include<iostream>
// #include<string>
using namespace std;
int N;
int A[201];

int main(){
    cin >> N;
    for (int i =0;i<N;++i) cin >> A[i];
    int res=0;

    while (true){
        bool exist_odd = false;
        for (int i=0;i<N;++i){
            if (A[i]%2 !=0) exist_odd=true;

        }
    if (exist_odd) break;

    for (int i=0; i<N; ++i){
        A[i]/=2;
    }
    ++res;
    }
    cout <<res <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<iterator>
#include<map>
#include<queue>
#define REP(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
using namespace std;

int A[200001] = {};
int B[200001] = {};

priority_queue<P,vector<P>,greater<P>> q;

int main()
{
	REP(i, 200001)
	{
		A[i] = -1;
		B[i] = 0;
	}
	int N, K;
	int cnt = 0;
	int ans = 0;
	cin >> N >> K;
	REP(i, N)
	{
		int tmp;
		cin >> tmp;
		if (B[tmp] == 0)
		{
			cnt++;
		}
		A[i] = tmp;
		B[A[i]]++;
	}
	REP(i, N+1)
	{
		if (B[i] == 0)continue;
		pair<int, int> p = make_pair(B[i], i);
		q.push(p);
	}
	while (q.empty()==false)
	{
		if (cnt <= K)break;
		P top = q.top();
		top.first -= 1;
		ans++;
		q.pop();
		if (top.first <= 0)
		{
			cnt--;
		}
		else
		{
			q.push(top);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3956
X, Y, Z, K = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)

arr = []

for i, a in enumerate(A):
    for j, b in enumerate(B):
        if (i+1) * (j+1) > K:
            break
        for k, c in enumerate(C):
            if (i+1) * (j+1) * (k+1) <= K:
                arr.append(a + b + c)
            else:
                break

arr.sort(reverse=True)

for i in range(K):
    print(arr[i])

Measured memory_bytes: 8708
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

min_cost = 10 ** 18

def func(n, select):
	global min_cost
	if n == 0:
		if len(set(select) - {0}) < 3:
			return
		#print(select)
		cost = 0
		a, b, c = 0, 0, 0
		for i, t in enumerate(select):
			if t == 1:
				if a != 0:
					cost += 10
				a += L[i]
			if t == 2:
				if b != 0:
					cost += 10
				b += L[i]
			if t == 3:
				if c != 0:
					cost += 10
				c += L[i]
		cost += abs(A - a)
		cost += abs(B - b)
		cost += abs(C - c)
		min_cost = min(min_cost, cost)
		return
	for i in range(4):
		func(n - 1, select + [i])

func(N, [])
print(min_cost)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here
bool check(vector<bool> C, vector<int> V) {
    return C.at(V.at(0)) * C.at(V.at(1)) * C.at(V.at(2));
}

int main() {
    vector<int> A(9); rep(i, 9) cin >> A.at(i);
    vector<bool> C(9, false);
    vector<vector<int>> bingo{{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{2,4,6},{8,4,0}};
    int n; cin >> n;

    rep(i, n) {
        int b; cin >> b;
        rep(j, 9) if(b == A.at(j)) C.at(j) = true;
    }

    rep(i, 8) {
        if (check(C, bingo.at(i))) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

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

using namespace std;

int main(){
  int n, k;cin>>n>>k;
  vector<int>a(n);
  rep(i, n){
    cin>>a[i];
  }

  int dp[100001];
  memset(dp, 0, sizeof(dp));
  
  dp[0]=-1;
  for(int i=1; i<=k; i++){
    bool f = true;
    rep(j, n){
      if(i >= a[j]){
        if(dp[i-a[j]]==-1){
          dp[i]=a[j];
          f=false;
          break;
        }
      }
    }
    if(f)dp[i]=-1;
//rep(i, k+1)cout<<dp[i]<<' ';cout<<endl;
  }

  if(dp[k] != -1)cout<<"First"<<endl;
  else cout<<"Second"<<endl;

  return 0;
}

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


using namespace std;

#define MAXH 2010
#define MAXW 2010

int h, w;
char mat[MAXH][MAXW];
int lef[MAXH][MAXW], rig[MAXH][MAXW], up[MAXH][MAXW], dow[MAXH][MAXW];

int main() {
    scanf("%d %d", &h, &w);
    int i, j, k;
    for (i=1; i<=h; i++) {
        scanf("%s", mat[i]+1);
    }

    for (i=1; i<=h; i++) {
        for (j=1; j<=w; j++) {
            if (mat[i][j]=='#') {
                lef[i][j]=0;
                up[i][j]=0;
            }
            else {
                lef[i][j]=lef[i][j-1]+1;
                up[i][j]=up[i-1][j]+1;
            }
        }
    }
    for (i=h; i>=1; i--) {
        for (j=w; j>=1; j--) {
            if (mat[i][j]=='#') {
                rig[i][j]=0;
                dow[i][j]=0;
            }
            else {
                rig[i][j]=rig[i][j+1]+1;
                dow[i][j]=dow[i+1][j]+1;
            }
        }
    }
    int ans = 0;
    for (i=1; i<=h; i++) {
        for (j=1; j<=w; j++) {
            ans = max(ans, lef[i][j]+rig[i][j]+up[i][j]+dow[i][j]-3);
        }
    }
    printf("%d\n", ans);
    return 0;
}








Measured memory_bytes: 67328
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}


int main(){
    int r,D;
    long long x2000;
    int c=2001;
    cin >>r>>D >>x2000;
    //int ans;

    while(c<2011){
        long long tmp= r*x2000 -D;
        cout<< tmp<<endl;
        c++;
        x2000=tmp;
    }
    
    
    //cout << ans << endl;
    return 0;
}

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

using namespace std;
vector<pair<int,int> > ans(100);
vector<vector<int> > da(100);
vector<bool> ju(100,false);

void dfs(int m,int &ti){
    bool ch=true;
    for(int i=0;i<da[m].size();i++){
        if(!ju[da[m][i]]){
            ju[da[m][i]]=true;
            ch=false;
            ti++;
            ans[da[m][i]].first=ti;
            dfs(da[m][i],ti);
        }
    }
    ti++;
    ans[m].second=ti;
}

int main(){
    int n,ti=0;
    cin >> n;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int y;
        cin >> y;
        vector<int> iin(y);
        for(int j=0;j<y;j++){
            cin >>iin[j];
            iin[j]--;
        }
        da[x-1]=iin;
    }
    for(int i=0;i<n;i++){
        if(!ju[i]){
            ju[i]=true;
            ti++;
            ans[i].first=ti;
            dfs(i,ti);
        }
    }
    for(int i=0;i<n;i++){
        cout << i+1 << ' ' << ans[i].first << ' ' << ans[i].second << endl; 
    }
}


Measured memory_bytes: 3168
#include <iostream>
using namespace std;
int count(int i){
    int sum=0;
    while(i>0)
    {
        sum+=i%10;
        i=i/10;
        
        
    }
    
    
    return sum;
}
 
int main() {
    int n,a,b;
    int sum=0;
    int cal;
    cin>>n>>a>>b;
    for(int i=0;i<=n;i++)
    {
        cal=count(i);
        if(cal<=b&&a<=cal)
            sum+=i;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    int ans = 1;
    int curr = 0;
    for(int i=0; i<n; i++){
        curr += l[i];
        if(curr <= x) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

signed main()
{
    int h,n;
    //int arr[n];
    cin>>h>>n;
     int arr[n];
    int s=0;
    for(int  i=0;i<n;i++)
    {
        cin>>arr[i];
        s+=arr[i];
    }
  if(s>=h)
  cout<<"Yes";
  else
  cout<<"No";
   // cout<<s;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

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

    if (a >= 13)
    {
        cout << b;
    }
    else if (a >= 6)
    {
        cout << b / 2;
    }
    else
    {
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
//PseudoName

    #pragma GCC optimize("O3")
    #include <bits/stdc++.h>
/*
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
    #define FOR(i,n) for(i=0;i<n;i++)
    #define FOR1(i,n) for(i=1;i<=n;i++)
    #define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
    #define pb push_back
    #define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
    #define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
    #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define endl "\n"
    #define min3(a,b,c) min(a,min(b,c))
    #define forr(n) for(int i=0;i<n;i++)
    #define frr(n) for(int i=1;i<=n;i++)
    #define MAX 200005
    #define inf 200008

    using namespace std;

    typedef long long ll;
    typedef long li;
    typedef vector<int> vi;
    typedef vector<ll> vli;
    typedef vector<vi> vvi;
    typedef vector<vli> vvli;
    typedef pair<int,int> pi;
    typedef pair<ll,ll> pli;
    typedef vector<pi> vpi;
    typedef vector<pli> vpli;




    int main() {
        fast();
       int x,y,z;
       cin>>x>>y>>z;
       swap(x,y);
       swap(x,z);
       cout<<x<<" "<<y<<" "<<z<<endl;

    }


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int n,A,B,C;
V<int> d;
inline int fanc(int i,int a,int b, int c){
  int res=INT_MAX;
  if(i==n){
      if(a&&b&&c)return abs(a-A)+abs(b-B)+abs(c-C);
       else return 1e5;
  }
  chmin(res,fanc(i+1,a,b,c));
  chmin(res,fanc(i+1,a+d[i],b,c)+(a?10:0));
  chmin(res,fanc(i+1,a,b+d[i],c)+(b?10:0));
  chmin(res,fanc(i+1,a,b,c+d[i])+(c?10:0));
  return res;
}
int main(){
  cin>>n>>A>>B>>C;
  d.resize(n);
  for(int i=0;i<n;i++)cin>>d[i];
  cout<<fanc(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
total_cnt = 0
cnt_list = []

for i in range(N):
    cnt_list.append(0)

    while (A_list[i] % 2 == 0):
        A_list[i] /= 2
        cnt_list[i] += 1

    total_cnt += cnt_list[i]

print(total_cnt)


Measured memory_bytes: 4148
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
    string s,t;
    cin >> s >> t;
    int n=  s.size();
    int m = t.size();
    int ans = m;
    for(int i=0;i+m-1<n;i++){
       int ch=0;
       for(int j=0;j<m;j++){
          ch += (s[i+j]!=t[j]);
       }
       ans = min(ans,ch);
    }
    cout << ans;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow

Measured memory_bytes: 3656
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
inline void solve(void){
  int N,K,S;in(N,K,S);
  if(K==N){
    rep(i,K){
      cout<<S<<" \n"[i==K-1];
    }
    return;
  }
  rep(i,K){
    cout<<S<<" ";
  }
  rep(i,N-K){
    if(S!=1)cout<<S/2+1<<" \n"[i==N-K-1];
    else cout<<S+1<<" \n"[i==N-K-1];
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int n,m; cin >> n >> m;
	vi k(m),p(m);
	vvi s(m);
	rep(i,m){
		cin >> k[i];
		s[i] = vi(k[i]);
		rep(j,k[i]){ 
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	rep(i,m) cin >> p[i];
	int ans = 0;
	rep(t,(1<<n)){
		bool all_on = true;
		rep(i,m){
			int sum = 0;
			rep(j,k[i]){ 
				if((t>>s[i][j])%2) sum++;
			}
			if(sum%2!=p[i]) all_on = false;
		}
		if(all_on) ans++;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll n, m;  cin >> n >> m;
	for(ll i = m / n + 1; 1 <= i ; i--){
		if(m % i == 0 && m / i >= n){
			cout << i << endl;
			break;
			}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    ll X;
    cin >> X;

    ll A, B;
    for (A = -120; A < 120; A++)
    {
        for (B = -120; B < 120; B++)
        {
            if (pow(A, 5) - pow(B, 5) == X)
            {
                printf("%lld %lld\n", A, B);
                return (0);
            }
        }
    }
    return (0);
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    string S,T;cin>>S>>T;
    vector<int> when[26];
    for(int i=0;i<S.size();i++){
        when[S[i]-'a'].push_back(i);
    }
    bool ok=true;
    ll cnt=-1;
    
    for(int i=0;i<T.size();i++){
        int a=T[i]-'a';
        if(when[a].size()==0){
            ok=false;
            break;
        }
        auto it=upper_bound(all(when[a]),cnt%ll(S.size()));
        if(it==when[a].end()){
            int b=when[a][0];
            cnt=(cnt/ll(S.size())+1)*ll(S.size())+b;
        }else{
            cnt=cnt/ll(S.size())*ll(S.size())+*it;
        }
    }
    
    if(ok) cout<<cnt+1<<endl;
    else cout<<-1<<endl;
}




Measured memory_bytes: 1216
from itertools import permutations
from collections import defaultdict
import math

def mapt(fn, *args):
    return tuple(map(fn, *args))

n = int(input())
cities = [mapt(int, input().split(" ")) for i in range(n)]
list1 = list(permutations(range(1, n+1), n))


def some(index1, index2):
    index1 -= 1
    index2 -= 1
    x1, y1 = cities[index1]
    x2, y2 = cities[index2]
    r = math.sqrt((x1-x2)**2 +(y1-y2)**2)
    # print(r)
    return r

ans = 0
for row in list1:
    for i in range(n-1):
        # print(row[i:i+2])
        ans += some(*row[i:i+2])
    # print()
print(ans/len(list1))

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

int n=1, m=1;

int main() {
    for (;n+m != 0;) {
        cin >> n >> m;
        int a[n*m];
        for (int i=0; i<n*m; i++) cin >> a[i];
        int sum[n];
        for (int i=0; i<n; i++) sum[i]=0;
        for (int i=0; i<n; i++) {
            for (int j=0; j<m; j++) sum[i] += a[j*n+i];
        }
        sort (sum , sum + n);
        if (n+m !=0) cout << sum[n-1] << endl;
    }
}


Measured memory_bytes: 3324
//abc118_b.cpp
//Tue Mar  5 20:19:41 2019

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

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

	int food[m];
	fill(food,food+m,0);
	for (int i=0;i<n;i++){
		int k;
		cin >> k;
		for (int j=0;j<k;j++){
			int a;
			cin >> a;
			a--;
			food[a]++;
		}
	}

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

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  
#include <numeric>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define endl '\n'
using ll = long long;
 
const int precision = 3;
const int modulo =  1000000007; // 10^9 + 7
const ll lmodulo =  1000000007; // 10^9 + 7
 
const double EPS = 1e-9;
const ll inf = 1e18;
 

void solve() {
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for (auto &it : h) cin >> it;

	vector<int> dp(n, 1e9 + 100);
	dp[0] = 0;

	for (auto i = 1; i < n; ++i) {
		for (int j = i - 1; j >= i - k and j >= 0; --j) {
			int a = abs(h[i] - h[j]);
			dp[i] = min(dp[i], a + dp[j]);
		}
	}

	cout << dp[n - 1];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(precision);
  cout.setf(ios_base::fixed);
  solve();
  return 0;
}



Measured memory_bytes: 1024