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


using namespace std;

const int N = 100100;

int x[N];
int dx[N];
int p[N];


int ans[N], tmp[N];

int main() {
	int n, m;
	long long k;
	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < n-1; ++i) {
		dx[i] = x[i+1] - x[i];
	}
	scanf("%d%lld", &m, &k);

	for (int i = 0; i < n-1; ++i) {
		p[i] = i;
	}

	for (int i = 0; i < m; ++i) {
		int y;
		scanf("%d", &y);
		y--;
		swap(p[y-1], p[y]);
	}

	for (int i = 0; i < n-1; ++i) {
		ans[i] = i;
	}
	// tem outro jeito que achar o ciclo explicitamente, mas esse mais facil codar...
	for (;k; k >>= 1) {
		if (k & 1) {
			for (int i = 0; i < n-1; ++i) {
				tmp[i] = ans[p[i]];
			}
			for (int i = 0; i < n-1; ++i) {
				ans[i] = tmp[i];
			}
		}

		for (int i = 0; i < n-1; ++i) {
			tmp[i] = p[p[i]];
		}
		for (int i = 0; i < n-1; ++i) {
			p[i] = tmp[i];
		}
	}
	long long val = x[0];
	printf("%lld\n", val);
	for (int i = 0; i < n-1; ++i) {
		val += dx[ans[i]];
		printf("%lld\n", val);
	}
}

Measured memory_bytes: 3200
//https://qiita.com/drken/items/dc53c683d6de8aeacf5a
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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 long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
n=int(input())
m=10**9+7
dp=[[[[0 for _ in range(5)]for _ in range(5)]for _ in range(5)]for _ in range(n+1)]
dp[0][0][0][0]=1
for x in range(n):
  for i in range(5):
    for j in range(5):
      for k in range(5):
        for l in range(1,5):
          if i==1 and j==2 and l==3:continue
          if i==1 and k==2 and l==3:continue
          if j==1 and k==2 and l==3:continue
          if j==2 and k==1 and l==3:continue
          if j==1 and k==3 and l==2:continue
          dp[x+1][j][k][l]+=dp[x][i][j][k]
          dp[x+1][j][k][l]%=m
a=0
for i in range(1,5):
  for j in range(1,5):
    for k in range(1,5):
      a+=dp[n][i][j][k]
      a%=m
print(a)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7
 
int main()
{
	ninja
			vector<pair<string, pair<int,int>>> v;

	int n;int i=1; cin>>n; 
	while(n--)
	{
		string s; cin>>s;
		int sc; cin>>sc;
		//int i=1;
		v.pb(mp(s,mp(-sc,i)));
i++;
	}
	sort(all(v));
	for(int i=0;i<v.size();i++)
		cout<<v[i].ss.ss<<nl;
}


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

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		TreeSet<Integer> set=new TreeSet<>();
		int n=in.nextInt();
		for(int i=0;i<n;i++) {
			set.add(Integer.parseInt(in.next()));
		}
		
		int m=in.nextInt();
		
		for(int i=0;i<m;i++) {
			int obj=Integer.parseInt(in.next());
			if(set.contains(obj))set.remove(obj);
			else set.add(obj);
		}
		
		PrintWriter out=new PrintWriter(System.out);
		Iterator<Integer> itr=set.iterator();
		while(itr.hasNext()) {
			out.println(itr.next());
		}
		out.flush();
	}

}



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

int n;
string s1, s2;
const lint mod = 1e9 + 7;

int main() {
    cin >> n >> s1 >> s2;
    int now = 0;
    lint ans = 1;
    while (now < n) {
        bool now_vertical = s1[now] == s2[now];
        if (now == 0) {
            if (now_vertical) {
                ans = ans * 3 % mod;
            } else {
                ans = ans * 6 % mod;
            }
        } else {
            bool before_vertical = s1[now - 1] == s2[now - 1];
            lint mult;
            if (before_vertical) {
                mult = 2;
            } else {
                if (now_vertical) {
                    mult = 1;
                } else {
                    mult = 3;
                }
            }
            ans = ans * mult % mod;
        }
        if (now_vertical) {
            now += 1;
        } else {
            now += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h> 
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin>>N;
  vector<int> v;
  int a = 0;
  int b = 0;
  int num = 0;
  for(int i = 0;i < N;i++){
    int c;
    cin>>c;
    v.push_back(c);
    //cout<<"ARR"<<arr[N]<<'\n';
  }
  sort(v.begin(),v.end());
  // for(int i = 0;i < N;i++){
  //   num += 1;
  //   if(num * 2 == N){
  //     a = arr[i];
  //     cout<<"A"<<arr[i]<<'\n';
  //     b = arr[i + 1];
  //     cout<<"B"<<arr[i]<<'\n';
  //   }

    // if((i + 1) * 2 == N){
    //   a = arr[i];
    //   b = arr[i + 1];
    //   break;       
    // } 
//}
  cout<<v[v.size() / 2] - v[v.size() / 2 - 1]<<'\n';
}

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	while (true) {
		cin >> n >> m;
		if (!n && !m) break;
		vector<int> p(n), half(1);
		for (auto& i : p) {
			cin >> i;
			half.push_back(i);
		}
		for (auto i = 0; i < n; i++)
			for (auto j = i; j < n; j++)
				half.push_back(p[i]+p[j]);
		sort(begin(half), end(half));
		int res = 0;
		for (auto& i : half) {
			if (i > m) break;
			auto ideal = m-i;
			auto ub = upper_bound(begin(half), end(half), ideal);
			if (ub != begin(half)) --ub; 
			res = max(res, i+*ub);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 5044
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        List<Integer> difficult = new ArrayList<Integer>();
        int N;
        
        N = sc.nextInt();
        for(int i=0; i<N; i++)  difficult.add(sc.nextInt());
        
        Collections.sort(difficult);
        
        System.out.println(difficult.get(N/2) - difficult.get(N/2 - 1));
    }
}


Measured memory_bytes: 62728
use std::io::*;
const MOD: u64 = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<Vec<char>> = (0..h)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();

    let mut dp: Vec<Vec<u64>> = vec![vec![0; w + 1]; h + 1];
    dp[0][0] = 1;
    for i in 0..h {
        for j in 0..w {
            if j < w - 1 && a[i][j + 1] == '.' {
                dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
            }
            if i < h - 1 && a[i + 1][j] == '.' {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
            }
        }
    }
    println!("{}", dp[h - 1][w - 1]);
}


Measured memory_bytes: 16764
N = int(input())
K = 1
while K * (K - 1) // 2 <= N:
    if K * (K - 1) // 2 == N:
        break
    K += 1
else:
    print('No')
    exit()

print('Yes')
s = 1
ans = [[] for i in range(K)]
for k in range(K - 1, 0, -1):
    for i in range(k):
        ans[K - k - 1].append(s + i)
        ans[K - k + i].append(s + i)
    s += k

print(K)
for i in range(K):
    ans[i].insert(0, len(ans[i]))
    print(*ans[i])



Measured memory_bytes: 12580
#include <iostream>
#include <string.h>

int main() {
  using namespace std;
  typedef unsigned long ulong;
  
  ios_base::sync_with_stdio(false);
  
  int ballCount;
  cin >> ballCount;
  
  int *ballno = new int[ballCount];
  for (int *p = ballno, *end = ballno + ballCount ; p != end ; p++) {
    cin >> *p;
  }
  
  int dicCount = ballCount + 1;
  int *dic = new int[dicCount];
  
  memset(dic, 0, dicCount<<2);
  for (int *p = ballno, *end = ballno + ballCount ; p != end ; p++) {
    dic[*p]++;
  }

  ulong sum = 0;
  for (int *p = dic, *end = dic + dicCount; p != end ; p++) {
    sum += ((ulong)*p) * (*p - 1);
  }
  sum >>= 1;
  
  for (int *p = ballno, *end = ballno + ballCount ; p != end ; p++) {
    cout << sum + 1 - dic[*p] << '\n';
  }
  
  delete[] ballno, dic;
}


Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int A[2][N];
  for (int i = 0; i < N; i++)
    cin >> A[0][i];
  for (int i = 0; i < N; i++)
    cin >> A[1][i];
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int tmp = 0;
    for (int j = 0; j <= i; j++)
      tmp += A[0][j];
    for (int j = i; j < N; j++)
      tmp += A[1][j];
    if (ans < tmp)
      ans = tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
//#define random_shuffle(r...) random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
ll prime[1000000];bool visprime[10000000];
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime[k++]=i;}}
int myrandom (int i) { return std::rand()%i;}

bool checkbit(int mask,int bit) {return (mask & (1<<bit));}

ll fact(ll n)
{
    if(n==0) return 1;
    if(n==1) return 1;
    ll ret=((n%mod)*(fact(n-1)%mod))%mod;
    return ret;

}

int main()
{

   int n;
   //cout<<fact(3)<<" "<<fact(8)<<endl;
   cin>>n;
   ll f=fact(n);
   double dis=0;
   vector<pair<int,int>>v;
   vector<int>p;
   vector<int>temp[50000];
   for(int i=0;i<n;i++)
   {
       double x,y;
       cin>>x>>y;
       v.pb({x,y});
       p.pb(i);

   }
   for(int i=0;i<p.size();i++)
       temp[0].pb(p[i]);
       int k=1;
    //cout<<p.size()<<endl;
   while(next_permutation(p.begin(),p.end()))
   {

       for(int i=0;i<p.size();i++)
       {temp[k].pb(p[i]); }

       k++;
   }




   //cout<<"HERE"<<endl;


   for(int i=0;i<f;i++)
   {
       double tem=0;
     //  cout<<temp[i][0]<<" ";
       for(int j=1;j<temp[i].size();j++)
         {

             //cout<<temp[i][j]<<" ";
             int k=temp[i][j];
             int l=temp[i][j-1];
             tem+= sqrt(((v[k].first-v[l].first)*(v[k].first-v[l].first)) +((v[k].second-v[l].second)*(v[k].second-v[l].second)));

         }
        // cout<<endl;

        dis+=tem;
        //cout<<tem<<endl;


   }




   //cout<<

   dis=dis/(double)f;
   printf("%.10f\n",dis);


}
















Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }




const int MOD = 998244353;
int m_add(int a, int b)
{
	return (a + b) % MOD;
}
int m_sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int m_mul(int a, int b)
{
	return (a * b) % MOD;
}
int m_pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = m_pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int m_div(int a, int b)
{
	return m_mul(a, m_pow(b, MOD - 2));
}
int m_comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = m_mul(p, (n - i + 1));
		p = m_div(p, i);
	}
	return p;
}
int m_comb_with_rep(int n, int r)
{
	return m_comb(n + r - 1, r);
}

//---------- 組み合わせ ----------
int comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = (p * (n - i + 1) / i) % MOD;
	}
	return p;
}



signed main()
{
	int N, M, K;
	cin >> N >> M >> K;

	int ans = m_mul(M, m_pow(M - 1, N - 1));

	int c = 1;

	for (int k = 1; k <= K; k++)
	{
		c = m_mul(c, N - 1 - (k - 1));
		c = m_div(c, k);

		int p = m_pow(M - 1, N - k - 1);
		int d = m_mul(M, p);
		d = m_mul(d, c);

		ans = m_add(d, ans);

	}

	cout << ans << endl;
}

 

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

int main() {
	string str;
	cin >> str;
	
  	int a = 0;
	for(int i = 0; i < str.size();i++){
		if(str.at(i) == 'a'){	
    		cout << "vowel" << endl;
        }
      	else if(str.at(i) == 'e'){
         	cout << "vowel" << endl;
        }
      	else if(str.at(i) == 'i'){
          	cout << "vowel" << endl;
        }
      	else if(str.at(i) == 'o'){
         	cout << "vowel" << endl;
        }
      	else if(str.at(i) == 'u'){
          	cout << "vowel" << endl;
        }
      	else{
     		cout << "consonant" << endl;
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int> > joho(N,vector<int>(4));
  for (int i=0; i<N; i++) {
      cin >> joho.at(i).at(0) >> joho.at(i).at(1) >> joho.at(i).at(2) >> joho.at(i).at(3);
  }
  vector<vector<vector<int> > > output(4,vector<vector<int> >(3,vector<int>(10)));
  
    for (int i=0; i<4; i++) {
      for (int j=0; j<3; j++) {
          for (int k=0; k<10; k++) {
              output.at(i).at(j).at(k)=0;
          }
      }
  }

for (int i=0; i<N; i++) {
    output.at(joho.at(i).at(0)-1).at(joho.at(i).at(1)-1).at(joho.at(i).at(2)-1)+=joho.at(i).at(3);
}
  
  for (int i=0; i<4; i++) {
      for (int j=0; j<3; j++) {
          for (int k=0; k<10; k++) {
              cout << " " << output.at(i).at(j).at(k);
          }
          cout << endl;
      }
      if (i!=3) cout << "####################" << endl;
  }
}


Measured memory_bytes: 3168
import java.util.Scanner;
class Main {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		// TODO Auto-generated method stub
		int a;
		a = scanner.nextInt();
		int b;
		b = scanner.nextInt();		
		
		System.out.println(a*b+" "+2*(a+b));
		
	}

}

Measured memory_bytes: 26060
#include<iostream>
#include<algorithm>

#define MAX		220
#define MISS	-100

using namespace std;

struct Huku
{
	//最低気温・最高気温・派手さ
	int max , min , h;
};

int main(void)
{
	int d , n;
	int dp[MAX][MAX] = {0};
	Huku huku[MAX] = {0};
	//日数別気温
	int days[MAX] = {0};
	//前日の派手さ
	int be[MAX][MAX] = {0};

	cin >> d >> n;
	for (int i = 0; i < d; i++)
	{
		cin >> days[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> huku[i].min >> huku[i].max >> huku[i].h;
	}

	for (int i = 0; i < n; i++)
	{
		if (huku[i].max >= days[0] && huku[i].min <= days[0])
		{
			be[0][i] = huku[i].h;
		}
		else
		{
			be[0][i] = MISS;
		}
	}

	for (int i = 1; i < d; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (huku[j].max >= days[i] && huku[j].min <= days[i])
			{
				for (int k = 0; k < n; k++)
				{
					//dpの前の部分がMISSなら不可
					if (be[i - 1][k] == MISS)
					{
						continue;
					}

					//現在の派手さと前回に選んだ派手さを比較
					int _max = max(be[i - 1][k] , huku[j].h);
					int _min = min(be[i - 1][k] , huku[j].h);

					if (dp[i][j] <= dp[i - 1][k] + _max - _min)
					{
						dp[i][j] = dp[i - 1][k] + _max - _min;
						be[i][j] = huku[j].h;
					}
				}
			}
		}
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		ans = max(ans , dp[d - 1][i]);
	}

	cout << ans << endl;

	return 0;


}

Measured memory_bytes: 1548
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<vector>
#include<cstring>
#define ll long long int
#define mod 1000000007
#define lp(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
ll max(ll a,ll b){
    return a>b?a:b;
}
int main(){
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        ll n;
        cin>>n;
       double p[n];
        lp(i,n)
        cin>>p[i];
       double dp[n+1][n+1];
        memset(dp,0.0,sizeof(dp));
        dp[0][0]=1.0;
        loop(i,1,n+1)
        lp(j,i+1){
            if(j!=0)
            dp[i][j]=p[i-1]*dp[i-1][j-1]+(1.0-p[i-1])*dp[i-1][j];
            else
            {
                dp[i][j]=(1.0-p[i-1])*dp[i-1][j];
                /* code */
            }
            
        }
        ll k=(n+1)/2;
       double ans=0.0;
        // lp(i,n+1)
        // {
        //     lp(j,i+1)
        //  //   cout<<dp[i][j]<<" ";
        //  //   cout<<endl;
        // }
        loop(i,k,n+1)
        {
           // cout<<dp[n][k]<<endl;
        ans+=dp[n][i];

        }

      //  cout<<ans<<endl;
        printf("%0.15lf",ans);
    }
    
    return 0;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define PI acos(-1LL)


#ifdef LOCAL
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#else
#define debug(...) 11;
#endif


const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 2e17 + 12;


void solve() {
    string s, t;
    cin >> s >> t;
    int mx = t.size();
    for(int i=0; i<=s.size()-t.size(); i++){
        int cnt = 0;
        for(int j=0; j<t.size(); j++){
            if(s[i+j] != t[j]) cnt++;
        }
        mx = min(mx, cnt);
    }
    cout << mx << endl;
}
signed main(){
    FAST
#ifdef TIMER
    clock_t start;
    double duration;
    start = clock();
#endif
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
#ifdef TIMER
    duration = (clock() - start) / (double) CLOCKS_PER_SEC;
    cerr <<"\n\nTotal time elapsed: "<< duration <<"sec\n";
#endif
}


Measured memory_bytes: 3652
n = int(input())
s = list(input())
p = []
i = 0
while i < n:
    if i < n-1 and s[i] == s[i+1]:
        p.append(s[i])
        i += 1
        while i < n-1 and s[i] == s[i+1]:
            i += 1
        i+=1
    else:
        p.append(s[i])
        i += 1
print(len(p))

Measured memory_bytes: 4652
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# from collections import deque
import heapq

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# A = sorted(A, reverse=True)
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

heapq.heapify(A)
for i in range(M):
    max_num = heapq.heappop(A) * (-1)
    heapq.heappush(A, (-1) * (max_num // 2))

A = map(lambda x: x*(-1), A)
print(sum(A))
    

Measured memory_bytes: 20540
w,h,n=map(int,input().split())
b=c=0
for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1:b=max(b,x)
    if a==2:w=min(w,x)
    if a==3:c=max(c,y)
    if a==4:h=min(h,y)
print(max(0,(w-b))*max(0,(h-c)))

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;

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

	string ans = "Three";
	for (int i = 0; i < N; i++)
	{
		string tmp;
		cin >> tmp;
		if (tmp == "Y")
		{
			ans = "Four";
			break;
		}
	}

	cout << ans << endl;

	return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
vector<ll> C(26);
vector<vector<ll>> S;

ll change_evaluation(vector<ll>& T, ll t, ll day) {
  t -= 1;
  day -= 1;
  vector<ll> last(26, -1);
  vector<ll> next(26, T.size());
  ll old = T.at(day) - 1;
  for (ll i = 0; i < day; ++i) {
    last.at(T.at(i) - 1) = i;
  }
  for (ll i = T.size() - 1; i > day; --i) {
    next.at(T.at(i) - 1) =  i;
  }
  ll score = S.at(day).at(t) - S.at(day).at(old);
  score += (next.at(t) - day) * (day - last.at(t)) * C.at(t);
  score -= (next.at(old) - day) * (day - last.at(old)) * C.at(old);
  return score;
}

ll evaluation(vector<ll>& T) {
  ll D = T.size();
  vector<ll> last(26, 0);
  ll score = 0;
  for (ll i = 0; i < D; ++i) {
    ll contest = T.at(i) - 1;
    last.at(contest) = i + 1;
    score += S.at(i).at(contest);
    for (ll j = 0; j < 26; ++j) {
      score -= (i + 1 - last.at(j)) * C.at(j);
    }
  }
  return score;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  //-----------input-------------
  ll D;
  cin >> D;
  vector<ll> T(D);
  S = vector<vector<ll>>(D, vector<ll>(26));
  for (ll i = 0; i < 26; ++i) {
    cin >> C.at(i);
  }
  for (ll i = 0; i < D; ++i) {
    for (ll j = 0; j < 26; ++j) {
      cin >> S.at(i).at(j);
    }
  }
  for (ll i = 0; i < D; ++i) {
    cin >> T.at(i);
  }
  //--------------------------------------
  // vector<ll> last(26, 0);
  // for (ll day = 0; day < D; ++day) {
  //   ll max_contest = 0;
  //   ll max_score = -INF;
  //   for (ll contest = 0; contest < 26; ++contest) {
  //     ll temp_score = evaluation(contest, day, last);
  //     if (temp_score > max_score) {
  //       max_score = temp_score;
  //       max_contest = contest + 1;
  //     }
  //   }
  //   last.at(max_contest - 1) = day;
  //   T.at(day) = max_contest;
  // }

  // for (ll i = 0; i < D; ++i) {
  //   cout << T.at(i) << "\n";
  // }

  ll score = evaluation(T);
  // cout << score << "\n";
  ll M;
  cin >> M;
  for (ll i = 0; i < M; ++i) {
    ll d, q;
    cin >> d >> q;
    score += change_evaluation(T, q, d);
    T.at(d - 1) = q;
    cout << score << "\n";
  }

  // vector<ll> ans = evaluation(C, S, T);
  // for (ll i = 0; i < ans.size(); ++i) {
  //   cout << ans.at(i) << "\n";
  // }
}


Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  long long a, b, k;  cin >> a >> b >> k;
  if(a>=k){
    cout << a-k << " " << b << endl;
  }else{
    cout << 0 << " " << max(b-(k-a), 0ll)<< endl;
  }
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

int main()
{
    int N, K;
    while (cin >> N >> K, N) {
        vector<int> a(N);
        int sum = 0, res = -(1e9);
        for (int i = 0; i < K; i++) {
            cin >> a[i];
            sum += a[i];
        }

        res = max(res, sum);
        for (int i = K; i < N; i++) {
            cin >> a[i];
            sum += a[i] - a[i-K];
            res = max(res, sum);
        }
        cout << res << endl;
    }
    return 0;
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

class UnionFind {
 public:
  vector<int> data;
  int count;
 public:
  UnionFind(int size) : data(size, -1), count(size) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
      --count;
    }
    return x != y;
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int solve(int N, int M, vi& x, vi& y, vi& z) {
    UnionFind uf(N);
    rep(i,M){
        uf.unionSet(x[i], y[i]);
    }
    map<int,int> rp;
    rep(i,N){
        int r = uf.root(i);
        if (!found(rp, r)) rp[r] = i;
    }
    return rp.size();
}

int main() {
    int N; int M; scanf("%d %d%*c", &N, &M);
    vi x(M), y(M), z(M);
    rep(i,M){
        scanf("%d %d %d%*c", &x[i], &y[i], &z[i]);
        x[i]--; y[i]--; z[i]%=2;
    }
    cout << solve(N,M, x,y,z) << endl;
    return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<int> a;
	for (int i = 11; i <= 55555; i+=5) {
		bool flag = true;
		int temp = i;		
		for (int j = 2; j <= sqrt(temp); j++) {
			if (temp % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) a.push_back(i);
	}
	for (int i = 0; i < N; i++)
		cout << a[i]<<" ";
	cout << endl;
}

Measured memory_bytes: 3616
K = int(input())
if K < 10:
	print(K)
	exit()
L = [1,2,3,4,5,6,7,8,9]
k = 9
i = 0
while k < K:
	l = L[i]
	a = l % 10
	if a > 0:
		L.append(l*10 + a - 1)
		k += 1
	L.append(l*10 + a)
	k += 1
	if a < 9:
		L.append(l*10 + a + 1)
		k += 1
	i += 1
print(L[K-1])

Measured memory_bytes: 45520
import java.util.*;
import java.io.*;

public class Main {
	
	static int mod = (int)1e9+7;
	static int n;
	static int[][][] memo;
	
	public static int dp(int i, int zero, int nine) {
		if(i == n) {
			if(zero == 1 && nine == 1)
				return 1;
			else
				return 0;
		}
		
		if(memo[i][zero][nine] != -1)
			return memo[i][zero][nine];
		
		int cnt = (int)(((1l * dp(i + 1, 1, nine) + dp(i + 1, zero, 1)) % mod + 8l * dp(i + 1, zero, nine)) % mod);
		
		return memo[i][zero][nine] = cnt;
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		n = sc.nextInt();
		if(n == 1) {
			pw.println(0);
		} else {
			memo = new int[n][2][2];
			for(int[][] j : memo)
				for(int[] i : j)
					Arrays.fill(i, -1);
			pw.println(dp(0, 0, 0));
		}
		
		pw.flush();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] array = new Integer[n];
			for (int i = 0; i < n; i++)
				array[i] = new Integer(nextInt());
			return array;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		public static int[] shuffle(int[] a) {
			int n = a.length;
			Random rand = new Random();
			for (int i = 0; i < n; i++) {
				int tmpIdx = rand.nextInt(n);
				int tmp = a[i];
				a[i] = a[tmpIdx];
				a[tmpIdx] = tmp;
			}
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 153892
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
SAT
---+/
/+---test
SUN
---+/
/+---test
TUE
---+/

void main(string[] args) {
  const S = readln.chomp;

  auto days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];

  auto x = days.countUntil!(x => x == S);
  (7 - x).writeln;
}


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

using namespace std;

#define MAX_V 10010
typedef vector<int> Vec;

int V,E;
Vec G[MAX_V];

bool visit(int v,Vec &order,Vec &color){
    color[v] = 1;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
        int to = G[v][i];
        if(color[to] == 2) continue;
        if(color[to] == 1) return false;
        if(!visit(to,order,color)) return false;
    }
    order.push_back(v);
    color[v] = 2;
    return true;
}

bool topologicalSort(Vec &order){
    Vec color(V,0);
    for(int i = 0 ; i < V ; i++){
        if(color[i] == 0 && !visit(i,order,color)){
            return false;
        }
    }
    reverse(order.begin(),order.end());
    return true;
}

int main(){
    int s,t;
    cin >> V >> E;
    for(int i = 0 ; i < E ; i++){
        cin >> s >> t;
        G[s].push_back(t);
    }
    Vec order;
    if(topologicalSort(order)){
        for(int i = 0 ; i < V ; i++){
            cout << order[i] << endl;
        }
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int sumw = 0;
    vector<int> v(n, 0);
    vector<int> w(n, 0);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> w[i];
        sumw += w[i];
    }

    int ans = sumw + v[0];
    int memo = ans;
    for(int i = 0; i < n-1; i++){
        memo = memo - w[i] + v[i+1];
        if(ans < memo){ans = memo;}
    }

    cout << ans << endl;
}

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

void MyFunc(unsigned int a, unsigned int b)
{
  unsigned int cost = 500*a;
  if (cost >= b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


int main(void)
{
  unsigned int K, X;

  cin >> K >> X;
  function<void(unsigned int, unsigned int)> func = MyFunc;
  func(K, X);

  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	a <- readInt
	print $ a + a ^ 2 + a ^ 3

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

void solve(long long N, long long M, vector<long long> a, vector<long long> b){
	pair<long long, long long> itv[M];
	for (int i = 0; i < M; i++) {
		itv[i].first = b[i];
		itv[i].second = a[i];
	}
	sort(itv, itv + M);

	long long ans = 0, t = 0;
	for (int i = 0; i < M; i++) {
		if (t < itv[i].second) {
			ans++;
			t = itv[i].first - 1;
		}
	}
	printf("%lld\n", ans);
}

int main(){
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> a(M-1+1);
	vector<long long> b(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&a[i]);
		scanf("%lld",&b[i]);
	}
	solve(N, M, a, b);
	return 0;
}


Measured memory_bytes: 4992
X,Y,A,B,C = map(int, input().split())
P=sorted(list(map(int,input().split())), reverse=True)
Q=sorted(list(map(int,input().split())), reverse=True)
R=sorted(list(map(int,input().split())), reverse=True)

C = P[:X] + Q[:Y] + R
C.sort(reverse=True)

print(sum(C[:X+Y]))


Measured memory_bytes: 22460
N, K = gets.chomp.split.map(&:to_i)

M = 10 ** 9 + 7

sums = [0]

(0..N).each { |num| sums << sums[-1] + num }

count = 0

K.upto(N+1) do |k|
  min = sums[k]
  max = sums[-1] - sums[- 1 - k]
  cnt = max - min + 1
  count += cnt
end

puts count % M

Measured memory_bytes: 16056
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=505;
int a[MAX_N][MAX_N];
int main()
{
	int H,W;
	cin>>H>>W;
	rep(i,0,H)
	{
		rep(j,0,W)
		{
			cin>>a[i][j];
		}
	}
	vector <pair<pii,pii> > res;
	rep(i,0,H)
	{
		rep(j,0,W)
		{
			if(i==H-1 && j==W-1)continue;
			if(a[i][j]&1)
			{
				if(j==W-1)
				{
					res.pb(mp(mp(i,j),mp(i+1,j)));
					a[i][j]--;
					a[i+1][j]++;
				}
				else
				{
					res.pb(mp(mp(i,j),mp(i,j+1)));
					a[i][j]--;
					a[i][j+1]++;
				}
			}
		}
	}
	cout<<res.size()<<endl;
	rep(i,0,res.size())
	{
		cout<<res[i].fi.fi+1<<" "<<res[i].fi.se+1<<" "<<res[i].se.fi+1<<" "<<res[i].se.se+1<<endl;
	}
	return 0;
}



Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
#define N int(1e5 + 5)
#define MOD 1000003
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int main(){
    IO
    string s; cin >> s;
    if(s[0] == 'S')
    cout << "Cloudy";
    else if(s[0] == 'C')
    cout << "Rainy";
    else
    cout << "Sunny";
}


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

int main(){
    int H, W; cin >> H >> W;
    string v[105];
    REP(i,H) cin >> v[i];
    int cnt[26];
    memset(cnt,0,sizeof(cnt));
    REP(i,H) REP(j,W) cnt[v[i][j]-'a']++;
    REP(i,26) cnt[i] %= 4;
    int cnt1 = 0;
    int cnt2 = 0;
    int cnt4 = 0;
    REP(i,26) {
        if(cnt[i] == 0) cnt4++;
        else if(cnt[i] == 2) cnt2++;
        else cnt1++;
    }
    if(H%2 && W%2) {
        if(cnt1 == 1 && cnt2 <= (H+W-2)/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(H%2 && !(W%2)) {
        if(cnt1 == 0 && cnt2 <= W/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(!(H%2) && W%2) {
        if(cnt1 == 0 && cnt2 <= H/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        if(cnt1 == 0 && cnt2 == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int size[] = {60, 80, 100, 120, 140, 160};
    int weight[] = {2, 5, 10, 15, 20, 25};
    int value[] = {600, 800, 1000, 1200, 1400, 1600, 0};

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        while(--n >= 0){
            int x, y, h, w;
            cin >> x >> y >> h >> w;
            int i = lower_bound(size, size+6, x+y+h) - size;
            int j = lower_bound(weight, weight+6, w) - weight;
            ret += value[max(i, j)];
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.ArrayList;

// ALDS1_2_D
public class Main {
	static int cnt;
	void insertionSort(int[] array, int n, int g) {
		int v, j;
		for (int i = g; i < n; i++) {
			v = array[i]; j = i - g;
			while (j >= 0 && array[j] > v) {
				array[j+g] = array[j];
				j = j -g;
				cnt++;
				array[j+g] = v;
			}
		}
	}

	void shellSort(int[] array, int n) {
		cnt = 0;
		int m = 0;
		ArrayList<Integer> G = new ArrayList<Integer>();

		for (int i = 1; i < n + 1; i = 3*i+1) {
			G.add(i);
			m++;
		}
		for (int i = m - 1; i >= 0; i--) {
			insertionSort(array, n, G.get(i));
		}

		System.out.println(m);
		for (int i = m - 1; i >= 0; i--) {
			System.out.print(G.get(i));
			if (i > 0) System.out.print(" ");
		}
		System.out.println();
		System.out.println(cnt);
		for (int v : array)
			System.out.println(v);
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		shellSort(array, n);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 299688
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int main()
{
  int N, T, D[100000];

  cin >> N >> T;
  for(int i = 0; i < N; i++) {
    cin >> D[i];
  }
  sort(D, D + N);
  
  long long ret = 1;
  for(int i = 0; i < N; i++) {
    (ret *= i + D - lower_bound(D, D + N, D[i] - T) + 1) %= mod;
  }
  cout << ret << endl;
}

Measured memory_bytes: 1564
# coding: utf-8
import math

n, d = map(int, input().split())

count = 0

points = []
for _ in range(n):
    points.append(list(map(int, input().split())))

for i in range(n-1):
    for j in range(i+1, n):
        point_i = points[i]
        point_j = points[j]
        a = ((point_i[k] - point_j[k]) ** 2 for k in range(d))
        distance = math.sqrt(sum(a)) 
        if int(distance) == distance:
            count += 1
print(count)
        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vint a(n);
    rep(i, n - 1)
    {
        int k;
        cin >> k;
        k--;
        a[k]++;
    }

    rep(i, n)
    {
        cout << a[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4052
def main():
    a, b, c, d = (int(i) for i in input().split())
    d1 = abs(a-b)
    d2 = abs(b-c)
    d3 = abs(a-c)
    if (d1 <= d and d2 <= d):
        print("Yes")
    elif(d3 <= d):
        print("Yes")
    else:
        print("No")
    
    
main()

Measured memory_bytes: 3060
N=int(input())
W=list(map(int,input().split()))

abs_val=0
abs_min=float('inf')

for T in range(1,N):
    abs_val=abs(sum(W[0:T+1])-sum(W[T+1:N+1]))
    if abs_val<abs_min:
        abs_min=abs_val

print(abs_min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin >> n;
    if(n[0] == n[1] && n[1] == n[2])
    {
        cout << "Yes" << endl;
    }
    else if(n[1] == n[2] && n[2] == n[3])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

string a,b,ans;



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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

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


int main(){
  ll A,B;
  cin >> A >> B;
  cout << A*B/gcd(A,B) << endl;
  
  return 0;
}




Measured memory_bytes: 384