akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Char
import Data.Maybe
import Control.Monad

main = do
    [n,k,q] <- map read . words <$> getLine :: IO [Int]
    xs <- VUM.replicate (n+1) 0 :: IO (VUM.IOVector Int)
    replicateM_ q $ do
        b <- B.getLine
        let (a,_) = fromJust $ B.readInt b
        VUM.modify xs (+1) a
    forM_ [1..n] $ \i -> do
        r <- VUM.read xs i
        if (q-r) < k
            then putStrLn "Yes"
            else putStrLn "No"

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
typedef long long ll; typedef long double db;
const int N = 5e3 + 5, M = 1e9 + 7;

ll f(ll b, ll n) {
  if (b > n) return n;
  return f(b, n / b) + n % b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  for (int i = 2; (ll)i * i <= n; i++) {
    if (f(i, n) == m) {
      cout << i;
      return 0;
    }
  }
  if (n > m) {
    n -= m;
    for (int i = n / (sqrt(n + m) + 1) + 1; i >= 1; i--) {
//    for (int i = 1; (ll)i * i <= n; i++) {
      if (n % i == 0) {
        ll b = n / i + 1;
        if (b > i && b > m - i && m - i >= 0) {
          cout << b;
          return 0;
        }
      }
    }
  }
  if (n == m) cout << n + 1;
  else cout << -1;
}


Measured memory_bytes: 3700
L=int(input())
s=bin(L)[2:]
l=len(s)-1
ans=[]
for i in range(l):
    ans.append([i+1,i+2,2**(l-i-1)])
    ans.append([i+1,i+2,0])
u=2**(l)
for k in range(1,l+1):
    if s[k]!='0':
        ans.append([1,k+1,u])
        u+=2**(l-k) 
        #print(k+1,l)
print(l+1,len(ans))
for a,b,c in ans:
    print(a,b,c)

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

int main(){
  string s, t;
  cin >> s >> t;
  if(s[1] != t[1]) cout << "NO" << endl;
  else {
    if(s[0] == t[2] && s[2] == t[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[27]:


L,R = map(int, input().split())


# In[30]:


MOD = 2019
res = MOD
if R - L < MOD:
    for l in range(L, R):
        for r in range(l+1, R+1):
            res = min(res, (l * r) % MOD)
else:
    res = 0
print(res)



Measured memory_bytes: 9052
#include<iostream>
#include<iomanip>
#include <cmath>
using namespace std;
int main()
{
    int n ,k;
    cin >> n >> k;
    long long max,now=0;
    int a[n];
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    int num = 0;
    for(;num<k;num++){
        now+=a[num];
    }
    max=now;
    for(;num<n;num++){
        now = now + a[num] - a[num-k];
        if(now>max){
            max=now;
        }
    }
    double ans;
    ans = (double)(max+k)/2.0000000000;
    cout << setprecision(10) << ans; 
    
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc063/tasks/abc063_b
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)
#define EACH(i, n) for (auto &i: n)

int main() {
  int count[255] = {0};
  char str[30];

  cin >> str;
  for (int i = 0; str[i] != '\0'; i++) {
    char c = str[i];
    if (count[c] > 0) {
      cout << "no" << endl;
      return 0;
    }
    count[c]++;
  }
  cout << "yes" << endl;

  return 0;
}


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

const ll mod = 1000000007;

vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

		 // 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back({ a, ex });
	}

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main()
{
	ll n; cin >> n;
	
	vector<ll> primeNum(1000,0);

	for (ll i = 2; i <= n ; i++) {

		vector<pair<ll, ll>> i_prime;		
		i_prime = prime_factorize(i);

		ll tmp_ans = 1;
		for (ll j = 0; j < i_prime.size(); j++) {
			primeNum[i_prime[j].first] += i_prime[j].second;
		}
	
	}

	ll ans = 1;
	for (ll i = 2; i <= 1000; i++) {
		ans *= primeNum[i] + 1;
        ans = ans % mod;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <map>
#include <cstdlib>
#include <ctime>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef pair<double, int> state;
const int CLK = CLOCKS_PER_SEC;

int s, g;
double memo[100];
int pre[100];
int name[100];
double x[100];
double y[100];

map<int, int> nums;

double dis(int i, int j){
  return sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
}

double heuristics(int v){
  return dis(v, nums[g]);
}

int main(){
  int n, m;
  int b;
  int cnt = 0;
  while(cin >> n &&n){
    nums.clear();
    rep(i, n){
      cin >> b >> x[i] >> y[i];
      name[i] = b;
      nums[b] = i;
    }
    cin >> m;
    for(int i = 0; i < m;i++){
      memset(pre, -1, sizeof(pre));
      fill(memo, memo + 100, 1e10);
      cin >> s >> g;
      memo[nums[s]] = heuristics(nums[s]);
      priority_queue<state, vector<state>, greater<state> > que;
      que.push(state(heuristics(nums[s]), nums[s]));
      
      while(!que.empty()){
	cnt++;
	state st = que.top();
	que.pop();
	int v = st.second;
	double fcost = st.first;
	double gcost = fcost - heuristics(v);
	if(name[v] == g){
	  break;
	}
	if(fcost > memo[v]) continue;
	for(int j = 0; j < n; j++){
	  if(j == v) continue;
	  double d = dis(v, j);
	  if(d > 50.0) continue;
	  if(memo[j] > gcost + d + heuristics(j)){
	    memo[j] = gcost + d + heuristics(j);
	    pre[j] = v;
	    que.push(state(memo[j], j));
	  }
	}
      }
      if(pre[nums[g]] == -1 && s != g){
	cout << "NA" << endl;
      }else{
	vector<int> res;
	int v = nums[g];
	res.push_back(v);
	//	for(int i = 0; i < n; i++) cout << pre[i] << " " ;
	//	cout << endl << nums[s] << endl;

	while(pre[v] >= 0){
	  v = pre[v];
	  res.push_back(v);
	}

	rep(j, (int)res.size()){
	  if(j != 0) cout << " " ;
	  cout << name[res[res.size() - 1 - j]];
	}
	cout << endl;
      }
    }
  }
  // cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> w(n);
	int dif=0;
	for (int i = 0; i < n; i++) {
		cin>>w[i];
		dif += w[i];
	}
	int min = dif;
	for (int i = 0; i < n; i++) {
		dif -= w[i] * 2;
		if (dif<min&&dif>-min) {
			min = dif;
		}
	}
	if (min >= 0)cout << min << endl;
	else cout << -min << endl;
	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
for i in range(N - 1):
    a0 = A[i]
    a1 = A[i + 1]
    if a0 + a1 > x:
        d = min(a1, (a0 + a1) - x)
        cnt += d
        a1 -= d
        A[i + 1] = a1
    if a0 + a1 > x:
        d = min(a0, (a0 + a1) - x)
        cnt += d
        a0 -= d
        A[i] = a0

print(cnt)


Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string c1, c2;
    cin >> c1 >> c2;
    reverse(ALL(c1));
    if (c1 == c2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c,d,e,k,m=0;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
	if(b-a<=k && c-a<=k && d-a<=k && e-a<=k && c-b<=k && d-b<=k && e-b<=k && d-c<=k && e-c<=k && e-d<=k) 
		printf("Yay!");
	else printf(":(");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// Binary Indexed Tree (BIT)
// Verified: AOJ DSL_2_B: Range Sum Query (int??????)
template <typename T>
struct BIT{
private:
    vector<T> array;
    const int n;

public:
    // ?????????
    BIT(int _n) : array(_n + 1, 0), n(_n) {}

    // 1???????????? i???????????§????´???????????±???????
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;      // LSB ??????
        }
        return s;
    }

    // [i, j] ???????´??????????
    T sum(int i, int j) {
        T ret_i = sum(i-1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // i ????????? ????´? x ?????????
    void add(int i, T x) {
        while(i <= n) {
            array[i] += x;
            i += i & -i;      // LSB ??????
        }
    }
};

signed main() {
    int n, q; cin >> n >> q;
    int c, x, y;
    BIT<int> bit(n);
    rep(i,0,q) {
        cin >> c >> x >> y;
        if(c == 0) bit.add(x, y);
        else cout << bit.sum(x, y) << endl;
    }
    return 0;
}

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

int N, K;

int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		if(a == 1){
			cout << ((N - 1) % (K - 1) == 0 ? (N - 1) / (K - 1) : (N - 1) / (K - 1) + 1) << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  int n,ans=0;
  cin >> n;
  int v[n];
  int c[n];
  for(int i=0;i<n;i++) cin >> v[i];
  for(int i=0;i<n;i++) cin >> c[i];
  for(int i=0;i<n;i++){
    if(v[i]-c[i]>0)ans+=v[i]-c[i];
  }
  cout << ans;
  return 0;
}

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

int main(void){
 int A,B,C,X,Y;
 long long int sum=0;
 cin>>A>>B>>C;
 cin>>X>>Y;
 sum=A*(X-min(X,Y))+B*(Y-min(X,Y))+C*2*min(X,Y);
 if((A+B)<2*C)std::cout<<A*X+B*Y<<std::endl;
 else if(C*2*max(X,Y)<sum)std::cout<<C*2*max(X,Y)<<std::endl; 
 else std::cout<<sum<<std::endl;
}
     
     

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

int main(){
    ll a, b;
    cin>>a>>b;
    ll ans;
    for(ll i=0;i<1e5;++i){
        if(a*i-(i-1)>=b){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ks ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
typedef pair<int,int>pa;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e6+177;
const ll mod=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
template<class T>inline void read(T &res){
    char c;T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}

int main(){
    int a;
    scanf("%d",&a);

    int ans=a+a*a+a*a*a;
    printf("%d\n",ans);


}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int n,a[30];
int ans;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=2;i<n;i++) 
		if((a[i]<a[i-1]&&a[i]>a[i+1])||(a[i]>a[i-1]&&a[i]<a[i+1])) ans++;
	cout<<ans;
	return 0;
}

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

#ifdef LOCAL
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define dbgv(x) cerr << #x << " = " << x << endl
#define dbga(arr, len) {cerr << #arr << " = "; for (int _ = 0; _ < len; _++)\
cerr << arr[_] << " "; cerr << endl;}
#define dbgi(it) {cerr << #it << " = "; for (const auto& _ : it)\
cerr << _ << " "; cerr << endl;}
#else
#define dbg(...) (void)0
#define dbgv(x) (void)0
#define dbga(arr, len) (void)0
#define dbgi(it) (void)0
#endif

using ll = long long;
using dbl = long double;
using pii = pair<int, int>;

void solve() {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a <= 9 && b <= 9) {
        printf("%d\n", a * b);
    } else {
        puts("-1");
    }
}

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

    solve();

    dbg("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#define Re register int
#define mod int(1e9+7)

struct Edge{
	int to,next;
}e[200005];
int cnt,head[100005];
int N,f[100005][2];

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	var=w?-x:x;
}
inline void AddEdge(int u,int v)
{
	e[++cnt]=(Edge){v,head[u]},head[u]=cnt;
	e[++cnt]=(Edge){u,head[v]},head[v]=cnt;
}
void dp(int now,int fa)
{
	f[now][0]=f[now][1]=1;
	for (Re i=head[now];i;i=e[i].next)
	{
		if (e[i].to==fa) continue;
		dp(e[i].to,now); f[now][0]=(1LL*f[now][0]*f[e[i].to][1])%mod;
		f[now][1]=(1LL*f[now][1]*(f[e[i].to][0]+f[e[i].to][1]))%mod;
	}
}
int main(int argc, char const *argv[])
{
	read(N);
	for (Re i=1,u,v; i<N; ++i)
		read(u),read(v),AddEdge(u,v);
	dp(1,0); printf("%d\n",(f[1][0]+f[1][1])%mod);
	return 0;
}

Measured memory_bytes: 7168
from collections import Counter

s=input()
t=input()
if len(Counter(t))==len(Counter(s)) and len(s)==len(t):
  ls1=sorted([Counter(t)[x] for i,x in enumerate(Counter(t))])
  ls2=sorted([Counter(s)[x] for i,x in enumerate(Counter(s))])
  for i in range(len(ls1)):
    if ls1[i]!= ls2[i]:
      print('No')
      exit()
  print('Yes')
else:
  print("No")


Measured memory_bytes: 4144
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int P[] = new int[N];


        for(int i = 0; i  < N; i++){
          A[i] = sc.nextInt();
        }

        for(int i = 0; i  < N; i++){
            P[A[i] - 1] = i + 1;
        }

        for(int i = 0; i < N; i++){
          System.out.print(P[i] + " ");
        }

    }
}







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

struct Node {
    int key;
    Node *parent, *left, *right;
};
Node *root, *NIL;

void insert(int k) {
    Node *y = NIL; //xの親
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inOrder(Node *u) {
    if (u == NIL) return;
    inOrder(u->left);
    cout << " " << u->key;
    inOrder(u->right);
}

void preOrder(Node *u) {
    if (u == NIL) return;
    cout << " " << u->key;
    preOrder(u->left);
    preOrder(u->right);
}

int main() {
    int m, k;
    cin >> m;
    string order;
    for (int i = 0; i < m; i++) {
        cin >> order;
        if (order == "insert") {
            cin >> k;
            insert(k);
        }
        if (order == "print") {
            inOrder(root);
            cout << endl;
            preOrder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 26652
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const LL inf = 1e16;
VI H,P, sorted; 

bool cmp(const int i, const int j)
{ return H[i]+P[i] < H[j]+P[j]; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        H = P = sorted = VI(n);
        FOR(i,0,n) {
            cin >> H[i] >> P[i];
            sorted[i] = i;
        }
        sort(ALL(sorted),cmp);
        vector<LL> dp = vector<LL>(n+1,inf);
        dp[0] = 0; int ans = 0;
        FOR(i,0,n) {
            const int j = sorted[i];
            FORR(x,n-1,-1) if (dp[x] != inf && dp[x] <= H[j]) {
                dp[x+1] = min(dp[x+1], dp[x]+P[j]);
                ans = max(ans, x+1);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 384
import numpy as np
def func1(n):
    if n%2==0 :
        return int(n/2)
    else :
        return int(3*n+1)

def func2(r,s):
    m = 1
    while True:
        tmp = func1(s)
        m+=1
        if r.ndim == 0:
            if r == tmp:
                return m
        else:
            for tmp1 in r:
                if tmp == tmp1:
                    return m
        r = np.append(r,tmp)
        s=tmp


a = list(map(int, input().split()))

s = a[0]
r = np.array(s)
print(func2(r,s))



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

#define MOD 1000000007

ll fac_num[200010], ifac_num[200010];

ll pow(ll a, ll x) {
	if (x == 0)return 1;
	if (x % 2 == 1) {
		return a * pow(a, x - 1)%MOD;
	}
	ll res = pow(a, x / 2)%MOD;
	return res * res%MOD;
}

ll C(int n, int r) {
	if (r<0 || n < r)return 0LL;
	return ((fac_num[n] * ifac_num[r] )% MOD *ifac_num[n - r] )% MOD;
}


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

	fac_num[0] = 1LL; 
	ifac_num[0] = 1LL;

	for (int i = 1; i <= 200000; i++) {
		fac_num[i] = (fac_num[i - 1] * i)%MOD;
		ifac_num[i] = pow(fac_num[i], (ll)(MOD - 2));
	}

	ll ans = 0;
	
	for (int i = b+1; i <= w; i++) {
		ans = (ans + C(h-a-1+i-1, i-1)*C(a-1+w-i, w - i) % MOD) % MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
using System;
using System.Linq;

class E
{
	struct R
	{
		public int A, B, C;
	}

	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var rs = new int[h[1]].Select(_ => read()).Select(r => new R { A = r[0], B = r[1], C = r[2] - h[2] }).ToArray();
		var map = rs.ToLookup(r => r.A);

		var c = Enumerable.Repeat(long.MinValue, n + 1).ToArray();
		c[1] = 0;
		for (long v, i = 0; i < n; i++)
			foreach (var r in rs)
				if (c[r.A] != c[0] && c[r.B] < (v = c[r.A] + r.C)) c[r.B] = v;

		var u = new bool[n + 1];
		foreach (var r in rs)
			if (c[r.A] != c[0] && c[r.B] < c[r.A] + r.C) Find(r.B, map, u);
		Console.WriteLine(u[n] ? -1 : Math.Max(c[n], 0));
	}

	static void Find(int p, ILookup<int, R> map, bool[] u)
	{
		u[p] = true;
		foreach (var r in map[p]) if (!u[r.B]) Find(r.B, map, u);
	}
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

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

	vi t(n);
	vector<string> s(n);
	rep(i,n) cin >> s[i] >> t[i];

	string x;
	cin >> x;

	int index;
	int ans = 0;
	rep(i,n)
	{
		if(x == s[i]) index = i;
	}
	for(int i = index+1; i < n; ++i)
	{
		ans += t[i];
	}

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

Measured memory_bytes: 256
from copy import deepcopy
from sys import stdin
input = stdin.readline
H,W,K = map(int, input().split())
mat = [list(input()) for _ in range(H)]
ans = 0
for b_i in range(2**H):
    mat_1 = deepcopy(mat)
    for i in range(H):
        if b_i >> i & 1:
            for col in range(W):
                mat_1[i][col] = '.'
        
    for b_j in range(2**W):
        mat_2 = deepcopy(mat_1)
        for j in range(W):
            if b_j >> j & 1:
                for row in range(H):
                    mat_2[row][j] = '.'

        cnt = 0
        for row in mat_2:
            cnt += row.count('#')
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9308
N=int(input())
ratio=[[0,0] for i in range(N)]
for i in range(N):
    ratio[i] = list(map(int,input().split()))

num=[ratio[0]]
for i in range(1,N):
    beta = max(num[i-1][0]//ratio[i][0],
               num[i-1][1]//ratio[i][1])
    num_next = list(map(lambda x:beta*x,ratio[i]))
    if num[i-1][0]<=num_next[0] and num[i-1][1]<=num_next[1]:
        num.append(num_next)
    else:
        num.append(list(map(lambda x:(beta+1)*x,ratio[i])))

# print(num)
# print()
print(sum(num[N-1]))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int N, K;
    cin >> N>>K;

    vector<int> A(N);
    REP(i, N){
        cin>>A[i];
    }

    vector<int> bucket(N, 0);

    // 数字の種類を数える
    int kind=0;
    REP(i, N){
        if(bucket[A[i]-1]==0) kind++;
        bucket[A[i]-1]++;
    }

    //REP(i, N){
    //    cout << i+1 <<": "<<bucket[i] << endl;
    //}
    //cout << kind << endl;

    int ans=0;
    // kind <= K になっているか
    if(kind <= K) ans=0;
    else{   // kindが余っている
        // 何種類余っているか
        int amari = kind - K;

        // 余っている種類を移す、ただし少ない個数から
        sort(bucket.begin(), bucket.end());
        int cnt=0;  // 移した種類
        REP(i, N){
            if(bucket[i]!=0) {  // 0個ではないものを移す
                ans+=bucket[i];
                cnt++;
                if(cnt == amari) break;
            }
        }
    }
    

    cout << ans << endl;

   return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf=0x3f3f3f3f,N=1e7+4,mod=998244353;
int n,inv[N],fac[N],fic[N],bin[N],bi[N];
int C(int x,int y)
{if(y>x)return 0;if(0==y)return 1;//cout<<x<<" "<<y<<" "<<fac[x]*fic[y]%mod*fic[x-y]%mod<<endl;
	return fac[x]*fic[y]%mod*fic[x-y]%mod;
}
main()
{inv[1]=fac[1]=fic[1]=1;bin[0]=bi[0]=fic[0]=1;
for(int i=2;i<=1e7;i++)inv[i]=mod-inv[mod%i]*(mod/i)%mod,fac[i]=fac[i-1]*i%mod,fic[i]=fic[i-1]*inv[i]%mod;
//for(int i=1;i<=3;i++)cout<<inv[i]<<" "<<fic[i]<<endl;
for(int i=1;i<=1e7;i++)bi[i]=bi[i-1]*3%mod,bin[i]=(bin[i-1]*2%mod);
	cin>>n;int ans=bi[n];//cout<<ans<<endl;
	for(int i=n/2+1;i<=n;i++)
	{
		int ret=C(n,i)*bin[n-i+1]%mod;ans=(ans-ret)%mod;
		//cout<<ans<<endl;
	}cout<<(ans+mod)%mod;
	return 0;
}


Measured memory_bytes: 390912
s = int(input())
judge = 0
numerical_sequence = [s]
i = 0
while judge==0:
    if numerical_sequence[i]%2==0: numerical_sequence.append(numerical_sequence[i]//2) 
    else: numerical_sequence.append(numerical_sequence[i]*3+1)
    i+= 1
    if numerical_sequence[i] in numerical_sequence[:i-1]:
        judge = 1
        print(i+1)

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> C;
    C.resize(h);
    for (int i = 0; i < h; i++) {
        cin >> C[i];
    }

    int ans[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ans[i][j] = 0;
        }
    }

    int cnt_st[h] = {0};
    bool check_blank[h] = {false};

    int num = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (C[i][j] == '#') {
                cnt_st[i]++;
                if (cnt_st[i] >= 2) {
                    num++;
                }
            }
            ans[i][j] = num;

        }
        if (cnt_st[i] >= 1) {
            num++;
        }
    }

    for (int i = 1; i < h; i++) {
        if (cnt_st[i] == 0) {
            for (int j = 0; j < w; j++) {
                ans[i][j] = ans[i - 1][j];
            }
        }
    }
    for (int i = h - 2; i >= 0; i--) {
        if (cnt_st[i] == 0) {
            for (int j = 0; j < w; j++) {
                ans[i][j] = ans[i + 1][j];
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j != 0) {
                cout << " ";
            }
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 1280
n = int(input())
b = list(map(int,input().split()))

#b 2 5  
#  2  2   5
b.append(10**16)
bsum = 0
for i in range(n-1,0,-1): 
    #print("min(b[i],b[i-1])",min(b[i],b[i-1]),i)
    bsum += (min(b[i],b[i-1]))
print(bsum+b[0])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    ll n,k,K;
    scanf("%d %d",&n,&k);
    if(n+1<2*k) return cout<<-1<<endl,0;
    if(n&1){
        K=(n+1)/2;
        k-=K;
        fr(i,K) printf("%lld %lld %lld\n",k+K+2*i,k+4*K-2-i,k+5*K-2+i);
        fr(i,K-1) printf("%lld %lld %lld\n",k+K+1+2*i,k+5*K-3-i,k+6*K-2+i);
    }
    else{
        K=n/2;
        k-=K;
        fr(i,K) printf("%lld %lld %lld\n",k+K+2*i,k+4*K-i,k+5*K+i);
        printf("%lld %lld %lld\n",k+3*K-1,k+3*K,k+6*K);
        fr(i,K-1) printf("%lld %lld %lld\n",k+K+1+2*i,k+5*K-1-i,k+6*K+1+i);


    }
}

Measured memory_bytes: 2304
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	int a,b;
	cin >> a >> b;
	cout << a*b;
}


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


int main(){
  int n,k;
  cin >> n >> k;
  ll rp,sp,pp;
  cin >> rp >> sp >> pp;
  string t;
  cin >> t;
  vector<char> tp;
  ll ans=0;
  rep(i,n){
    if(t[i]=='r'){
      if(k<=i && tp[i-k]=='p'){tp.push_back('g');}
      else{tp.push_back('p');}
    }
    if(t[i]=='s'){
      if(k<=i && tp[i-k]=='r'){tp.push_back('g');}
      else{tp.push_back('r');}
    }
    if(t[i]=='p'){
      if(k<=i && tp[i-k]=='s'){tp.push_back('g');}
      else{tp.push_back('s');}
    }
  }
  rep(i,n){
    if(tp[i]=='r'){ans+=rp;}
    else if(tp[i]=='s'){ans+=sp;}
    else if(tp[i]=='p'){ans+=pp;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
(defun next (i.j N)
  (let ((i (car i.j))
	(j (cdr i.j)) )
    (if (< (1+ j) N)
	(cons i (1+ j)) (cons (1+ i) (+ i 2)) )))

(let ((N (read))
      (D (read))
      (counter 0) )

  (setf array (make-array N))

  (dotimes (x N)
    (setf (aref array x) (loop :repeat D :collect (read))))

  (do ((i.j '(0 . 1) (next i.j N)))
      ((>= (car i.j) (1- N)))

    (let ((i (car i.j))
	  (j (cdr i.j)) )
      (let ((d^2 (reduce #'+
			 (mapcar #'(lambda (x y) (expt (- x y) 2))
				 (aref array i)  (aref array j) ))))
	(if (= d^2 (expt (isqrt d^2) 2))
	    (setf counter (1+ counter)) ))
      ;(princ (cons i j))
      ))
  (princ counter) )




Measured memory_bytes: 6632
using System;
using System.Linq;

namespace ALDS1_6_A_CountingSort
{
	class Program
	{
		static void Main ( string[] args )
		{
			int dataCount = int.Parse (Console.ReadLine ());
			int[] inputArray = new int[dataCount];
			inputArray = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			int[] result = CountingSort (inputArray);

			string output = string.Join (" ", Array.ConvertAll (result, num => num.ToString ()));
			Console.WriteLine (output);
		}

		static int[] CountingSort ( int[] numArray )
		{
			int[] result = new int[numArray.Length];
			CountingSort (numArray, result, 10000);
			return result;
		}

		static void CountingSort ( int[] numArray, int[] resultArray, int maxValue )
		{
			int[] countArray = new int[maxValue + 1];

			//C#?????´??????????????????
			/*
			for (int lp = 0; lp < length; lp++)
			{
				countArray[lp] = 0;
			}
			*/

			//???????´??????°?????°??????
			for (int lp = 0; lp < numArray.Length; lp++)
			{
				int index = numArray[lp];
				countArray[index]++;
			}

			//???????´?????´???????????±???????
			for (int lp = 0; lp < maxValue; lp++)
			{
				countArray[lp + 1] += countArray[lp];
			}

			for (int lp = numArray.Length - 1; lp >= 0; lp--)
			{
				int value = numArray[lp];

				int resultIndex = countArray[value] - 1;
				resultArray[resultIndex] = value;

				countArray[value]--;
			}
		}
	}
}

Measured memory_bytes: 257920
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
int main(){
//int n,a[100001]={0};
//cin>>n;
//cout<< <<endl;
int n;
cin>>n;
if(n/10==9||n%10==9)cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

bool in_range(int a, int b){
  return a >= 0 && a < b;
}

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> S(h);
  for(int i = 0; i < h; ++i) cin >> S[i];
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(S[i][j] != '#') continue;
      bool f = true;
      for(int d = 0; d < 4; ++d){
        if(in_range(i + dx[d], h) && in_range(j + dy[d], w) && S[i+dx[d]][j+dy[d]] == '#'){
          f = false;
          break;
        }
      }
      if(f){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K,a;
  cin>>N>>K;
  a=K;
  for(ll i=0;;i++){
    if(a>N){
      cout<<i+1<<endl;
      return 0;
    }
    a=a*K;
  }
}
    


Measured memory_bytes: 3632
#include <iostream>

int main(int argc, char *argv[]){
    long int W, H, x, y;
    std::cin >> W >> H >> x >> y;
    double area = static_cast<double>(W*H)/2.0;
    int isPlural=0;
    if( ((W&1)==0 && W/2==x)&&((H&1)==0 && H/2==y) ){
        isPlural=1;
    }
    std::cout << area << " " << isPlural << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s,t;
    int sum=0;
    cin>>s>>t;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]==t[i])
        {
            sum++;
        }
    }
    if(sum==s.size())
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
int main(){
	int a,b,out;
  	cin >> a >> b;
  	if (a+b == 3) out = 3;
  	else if(a+b == 4) out = 2;
  	else if(a+b == 5) out = 1;
  cout << out << endl;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)


struct UnionFind {
  vector<int> data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main (void) {
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    REP(i,M) {
        int x,y,z;
        cin >> x >> y >> z;
        x--; y--;
        uf.unite(x,y);
    }
    vector<bool> used(N,false);
    int ans = 0;
    REP(i,N) {
        if (!used[uf.find(i)]) {
            ans ++;
            used[uf.find(i)] = true;
        } 
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long int
#define endl '\n'
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p){ //x^y % p
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {
        if (y & 1) // If y is odd, multiply x with result 
        res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}

ll MIN(ll a, ll b) {
    if(a<b) return a;   return b;
}

ll MAX(ll a, ll b) {
    if(a>b) return a;   return b;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    
    int h[n+1] {0};
    for(int i=0;i<n-1;i++)
    {
        int x;
        cin>>x;
        h[x]++;
    }
    
    for(int i=1;i<=n;i++)
        cout<<h[i]<<endl;
	// your code goes here
	return 0;
}


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

#define pi acos(-1)
#define eps 1e-9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define clock 1.0*clock()/CLOCKS_PER_SEC
#define filein freopen("in.txt","r",stdin)
#define fileout freopen("out.txt","w",stdout)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dr[]={0,-1,0,1,-1,-1,1,1};
const int dc[]={1,0,-1,0,1,-1,-1,1};
const int maxx = 100;

ll weight[maxx+7];
ll value[maxx+7];
map<pair<ll,ll>,ll> dp;
map<pair<ll,ll>,bool> used;
ll n;

ll knapsack(ll index, ll rem){
	if(rem==0) return 0;
	if(index>n) return 0;
	if(used[pii(index,rem)]) return dp[pii(index,rem)];
	ll ret=0;
	if(weight[index]>rem) ret=knapsack(index+1,rem);
	else ret = max(knapsack(index+1,rem),value[index]+knapsack(index+1,rem-weight[index]));
	used[pii(index,rem)]=true;
	return dp[pii(index,rem)]=ret;
}

int main ()
{
	ll w;
	cin>>n>>w;
	for(int i=1;i<=n;i++){
		cin>>weight[i]>>value[i];
	}
	cout<<knapsack(1,w)<<endl;
    return 0;
}



Measured memory_bytes: 12288
N = int(input())
a = list(map(int, input().split()))
 
COLOR = 8
cnt, ov = [0] * COLOR, 0
for i in range(N):
    if a[i] < 3200:
        cnt[a[i] // 400] += 1
    else:
        ov += 1
 
used = 0
for c in cnt:
    if c > 0:
        used += 1

unused = N - used 
print(max(1, used), used + min(unused, ov))

Measured memory_bytes: 3064
#include<iostream>
#include<map>

int main() {
  int N;
  std::cin >> N;
  std::map<int, int> num;
  for (int i=0; i<N; i++) {
    int temp_num;
    std::cin >> temp_num;
    num[temp_num] = 1;
  }
  std::cout << num.size() << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,ax=0;
  cin >> n;
  int x[n];
  for(int i = 0;i < n;++i)cin >> x[i];
  for(int i = 0;i < n-1;++i){
    for(int j = i+1;j < n;++j){
  	  ax = std::max(ax,abs(x[i]-x[j]));
    }
  }
  cout << ax <<endl;
  return 0;
}

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

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

  bool fin = false;
  for (int i = 0; i <= b-a; i++) {
    if ((a+i)%k == 0) {
      cout << "OK" << endl;
      fin = true;
      break;
    }
  }
  if (!fin) {
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3548
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int flag[4];
  for (int i = 0; i < 4; i++) {
    flag[i] = 0;
  }

  for (int i = 0; i < 3; i++) {
    int a, b;
    cin >> a >> b;
    flag[--a]++;
    flag[--b]++;
  }
  for (int i = 0; i < 4; i++) {
    if (!(flag[i] == 1 || flag[i] == 2)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

main(){
	int n,k;
	cin >> n >> k;
	long long int h[n];
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	sort(h,h+n);

	long long int min=1000000000000;
	for(int i=0;i<n-k+1;i++){
		if(min>(h[k+i-1]-h[i])){
			min=h[k+i-1]-h[i];
			//cout << h[k+i] << " " << h[i] << endl;
		}
	}
	cout << min << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;


typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(){}
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

pair<Weight, Edges> VoronoiMST(const Graph &G1,const vint &S,Graph &G2){
  int N = S.size();
  G2.resize(N);
  Weight total=0;
  Edges F;
  priority_queue<Edge> Q;
  vint dist(G1.size(),0),used(G1.size(),0),from(G1.size(),-1);
  repeat(i,N){
    Q.push({-1,S[i],0});
    from[S[i]]=i;
  }
  int cnt=1;
  while(!Q.empty()){
    Edge e=Q.top();Q.pop();
    int v = e.dst;
    if(used[v]){
      if(used[v]>used[e.src]){
        total += dist[v]+e.weight;
        F.push_back({from[v],from[e.src],dist[v]+e.weight});
        G2[from[v]].push_back({from[v],from[e.src],dist[v]+e.weight});
        G2[from[e.src]].push_back({from[e.src],from[v],dist[v]+e.weight});
      }
      continue;
    }
    used[v]=cnt;
    cnt++;
    dist[v] = e.weight;
    from[v] = from[e.src];
    for(Edge f:G1[v]){
      Q.push({v,f.dst,dist[v]+f.weight});
    }
  }
  return make_pair(total,F);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;Weight D;cin>>N>>D;
  Graph G(N*2);
  repeat(i,N-1){
    G[i].push_back({(int)i,(int)i+1,D});
    G[i+1].push_back({(int)i+1,(int)i,D});
  }
  repeat(i,N){
    Weight A;cin>>A;
    G[i].push_back({(int)i,(int)i+N,A});
    G[i+N].push_back({(int)i+N,(int)i,A});
  }
  vint S(N);
  repeat(i,N){
    S[i]=N+i;
  }
  Graph G2;
  cout << VoronoiMST(G,S,G2).first<<endl;
  return 0;
}


Measured memory_bytes: 70504
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

		// 整数の入力
        int a = sc.nextInt();
        int b = sc.nextInt();
        int big = Math.max(a, b);
        int aa = a;
        int bb = b;
        
        int i = 2;
        boolean divided = true;
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        while (divided) {
            i = 2;
            while (i <= big) {
                if (aa % i == 0 && bb % i == 0) {
                    aa = aa / i;
                    bb = bb / i;
                    list.add(i);
                    break;
                }
                i++;
            }
            if (i > big)
                divided = false;
        }
        long ans = 1;
        for (int ele : list) {
            ans *= ele;
        }
        ans = ans * aa * bb;

        System.out.println(ans);
	}
}

Measured memory_bytes: 22868
import java.util.Arrays;
import java.util.Scanner;

//Butterfly
public class Main{

	int n;
	int[] d, s, dp;
	
	int get(int S){
		if(dp[S]!=-1)return dp[S];
		int max = 0;
		for(int i=0;i<n;i++){
			if((S&d[i])==d[i]){
				max = Math.max(max, s[i]+get(S-d[i]));
			}
		}
		return dp[S] = max;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			d = new int[n]; s = new int[n];
			for(int i=0;i<n;i++){
				int k = sc.nextInt();
				s[i] = sc.nextInt();
				while(k--!=0){
					int S = sc.nextInt()-6, E = sc.nextInt()-6;
					for(int j=S;j<E;j++)d[i]+=1<<j;
				}
			}
			dp = new int[1<<16];
			Arrays.fill(dp, -1);
			System.out.println(get((1<<16)-1));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 16000
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        a: [[usize; m]; n]
    }
    let d = 998244353;
    let r = rank2(&a);
    let ans = pow_m(2, n + m - 1, d) + d - pow_m(2, n + m - r - 1, d);
    println!("{}", ans % d);
}

fn rank2(a: &Vec<Vec<usize>>) -> usize {
    let n = a.len();
    let m = a[0].len();
    let mut b = a.clone();
    let mut r = 0;
    for i in 0..n {
        let mut idx = 0;
        while idx < m && b[i][idx] == 0 {
            idx += 1;
        }
        if idx == m {
            continue;
        }
        for j in i + 1..n {
            if b[j][idx] == 1 {
                for k in 0..m {
                    b[j][k] = (b[j][k] + b[i][k]) & 1;
                }
            }
        }
        r += 1;
    }
    r
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}


Measured memory_bytes: 4352