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

using namespace std ;

const int MAX = 1e6 + 10 ;

string arr[MAX] ;
int n ;
int freq[26] ;

bool cmp(string &a , string &b)
{
	return a.size() < b.size() ;
}

int tree[MAX][26] , cnt[MAX][26] ;

int id = 1 ;

void insert(string &s , char c)
{
	int node = 1 ;
	for(auto &c : s)
	{
		if(!tree[node][c-'a'])
			tree[node][c-'a'] = ++id ;
		node = tree[node][c-'a'] ;
	}
	cnt[node][c-'a']++ ;
}

int calc(int node)
{
	int x = 0 ;
	for(int j = 0 ; j < 26 ; ++j)
	{
		if(freq[j])
			x += cnt[node][j] ;
	}
	return x ;
}

int query(string &s)
{
	int node = 1 ;
	int x = calc(node) ;
	for(auto &c : s)
	{
		freq[c-'a']-- ;
		if(!tree[node][c-'a'])
			return x ;
		node = tree[node][c-'a'] ;
		x += calc(node) ;
	}
	return x ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	sort(arr , arr + n , cmp) ;
	string s ;
	long long ans = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		for(int c = 0 ; c < 26 ; ++c)
			freq[c] = 0 ;
		for(int j = 0 ; j < arr[i].size() ; ++j)
			freq[arr[i][j] - 'a']++ ;
		s = "" ;
		for(int j = arr[i].size()-1 ; j >= 1 ; --j)
			s.push_back(arr[i][j]) ;
		ans += query(s) ;
		insert(s , arr[i][0]) ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 185476
<?php
    $input_lines = trim(fgets(STDIN));
    $sLine1 = explode(" ",$input_lines);
    $a = (int)$sLine1[0];
    $b = (int)$sLine1[1];
    $c = (int)$sLine1[2];

    if($a == $b && $b == $c){
        echo 1;
    } elseif ($a == $b || $b == $c || $a == $c){
        echo 2;
    } else {
        echo 3;
    }
?>


Measured memory_bytes: 3580
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
        int n, m; cin >> n >> m;
        cout << n*m;
    	return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NAB = Console.ReadLine().Split(' ').Select(s => BigInteger.Parse(s)).ToArray();
            var N = NAB[0];
            var A = NAB[1];
            var B = NAB[2];
            BigInteger ans = 0;
            BigInteger ones = A + B;

            BigInteger loops = N / ones;
            BigInteger mods = N % ones;

            ans = loops * A;
            if (mods < A)
            {
                ans += mods;
            }
            else
            {
                ans += A;
            }

            Console.WriteLine(ans);
        }
    }
}


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



int main(){
    int  h, w;
    cin >> h >> w;
    stringstream ss;
    for(int i = 0; i < (w+2); ++i){
        ss << "#";
    }
    ss << endl;

    for(int i = 0; i < h; ++i){
        string s;
        cin >> s;
        ss << "#" << s << "#" << endl;
    }

    for(int i = 0; i < (w+2); ++i){
        ss << "#";
    }
    ss << endl;

    // Failed to predict input format
    cout << ss.str();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
bool isRight(int a, int b, int c)
{
    //?????§???c??????????????????????????´???
    if (a > c) {
        std::swap(a, c);
    }
    if (b > c){
        std::swap(b, c);
    }
    
    return a * a + b * b == c * c;
}

int main()
{
    int N;
    int a, b, c;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> a >> b >> c;
        if (isRight(a, b, c)) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define frr(i,s,n) for(int i=s;i<=n;i++)
#define fr(i,s,n) for(int i=s;i<n;i++)
#define lli long long int
#define llu unsigned long long int
#define vi vector <int>
#define vii vector <long long int>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define mk make_pair
#define mpp map<int,int>
#define ff first
#define ss second
#define mod 1000000007

using namespace std;

vector <int> v[100001];
vector <int> vis(100001);
int dp[100001];
int dfs(int node)
{
	if(vis[node])
		return dp[node];
	vis[node] = 1;
	int mx = 0;
	for(auto child : v[node])
		mx = max(mx,dfs(child) + 1);
	return dp[node] = mx;
}

void loop()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
	}
	int mx = 0;
	for(int i=1;i<=n;i++)
		mx = max(mx,dfs(i));
	cout<<mx<<"\n";
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	fast;
    int t=1;
    //cin>>t;
    while(t--)
    	loop();
}


Measured memory_bytes: 11524
def impossible(a,b,P):
    if(b == 0 and P == 1):
        return True
    if(a == 0 and b == 1 and P == 0):
        return True
    
    return False

def func():
    N,P = map(int,input().split())

    lists = list(map(int,input().split()))
    dp = [0] * 2

    for l in lists:
        if(l % 2 == 0):
            dp[0] += 1
        else:
            dp[1] += 1
    ans = 2 ** dp[0]
    if(dp[1] > 0):
        ans *= 2 ** (dp[1] - 1)
    else:
        ans *= 1

    if(impossible(dp[0],dp[1],P)):
        ans = 0

    print(ans)
func()

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int r,D,x = 0;
    int result = 0;
    
    scanf("%d",&r);
    scanf("%d",&D);
    scanf("%d",&x);
    
    result = x;
    for (int i=0; i<10; i++) {
        result = r*result-D;
        printf("%d\n",result);
    }
}


Measured memory_bytes: 128
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>

int solve(int n,const std::vector<int> &v) {
  std::vector<std::vector<int>> w(4),f(4);
  for ( int i=0; i<4; i++ ) {
    w[i].resize(n*n);
    f[i].resize(n*n);
    for ( int j=0; j<n*n; j++ )
      f[i][j]=1;
  }
  std::vector<int> c(n*n,1);
  for ( int i=0; i<n; i++ ) {
    f[0][i]=0;
    f[1][i*n]=0;
    f[2][(n-1)*n+i]=0;
    f[3][(i+1)*n-1]=0;
    int u=i,d=n-1-i;
    for ( int j=0; j<n; j++ ) {
      int k=std::min(j,n-1-j);
      if ( u<=d ) {
        w[0][i*n+j]=w[1][j*n+i]=std::min(k+1,u);
      }
      else {
        w[0][i*n+j]=w[1][j*n+i]=std::min(k+1,d+2);
      }
      if ( d<=u ) {
        w[2][i*n+j]=w[3][j*n+i]=std::min(k+1,d);
      }
      else {
        w[2][i*n+j]=w[3][j*n+i]=std::min(k+1,u+2);
      }
    }
  }
  std::vector<int> m(n*n);
  for ( int j=0; j<n*n; j++ ) {
    int x=w[0][j];
    for ( int i=1; i<4; i++ ) {
      x=std::min(x,w[i][j]);
    }
    m[j]=x;
  }
  int ans=0;
  int dir[4]={-n,-1,n,1};
  std::vector<int> q;
  for ( auto e: v ) {
    ans+=m[e];
    c[e]=0;
    q.push_back(e);
    while ( !q.empty() ) {
      int i=*q.rbegin();
      q.pop_back();
      int t=m[i]+c[i];
      for ( int d=0; d<4; d++ ) {
        if ( !f[d][i] )
          continue;
        int j=i+dir[d];
        w[d^2][j]=t;
        if ( t<m[j] ) {
          m[j]=t;
          q.push_back(j);
        }
      }
    }
  }
  return ans;
}

int main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n;
  std::cin >> n;
  std::vector<int> v(n*n);
  for ( int i=0; i<n*n; i++ ) {
    int x;
    std::cin >> x;
    v[i]=x-1;
  }
  std::cout << solve(n,v) << std::endl;
}


Measured memory_bytes: 14432
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, T;
    cin >> N >> T;

    vector<int> cs;
    REP(i, N) {
        int c, t;
        cin >> c >> t;
        if (t > T) {
            continue;
        } else {
            cs.push_back(c);
        }
    }

    if (cs.size() == 0) {
        cout << "TLE" << endl;
    } else {
        cout << *min_element(ALL(cs)) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I=ll(A);I<ll(B);++I)

int main(){
	int ans = 0;
	string w,t;
	cin >> w;
	for(auto &x:w)if(x<='Z'&&x>='A')x+='a'-'A';
	while(cin>>t){
		if(t=="END_OF_TEXT")break;
		for(auto &x:t)if(x<='Z'&&x>='A')x+='a'-'A';
		if(t==w)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3196
#include<cstdio>
#define MAX 50
#define NIL -1
int F[MAX];
int n;

int fibo(int n){
  if(n==0||n==1)return F[n]=1;
  if(F[n]!=NIL){
    return F[n];
  }

  return F[n]=fibo(n-2)+fibo(n-1);
}

int makeFibo(int n){
  F[0]=F[1]=1;
  for(int i=2;i<=n;i++){
    F[i]=fibo(i-1)+fibo(i-2);
  }
  return F[n];
}



int main(){
  //int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)F[i]=NIL;
  printf("%d\n",makeFibo(n));


}



Measured memory_bytes: 2764
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, m, a, b, ans = 0, cnt = 0;
vector<vector<ll>> to(200005);
bool visited[200005] = {};

void dfs(ll cur) {
	bool ok = false;
	visited[cur] = true;
	cnt++;
	rep(i, sz(to[cur])) {
		if (!visited[to[cur][i]]) {
			dfs(to[cur][i]);
			ok = true;
		}
	}
}

int main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a >> b;
		to[a].pub(b);
		to[b].pub(a);
	}
	rep(i, n) {
		if (!visited[i]) {
			dfs(i);
			chmax(ans, cnt);
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23548
#include<iostream>
#include<unordered_map>
using namespace std;
#define SZ(a) ((int)(a).size())
#define F first
#define S second
/*>_<*/
unordered_map<int,int> m[2];
const int N = 4.2e5;
int dp[N];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin >> s;
	m[1][0] = 0;
	int v = 0;
	for (int i = 0; i < SZ(s); ++i) {
		auto & me = m[i&1];
		auto & mo = m[i&1^1];
		v ^= 1<<(s[i]-'a');
		dp[i] = N;
		for (int j = 0; j < 26; ++j) {
			auto it = mo.find(1<<j ^ v);
			if (it != mo.end())
				dp[i] = min(dp[i], it->S);
		}
		auto it = me.find(v);
		if (it != me.end()) {
			dp[i] = min(it->S, dp[i]) + 1;
			it->S = min(it->S, dp[i]);
		} else {
			me[v] = ++dp[i];
		}
//cerr << s[i] << " : " << dp[i] << endl;
	}
	cout << dp[SZ(s)-1] << '\n';
}


Measured memory_bytes: 9436
/*
                    author         : TAPAN SAVANI 
                    codeforces     : savanitapan2001
                    codechef       : savanitapan17
*/

/*
------------------------------------------------------------------------

░██╗░░░░░░░██╗░█████╗░██████╗░██╗░░██╗  ██╗░░██╗░█████╗░██████╗░██████╗░
░██║░░██╗░░██║██╔══██╗██╔══██╗██║░██╔╝  ██║░░██║██╔══██╗██╔══██╗██╔══██╗
░╚██╗████╗██╔╝██║░░██║██████╔╝█████═╝░  ███████║███████║██████╔╝██║░░██║
░░████╔═████║░██║░░██║██╔══██╗██╔═██╗░  ██╔══██║██╔══██║██╔══██╗██║░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝██║░░██║██║░╚██╗  ██║░░██║██║░░██║██║░░██║██████╔╝
░░░╚═╝░░░╚═╝░░░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝  ╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░
 
------------------------------------------------------------------------
*/

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

#define HAPPY_CODING              \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())
#define mod 1000000007
#define pi 3.141592653589793238
#define ll long long int
#define ull unsigned long long
#define be begin()
#define en end()
#define FOR(i, a, b) for (long long int i = a; i < b; i++)
#define FORI(i, a, b) for (int i = a; i >= b; i--)

typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef vector<PI> VPI;

int main()
{
    HAPPY_CODING;

    int n, c=0, d=0;
    cin >> n;

    vector<pair<int, int>> a(n);
    int b[n];
    FOR(i,0,n)
    {
        cin >> a[i].first >> a[i].second;
        if(a[i].first == a[i].second)
        {
            c++;
        }
        else 
        {
            c = 0;
        }

        if(c>=3)
            d=1;
    }

    if(d==1)
        cout << "Yes\n";

    else 
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
int n,k,r,s,p,ans;string t,a="";
int jan(char st){
  if(st == 'r')return p;
  if(st == 's')return r;
  if(st == 'p')return s;
}
int main(){
  cin >> n >> k >> r >> s >> p >> t;
  for (size_t i = 0; i < n; i++) {
    if(i < k){
      ans += jan(t[i]);
      a += "2";
    }else{
      if(t[i] != t[i-k] || (t[i] == t[i-k] && a[i-k] == '0')){
        ans += jan(t[i]);
        a += "1";
      }else{
        a += "0";
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
S = input()
from collections import defaultdict
d = defaultdict(int)
before = 0
for i in range(1,len(S)+1):
    now = (int(S[-i])*pow(10,i,2019)+before) % 2019
    d[now] += 1
    before = now
d[0] += 1
ans = 0
for i in d.values():
    ans += i*(i-1)//2
print(ans)

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<62)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


//{{補充回数,残り燃料},位置}
using P = pair<pair<lli,lli>,lli>;
vector<pair<lli,lli>> G[400];

void func(long long N, long long M, long long L, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, long long Q, std::vector<long long> s, std::vector<long long> t){

    vector<vector<pair<lli,lli>>> dist(N,vector<pair<lli,lli>>(N,{INF,INF}));
    priority_queue<P,vector<P>,greater<P>> q;

    REP(i,0,N){
        dist[i][i]={0,0};
        q.push({{0,0},i});

        while(q.size()){
            pair<lli,lli> p =  q.top().first;
            lli nowD = q.top().first.first;
            lli nowI = q.top().second;
            lli nowL = q.top().first.second;
            q.pop();
            if(p > dist[i][nowI])continue;
            for(auto e:G[nowI])
            {
                if(e.second > L)continue;
                lli nextI = e.first;
                lli nextL = nowL+e.second;
                pair<lli,lli> np = {nowD,nextL};
                if(nextL>L){
                    np.second = e.second;
                    np.first = dist[i][nowI].first+1;
                }
                if(chmin(dist[i][nextI],np)){
                    q.push({dist[i][nextI],nextI});
                }
            }
        }
    }

    REP(i,0,Q){
        lli dis = min(dist[s[i]][t[i]].first,dist[t[i]][s[i]].first);
        if(dis==INF)cout<<-1<<endl;
        else cout<<dis<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long L;
    scanf("%lld",&L);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
        A[i]--;B[i]--;
        G[A[i]].push_back({B[i],C[i]});
        G[B[i]].push_back({A[i],C[i]});
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> s(Q);
    std::vector<long long> t(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&t[i]);
        s[i]--,t[i]--;
    }
    func(N, M, L, std::move(A), std::move(B), std::move(C), Q, std::move(s), std::move(t));
    return 0;
}


Measured memory_bytes: 10404
#include<iostream>
using namespace std;
int x[10];
int func(int n,int r,int l){
    if(n == 10)return 1;
    if(x[n]>r){
        if(func(n+1,x[n],l))return 1;
    }
    if(x[n]>l){
        if(func(n+1,r,x[n]))return 1;
    }
    return 0;
}
int main(){
	int k;
	cin>>k;
	while(k-->0){
		for(int i=0;i<10;i++)
			cin>>x[i];
		if(func(0,0,0))
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
print(n-k+1)

Measured memory_bytes: 23284
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

bool dfs(vector<int>& v, int num, int& cnt, int K)
{
    if (v.size() == num) {
        cnt++;
        if (cnt == K) {
            int i;
            for (i = 0; i < (int)v.size(); i++) {
                printf("%d", v[i]);
            }
            printf("\n");
            return true;
        }
        return false;
    }
    assert(!v.empty());
    int tmp = v.back();
    int i;
    for (i = MAX(0, tmp - 1); i <= MIN(9, tmp + 1); i++) {
        v.push_back(i);
        if (dfs(v, num, cnt, K)) {
            return true;
        }
        v.pop_back();
    }

    return false;
}

void solve()
{
    int K;
    scanf("%d", &K);

    int cnt = 0;
    int i,j;
    for (i = 1; i < 12; i++) {
        vector<int> v;
        for (j = 1; j < 10; j++) {
            v.push_back(j);
            if (dfs(v, i, cnt, K)) {
                return;
            }
            v.pop_back();
        }
    }
    assert(false);
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d%d", &T, &B);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n, m;

int main() { 

  cin >> n >> m;

  if (n == 1 || m == 1) {
    cout << 1 << endl;
    return 0;
  }

  long long ans = 0;
  ans = 1ll * ((n + 1) / 2) * ((m + 1) / 2);
  ans += 1ll * (n / 2) * (m / 2);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    set<string> S;
    for (int i = 0; i < N; i++) {
        string s; cin >> s; S.insert(s);
    }
    cout << S.size() << '\n';
    return 0;
}


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

int main(){
    int A[3];
    cin>>A[0]>>A[1]>>A[2];
    sort(A,A+3);
    cout<<10*A[2]+A[1]+A[0]<<endl;
}


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

int main() {
  long long k, a, b;

  cin >> k >> a >> b;

  long long ans = 1;

  if (a >= b || b - a <= 1) {
    ans += k;
    cout << ans << endl;
    return 0;
  }

  long long i = 0;
  while (true) {
    if (i == k) {
      break;
    }
    if (i <= k - 2 && ans >= a) {
      i += 2;
      ans += b - a;
    }
    else {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def ev( a, b, oper ):
    if oper == '+': return a+b
    if oper == '-': return a-b
    if oper == '*': return a*b
    if oper == '/': return a/b
    return 0

while True:
    try:
        expr = raw_input().split()
    except EOFError:
        break
    stack = []
    for c in expr:
        try:
            stack.append( float(c) )
        except ValueError:
            a, b = stack.pop(), stack.pop()
            stack.append( ev(b, a, c) )
    print stack.pop()

Measured memory_bytes: 4236
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 305;

int h, w;
int cost[MAX_N][MAX_N][MAX_N];

int solve(vs& s, int id, int x, int y)
{
    int res = 0;
    rep(i,h-x){
        if(y <= x+i){
            res += (s[i][id] == s[x+i-y][id+1]);
        }
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    vs s(h);
    rep(i,h){
        cin >> s[i];
    }
    rep(i,w-1){
        srep(gap,-h,h+1){
            if(gap >= 0){
                srep(j,1,h-gap+1){
                    cost[i][h-j][h-gap-j] = cost[i][h-j+1][h-gap-j+1] + (s[j-1][i] == s[j+gap-1][i+1]);
                }
            }else{
                srep(j,1,h+gap+1){
                    cost[i][h+gap-j][h-j] = cost[i][h+gap-j+1][h-j+1] + (s[j-gap-1][i] == s[j-1][i+1]);
                }
            }
        }
    }
    int ans = 0;
    rep(i,w-1){
        vvi dp(h+1,vi(h+1,INF));
        dp[0][0] = 0;
        srep(j,1,2*h+1){
            srep(x,max(0,j-h),min(h,j)+1){
                int y = j - x;
                if(x > 0){
                    cmn(dp[x][y], dp[x-1][y]+cost[i][x-1][y]);
                }
                if(y > 0){
                    cmn(dp[x][y], dp[x][y-1]+cost[i][x][y-1]);
                }
            }
        }
        int mn = INF;
        rep(j,h+1){
            cmn(mn, dp[j][h]);
            cmn(mn, dp[h][j]);
        }
        ans += mn;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 111368
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N % 2 == 0) {
			System.out.println(N / 2);
		} else {
			System.out.println(N / 2 + 1);
		}
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
long long knapSack1(int W, int weight[], int val[], int n) 
{ 
   	int k, w; 
   	long long **F = new long long *[n+1];
   	for(int i=0;i<n+1;i++)
   		F[i]= new long long[W+1];
   
   	// Build table K[][] in bottom up manner 
   	for (k = 0; k <= n; k++) { 
       	for (w = 0; w <= W; w++) { 
			if (k==0 || w==0) 
			   F[k][w] = 0; 
			else if (weight[k-1] <= w) 
			    F[k][w] = max(F[k-1][w], F[k-1][w-weight[k-1]]+val[k-1]);  
			else
			     F[k][w] = F[k-1][w]; 
			//cout<<std::setw(2)<<F[k][w]<<" ";
       	} 
       	//cout<<endl;
   	} 
   	long long result = F[n][W];
   	for(int i=0;i<n+1;i++)
		delete []F[i];
	delete []F;
   	return  result;
} 

long long knapSack2(int W, int weight[], int val[], int n) 
{ 
   long long F[n+1][W+1]; 
   //Build table K[][] in bottom up manner 
   for (int k = 0; k <= n; k++) 
   { 
       for (int w = 0; w <= W; w++) 
       	{ 
			if (k==0 || w==0) 
			   F[k][w] = 0; 
			else if (weight[k-1] <= w) 
			     F[k][w] = max(F[k-1][w], F[k-1][w-weight[k-1]]+val[k-1]); 
			else
			     F[k][w] = F[k-1][w]; 
       	} 
   } 
   return F[n][W]; 
} 

long long knapSack3(int W, int weight[], int val[], int n) 
{
	long long vsum = 0;
    for(int i=0;i<n;i++){
      	vsum += val[i];
    }
  
    long long *dp=new long long[vsum+1];
    for(long long i=0;i<vsum+1;i++)
		dp[i] = pow(10, 18)+5;
    dp[0] = 0;
    
    for(int i=0;i<n;i++){
        for(long long j=vsum; j>=val[i]; j--){
            dp[j] = min(dp[j], dp[j-val[i]] + weight[i]);
        }
    }
    
    long long i;
    for(i=vsum; i>=0; i--){
        if(dp[i]<=W){
            //cout << i;
            break;
        }
    }
    delete []dp;
    return i;
}

int main()
{

    std::ios::sync_with_stdio(false);
    
	int n, W;
	std::cin>>n>>W;
	int *val=new int[n];
	int *wt = new int[n];
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
    std::cout<< knapSack3(W, wt, val, n)<<endl; 
    delete []val;
	delete []wt;
    
    return 0;
}

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

using namespace std;

using ll = long long;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes";
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No";
            return 0;
        }
    }
}


Measured memory_bytes: 3664
import java.lang.Long.min

fun main(args: Array<String>) {
    val (l, r) = readIntList()

    var ans = Long.MAX_VALUE
    for (i in l until r) {
        for (j in i + 1..r) {
            val tmp = i.toLong() * j.toLong() % 2019L
            ans = min(ans, tmp)
            if (ans == 0L) {
                println(0)
                return
            }
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 36436
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n;
	int ans=0;
	
	cin>>n;
	for(int i=1;i<n+1;i++)
		ans+=i;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
3ツづつづ稽inツづ?ツづつづ稽inツづーツ堕ォツつオツ債?づュツつケツづ? 50ツづーツ暗クツつ「ツづ?出ツ療債つオツづ慊つオツづ・ツつ、.
 */

#include <iostream>
#include <climits>
using namespace std;

int main(){
  int p = INT_MAX;

  for(int i = 0; i < 3; i++){
    int x;
    cin >> x;
    p = min(p, x);
  }

  int j = INT_MAX;

  for(int i = 0; i < 2; i++){
    int x;
    cin >> x;
    j = min(j, x);
  }

  cout << p + j - 50 << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = 200005;
int ar[NN];
int n, m, k;


integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    if (s[1] == 'B'){
        cout << "ARC";
    } else {
        cout << "ABC";
    }

}


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

long long solve(long long n) {
  if (n == 1) return 1;
  return 1 + 2 * solve(n / 2);
}

int main(void) {
  long long H;
  cin >> H;
  cout << solve(H) << endl;
  return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var result = '';
for(var i=0;i<input.length;i++){
  if(input.charCodeAt(i) >= 65 && input.charCodeAt(i) <= 90){
    result = result + input.charAt(i).toLowerCase();
  }
  else{
    result = result + input.charAt(i).toUpperCase();
  }
}
console.log(result.trim());



Measured memory_bytes: 15916
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int n;
ll int y;
ll int z;
int s;

int main(){
  cin >> n >> y;
  s = (y % 5000) / 1000;
  while(s <= n){
    z = y - s * 1000;
    if(z >= 5000 * (n - s) && z <= 10000 * (n - s)){
      REP(i, n - s + 1){
        if((i * 10000 + (n - s - i) * 5000) == z){
          cout << i << " " << n - s - i << " " << s << endl;
          return 0;
        }
      }
    }
    s += 5; 
  }

  cout << -1 << " " << -1 << " " << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N = int(input())
V = list(map(int, input().split()))

count = 0

from collections import Counter

odd = V[0::2]
even = V[1::2]

od = Counter(odd)
ev = Counter(even)

# これをいれとかないと、最頻値が１しか無い時に２つめを取得できなくなる
od[0] = 0
ev[0] = 0

# 1要素だけ取得
co1 = od.most_common(1)
ce1 = ev.most_common(1)

# 多い順に2要素だけ取得
co2 = od.most_common(2)
ce2 = ev.most_common(2)

# 最頻値が同じ場合は、odd/evenの片方を二番目の最頻値にして、少ない方を採用
if co1[0][0] == ce1[0][0]:
    print(min(N - co1[0][1] - ce2[1][1], N - co2[1][1] - ce1[0][1]))
else:
    # 違う場合は、出現回数を引いてやればいい
    print(N - co1[0][1] - ce1[0][1])


Measured memory_bytes: 18976
#include <stdio.h>
#include <string.h>

#define N 26

int main() {
	static char s[N + 1];
	static int kk[N];
	int n, i;

	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; i++)
		kk[s[i] - 'a']++;
	for (i = 0; i < n; i++)
		if (kk[s[i] - 'a'] != 1) {
			printf("no\n");
			return 0;
		}
	printf("yes\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(k,n) for(int i=k;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  rep(0,n) cin>>h[i];
  vector<int> c(n,0);
  c[0]=0;
  c[1]=abs(h[1]-h[0]);
  rep(2,n) c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]));
  cout<<c[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INT long long
using namespace std;
INT n, a[10010], b[10010], X, Y;
bool ans = false;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ ) cin>>a[i];
    for(int i = 0 ; i < n ; i++ ) cin>>b[i];
    for(int i = 0 ; i < n ; i++ )
        if( b[i]-a[i] > 0 ) X += (b[i]-a[i])/2;
        else Y += (b[i]-a[i]);
    if( X >= abs(Y) ) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
	/*int t; cin>>t;

	while(t--)
	{
		int c=0, st=105, end;
		string s; cin>>s; int n=s.size();
		for(int i=0; i<n; ++i)
		{
					if(s[i]=='1') {st=i; break;}
	    }
		for(int j=n-1; j>=0; --j)
		{
					if(s[j]=='1') {end=j; break;}
		}
		for(int x=st; x<=end; ++x)
		{
			if(s[x]=='0') c++;

		}
		cout<<c<<endl;
	}
*/

	//nastya and rice

	int n, x, t; cin>>n>>x>>t;
	//bool f=false;
	/*while(!(n<x))
	{
		if(x==1) {cout<<n*t<<endl; f= true; break;}
		if(n>=x) {n-=x; ans+=t;}
	}
	if(!f) cout<<ans+t<<endl;*/

	if(n%x==0)
		cout<<((n/x)*t)<<endl;
	else
		cout<<((n/x)*t+t)<<endl;



	return 0;

}



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

int main() {
    long long A, B, C; cin >> A >> B >> C;
    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) cout << 0 << endl;
    else cout << min({A*B, B*C, C*A}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll m;
    cin >> m;
    ll fig = 0, sum = 0;
    rep(i, m) {
        ll d, c;
        cin >> d >> c;
        fig += c;
        sum += d * c;
    }
    cout << ((fig - 1) + ((sum - 1) / 9)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
int h,w,H,W;
int main()
{
	int n;
	while(cin>>H>>W>>h>>w)
	{
		if(H%h==0&&W%w==0)
		{
			puts("No");
			continue;
		}
		puts("Yes");
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				if(i%h==0&&j%w==0)
					cout<<1000*(h*w-1)-1<<' ';
				else
					cout<<-1000<<' ';	
			}	
			cout<<endl;
		}	
  
	}
	return 0;
}

Measured memory_bytes: 1664
def solve(i, j):
    if i > j:
        print("GREATER")
        exit()
    if i < j:
        print("LESS")
        exit()
a = input()
b = input()
solve(len(a), len(b))
if int(a) == int(b):
    print("EQUAL")
    exit()
for ai, bi in zip(a, b):
    solve(int(ai), int(bi))

Measured memory_bytes: 3060
# frozen_string_literal: true

M, D = gets.split.map(&:to_i)
count = 0
1.upto(M) do |m|
  1.upto(D) do |d|
    d1 = d % 10
    d10 = (d / 10) % 10
    count += 1 if d1 >= 2 && d10 >= 2 && d1 * d10 == m
  end
end

puts count


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<" "
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);

int main()
{
    fast;
    ll n,k;
    cin >> n >> k;
    ll a[n],dp[n]={0};
    input(a,n);
    fr(i,1,n)
    {
        dp[i]=INT_MAX;
        fr(j,max(dp[0],i-k),i)
            dp[i]=min(dp[j]+abs(a[j]-a[i]),dp[i]);
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1792
#include<iostream>


using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  int count = 0;
  int h;
  for(int i=0;i<n;i++){
    cin >> h;
    if(h>=k) count += 1;
  }
  cout << count << endl;
  return 0;
}




Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!

    var count = 0
    for (i in 0 until S.length - 2) {
        if (S.substring(i..i + 2) == "ABC") {
            count++
        }
    }
    println(count)

}



Measured memory_bytes: 31996
n,m=gets.chomp.split.map(&:to_i)
nStrings=n.times.map{gets.chomp.split(" ").join}
mStrings=m.times.map{gets.chomp.split(" ").join}
result = "No"
(0..(n-m)).each do |yIndex|
  (0..(n-m)).each do |xIndex|
    if nStrings[yIndex].index(mStrings[0],xIndex) != nil
      result = "Yes"
      mStrings.each_with_index do |mString,tempIndex|
        next if tempIndex == 0
        findNumber = nStrings[tempIndex+yIndex].index(mString,xIndex)
        if findNumber == nil || findNumber != xIndex
          result = "No"
          break
        end
      end
    end
    break if result == "Yes"
  end
 break if result == "Yes"
end
puts result

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N=50005;
string s;
int main()
{
    cin>>s;
    int l=s.size(),f=1;
    for(int i=0; i<l/2; i++)
    {
        if(s[i]!=s[l-1-i])
        {
            f=0;
            break;
        }
    }
    if(!f)
    {
        printf("No\n");
        return 0;
    }
    for(int i=0; i<(l-1)/2; i++)
    {
        if(s[i]!=s[(l-1)/2-1-i])
        {
            f=0;
            break;
        }
    }
    if(!f)
    {
        printf("No\n");
        return 0;
    }
    for(int i=(l+3)/2-1; i<l; i++)
    {
        if(s[i]!=s[l-1-i])
        {
            f=0;
            break;
        }
    }
    if(!f)
    {
        printf("No\n");

    }
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
import sys,random,time,bisect
input=sys.stdin.buffer.readline

start=time.time()
N=int(input())
vw=[(-1,-1)]
for i in range(N):
    vw.append(tuple(map(int,input().split())))

dp=[[] for i in range(2**9)]
def make_dp(v):
    t=[[0,0] for i in range(15)]
    V=v
    id=0
    while v>=1:
        t[id]=vw[v]
        id+=1
        v//=2
    n=id
    temp=[[0,0] for i in range(2**n)]
    for i in range(n):
        for j in range(2**i,2**(i+1)):
            temp[j][0]=temp[j-2**i][0]+t[i][0]
            temp[j][1]=temp[j-2**i][1]+t[i][1]
    temp.sort(key=lambda x:x[1])
    while temp and temp[-1][1]>10**5:
        temp.pop()
    m=len(temp)
    for i in range(1,m):
        temp[i][0]=max(temp[i][0],temp[i-1][0])

    dp[V]=[0]*(10**5+1)
    for i in range(m-1):
        L=temp[i][1]
        R=temp[i+1][1]
        for j in range(L,R):
            dp[V][j]=temp[i][0]
    else:
        L=temp[-1][1]
        for j in range(L,10**5+1):
            dp[V][j]=temp[-1][0]

MAX=min(2**9,N+1)
for i in range(1,MAX):
    make_dp(i)

Q=int(input())
query=[[] for i in range(N+1)]
for i in range(Q):
    v,L=map(int,input().split())
    query[v].append((L,i))

ans=[0]*Q
temp=[[0,0] for i in range(2**9)]
t=[[0,0] for i in range(15)]
def solve(v):
    V=v
    id=0
    while v>=2**9:
        t[id]=vw[v]
        id+=1
        v//=2
    n=id
    for i in range(n):
        for j in range(2**i,2**(i+1)):
            temp[j][0]=temp[j-2**i][0]+t[i][0]
            temp[j][1]=temp[j-2**i][1]+t[i][1]

    for L,ID in query[V]:
        res=0
        for i in range(2**n):
            if L>=temp[i][1]:
                res=max(res,temp[i][0]+dp[v][L-temp[i][1]])
        ans[ID]=res

for i in range(1,N+1):
    if query[i]:
        solve(i)

for i in range(Q):
    print(ans[i])


Measured memory_bytes: 534536
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amotoma3
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int[] t = new int[n];
            int[] x = new int[n];
            int[] y = new int[n];
            for (int i = 0; i < n; i++) {
                t[i] = in.nextInt();
                x[i] = in.nextInt();
                y[i] = in.nextInt();
            }

            {
                int d = Math.abs(x[0]) + Math.abs(y[0]);
                if (t[0] < d || t[0] % 2 != d % 2) {
                    out.println("No");
                    return;
                }
            }

            for (int i = 0; i < n - 1; i++) {
                int td = t[i + 1] - t[i];
                int d = Math.abs(x[i] - x[i + 1]) + Math.abs(y[i] - y[i + 1]);

                if (td < d || td % 2 != d % 2) {
                    out.println("No");
                    return;
                }
            }

            out.println("Yes");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 43236
// https://atcoder.jp/contests/abc079/tasks/abc079_d
// Warshall Floyd

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)

typedef long long ll;

#define MAX_V 15
ll d[MAX_V][MAX_V];
int V;

void warshall_floyd()
{
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

void Main()
{
	int H, W; cin >> H >> W;
	V = 10;
	rep(i,10) {
		rep(j,10) {
			cin >> d[i][j];
		}
	}
	int nums[15];
	memset(nums, 0, sizeof(nums));
	rep(i,H) {
		rep(j,W) {
			int a; cin >> a;
			if (a == -1) continue;
			++nums[a];
		}
	}
	warshall_floyd();
	ll res = 0;
	rep(i,10) {
		res += d[i][1] * nums[i];
	}
	cout << res << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


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

int N;
const int MAX_N = 1.0e5 + 100;
int A[MAX_N];

int main() {
    cin >> N;
    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        mp[A[i]]++;
    }

    if (mp[0] == N) {
        cout << "Yes" << endl;
    }
    else if (N % 3 == 0) {
        bool f = false;
        int zero;
        int xyz[3];
        int keys[3];
        int i = 0;
        for (auto itr = mp.begin(); itr != mp.end(); itr++) {
            int key = itr->first;
            int val = itr->second;

            if (key == 0) {
                zero = val;
            }
            else {
                if (i >= 3) {
                    break;
                }
                xyz[i] = val;
                keys[i] = key;
                i++;
            }
        }

        if (zero == N/3 && xyz[0] == 2*N/3) {
            cout << "Yes" << endl;
        }
        else if (xyz[0] == N/3 && xyz[1] == N/3 && xyz[2] == N/3) {
            if ((keys[0] xor keys[1] xor keys[2]) == 0) {
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 4224