akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
vector<int> to[N];
int k;
ll ans=1;
void dfs(int no=0,int p=-1){
    if(-1==p){
        for(int i=k-1;i>=k-SZ(to[no]);i--){
            ans*=i;
            ans%=MOD;
        }
    }else{
        for(int i=k-2;i>=k-SZ(to[no]);i--){
            ans*=i;
            ans%=MOD;
        }
    }
	for(auto s:to[no]){
		if(s==p)continue;
		
		dfs(s,no);
	}
}
int main(){
    int n;
    cin>>n>>k;
    REP(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs();
    ans*=k;
    ans%=MOD;
    OUT(ans);
	return 0;
}

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

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

	cin >> k;
	cin >> a >> b;
	string s = "NG";
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			s = "OK";
		}
	}
	cout << s;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

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

int n, a[100002], ans;

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		ans = gcd(ans, a[i]);
	}

	cout << ans << '\n';
}

Measured memory_bytes: 640
/* Reverse Polish notation (逆ポーランド記法) */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define MAX 1000

void initialize(int *top)
{
   *top = 0;
}

int isEmpty(int *top)
{
    return *top == 0;
}

int isFull(int *top)
{
    return *top >= MAX - 1;
}

void push(int *S, int *top, int x)
{
    if (isFull(top))
    {
        printf("error(overflow)\n");
        exit(0);
    }
    *top += 1;
    S[*top] = x;
}

int pop(int *S, int *top)
{
    if (isEmpty(top))
    {
        printf("error(underflow)\n");
        exit(0);
    }
    *top -= 1;
    return S[*top + 1];
}

int main(void)
{
    int S[102];
    int top;
    char s[202];
    int x;

    initialize(&top);

    while (scanf("%s", s) != EOF)
    {
        if (s[0] == '+')
        {
            x = pop(S, &top);
            S[top] += x;
        }
        else if (s[0] == '-')
        {
            x = pop(S, &top);
            S[top] -= x;
        }
        else if (s[0] == '*')
        {
            x = pop(S, &top);
            S[top] *= x;
        }
        else
        {
            x = atoi(s);
            push(S, &top, x);
        }
    }

    printf("%d\n", S[top]);

    return 0;
}


Measured memory_bytes: 2112
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
const int MAX=1e5;
const int MAAX=1e9;
const int MOD=1e9+7;
in main()
{
int n,k;
cin>>n>>k;
string ans="";
int fans=0;
while(n)
{ fans++;
    n/=k;
}
cout<<fans<<endl;

    return 0;
}


Measured memory_bytes: 256
from copy import deepcopy
N, M = map(int, input().split())
graph = dict()
for i in range(N):
    graph[i] = []
ab = [tuple(map(int, input().split())) for _ in range(M)]

import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
inf = float("inf")

graph = np.zeros((N, N))

for a, b in ab:
    graph[a - 1][b - 1] = 1
counter = 0
for a, b in ab:
    g = deepcopy(graph)
    g[a - 1][b - 1] = 0
    g = csr_matrix(g)
    shortest_paths = shortest_path(g, directed=False, method="D")
    if inf in shortest_paths[0]:
        counter += 1
print(counter)


Measured memory_bytes: 27952
#include <stdio.h>

int numberd=1, numberf=1;
int map[100][100];
int numofroot[100];
int visited[100];
int d[100];
int f[100];
int map_size;
 
void get_map();
void print_map();
int search(int node);
void print_result();
int main()
{
  get_map();
  //print_map();
  for(int i=0;i<map_size;i++)
    {
      if(d[i]==0)
	{
	  search(i);
	}
    } 
  print_result();
  return 0;
}

int search(int node)
{
  int k;
  if(d[node]==0)//not visited
    {
      d[node]=numberd;//visited
      numberd++;
      if(numofroot[node]!=0)
	{
	  for(int i=0;i<numofroot[node];i++)
	    {
		{
		  k=search(map[node][i]-1);
		  if(k==-1)
		    {
		      //f[node]=numberd;
		      //numberd++;
		      //return -1;
		    }
		}
	    }
	}
      //else
	{
	  f[node]=numberd;
	  numberd++;
	  return -1;
	}
    }
  else//visited
    {
      return 1;
    }

  return -1;
}

void print_result()
{
  for(int i=0;i<map_size;i++)
    {
      printf("%d %d %d\n",i+1, d[i],f[i]);
    }
  return ;
}

void get_map()
{
  int k;
   scanf("%d", &map_size);
  for(int i=0;i<map_size;i++)
    {
      scanf("%d", &k);
      scanf("%d", &numofroot[i]);
      for(int j=0;j<numofroot[i];j++)
	{
	  scanf("%d", &map[i][j]);
	}
    }
  return ;
}

void print_map()
{
  for(int i=0;i<map_size;i++)
   {
     printf("%d", numofroot[i]);
     for(int j=0;j<numofroot[i];j++)
       {
	 printf("%d", map[i][j]);
       }
     if(i!=map_size-1)
       {
     puts("");
       }
   }
  puts("");
  return ;
}

Measured memory_bytes: 1064
#include <stdio.h>
int main(void) {
	int h, w, i, x, y, current;
	char room[110][110], passed[100100], tile;

	while (1) {
		scanf("%d %d ", &h, &w);
		if (!h)
			break;

		for (i = 0; i < h; i++) {
			fgets(room[i], 105, stdin);
		}

		x = y = 0;
		current = x * 1000 + y;
		for (i = 0; i < 100100; i++) {
			passed[i] = 0;
		}

		while (1) {
			passed[current] = 1;
			tile = room[y][x];

			if (tile == '>') {
				x += 1;
			} else if (tile == '<') {
				x -= 1;
			} else if (tile == 'v') {
				y += 1;
			} else if (tile == '^') {
				y -= 1;
			} else {
				printf("%d %d\n", x, y);
				break;
			}

			current = x * 1000 + y;
			if (passed[current]) {
				puts("LOOP");
				break;
			}
		}
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  long sum = 0;
  for (int i = 0; i < pow(2, s.size() - 1); i++) {
    long x = 0;
    long y = s.at(0) - '0';
    for (int j = 0; j < int(s.size()) - 1; j++) {
      int c = s.at(j+1) - '0';
      bool brk = bool((i & int(pow(2, j))) == 0);
      if (brk) {
        x += y;
        y = c;
      } else {
        y = y * 10 + c;
      }
    }
    x += y;
    sum += x;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 512
def has_duplicated_elem(word_list):
    if len(list(set(word_list))) == len(word_list):
        return False
    else:
        return True


def break_shiritori_rule(word_list):
    for i,word in enumerate(word_list):
        
        if i+1 == len(word_list):
            return False
        if word[-1] == word_list[i+1][0]:
            continue
        else:
            return True
    else:
        return False

num = int(input())
word_list = []
for i in range(num):
    word_list.append(input())

if has_duplicated_elem(word_list) or break_shiritori_rule(word_list):
    print('No')
else:
    print('Yes')



Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <assert.h>
#include <vector>
#include <set>
#pragma warning(disable : 4996)

#define N_MAX 500001
#define Q_MAX 20000

int N;
char S[N_MAX];
std::set<int> infos[26];
int Q;

int main(void) {
	scanf("%d", &N);
	scanf("%s", &S[0]);
	for (int i = 0; i < N; ++i) {
		int c = (int)(S[i] - 'a');
		infos[c].insert(i);
	}
	for (int i = 0; i < 26; ++i) {
		infos[i].insert(N);
	}
	scanf("%d", &Q);
	for (int j = 0; j < Q; ++j) {
		int q;
		scanf("%d", &q);
		if (q == 1) {
			int i;
			char c;
			scanf("%d %c", &i, &c);
			i -= 1;
			int oc = (int)(S[i] - 'a');
			infos[oc].erase(infos[oc].find(i));
			infos[(int)(c - 'a')].insert(i);
			S[i] = c;
		}
		else {
			int l, r;
			scanf("%d %d", &l, &r);
			l -= 1;
			r -= 1;
			int sum = 0;
			for (int c = 0; c < 26; ++c) {
				std::set<int>::iterator it = infos[c].lower_bound(l);
				if ((*it) <= r) {
					++sum;
				}
			}
			printf("%d\n", sum);
		}
	}
	return 0;
}
 

Measured memory_bytes: 24192
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,k,n,ans,x,a[17],st[100],sst[100],gt[100];
  while(cin >> n){
    ans = 0;
    for(i=0;i<17;i++) a[i] = -1;
    sst[0] = st[0] = 0;
    gt[0] = 0;
    for(i=1;i<100;i++){
      sst[i] = st[i] = i * 5;
      gt[i] = 0;
    }

    x = 0;
    for(i=0;i<=sst[n];i++){

      //for(j=0;j<17;j++) printf("%2d ",a[j]);
      //cout << endl;

      for(j=0;j<100;j++){
	if(gt[j] > 0 && gt[j] == i){
	  for(k=0;k<17;k++){
	    if(a[k] == j) a[k] = -1;
	  }
	}
      }
      
      while(i == sst[x]){
	int c=0;
	
	for(j=0;j<17;j++){
	  if(a[j] == -1) c++;
	  else c = 0;
	  if(x % 5 == 1 && c == 5 || x % 5 != 1 && c == 2) break;
	}
	
	if(j == 17) break;

	for(k=j;k>j-c;k--) a[k] = x;
	gt[x] = sst[x] + 17*(x%2) + 3*(x%3) + 19;
	x++;
      }
      for(j=x;j<100;j++){
	if(st[j] <= i) sst[j]++;
	else break;
      }
    }

    cout << sst[n] - st[n] << endl;
    
  }
  return 0;
}

Measured memory_bytes: 0
import sys
d={}
B1=['* =',' *=']
B2=[' ****','* ***','** **','*** *','**** ']
f=0
for i in range(10): d[str(i)]=B1[i/5]+B2[i%5]
for s in sys.stdin:
  A=[d[e] for e in ('0'*5+s[:-1])[-5:]]
  if f: print
  for y in range(8): print "".join([A[x][y] for x in range(len(A))])
  f=1

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

int main() {
  int N;
  cin >> N;
  vector<int> array(N);
  for (int i = 0; i < N; i++) {
    cin >> array.at(i);
  }
  bool judge = false;
  int ans = 0;
  int index = 1;
  for (int i = 0; i < N; i++) {
    if (index != 2) {
      index = array.at(index-1);
      ans++;
    }
    else if (index == 2) {
      judge = true;
      break;
    }
  }
  if (judge)
    cout << ans << endl;
  else
    cout << -1 << endl;
}

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

int main(){
    int i,t;
    cin >> t;
    int h[t];
    int temp = 0, tot = 0, highest=0;
    for(i=0;i<t;i++){
        cin >> h[i];

        if(h[i]>highest) highest = h[i];

        if(h[i]>=temp && h[i]>=highest)
            temp = h[i];
        else{

            tot++;
            temp = h[i];
        }

    }

    cout << t-tot << endl;
}


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

#define NIL -1
#define INF 1000000001

using namespace std;

struct node{
    int key,parent,left,right;
};

int main(){
    int size_of_H;
    int temp;
    scanf("%d",&size_of_H);
    vector<node> heap_array(size_of_H+1,node{-1,-1,-1,-1});
    
    for(int i = 1;i <= size_of_H;i++){
        scanf("%d",&temp);    
        heap_array[i].key = temp;
    }
    int i = 1;
    while(i <= size_of_H ){
        if(i != 1) heap_array[i].parent = i/2;
        if(2*i  < size_of_H + 1) heap_array[i].left = 2*i;
        if(2*i+1< size_of_H + 1) heap_array[i].right = 2*i+1;
        i++;
    }

    for(int i = 1;i <= size_of_H;i++){
        printf("node %d: key = %d, ",i,heap_array[i].key);
        if(heap_array[i].parent > 0) printf("parent key = %d, ",heap_array[heap_array[i].parent].key);
        if(heap_array[i].left > 0) printf("left key = %d, ",heap_array[heap_array[i].left].key);
        if(heap_array[i].right > 0) printf("right key = %d, ",heap_array[heap_array[i].right].key);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3232
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#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 <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <bitset>

#ifdef LOCAL
#include "local.h"
#endif

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

template <typename T, typename U> void upmin(T& a, const U& b) { a = min<T>(a, b); }
template <typename T, typename U> void upmax(T& a, const U& b) { a = max<T>(a, b); }
template <typename T> void uniq(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

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

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


int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    char c[16][16];
    rep(y, h)
        cin >> c[y];

    vector<pint> start_imo(6);
    const char* imoimo = "Sabcde";
    rep(y, h) rep(x, w)
    {
        if (isalpha(c[y][x]))
            start_imo[strchr(imoimo, c[y][x]) - imoimo] = pint(x, y);
    }

    int res = -1;
    map<pair<int, vector<pint>>, int> dp;
    queue<pair<int, vector<pint>>> q;
    q.push(make_pair(0, start_imo));
    while (!q.empty())
    {
        const int esa = q.front().first;
        const vector<pint> imo = q.front().second;
        const int ncost = dp[q.front()] + 1;
        q.pop();
        assert(imo.size() == 6);

        rep(dir, 4)
        {
            int nx = imo[0].first + dx[dir];
            int ny = imo[0].second + dy[dir];
            if (in_rect(nx, ny, w, h) && c[ny][nx] != '#' &&
                count(imo.begin() + 1, imo.begin() + 5, pint(nx, ny)) == 0)
            {
                vector<pint> nimo;
                nimo.push_back(pint(nx, ny));
                rep(i, 5)
                    nimo.push_back(imo[i]);

                int nesa = esa;
                if (c[ny][nx] - '1' == esa)
                    ++nesa;

                if (nesa == n)
                {
                    res = ncost;
                    goto end;
                }

                auto next = make_pair(nesa, nimo);
                if (!dp.count(next))
                {
                    dp[next] = ncost;
                    q.push(next);
                }
            }
        }
    }
end:;
    cout << res << endl;
}


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

int main(){
	int n;cin>>n;
	ll ans=0;
	ll mn=1e9;
	bool is=true;
	for(int i=1;i<=n;i++){
		ll u,v;cin>>u>>v;
		ans+=u;
		if(v<u){
			mn=min(mn,v);
		}
		if(u!=v){
			is=false;
		}
	}
	if(is)cout<<0;
	else cout<<ans-mn;
	return 0;
}

Measured memory_bytes: 3604
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

template<typename T> std::vector<T> divisor(T n) {
  std::vector<T> res;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0){
      res.emplace_back(i);
      if (i * i != n){
        res.emplace_back(n / i);
      }
    }
  }
  std::sort(res.rbegin(), res.rend());

  return res;
}

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

  int n, k; cin >> n >> k;
  
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));

  int sum = accumulate(all(a), int());
  vector<int> v = divisor(sum);

  for (size_t i = 0; i < v.size(); ++i) {
    vector<int> b = a;
    for (int j = 0; j < n; ++j) {
      //b[j] %= v[i];
      b[j] -= b[j] / v[i] * v[i];
    }

    sort(all(b));

    int sum2 = accumulate(all(b), int());
    int div = sum2 / v[i];
    int cost = 0;
    for (int j = 0; j < div; ++j) {
      cost += (v[i] - b[n - 1 - j]);
    }
    if (cost <= k) {
      print(v[i]); return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;



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




Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_HW(205);

int H, W, F[Max_HW][Max_HW][Max_HW], G[Max_HW][Max_HW][Max_HW], _F[Max_HW][Max_HW][Max_HW], _G[Max_HW][Max_HW][Max_HW], Ans;
char S[Max_HW][Max_HW];

inline void upd(int &a, int b)
{
	a = max(a, b);
}

void dp()
{
	for (int i = 1;i <= H;++i)
		for (int l = 1;l <= W;++l)
			for (int r = 1;r <= W;++r)
				if (F[i][l][r] += F[i + F[i][l][r]][l][r])
					upd(_G[l][i][i + F[i][l][r] - 1], r - l + 1);
	for (int j = 1;j <= W;++j)
		for (int l = 1;l <= H;++l)
			for (int r = l;r <= H;++r)
				if (G[j][l][r] += G[j + G[j][l][r]][l][r])
					upd(_F[l][j][j + G[j][l][r] - 1], r - l + 1);
	for (int i = 1;i <= H;++i)
		for (int l = 1;l <= W;++l)
			for (int r = W;r >= l;--r)
				upd(F[i][l][r], max(F[i][l][r + 1], _F[i][l][r]));
	for (int j = 1;j <= W;++j)
		for (int l = 1;l <= H;++l)
			for (int r = H;r >= l;--r)
				upd(G[j][l][r], max(G[j][l][r + 1], _G[j][l][r]));
}

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 1;i <= H;++i)
		scanf("%s", S[i] + 1);
	for (int i = 1;i <= H;++i)
		for (int l = 1;l <= W;++l)
		{
			F[i][l][l] = 1;
			for (int r = l + 1;r <= W;++r)
				F[i][l][r] = (S[i][r] == S[i][r - 1]) * F[i][l][r - 1]; 
		}
	for (int i = H - 1;i >= 1;--i)
		for (int l = 1;l <= W;++l)
			for (int r = l;r <= W;++r)
				if (F[i][l][r])
					F[i][l][r] += F[i + 1][l][r] * (S[i][l] == S[i + 1][l]);
	for (int j = 1;j <= W;++j)
		for (int l = 1;l <= H;++l)
		{
			G[j][l][l] = 1;
			for (int r = l + 1;r <= H;++r)
				G[j][l][r] = (S[r][j] == S[r - 1][j]) * G[j][l][r - 1];
		}
	for (int j = W - 1;j >= 1;--j)
		for (int l = 1;l <= H;++l)
			for (int r = l;r <= H;++r)
				if (G[j][l][r])
					G[j][l][r] += G[j + 1][l][r] * (S[l][j] == S[l][j + 1]);
	for (Ans = 0;F[1][1][W] < H;)
		++Ans, dp();
	printf("%d", Ans);
	return 0;
}

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

int main()
{
	string input;
	cin >> input;

	if (input.size() < 4) {
		cout << "No";
	}
	else if (input.at(0) == 'Y' && input.at(1) == 'A' && input.at(2) == 'K' && input.at(3) == 'I') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No";
	}

	return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> s(n);
    int sum = 0;
    for(int in=0;in<n;in++) {
        cin >> s.at(in);
        sum += s.at(in);
    }

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

    for(int in=0;in<n;in++) {
        if(sum%10!=0) {
            cout << sum << endl;
            return 0;
        }
        else {
            if(s.at(in)%10==0) continue;
            else sum -= s.at(in);
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3624
import numpy as np

N, M = map(int, input().split())
stairs_exist = np.ones(N+1)
div_num = 10 ** 9 + 7

for c in range(M):
    stairs_exist[int(input())] = 0
    
steps = np.zeros(N+1)
steps[0] = 1
for i in range(N):
    for j in range(i+1, min(N+1, i+3)):
        if stairs_exist[j]:
            steps[j] += steps[i]
            steps[j] %= div_num
            
print(int(steps[-1]))

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int K;
int cnt = 1;

int main() {

    Scd(K);

    deque<ll> q;

    Repe(i,10,1) q.push_back(i);

    int cnt = 0;
    ll ans = 0;
    while( q.size() ){
        ll from = q.front();
        q.pop_front();
        if( ++cnt == K ) ans = from;
        if( ans ) break;
        int la = from%10;
        if( la>0 ) q.push_back( from*10+la-1 );
        q.push_back( from*10+la );
        if( la<9 ) q.push_back( from*10+la+1 );
    }

    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 1792
using System;
public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        string[] s = new string[N];
        for(int i = 0;i < N;i++){
            s[i] = Console.ReadLine();
        }
        int M = int.Parse(Console.ReadLine());
        string[] t = new string[M];
        for(int i = 0;i < M;i++){
            t[i] = Console.ReadLine();
        }
        int ans = 0;
        for(int i = 0;i < N;i++){
            int count = 0;
            for(int j = 0;j < N;j++){
                if(s[i] == s[j]){
                    count++;
                }
            }
            for(int k = 0;k < M;k++){
                if(s[i] == t[k]){
                    count--;
                }
            }
            ans = Math.Max(ans,count);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    #include <set>
    #include <vector>
    #include <string>

    using namespace std;

    const int CMax = 100002;

    int a, b, c, d, e, f, atss, atsw;
    double md;

    int main ()
    {
        scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

        for (int i = 0; i*100*a <= f; i++) {
            for (int j = 0; i*100*a + j*100*b <= f; j++) {
                for (int k = 0; (i + j == 0 || (double)(k*c) / (double)(i*a + j*b) <= e) && i*100*a + j*100*b + k*c <= f; k++) {
                    for (int l = 0; (i + j == 0 || (double)(k*c + l*d) / (double)(i*a + j*b) <= e) && i*100*a + j*100*b + k*c + l*d <= f; l++) {
                        if ((i + j) > 0 && (100.0 * (double)(k*c + l*d))/(double)(i*100*a + j*100*b + k*c + l*d) > md) {
                            atss = k*c + l*d;
                            atsw = i*100*a + j*100*b + k*c + l*d;
                            md = (100.0 * (double)(k*c + l*d))/(double)(i*100*a + j*100*b + k*c + l*d);
                        }
                    }
                }
            }
        }

        printf("%d %d\n", atsw > 0 ? atsw : a * 100, atss);
    }


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}



int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>p(n);
  for(i=0;i<n;i++)cin>>p[i];
  vector<ll>a(n),b(n);
  for(i=0;i<n;i++){
    a[i]=20000*(i+1);
    b[i]=20000*(n-i);
  }
  for(i=0;i<n;i++){
    a[p[i]-1]+=i+1;
  }
  for(i=0;i<n;i++)cout<<a[i]<<" ";
  cout<<endl;
  for(i=0;i<n;i++)cout<<b[i]<<" ";
  cout<<endl;
  return 0;
}

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

int main() {
	int N;
  	cin >> N;
  	string S;
  
  	for(int n_loop = 0; n_loop<N; n_loop++){
  	
     cin >> S;
      
     if(S=="Y"){
		cout << "Four" << endl;
       	return 0;
     } 
    }
  	cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main()
{
	for(std::size_t N, Q;;){
		std::cin >> N>> Q;
		if(N == 0 and Q == 0){break;}
		std::map<std::string, std::pair<std::size_t,std::size_t>> mp;
		for(std::size_t i = 0,g,w; i < N; i++){
			std::string s;
			std::cin >> s >> w >>g, mp[s] = {g-w, g};
		}
		for(std::size_t q = 0,y; q < Q; q++){
			std::cin >> y;
			std::string ans = "Unknown";
			for(const auto p:mp){
				const std::size_t d = p.second.first, l = p.second.second;
				if(y > d and y <= l){
					ans = p.first + " " + std::to_string(y-d);
					break;
				}
			}
			std::cout << ans << std::endl;
		}
	}	
}


Measured memory_bytes: 3376
#include <stdio.h>

int main() {
  int i, n; //n <= 999
  scanf("%d", &n);

  n %= 10;
  
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    printf("hon");
  else if (n == 0 || n == 1 || n == 6 || n == 8)
    printf("pon");
  else
    printf("bon");
  
  return(0);
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

template<class T>T gcd(T a, T b){if(a<b){a^=b;b^=a;a^=b;}return b?gcd(b,a%b):a;}
template<class T>T lcm(T a, T b){return a*b/gcd(a,b);}

int N;
int A[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];

    int ans=0;
    rep(i,N){
        ans=gcd(ans,A[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#define rep(i,l,r) for(i=l;i<r;i++)
#define repb(i,r,l) for(i=r;i>l;i--)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
const int mod=998244353;
using namespace std;
ll gcdl(ll a ,ll b){ 
    if (a == 0) 
        return b;  
    return gcdl(b % a, a);  
 }
 vector<ll> prime;
ll phi(ll n) 
{ 
    ll result = n; // Initialize result as n 
  
    // Consider all prime factors of n and subtract their 
    // multiples from result 
    for (auto p:prime) { 
        if(p*p>n){
            break;
        }
        // Check if p is a prime factor. 
        if (n % p == 0) { 
              
            // If yes, then update n and result 
            while (n % p == 0) 
                n /= p; 
            result -= result / p; 
        } 
    } 
  
    // If n has a prime factor greater than sqrt(n) 
    // (There can be at-most one such prime factor) 
    if (n > 1) 
        result -= result / n; 
    return result; 
} 
ll power(ll x, ll y) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % mod;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % mod; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll n) 
{ 
    return power(n, mod-2); 
} 
int main(){
    int n;
    cin>>n;
    ll x[n];
    int i;
    ll s=0;
    rep(i,0,n){
        cin>>x[i];
        s+=x[i];
    }
    s=s/n;
    ll ans=0,ans2=0;
    rep(i,0,n){
        ans+=(x[i]-s)*(x[i]-s);
        ans2+=(x[i]-s-1)*(x[i]-s-1);
    }
    if(ans<ans2){
        cout<<ans;
    }
    else{
        cout<<ans2;
    }
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	long long N,ans=1e15; cin >> N;
	vector<long long> a(110,0);
	for (int i = 0; i < N; i++) {
		int b; cin >> b;
		a[b]++;
	}

	for (int i = 1; i <= 100; i++) {
		long long c = 0;
		for (int j = 1; j <= 100; j++) {
			c += a[j]*pow(j - i, 2);
		}
		ans = min(ans, c);
	}
	cout << ans << endl;
}





Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int i = a + b ;

		if ( i <= 23 ) {

			System.out.println( i );

		} else {

			System.out.println( i - 24);

		}
	}
}


Measured memory_bytes: 22100
from operator import itemgetter

n = int(input())
s = []; p = []; c = []
for i in range(n):
    s0, p0 = input().split()
    c.append(i); s.append(s0); p.append(int(p0))

ans = list(zip(s, p, c))
ans.sort(key=itemgetter(1), reverse=True)
ans.sort(key=itemgetter(0))

# print(ans)
for i in range(n):
    print(ans[i][2]+1)

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

int main(){
	int a,b; cin>>a>>b;
	string c;
	int ans=0;
	for(int i=a;i<=b;i++){
		c=to_string(i);
		int l=0,r=c.length()-1;
		bool check=true;
		while(l<r){
			if(!(c[l]==c[r])){
				check=false;
				break;
			}
			l++;
			r--;
		}
		if(check) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	string s;
	cin >> s;
	long long k;
	cin >> k;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'a'&&'z' - s[i] + 1 <= k) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
		if (i == s.size() - 1) {
			s[i] += k % 26;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 512
s = input()
n = len(s)
l = [0]*n
t=0
for i in range(n-1):
    if s[i]=='L':
        continue
    elif s[i]=='R' and s[i+1]=='R':
        t +=1
    else:
        t+=1
        l[i]+=t-t//2
        l[i+1]+=t//2
        t = 0
t=0
for j in range(n-1):
    i = n-1-j
    if s[i]=='R':
        continue
    elif s[i]=='L' and s[i-1]=='L':
        t+=1
    else:
        t+=1
        l[i]+=t-t//2
        l[i-1]+=t//2
        t=0
for i in range(n):
    print(l[i],end='')
    if i != n-1:
        print(' ',end='')
print()

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

typedef long long ll;
typedef vector<string> vs;

const int MOD = 1e9+7;

ll dp[1005][1005];

int main() {
	int H,W;
	cin>>H>>W;
	vs A(H);
	rep(i,H)cin>>A[i];
	dp[0][0] = 1;
	rep(i,H)rep(j,W){
		dp[i][j] %=MOD;
		if(A[i][j] == '.'){
			dp[i+1][j] += dp[i][j];
			dp[i][j+1] += dp[i][j];
		}
	}
	cout<<dp[H-1][W-1]<<endl;
}

Measured memory_bytes: 9216
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // in
            int x = Integer.parseInt(sc.next());
            int y = Integer.parseInt(sc.next());

            String ans = "";
            if (y % 2 != 0) {
                ans = "No";
            } else {
                if ((y / 2) >= x && x >= ((y / 4)+(y % 4 / 2)) ) {
                    ans = "Yes";
                } else {
                    ans = "No";
                }
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 35416
#include <iostream>
#include <cmath>

using namespace std;

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

  long long A,B; 
  A = a/x;
  B = b/x;
//   cout << "a: " << a << endl;
//   cout << "b: " << b << endl;
//   cout << "A: " << A << endl;
//   cout << "B: " << B << endl;
//   cout << "B-A: " << B-A << endl;

  if(a%x == 0) cout << B-A+1 << "\n";
  else cout << B-A << "\n";
  //  cout << LLONG_MAX << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

char N[100000];
int A[100000];
int B[100000];

int partition(int p, int r){
    int x = A[B[r-1]];
    int i = p;
    for(int j = p; j < r - 1; j++){
        if(A[B[j]] <= x){
            int temp = B[i];
            B[i] = B[j];
            B[j] = temp;
            i++;
        }
    }
    int temp = B[i];
    B[i] = B[r-1];
    B[r-1] = temp;
    return i;
}

void quicksort(int p, int r){
    if(r - p >= 2){
        int q = partition(p, r);
        quicksort(p, q);
        quicksort(q+1, r);
    }
}

int main(void){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        getchar();
        scanf("%c", &N[i]);
        scanf("%d", &A[i]);
        B[i] = i;
    }
    quicksort(0, n);
    int m = A[B[0]];
    int stable = 1;
    for(int i=1; i<n; i++){
        if(A[B[i-1]] == A[B[i]] && B[i-1] > B[i])
            stable = 0;
    }
    puts(stable ? "Stable" : "Not stable");
    for(int i=0; i<n; i++)
        printf("%c %d\n", N[B[i]], A[B[i]]);
}



Measured memory_bytes: 2576
#include <iostream>
using namespace std;
int main(){
    int n,y;
    cin >> n >> y;
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= n-i; j++)
        {
            int k = n-i-j;
            if (10000*i+5000*j+1000*k == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 998244353;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
constexpr int ms = 3013;
long long dp[ms][ms];
int main() 
{
    buff();
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    dp[a][b] = 1; 
    for(long long i = 1; i <= c; ++i)
    {
        for(long long j = 1; j <= d; ++j)
        {
            if(i <= a && j <= b) continue;
            long long on = (dp[i][j - 1] + dp[i - 1][j]) % MOD;
            long long off_row = (dp[i - 1][j] * (j - 1)) % MOD;
            long long off_col = (dp[i][j - 1] * (i - 1)) % MOD;
            long long off_int = (dp[i - 1][j - 1] * (j - 1) * (i - 1) ) % MOD;

            dp[i][j] = (on + off_row + off_col) % MOD;
            dp[i][j] = (dp[i][j] + MOD - off_int) % MOD;
        }
    }

    cout << dp[c][d] << '\n';
    return 0;
}



Measured memory_bytes: 74236
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define MAX 1000
typedef pair<int, int> P;
int h, w;
char a[MAX][MAX];
int d[MAX][MAX];
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
queue<P> que;

void bfs() {
    while (que.size()) {
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if (0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.' && d[ny][nx] == INT_MAX) {
                d[ny][nx] = d[p.first][p.second] + 1;
                que.emplace(P(ny, nx));
            }
        }
    }
    return;
}


int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
            if (a[i][j] == '#') {
                d[i][j] = 0;
                que.emplace(P(i, j));
            }
            else {
                d[i][j] = INT_MAX;
            }
        }
    }
    bfs();
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            chmax(ans, d[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 16372
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;
int main()
{
	int64 aa, bb;
	cin >> aa >> bb;
	aa = max(aa + bb, max(aa - bb, aa * bb));
	cout << aa << endl;
	return 0;
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.EducationalDP
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            int n = nk[0];
            int k = nk[1];
            int[] hs = ReadInts();
            long[] dp = new long[n];
            dp[0] = 0;
            for (int i = 1; i < n; i++)
            {
                long val = long.MaxValue;
                for(int j = Math.Max(i - k, 0); j < i; j++)
                {
                    val = Math.Min(val, dp[j] + Math.Abs(hs[i] - hs[j]));
                }
                dp[i] = val;
            }
            Console.WriteLine(dp[n - 1]);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 19680
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			String str=scan.next();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		}
		scan.close();
}
}


Measured memory_bytes: 26396
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	flags := make(map[int]bool)
	ans := false
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		if exist := flags[a]; exist {
			ans = true
		}
		flags[a] = true
	}

	if ans {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Measured memory_bytes: 10500
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack> 
#include <set>
#include <map>
using namespace std;
#define rg register
#define LL long long
#define __endl putchar('\n')
#define __space putchar(' ')
template <typename qwq> inline void read(qwq & x)
{
	x = 0;
	rg int f = 1;
	rg char c = getchar();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9')
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= f;
}
template <typename qaq> inline void print(qaq x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}
int cnt = 1, ans, flag;
char last;
int tmp[233333];
char s[233333];
int main()
{
//	freopen("data.in", "r", stdin); 
	scanf("%s", s + 1);
	rg int len = strlen(s + 1);
	rg int tmplen = 1;
	for (rg int i = 1; i <= len; ++i)
	{
		if (s[i] == s[i + 1])
		{
			if (tmplen == 1)
			{
				if (i == len - 1)
				{
					++ans;
					break;
				}
				++ans;
				++tmplen;
			}
			else
			{
				++i, ++ans;
				tmplen = 1;
			}
		}
		else
		{
			if (tmplen == 1) ++ans;
			else ++ans, tmplen = 1, ++i;
		}
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
        Set<Integer> treeSet = new TreeSet<Integer>();
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for (int i = 0; i < k; i++){
            int d = scanner.nextInt();
            for (int j = 0; j < d; j++){
                treeSet.add(scanner.nextInt());
            }
        }
        int count = 0;
        for (int i = 1; i < n + 1; i++) {
            if (!treeSet.contains(i)) {
                count++;
            }
        }
        printWriter.println(count);
        printWriter.flush();
    }
}


Measured memory_bytes: 46444
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

struct Entry {
	size_t index;
	int value;
	size_t order;
}

void main() {
	immutable n = readNum();
	immutable mid = n / 2 - 1;
	auto nums = readNums.enumerate.map!(e => Entry(e.index, e.value)).array;
	nums.sort!"b.value < a.value"();
	foreach(i, ref e; nums) {
		e.order = i;
	}
	immutable sorted = nums.idup;
	nums.sort!"a.index < b.index"();
	
	foreach(e; nums) {
		writefln("%d", sorted[e.order <= mid ? mid + 1 : mid].value);
	}
}


Measured memory_bytes: 21344
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    v_int a(n),b(n),c(n-1);
    cin >> a >> b >> c;

    int sum = 0;
    rep(i,n) {
        sum += b[a[i]-1];
    }
    rep(i,n-1) {
        if(a[i]+1 == a[i+1]) {
            sum += c[a[i]-1];
        }
    }
    cout << sum << endl;
    return 0;
} /*atcoder*/



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

int main(){
  int n,a,b;
  cin >> n;
  pair<int, int>w[n];
  for(int i=0;i<n;i++){
  	cin >> a >> b;
    w[i] =make_pair(b, a);
  }
  sort(w, w+n);
  
  int sum=0;
  bool flag=true;
  for(int i=0;i<n;i++){
    sum+=w[i].second;
  	if(sum>w[i].first) flag=false;
  }
  
  if(flag) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

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

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

void solve(long long N, long long i) {
  cout << N - i + 1 << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long i;
  scanf("%lld", &i);
  solve(N, i);
  return 0;
}


Measured memory_bytes: 256