akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc015/tasks/abc015_4

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
int H, W;
vector<string> field;
int result = 100;
int dfs_res = 0;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void add(ll &a, ll b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

int main() {


    int H, W;
    cin >> H >> W;
    char grid[H][W];
    ll dp[H+10][W+10];
    //vector<int> dp(N+1, MAX);
    REP(i, H)REP(j, W){ cin >> grid[i][j]; }
    REP(i, H+1)REP(j, W+1){ dp[i][j] = 0; }

    dp[0][0] = 1;
    //REP(i, H){
    //    REP(j, W){
    //        if(i == 0 && j == 0)/*dp[i][j] = 1*/;
    //        else if(i == 0){
    //            if(grid[i][j] == '#'){
    //                dp[i][j] = 0;
    //            } else {
    //                dp[i][j] = dp[i][j-1];
    //            }
    //        }else if(j == 0){
    //            if(grid[i][j] == '#'){
    //                dp[i][j] = 0;
    //            } else {
    //                dp[i][j] = dp[i-1][j];
    //            }
    //        }
    //        else {
    //            if(grid[i-1][j] == '#'){
    //                dp[i][j] = dp[i][j-1];
    //            } else if(grid[i][j-1] == '#'){
    //                dp[i][j] = dp[i-1][j];
    //            } else {
    //                dp[i][j] = dp[i-1][j] + dp[i][j-1];
    //            }
    //       }
    //       dp[i][j] %= MOD;
    //    }
    //}
    //REP(i, H){
    //    REP(j, W){ 
    //        cout << dp[i][j] << " "; 
    //    }cout << endl; 
    //}
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (i+1 < H && grid[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
            if (j+1 < W && grid[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
            //dp[i][j] %= MOD;
        }
    }
    cout << dp[H-1][W-1] << endl;

    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/




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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll in[100005];
ll s[100005];
int main()
{
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> in[i];

	std::sort(in, in + n);

	s[0] = in[0];
	for (int i = 1; i < n; ++i)
		s[i] = s[i - 1] + in[i];

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ll min = 1;
		ll sum = s[i];
		while (sum < in[n - 1]) {
			auto p = std::distance(in, std::upper_bound(in + min, in + n, 2 * sum)) - 1;
			if (p < min)
				break;
			sum = s[p];
			min = p + 1;
		}

		if (sum >= in[n - 1]) {
			ans = n - i;
			break;
		}
	}

	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#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;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<double> que;
    rep(i, n){
        double a;
        cin >> a;
        que.push(a);
    }

    rep(i, m){
        double a = que.top();
        que.pop();
        que.push(a/2);
    }

    ll ans = 0;
    rep(i, n){
        int a = que.top();
        que.pop();
        ans += a;
    }

    cout << ans << endl;
}

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 0;
  }
  else { // 発見できなかったとき
    return 1;
  }
}

int main() {
    int N;
    long long K;
    cin >> N >> K;
    std::vector<int> A;
    for(int i = 0; i < N; i++){
        int l;
        cin >> l;
        A.push_back(l);
    }
    if(K >= N){
        std::set<int> visited;
        std::vector<int> vlist;
        int visit = 1;
        while(!(visited.count(visit))){
            visited.insert(visit);
            vlist.push_back(visit);
            visit = A.at(visit-1);
        }

        auto itr = std::find(vlist.begin(), vlist.end(),visit);
        long long index = std::distance(vlist.begin(), itr);

        long long len = visited.size() - index;
        long long mod = ((K - index) % len);
        cout << vlist.at(mod + index);
    } else {
        int visit = 1;
        for(int i = 0; i < K; i++){
            visit = A.at(visit-1);
        }
        cout << visit;
    }
    
}

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

using namespace std;

int main(void) {
  long long n,m,d;
  cin >> n >> m >> d;

  double ans = (double)(n-d)/n/n*(m-1);
  if(d!=0){
    ans *= 2;
  }

  cout.precision(16);
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
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;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    int A,B,X; cin>>A>>B>>X;
    bool flag=0;
    if(A<=X && A+B>=X) flag=1;
    else flag=0;
    
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	var s, t string
	fmt.Scan(&n, &m, &s, &t)

	l := lcm(n, m)
	dic := map[int]rune{}

	for i, c := range s {
		j := i * l / n
		dic[j] = c
	}

	for i, c := range t {
		j := i * l / m
		if _, ok := dic[j]; ok {
			if dic[j] != c {
				fmt.Println(-1)
				return
			}
		}
	}
	fmt.Println(l)
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func gcd(x, y int) int {
	switch {
	case x < y:
		return gcd(y, x)
	case y == 0:
		return x
	default:
		return gcd(y, x%y)
	}
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <cmath>

//using namespace std;

int64_t gcd(int64_t a, int64_t b)
{
    if (a < b) {
        int64_t tmp = a;
        a = b;
        b = tmp;
    }

    int64_t r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main(int argc, char* argv[]) {
    int64_t N, M;

    std::cin >> N >> M;

    int64_t res = 1;
    for (int64_t i = 1; i * i < M; i++) {
        if (M % i == 0) {
            if (i <= M / N) {
                res = std::max(res, i);
            }
            if (i >= N) {
                res = std::max(res, M / i);
            }
        }
    }

    std::cout << res << std::endl;

    return 0;
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    print(a - 1, b) if u == s else print(a, b - 1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define MAX 100010
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

Point A[MAX];
int n;

bool compare_y(const Point &a,const Point &b){
  return a.y<b.y;
}

double closest_pair(Point *a,int n){
  if(n<=1)return inf;
  int m=n/2;
  double x=a[m].x;
  double d=min(closest_pair(a,m),closest_pair(a+m,n-m));
  inplace_merge(a,a+m,a+n,compare_y);

  vector<Point> b;
  for(int i=0;i<n;i++){
    if(fabs(a[i].x-x)>=d)continue;

    for(int j=0;j<b.size();j++){
      double dx=a[i].x-b[b.size()-j-1].x;
      double dy=a[i].y-b[b.size()-j-1].y;
      if(dy>=d)break;
      d=min(d,sqrt(dx*dx+dy*dy));
    }
    b.push_back(a[i]);
  }
  return d;
}

int main()
{
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i].x>>A[i].y;

  sort(A,A+n);

  printf("%.10f\n",closest_pair(A,n));

  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int a[210000];
    int num[210000] = {0};
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        ++num[a[i]-1];
    }
    
    sort(num, num + n);
    
    int ans = 0;
    for(int i = 0; i < n - k; ++i) {
        ans += num[i];
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

/*
ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}*/

int n, m, a, b, cnt;
pair<int, int>ab[100000];

int main(){
	cin >> n >> m;
	lp(m) {
		cin >> a >> b;
		ab[i]=make_pair(a, b);
	}
	sort(ab, ab+m);
	cnt = 1;
	b = ab[0].second;
	lp(m) {
		if (b <= ab[i].first) {
			cnt++;
			b = ab[i].second;
		}
		b = min(b, ab[i].second);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;


int d[100010];
int po[100010];
vector<int> G[100010];
int n,m;
queue<int> que;


int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);		
	}
	fill(po,po+100010,MOD);
	fill(d,d+100010,MOD);
	
	que.push(0);
	while(que.size())
	{
		int p=que.front();que.pop();
		for(int i=0;i<G[p].size();i++)
		{
			int q=G[p][i];
			if(d[q]==MOD)
			{
				que.push(q);
				d[q]=d[p]+1;
				po[q]=p;
			}
		}
	}
	cout<<"Yes"<<"\n";
	for(int i=1;i<n;i++)
	{
		cout<<po[i]+1<<"\n";
	}
	return 0;
}

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

void fnInput(string& rsMaxNum)
{
  cin >> rsMaxNum;
}

int fnDgtDP(string sMaxNum)
{
  // dp[nPos][nSmall][nFlag] :=  nPos  : 上位 nPos 桁目まで決定
  //                             nSmall: small(数字を自由に選べる)か
  //                             nFlag : 上位 nPos 桁までで {3,5,7} を選択したかflag
  //                             ( 0:選択なし, 1: 3   選択, 2: 5   選択, 3: 3 5   選択, 
  //                               4: 7 選択 , 5: 3 7 選択, 6: 5 7 選択, 7: 3 5 7 選択 )
  //                             の条件を満たす数値の数
  int dp[11][2][8] = {};
  dp[0][0][0] = 1;

  int nLen = sMaxNum.size();

  for (int nPos = 0; nPos < nLen; ++nPos)
    for (int nSmall = 0; nSmall < 2; ++nSmall)
      for (int nFlag = 0; nFlag < 8; ++nFlag)
      {
        if (!dp[nPos][nSmall][nFlag]) continue;

        if (nSmall == 1)               // small ([0, 9] から数字を選べる)か
        {
          if (!nFlag)
            dp[nPos + 1][1][0]       += dp[nPos][1][0];                    // nothing

          dp[nPos + 1][1][nFlag | 1] += dp[nPos][1][nFlag];                // +3
          dp[nPos + 1][1][nFlag | 2] += dp[nPos][1][nFlag];                // +5
          dp[nPos + 1][1][nFlag | 4] += dp[nPos][1][nFlag];                // +7
        }
        else                           // not small ([0, nDgt] から数字を選べる)か
        {
          int nDgt = sMaxNum[nPos] - '0';

          if (!nFlag)    dp[nPos + 1][1][0]         += dp[nPos][0][0];     // nothing

          if (nDgt == 3) dp[nPos + 1][0][nFlag | 1] += dp[nPos][0][nFlag]; // +3
          if (3 < nDgt)  dp[nPos + 1][1][nFlag | 1] += dp[nPos][0][nFlag]; // +3
          if (nDgt == 5) dp[nPos + 1][0][nFlag | 2] += dp[nPos][0][nFlag]; // +5
          if (5 < nDgt)  dp[nPos + 1][1][nFlag | 2] += dp[nPos][0][nFlag]; // +5
          if (nDgt == 7) dp[nPos + 1][0][nFlag | 4] += dp[nPos][0][nFlag]; // +7
          if (7 < nDgt)  dp[nPos + 1][1][nFlag | 4] += dp[nPos][0][nFlag]; // +7
        }
      }
/*
  for (int nPos = 0; nPos <= nLen; ++nPos)
     for (int nSmall = 0; nSmall < 2; ++nSmall)
       for (int nFlag = 0; nFlag < 8; ++nFlag)
         if (dp[nPos][nSmall][nFlag])
         {
           cout << "dp[" << nPos << "][" << nSmall << "][" << nFlag << "] = (";
           cout << dp[nPos][nSmall][nFlag] << ")" << endl;
         }
*/
  return dp[nLen][0][7] + dp[nLen][1][7];
}

int main()
{
  string sMaxNum;

  fnInput(sMaxNum);
  cout << fnDgtDP(sMaxNum) << endl;
  
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


ll power(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1)
            res = (res*x)%md;
        x = (x*x)%md;
        y = y/2;
    }
    return res;
}


void solve(){
	ll x,y;
	cin>>x>>y;
	if(x == 1 || y == 1)
		cout<<1;
	else if(x*y %2 ==0)
		cout<<x*y/2;
	else
		cout<<(x*y)/2+1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   // int n; cin>>n; for (int i = 0; i < n; ++i)
    solve();
    return 0;
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

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

  int ans = 0;
  for(int i=0;i<n;++i) {
    ans = ans ^ a[i];
  }
  if(ans == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
/**

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*/

#include <bits/stdc++.h>
#define ll long long
#define mp(a,b) make_pair((a),(b))
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapl map<pll,ll>
#define pi acos(-1)
#define gcd2(a,b) __gcd((a),(b))
#define eps 1e-6
#define meme memset(x,0,sizeof(x))
#define ft first
#define sn second
#define bn0(z) __builtin_clz(z)
#define nd0(z) __builtin_ctz(z)
#define no1(z) __builtin_popcount(z)
using namespace std;

const int N = 200043;
const int MOD = 998244353;
int fact[N];
long long Binexpo(long long a,long long b){
    if(b==0)
        return 1;
    long long res=Binexpo(a,b/2);
    if(b%2){return res*res*a;}
    else{return res*res;}
}

int add(int x, int y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}

int inv(int x)
{
    return Binexpo(x, MOD - 2);
}

int divide(int x, int y)
{
    return mul(x, inv(y));
}
void precalc()
{
    fact[0] = 1;
    for(int i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

int C(int n, int k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}

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

long long primechk[10000];

void preprocess(long long N){
    long long i,j;
    for(i=2;i<=N;i++){
        primechk[i]=1;
    }
    for(i=2;i<=N;i++){
        if(primechk[i]==1){
            for(j=2;i*j<=N;j++){primechk[i*j]=0;}
        }
    }
}

bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
long long Pwr(long long a,long long b,long long m){
    a%=m;
    long long res=1;
    while(b>0){
        if(b%2){res=res*a%m;}
        a=a*a%m;
        b>>=1;
    }
    return res;
}
int main()
{   long long a,b,c,d,e,f,g=500,h,i,j,k,x,y,z,sum=0,cnt=0,n,l,r,hi,lo,testc,val=1;
    //cin>>testc;
    testc=1;
    while(testc--){
        char s;
        cin>>s;
        if(isupper(s)){cout<<"A";}
        else{cout<<"a";}
    }
    return 0;
}


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

bool solve(string &s, string &t){
    int L = s.size();
    map<int, set<int>> st,ts;
    vector<int> vis(26,0);
    for(int i = 0; i < L; i++){
        int ch = (int)(s[i] - 'a'),target = (int)(t[i] - 'a');
        st[ch].insert(target);
        ts[target].insert(ch);
    }
    for(int i = 0; i < 26; i++){
        if(st[i].size() >= 2 || ts[i].size() >=2){
            return false;
        }
    }
    return true;
}

int main(){
    string s,t;
    cin >> s >>t;
    cout << (solve(s,t) ? "Yes":"No") << endl;
    return 0;

}

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

int main(){
    string S;  cin >> S;
    for(int i=1; i<4; i++){
        if(S[i-1]==S[i]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] A = new long[n];
        long ans = Long.MAX_VALUE;
        for(int i = 0; i < n; i++) A[i] = sc.nextLong();
        for(int i = 0; i < 1<<n; i++) {
            long m = A[0];
            long sum = 0;
            if(Integer.bitCount(i) != k - 1 ||
               (i>>n-1 & 1) == 1) continue;
            for(int j = n-2; j >= 0; j--) {
                long inc = 0;
                if((i>>j & 1) == 1) {
                    if(A[n-j-1] <= m) {
                        inc = m - A[n-j-1] + 1;
                    }
                }
                m = Math.max(m, A[n-j-1]+inc);
                sum += inc;
            }
            ans = Math.min(ans, sum);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
fn main() {
    let mut reader = acio::Reader::new();
    let n = reader.read::<usize>();
    let d = reader.read::<usize>();
    let mut ps = vec![];
    for _ in 0..n {
        ps.push(reader.read_by::<f64>(d));
    }
    let mut c = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            let mut p = 0.0;
            for k in 0..d {
                let s = ps[i][k] - ps[j][k];
                p += s * s;
            }
            let ps = p.sqrt();
            if ps.floor() == ps.ceil() {
                c += 1;
                //println!("{}-{} is it", i, j);
            } else {
                //println!("{}-{} is not", i, j);
            }
        }
    }
    println!("{}", c);
}

/// Mathematics Module
#[allow(dead_code)]
mod math {
    trait Math {
        fn lcm(v1: Self, v2: Self) -> Self;
        fn gcd(v1: Self, v2: Self) -> Self;
    }

    macro_rules! integer {
        ($t:ty) => {
            impl Math for $t {
                fn lcm(v1: $t, v2: $t) -> $t {
                    v1 * v2 / Self::gcd(v1, v2)
                }

                fn gcd(v1: $t, v2: $t) -> $t {
                    let (mut v1, mut v2) = (v1, v2);
                    while v1 != v2 {
                        if v1 < v2 {
                            v2 -= v1;
                        } else {
                            v1 -= v2;
                        }
                    }
                    v1
                }
            }
        };
    }

    integer!(i8);
    integer!(i16);
    integer!(i32);
    integer!(i64);
    integer!(isize);
    integer!(u8);
    integer!(u16);
    integer!(u32);
    integer!(u64);
    integer!(usize);
}

/// IO Module for AtCoder
#[allow(dead_code)]
mod acio {
    use std::fmt::Debug;
    use std::io::{stdin, Stdin};
    use std::str::FromStr;

    pub struct Reader {
        input: Stdin,
        stack: Vec<String>,
    }

    impl Reader {
        pub fn new() -> Self {
            Reader {
                input: stdin(),
                stack: vec![],
            }
        }

        pub fn read_by<F>(&mut self, count: usize) -> Vec<F>
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            let mut v = vec![];
            for _ in 0..count {
                v.push(self.read());
            }
            v
        }

        pub fn read<F>(&mut self) -> F
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            while self.stack.is_empty() {
                let mut line = self.read_line();
                self.stack.append(&mut line);
                self.stack.reverse();
            }
            self.stack.pop().unwrap().parse().unwrap()
        }

        fn read_line(&mut self) -> Vec<String> {
            let mut buf = String::new();
            self.input.read_line(&mut buf).unwrap();
            buf.split_whitespace().map(|s| s.to_string()).collect()
        }
    }
}


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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 96181;

const int N = 2e5 + 20;
int n, dp[N], f[N], a[N];

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	dp[1] = f[a[1]] = 1;
	for (int i = 2; i <= n; i++) {
		if (a[i] - a[i - 1]) {
			dp[i] = (dp[i - 1] + f[a[i]]) % MOD;
			f[a[i]] = (f[a[i]] + dp[i - 1]) % MOD;
		}
		else {
			dp[i] = dp[i - 1];
		}
	}
	cout << dp[n] << endl;
}



Measured memory_bytes: 2560
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9 + 7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    //
    ll maxH = 0;
    ll ans = 0;
    rep(i, N)
    {
        ll Hi;
        cin >> Hi;
        if (maxH <= Hi) ++ans;
        chmax(maxH, Hi);
    }
    cout << ans;
    return 0;
}

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


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n ;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int ans = M;
    for(int median = 0;median <= 100; median++)
    {
        int tans = 0;
        for(int i=0;i<n;i++)
        {
        
            tans += (a[i]-median)*(a[i]-median);
        }
        ans = min(ans, tans);
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
n, m, k = map(int, input().split())
mod = 998244353

fact = [1] * (n + 1)
revfact = [1] * (n + 1)
for i in range(n):
    fact[i + 1] = ((i + 1) * fact[i]) % mod
revfact[n] = pow(fact[n], mod - 2, mod)
for i in reversed(range(n)):
    revfact[i] = ((i + 1) * revfact[i + 1]) % mod
def combination(n, k, p):
    return (fact[n] * revfact[k] * revfact[n - k]) % p

count = 0
m_pow = [1]
for i in range(n):
    m_pow.append(m_pow[-1] * (m - 1) % mod)
for i in range(k + 1):
    temp = m
    temp *= m_pow[n - i - 1]
    temp *= combination(n - 1, i, mod)
    temp %= mod
    count += temp
count %= mod
print(count)

Measured memory_bytes: 32620
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    ll q; cin >> q;
    vector <ll> ps(n, 0);
    REP(i, q){
        ll a; cin >> a;
        ps[a-1]++;
    }
    REP(i, n){
        ll b; b = ps[i];
        if (q >= k+b){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))
    


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

long long int n, c;
vector<long long int> x, v, a, b;
long long int ans;
typedef pair<long long int, long long int> P;
vector<P> p, q;

int main(){
	cin >> n >> c;
	for(int i=0; i<n; ++i){
		long long int s, t;
		cin >> s >> t;
		x.push_back(s);
		v.push_back(t);
	}
	a.push_back(v[0]-x[0]);
	for(int i=1; i<n; ++i)
		a.push_back(v[i] - x[i] + x[i-1]);
	b.push_back(v[n-1]-c+x[n-1]);
	for(int i=1; i<n; ++i)
		b.push_back(v[n-1-i] - x[n-i] + x[n-1-i]);
	for(int i=1; i<n; ++i){
		a[i] += a[i-1];
		b[i] += b[i-1];
	}
	p.push_back(P(a[0], 0));
	q.push_back(P(b[0], n-1));
	for(int i=1; i<n; ++i){
//		a[i] = max(a[i], a[i-1]);
//		b[i] = max(b[i], b[i-1]);
		if(a[i] > p[i-1].first) p.push_back(P(a[i], i));
		else p.push_back(p[i-1]);
		if(b[i] > q[i-1].first) q.push_back(P(b[i], n-i-1));
		else q.push_back(q[i-1]);
	}
/*	for(int i=0; i<n; ++i)
		cout << i << " " << a[i] << " " <<  b[i] << endl;
*/	for(int i=0; i<n; ++i){
		ans = max(ans, p[i].first);
		ans = max(ans, q[i].first);
	}
	for(int i=0; i<n-1; ++i){
		ans = max(ans, q[i].first + p[n-i-2].first - min(c - x[q[i].second], x[p[n-i-2].second]));
	}
	cout << ans << endl;
/*	for(int i=0; i<n; ++i){
		printf("%d %lld %lld %lld %lld\n", i, p[i].first, p[i].second, q[i].first, q[i].second);
	}
*/
}

Measured memory_bytes: 6668
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int c = n, m = 0;
    while(n){
        m = m * 10 + n % 10;
        n /= 10;
    }

    if(m == c) cout << "Yes";
    else cout << "No";

    return 0;
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

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

  ll SUM = 0, MAX = -1;
  for (int i = 0; i < N; i++) {
    ll temp;
    cin >> temp;
    SUM += temp;
    MAX = max(MAX, temp);
  }

  string ans = "Yes";
  if ( SUM - MAX <= MAX ) {
    ans = "No";
  }

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

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, ) = input!(u64);

    let an = 1..(n+1);
    // let pn = an.clone().skip(1).chain(1..2);
    // let z = an.clone().zip(pn)
    //             .map(|(a, p)| a % p);
    let ans: u64 = an.sum();

    println!("{}", ans - n);
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
while True :
    n=int(input())
    if n==0:
        break
    su,amin,amax=0,1000,0
    for i in range(n):
        a=int(input())
        amin=min(amin,a)
        amax=max(amax,a)
        su+=a
    print((su-amin-amax)//(n-2))


Measured memory_bytes: 5596
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
class state{
public:
  int t,s,d;
  bool operator<(const state & a)const{
    return t < a.t;
  }
};

main(){
  int n,m;
  while(cin>>n>>m && n){
    state in[m];
    rep(i,m)cin>>in[i].t>>in[i].s>>in[i].d;
    sort(in,in+m);
    set<int> S;
    S.insert(1);
    rep(i,m){
      if ( S.find(in[i].s)!=S.end())S.insert(in[i].d);
    }
    cout <<S.size() << endl;
  }
  return false;
}

Measured memory_bytes: 1616
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    int k[10],s[10][10],p[10];
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    for(int i=0;i<m;i++) cin>>p[i];
    int ans=0;
    for(int bit=0;bit<(1<<n);bit++){
        int sum=0;
        for(int i=0;i<m;i++){
            int count=0;
            for(int j=0;j<k[i];j++){
                if(bit&(1<<s[i][j])) count++;
            }
            if(count%2==p[i]) sum++;
        }
        if(sum==m) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // 追加
#include <cmath>  // 追加
using namespace std;

int main(){
double r;
cin>>r;  
double pi =acos(-1);// 円周率
cout<<fixed<<setprecision(6);
double area = r * r * pi;
double cir =(r+r) * pi;
cout<<area<<" "<<cir<<endl;
}


Measured memory_bytes: 3264
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
XY = []
for _ in range(N):
    a = int(sys.stdin.buffer.readline())
    xy = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(a)]
    XY.append([(x - 1, y) for x, y in xy])

ans = 0
for choice in itertools.product([0, 1], repeat=N):
    ok = True
    for i in range(N):
        if choice[i] == 0:
            continue
        # choice[i] == 1 のとき正直者
        for x, y in XY[i]:
            ok &= (choice[x] == y) == choice[i]
    if ok:
        ans = max(ans, sum(choice))
print(ans)


Measured memory_bytes: 43500
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, m; readV(n, m);
  int[] l, r; readC(n, l, r);

  auto k = new int[][](m+1);
  foreach (i; 0..n) k[r[i]-l[i]+1] ~= l[i];

  auto ft = new FenwickTree!int(m+1), t = n;
  foreach (d; 1..m+1) {
    auto s = t;
    for (auto i = d; i <= m; i += d) s += ft[0..i+1];
    writeln(s);

    foreach (ki; k[d]) {
      ++ft[ki];
      --ft[ki+d];
    }
    t -= k[d].length;
  }
}

class FenwickTree(T)
{
  const size_t n;
  T[] buf;

  this(size_t n)
  {
    this.n = n;
    this.buf = new T[](n+1);
  }

  void opIndexOpAssign(string op)(T val, size_t i) if (op == "+" || op == "-")
  {
    ++i;
    for (; i <= n; i += i & -i) mixin("buf[i] " ~ op ~ "= val;");
  }

  void opIndexUnary(string op)(size_t i) if (op == "++" || op == "--")
  {
    ++i;
    for (; i <= n; i += i & -i) mixin("buf[i]" ~ op ~ ";");
  }

  pure T opSlice(size_t r, size_t l) { return get(l) - get(r); }
  pure T opIndex(size_t i) { return opSlice(i, i+1); }
  pure size_t opDollar() { return n; }

private:

  pure T get(size_t i)
  {
    auto s = T(0);
    for (; i > 0; i -= i & -i) s += buf[i];
    return s;
  }
}


Measured memory_bytes: 11004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k;
  in2(n, k);
  n = n % k;
  if(n > k - n)
    n = k - n;
  out(n);
  memi;
}

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

using namespace std;
int main()
{
     int n;
     float ans,t;

     vector<float>a;
cin>>n;
     for(int i=0;i<n;i++)
     {
               cin>>t;
     a.push_back(t);
     }

     sort(a.begin(),a.end());

     if(n==2)
     ans=(float)(a[0]+a[1])/2;
     else{
                ans=(a[0]+a[1])/2;
     for(int i=2;i<n;i++)
     {
          ans=(float)(ans+a[i])/2;
     }

     }


printf("%.5f\n", ans);
return 0;




}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    string s;
    cin >> s;
    int n = (int)s.size();
    map<char,ll>mp;
    rep(i,n){
        mp[s[i]]++;
    }
    ll ans = (ll)n*(n-1)/2;
    for(char c = 'a'; c<='z';c++){
        ans -= mp[c]*(mp[c]-1)/2;
    }
    cout << ans + 1 << endl;
}

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

int compare(const void * a, const void * b) {
  return strcmp(a, b);
}

int main() {
    int n, l;
    scanf("%d %d", &n, &l);
    char str[n][l+1];
    for (int i=0; i<n; ++i)
        scanf("%s", str[i]);

    qsort(str, n, sizeof(str[0]), compare);

    for (int i=0; i<n; ++i)
        printf("%s", str[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <map>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iterator>
#include <deque>
#include <bitset>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <fstream>
#include <ios>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <bitset>
#include <queue>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
	string a;
	string b;
	long long ans=999999999999;
	cin >> a >> b;
	for (int i = 0; i < a.size()-b.size()+1; i++) {
		int otl=0;
		for (int j = 0; j < b.size(); j++) {
			if (b[j] != a[i + j]) {
				otl++;
			}
		}
		if (otl < ans) {
			ans = otl;
		}
	}
	cout << ans;
}



Measured memory_bytes: 3616
n = int(input())
l = list(input())
left = []
right = []
left.append(0)
lc = 0
rc = 0
for i in range(n):
    if l[i] == "W":
        lc += 1
    if l[-1-i] == "E":
        rc += 1
    left.append(lc)
    right.append(rc)
right.append(0)
count = 300000

for i in range(n):
    a = left[i]+right[n-2-i]
    count = min(a,count)
print(count)


Measured memory_bytes: 20556
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1e9+7
#define INF 1e9+9
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define so sizeof 
#define pii pair<ll,ll>
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define repe(i,a) for(auto i:a)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=b;i>=a;i--)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
void solve(){
  ll n,k;
  cin>>n>>k;
  ll a[n+1];
  rep(i,1,n)cin>>a[i];
  ll dp[n+1];
  dp[0]=dp[1]=0;
  rep(i,2,n){
    ll res=INF;
    rep(j,1,k){
        if(i-j>=1){
           res=min((abs(a[i]-a[i-j])+dp[i-j]),res);
        }
    }
    dp[i]=res;
  }
  cout<<dp[n]<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    fast
    solve();
    return 0;
}

Measured memory_bytes: 5176
N1=list(map(int,input().split()))
N2=list(map(int,input().split()))
N3=list(map(int,input().split()))
N=int(input())
b=[int(input()) for i in range(N)]
if b.count(N1[0])==b.count(N1[1])==b.count(N1[2])==1:
    print("Yes")
elif b.count(N2[0])==b.count(N2[1])==b.count(N2[2])==1 or b.count(N3[0])==b.count(N3[1])==b.count(N3[2])==1:
    print("Yes")
elif b.count(N1[0])==b.count(N2[0])==b.count(N3[0])==1 or  b.count(N1[1])==b.count(N2[1])==b.count(N3[1])==1 or b.count(N1[2])==b.count(N2[2])==b.count(N3[2])==1:
    print("Yes")
elif b.count(N1[0])==b.count(N2[1])==b.count(N3[2])==1 or b.count(N3[0])==b.count(N2[1])==b.count(N1[2])==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<float.h>
using namespace std;


int main() {
    char a, b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    if (a == f && c == d) {
        if (b == e) {
            cout << "YES" << endl;
        }
        else cout << "NO" << endl;
    }
    else cout << "NO" << endl;
  
    return 0;
}

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

using namespace std;

typedef long long ll;
//typedef pair<ll, ll> P;
//typedef vector<ll> vl;
//typedef vector<vl> vvl;
//template<typename T> using pq = priority_queue<T>;
//template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
//template<typename T, typename K> using ump = unordered_map<T, K>;
//const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//const ll mod = 1000000007;
//const ll inf = ll(1e9);
const ll e5 = ll(1e5);
//const ll ll_inf = ll(1e9) * ll(1e9);
//
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
//#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
//#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
//#define F first
//#define S second
//#define all(obj) (obj).begin(), (obj).end()
//
//template<class T>
//void dump_debug(T list) {
//#ifdef MY_DEBUG
//    each(e, list) cout << e << " ";
//    printf("\n");
//#endif
//}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
vector<ll> G[2 * e5];
vector<ll> ans(2 * e5);
unordered_map<ll, ll> pl;
vector<bool> seen(2 * e5);

void dfs(ll now, ll value) {
    seen[now] = true;
    ans[now] = value;
    each(e, G[now]) {
        if (!seen[e]) {
            dfs(e, value + pl[e]);
        }
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n, q;
        scanf("%lli %lli", &n, &q);
        rep(i, n - 1) {
            ll a, b;
            scanf("%lli %lli", &a, &b);
            G[--a].eb(--b);
            G[b].eb(a);
        }

        rep(i, q) {
            ll p, x;
            scanf("%lli %lli", &p, &x);
            pl[--p] += x;
        }
        dfs(0, pl[0]);

        rep(i, n) {
            printf("%lli ", ans[i]);
//            cout << ans[i] << " ";
        }

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 32584
n, m = gets.chomp.split.map(&:to_i)
match = Array.new(n, 2)
m.times{match[n - 1 - (gets.to_i / 2)] -= 1}
answer = n - 1
(n - 1).downto(1){|i|
    answer -= 1 if match[i] != 2
    match[i / 2] -= 1 if match[i] == 0
}
puts answer


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  vl l;
  l.eb(0);
  ll t = 1;
  ll t5 = 1;
  ll s = 1;
  while(true) {
    t5=t*t*t*t*t;
    if(s>1000) break;
    l.eb(t5);
    t++;
    s++;
  }

  ll x;
  cin >> x;
  ll sl = l.size();
  rep(i,sl) rep(j,sl) {
    ll a5 = l.at(i);ll b5 = l.at(j);
    if(a5-b5==x) {
      cout << i << " " << j << endl;
      return 0;
    } else if(a5+b5==x) {
      cout << i <<  " " << -j << endl;
      return 0;
    } else if(b5-a5==x) {
      cout << -i <<  " " << -j << endl;
     return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3552