akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) {}
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
/***********************************************************************/

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int n;
  cin >> n;
  vector<int> a(n), pre(n), suf(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    pre[i] = suf[i] = a[i];
    if (i > 0) uax(pre[i], pre[i - 1]);
  }
  for (int i = n - 2; i >= 0; --i) {
    uax(suf[i], suf[i + 1]);
  }
  for (int i = 0; i < n; ++i) {
    int ans = 0;
    if (i > 0) uax(ans, pre[i - 1]);
    if (i + 1 < n) uax(ans, suf[i + 1]);
    cout << ans << '\n';
  }
    
  return 0;
}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

int mymod(int num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;


int main ()
{
  prep();
  int n, m, l;
  cin >> n >> m >> l;
  vector<pair<int, int> > graph[n+1];
  int dists[301][301];
  int mingas[301][301];
  for (int i=1; i<=n; i++){
      for (int j=1; j<=n; j++){
          dists[i][j] = 1000000000LL;
          mingas[i][j] = 0;
      }
  }
  for (int i=0; i<m; i++){
      int a, b, c;
      cin >> a >> b >> c;
      if (c > l){
          continue;
      }
    
      graph[a].push_back({c, b});
      graph[b].push_back({c, a});
  }
  for (int i=1; i<=n; i++){
      queue<pair<int, pair<int, int> > > pq;
      pq.emplace(0, make_pair(l, i));
      
      while (!pq.empty()){
          pair<int, pair<int, int> > front = pq.front();
          pq.pop();
          int node = front.second.second;
          int gas = front.second.first;
          int many = front.first;
          
          for (int j=0; j<graph[node].size(); j++){
              int need = graph[node][j].first;
              int cur = graph[node][j].second;
              int fills = many;
              int put = gas;
              if (need > gas){
                  fills++;
                  put = l-need;
              }else{
                  put -= need;
              }
              if (fills == dists[i][cur]){
                  if (put > mingas[i][cur]){
                      mingas[i][cur] = put;
                  }else{
                      continue;
                  }
              }else if (fills < dists[i][cur]){
                  dists[i][cur] = fills;
                  mingas[i][cur] = put;
              }else{
                  continue;
              }
              pq.emplace(fills, make_pair(put, cur));
              
          }
      }
  }
  int q;
  cin >> q;
  for (int i=0; i<q; i++){
      int a, b;
      cin >> a >> b;
      if (dists[a][b] == 1000000000LL){
          cout << -1 << '\n';
      }else{
          cout << dists[a][b] << '\n';
      }
      
  }
  
  return 0; 
}


Measured memory_bytes: 2432
void main()
{
    long n, k;
    rdVals(n, k);

    foreach (i; 1 .. 100)
    {
        if (k ^^ (i - 1) <= n && n < k ^^ i)
        {
            i.writeln;
            return;
        }
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

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

const int N = 1e5 + 1;

int n, m;
int dp[N];
std::vector<int> g[N];

int DFS(int u) {
    if (dp[u]) return dp[u];

    for (int v : g[u]) {
        dp[u] = std::max(dp[u], DFS(v));
    }

    return ++dp[u];
}

signed main() {
    std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);

    std::cin >> n >> m;

    while (m--) {
        int u, v;
        std::cin >> u >> v;
        g[u].push_back(v);
    }

    int ans = 0;

    for (int i = 1; i <= n; i++) {
        ans = std::max(ans, DFS(i));
    }

    std::cout << ans - 1;

    return 0;
}



Measured memory_bytes: 11428
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
f = 0
for i in sorted(list(range(n)),reverse=True):
	k = n//(i+1)
	if a[i] == 1:
		if k == 1:
			b[i] = 1
		else:
			c = 0
			for j in range(0,k):
				c+=b[i+(j*(i+1))]
			if c % 2 == 0:
				b[i] = 1
	else:
		if k != 1:
			c = 0
			for j in range(0,k):
				c+=b[i+(j*(i+1))]
			if c % 2 == 1:
				b[i] = 1
print(sum(b))
result=[]
for i in range(len(b)):
	if b[i] == 1:
		result.append(i+1)
if len(result) > 0:
	print(*result)

Measured memory_bytes: 16228
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const int maxn = 200200;
int a[maxn], d[maxn];
int main(void) {
//    freopen("d.in","w",stdout);
//    printf("200000\n");
//    for (int i=0;i<200000;i++) printf("0 "); puts("");
    //freopen("d.in","r",stdin);
    int n; scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    int tot=0;
    for (int i=1;i<=n;i++)
        if (a[i]||i==1||a[tot]) a[++tot]=a[i],d[tot]=1;
        else d[tot]++;
    LL ans=0;
    for (int i=1;i<=tot;i++) {
        ans += d[i]*(LL)(d[i]+1)/2;
        int s=a[i];
        for (int j=i+1;j<=tot;j++) {
            if ((s&a[j])==0) ans += (LL)d[j]*d[i], s|=a[j];
            else break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
    
    long x, y, a;
    long rest;
    
    cin >> x >> y;
    
    if ( x < y ){
        a = x;
        x = y;
        y = a;
    } 
    while ( x % y != 0){
        rest = x % y;
        x = y;
        y = rest;
    }
    cout << y << endl;
}


Measured memory_bytes: 3092
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int[] a = new int[n];
		int min = 101;
		int max = -101;
		for (int i=0; i<n; i++) {
			a[i] = in.nextInt();
			min = Math.min(min, a[i]);
			max = Math.max(max, a[i]);
		}

		int ans = Integer.MAX_VALUE/2;
		for (int i=min; i<=max; i++) {
			int tmp = 0;
			for (int j=0; j<n; j++) {
				tmp += (a[j] - i)*(a[j] - i);
			}
			ans = Math.min(ans, tmp);
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 10068
#include <stdio.h>
#include <map>

int main()
{
    int n;
    std::map<int, int> m;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        m[x]++;
    }
    int ans = 0;
    for(auto dat : m)
    {
        if(dat.second % 2 == 1) ans++;
    }
    printf("%d", ans);
}

Measured memory_bytes: 4992
H, W = map(int, input().split())

white = [0]*W
board = []
for _ in [0]*H:
    line = input().rstrip()
    for i in range(W):
        if line[i] == '.': white[i] += 1
    if '#' in line:
        board.append(list(line))

for line in board:
    for i in range(W):
        if white[i] == H: continue
        else: print(line[i], end='')
    print()

Measured memory_bytes: 4596
import math
from decimal import Decimal
a,b,c=map(int,input().split())


a,b,c=Decimal(a).sqrt(),Decimal(b).sqrt(),Decimal(c).sqrt()
#a,b,c=math.sqrt(a),math.sqrt(b),math.sqrt(c)
#a,b,c=Decimal(a),Decimal(b),Decimal(c)
if a+b<c:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1) 
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
#define MOD 1e9+7
#define inf 1e9+9
#define int long long
#define ld long double
#define fast  ios_base::sync_with_stdio(false);  cin.tie(NULL);
typedef vector<int> vi;
typedef pair<int,int> pii; 


void solve(){
	int n, w; cin>>n>>w;
	int wt[n+1], value[n+1];
	int total_value=0;
	for(int i=0;i<n;i++){
		cin>>wt[i]>>value[i];
		total_value+=value[i];
	}
	int dp[n+1][total_value+1];
	dp[0][0]=0;
	for(int i=1;i<=total_value;i++)dp[0][i]=inf;
	for(int i=1;i<=n;i++){
		for(int j=total_value;j>=0;j--){
			if(j>=value[i-1])
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-value[i-1]] + wt[i-1]);
			else
				dp[i][j]=dp[i-1][j];
		}
	}
 
	 
	for(int i=total_value;i>=0;i--){
		if(dp[n][i]<=w){
			cout << i <<endl;
			break;	
		}
	}
}


int32_t main(){
	fast
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 82492
import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
test=[]
for i in itertools.permutations(range(1,N+1)):
    test.append(''.join(list(map(str,i))))
print(abs(test.index(''.join(list(map(str,P))))-test.index(''.join(list(map(str,Q))))))


Measured memory_bytes: 11996
#include<bits/stdc++.h>
using namespace std;
int hs[100][100];
int main(){
  int n;
  double r;
  while(cin>>r>>n,r+n){
    memset(hs,0,sizeof(hs));
    for(int i=0;i<n;i++){
      int x1,x2,h;
      cin>>x1>>x2>>h;
      x1+=20;
      x2+=20;
      for(int i=x1;i<x2;i++){
	for(int j=0;j<=h;j++)
	  hs[i][j]=1;
      }
    }
    auto check = [&](double t){
      for(int i=0;i<r;i++){
	double x=i;
	int y=sqrt(r*r-x*x)+t+1-r;
	//cout<<i<<" "<<t<<" "<<y<<endl;
	if(y<=0)continue;
	if(!hs[i+20][y])return false;
	if(!hs[-i+20-1][y])return false;
     
      }
      return true;
    };
    double ub=100,lb=0,mid;
    for(int i=0;i<200;i++){
      mid=(ub+lb)/2;
      if(check(mid))lb=mid;
      else ub=mid;
    }
    cout<<fixed<<setprecision(12)<<lb<<endl;
  }
  return 0;
}



Measured memory_bytes: 3264
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		sc.close();

		if (n == 1 && m == 1) {
			System.out.println(1);
		} else if (n == 1) {
			System.out.println(m - 2);
		} else if (m == 1) {
			System.out.println(n - 2);
		} else {
			System.out.println((n - 2) * (m - 2));
		}
	}
}


Measured memory_bytes: 23252
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'

ll n, x[202020], v[202020], c, mx[202020], ans, rev[202020], val[101010], rval[101010];


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n >> c;

rep(i, 1, n){

    cin >> x[i] >> v[i];

}


rep(i, 1, n){

    mx[i] = val[i-1]+v[i] - x[i];
    val[i]=val[i-1]+v[i];

}


rep(i,1, n){

    mx[i] = max(mx[i-1], mx[i]);
    ans = max(ans, mx[i]);

}



rep1(i, n, 1){

    rval[i]+=rval[i+1]+v[i];
    ll temp = -2*(c-x[i]) + rval[i];
    ans = max(ans, temp + mx[i-1] );
    //cout << temp + mx[i-1] << endl;

}

rep1(i, n, 1){
    mx[i]=0;
    val[i]=0;
    mx[i] = val[i+1]+v[i] - (c-x[i]) ;
    val[i] = val[i+1]+v[i];
    //cout << mx[i] << " " << val[i] << endl;
}

rep1(i, n, 1){

    mx[i] = max(mx[i+1], mx[i]  );
    ans = max(ans, mx[i]);

}

rep(i, 0, n){

    rval[i]=0;
    rval[i]=rval[i-1]+v[i];
    ll temp = rval[i] - 2*x[i];
    ans = max(ans , temp+mx[i+1]);
    //cout << temp + mx[i] << endl;
}

cout << ans << endl;

return 0;}
///....


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

vector<long long> g[200005];
vector<long long> x;

void dfs(int v, int p = -1)
{
  for (int u: g[v]) {
    if (u == p) {
      continue;
    }
    x[u] += x[v];
    dfs(u, v);
  }
}


int main () {
  long long  n, q;
  cin >> n >> q;

  for (int i = 1; i < n; i++)
  {
    long long from, to;
    cin >> from >> to;
    from--;
    to--;
    g[from].push_back(to);
    g[to].push_back(from);
  }

  x.resize(n);
  for (int i = 1; i <= q; i++)
  {
    long long from, value;
    cin >> from >> value;
    from--;
    x[from] += value;
  }

  dfs(0, -1);
  
  for (int i = 0; i < n; i++) {
    cout << x[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 24320
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    if( ( a * b ) % 2 ) cout << "Yes";
    else cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    final double EPS = 1.0e-10;
    final int INF = 1 << 28;
    int k;
    double p;
    double e;
    double t;

    void run() {
        Scanner sc = new Scanner(System.in);
        k = sc.nextInt();
        double l = sc.nextInt();
        double r = sc.nextInt();
        p = sc.nextDouble();
        e = sc.nextDouble();
        t = sc.nextDouble();
        System.out.printf("%.10f\n", solve(0, l, r));
    }

    double solve(int n, double l, double r) {
        double h = (l + r) / 2;
        if (n == k) {
            if (Math.abs(t - h) <= e) {
                return 1;
            } else {
                return 0;
            }
        }
        if (r < t - e || t + e < l)
            return 0;
        else if (t - e <= l && r <= t + e)
            return 1;

        if (h > t) {
            return (1 - p) * solve(n + 1, l, h) + p * solve(n + 1, h, r);
        } else {
            return p * solve(n + 1, l, h) + (1 - p) * solve(n + 1, h, r);
        }
    }

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

Measured memory_bytes: 12000
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
	int n[5];
	for (int i = 0; i != 5; ++i) {
		scanf("%d", &n[i]);
	}
	sort(n, n+5);
	printf("%d %d %d %d %d\n", n[4], n[3], n[2], n[1], n[0]);
	return 0;
}

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

int main() {
  int n, m, t;
  cin >> n >> m >> t;
  int a[n];
  bool shosai[t];
  for (int i = 0; i < t; i++)
    shosai[i] = true;

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

  for (int i = 0; i < n; i++) {
    for (int j = a[i] - m; j < a[i] + m && j < t; j++) {
      shosai[j] = false;
    }
  }

  int count = 0;
  for (int i = 0; i < t; i++)
    if (shosai[i]) count++;

  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3104
// #include <iostream>
// #include <string>
// #include <math.h>
// #include <map>
// #include <vector>
// #include <tuple>
// #include <algorithm>
// #include <queue>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;
int main(){
  string s;
  cin >> s;
  bool flag = true;
  F(i, s.length()){
    if(i%2 == 1 && (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')){
      flag = true;
    }
    else if(i%2 == 0 && (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
      flag = true;
    }
    else{
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

const char of[] = "RGB";

int N, H[20], W[20];
char f[4][4];
int Qi, Qn, Q[65536], dp[65536];
int m, mask[1000], chg[256][4];

int main() {
    scanf("%d", &N);
    rep(i, N) scanf("%d%d", H+i, W+i);
    rep(i, 4) rep(j, 4) scanf(" %c", f[i]+j);
    rep(k, N) for(int i=-3; i<4; i++) for(int j=-3; j<4; j++) {
        int b = 0;
        const int xmx = min(i+H[k], 4), ymx=min(j+W[k], 4);
        for(int x=max(i, 0); x<xmx; x++) {
            for(int y=max(j, 0); y<ymx; y++) {
                b |= 1<<(x*4+y);
            }
        }
        mask[m++] = b;
    }
    sort(mask, mask+m);
    m = unique(mask, mask+m)-mask;
    rep(i, m) rep(x, 4) rep(y, 4) if(mask[i]&(1<<(x*4+y))) {
        rep(k, 3) if(f[x][y]==of[k]) chg[i][k] |= 1<<(x*4+y);
    }
    rep(i, m) mask[i] = ~mask[i];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    Q[Qn++] = 0;
    while(Qi<Qn && dp[65535]==-1) {
        const int cur = Q[Qi++];
        rep(i, m) rep(k, 3) {
            const int nxt = (cur&mask[i]) | chg[i][k];
            if(dp[nxt]==-1) {
                dp[nxt] = dp[cur]+1;
                Q[Qn++] = nxt;
            }
        }
    }
    printf("%d\n", dp[65535]);
    return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, m;
llong a[128];
llong sum = 0;

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

    llong d = (sum + 4 * m - 1) / (4 * m);
    llong cnt = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] >= d) cnt++;
    }

    if (cnt >= m) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

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

namespace HelloWorld
{
    internal class Coord
    {
        internal decimal X { get; set; }
        internal decimal Y { get; set; }
    }
    class Program
    {
        static void Main()
        {
            int times = int.Parse(Console.In.ReadLine());
            while (times-->0)
            {
                var frag = Console.In.ReadLine().Split().Select(decimal.Parse).ToArray();
                var A = new Coord { X = frag[0], Y = frag[1] };
                var B = new Coord { X = frag[2], Y = frag[3] };
                var C = new Coord { X = frag[4], Y = frag[5] };
                var D = new Coord { X = frag[6], Y = frag[7] };
                Console.Out.WriteLine((B.Y - A.Y) * (D.X - C.X) == (D.Y - C.Y) * (B.X - A.X) ? "YES" : "NO");
            }
        }
    }
}


Measured memory_bytes: 16232
#!/usr/bin/env python3

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

def tri(m):
    if m==1:
        return 1
    s = 0 
    ans = 0 
    for i in range(1, m): 
        s += i
        if s > m:
             break
        ans += 1
    return ans 

n = int(input())
ans = 0 
fts = factorization(n)
if n == 1:
    print(0)
    exit(0)
for i in fts:
    ans += tri(i[1])
print(ans)


Measured memory_bytes: 9432
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const long double PI=acos(-1.0l);

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

  long double D;
  cin>>D;
  cout<<fixed<<setprecision(10)<<2*D*PI<<endl;

  return 0;
}


Measured memory_bytes: 3824
#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...));
}

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;
}
ll dp[102][100002];

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

    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    REP(i, N) { cin >> w.at(i) >> v.at(i); }

    ll sum_v = 0;
    REP(i, N) { sum_v += v[i]; }
    memset(dp, INF, sizeof(dp));
    REP(i, N) { dp[i][0] = 0; }

    REP(i, N) {
        REP(j, sum_v + 1) {
            if (v[i] + j <= sum_v) {
                chmin(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
            }
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }

    int max_v = 0;
    REP(j, sum_v + 1) {
        if (dp[N][j] <= W) {
            max_v = j;
        }
    }

    cout << max_v << endl;

    return 0;
}


Measured memory_bytes: 80000
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val m = sc.nextLong()
  val a = (1..m).map {
    sc.nextInt()
  }

  println(abc163b(n, m, a))
}

private fun abc163b(n: Long, m: Long, a: List<Int>): Int {
  val sumA = a.sum()
  if (sumA > n) return -1

  return n.toInt() - sumA
}


Measured memory_bytes: 48412
#include<stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include<cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>

using namespace std;
const int mod=1000000007;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long int t,n,m,a,b,c,k,q,d,x,l;
    vector<int> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>k;k--;
    cout<<vec[k];
    
    return 0;
}


Measured memory_bytes: 256
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int A = in.nextInt(), B = in.nextInt();
        String ans;
        A = A == 1 ? 14 : A;
        B = B == 1 ? 14 : B;
        if (A < B) {
            ans = "Bob";
        } else if (A > B) {
            ans = "Alice";
        } else {
            ans = "Draw";
        }
        System.out.println(ans);
    }
}

class Scanner implements Closeable {
    private final InputStream stream;
    private final byte[] buf = new byte[1024];
    private int cur;
    private int num;

    Scanner(InputStream stream) {
        this.stream = stream;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    int nextInt() {
        return (int) nextLong();
    }

    long nextLong() {
        int c = read();
        while (isdel(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long l = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            l *= 10;
            l += c - '0';
            c = read();
        } while (!isdel(c));
        return l * sgn;
    }

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

    String next() {
        int c = read();
        while (isdel(c))
            c = read();
        StringBuilder s = new StringBuilder();
        do {
            s.appendCodePoint(c);
            c = read();
        } while (!isdel(c));
        return s.toString();
    }

    private int read() {
        if (num == -1)
            throw new InputMismatchException();
        if (cur >= num) {
            cur = 0;
            try {
                num = stream.read(buf);
            } catch (Exception e) {
                throw new InputMismatchException();
            }
            if (num <= 0)
                return -1;
        }
        return buf[cur++];
    }

    private boolean isdel(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    @Override
    public void close() {
        try {
            stream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll N,H,W;
  cin >> N >> H >> W;
  ll a,b;
  ll cnt = 0;
  rep(i,N){
    cin >> a >> b;
    if(a >= H && b >= W){
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


long long int h,w;
string str[25];
int main() {
	cout << fixed << setprecision(18);
	cin>>w>>h;
	while(w!=0){
		for(int i=0;i<h;i++){
			cin>>str[i];
		}
		long long int start_h,start_w;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(str[i][j]=='@'){
					start_h=i;
					start_w=j;
				}
			}
		}
		long long int num=1;
		queue<pair<long long int,long long int> >task;
		task.push({start_h,start_w});
		bool used[25][25]={};
		used[start_h][start_w]=true;
		while(!task.empty()){
			long long int hnow=task.front().first;
			long long int wnow=task.front().second;
			if(hnow!=0&&str[hnow-1][wnow]=='.'&&!used[hnow-1][wnow]){
				used[hnow-1][wnow]=true;
				num++;
				task.push({hnow-1,wnow});
			}
			if(hnow!=h-1&&str[hnow+1][wnow]=='.'&&!used[hnow+1][wnow]){
				used[hnow+1][wnow]=true;
				num++;
				task.push({hnow+1,wnow});
			}
			if(wnow!=0&&str[hnow][wnow-1]=='.'&&!used[hnow][wnow-1]){
				used[hnow][wnow-1]=true;
				num++;
				task.push({hnow,wnow-1});
			}
			if(wnow!=w-1&&str[hnow][wnow+1]=='.'&&!used[hnow][wnow+1]){
				used[hnow][wnow+1]=true;
				num++;
				task.push({hnow,wnow+1});
			}
			//cout<<"DEBUG"<<hnow<<" "<<wnow<<endl;
			task.pop();
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				//cout<<used[i][j]<<" ";
			}
			//cout<<endl;
		}
		cout<<num<<endl;
		cin>>w>>h;
	}
} 


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

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

  for (int i = 1; i < 10; i++) {
    if (n % i == 0) {
      ans = n / i;
    }
    if (ans <= 9) {
      break;
    }
  }
  if (ans <= 9) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define All(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n, d);
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) cin >> x[i][j];
  }

  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int distance = 0;
      for (int k = 0; k < d; ++k)
        distance += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      int rt = (int)sqrt(distance);
      if (distance == rt * rt) ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

int main() {
    int n;
    int R[2000000] = {0};
    int Rmin;
    int Vt;
    int ans;

    scanf("%d", &n);
    for ( int i = 0 ; i < n; ++i ) {
        scanf("%d", R + i);
    }

    Rmin = R[0];
    ans = R[1] - R[0];

    for ( int i = 1; i < n; ++i ) {
        if ( Rmin > R[i] ) {
            Rmin = R[i];
        }
        else {
            Vt = R[i] - Rmin;
            if ( Vt > ans ) {
                ans = Vt;
            }
        }
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 9668
from collections import Counter

s=Counter(input())
b,m=max(s.values()),min(s.values())
kind = len(s.keys())
if kind==3:
    if b-m<=1: print("YES")
    else: print("NO")
elif kind==2:
    if b==1 and m==1: print("YES")
    else: print("NO")
else:
    if b==1: print("YES")
    else: print("NO")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    char a[15],b[15],c[15];
    scanf("%s%s%s",&a,&b,&c);
    printf("%c%c%c\n",a[0]-32,b[0]-32,c[0]-32);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
R_dot, B_dot = [],[]
for _ in range(N):
    R_dot.append(list(map(int,input().split())) + [0])
for _ in range(N):
    B_dot.append(list(map(int,input().split())))

R_dot = sorted(R_dot, key = lambda x: x[1], reverse = True)
B_dot = sorted(B_dot, key = lambda x: x[0])

ans = 0
for i in range(N):
    for j in range(N):
        if R_dot[j][0] < B_dot[i][0] and R_dot[j][1] < B_dot[i][1] and R_dot[j][2] == 0:
            ans += 1
            R_dot[j][2] = 1
            break
            
print(ans)

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

int main()
{
    //ドーナツ種類
    int N;
    cin >> N;
    //お菓子の材料
    int X;
    cin >> X;
    
    int sumDonatu = 0;
    int minM = 1 << 30;
    //ドーナツの材料指定
    int m[N];
    for (int i = 1; i <= sizeof(m)/sizeof(*m); i++){
        cin >> m[i];
        X -= m[i];
        sumDonatu++;
        //最小の材料を求める
        if (m[i] <= minM) {
            minM = m[i];
        }
    }
    
    while (minM <= X){
        X -= minM;
        sumDonatu++;
    }
    
    cout << sumDonatu << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h> 
using namespace std;
int b;
int main()
{
    string a;
    cin>>a;
    int l=a.size();
    for(int i=0;i<l;i++)        
    {
        if(a[i]=='S')           
        {
            b=0;                
            for(int i=0;i<l;i++){if(a[i]=='N'){b=1;break;}}
            if(b==0){cout<<"No"<<'\n';return 0;}
        }
        if(a[i]=='N')                  
        {
            b=0;
            for(int i=0;i<l;i++){if(a[i]=='S'){b=1;break;}}
            if(b==0){cout<<"No"<<'\n';return 0;}
        }
        if(a[i]=='E')          
        {
            b=0;
            for(int i=0;i<l;i++){if(a[i]=='W'){b=1;break;}}
            if(b==0){cout<<"No"<<'\n';return 0;}
        }
        if(a[i]=='W')           
        {
            b=0;
            for(int i=0;i<l;i++){if(a[i]=='E'){b=1;break;}}
            if(b==0){cout<<"No"<<'\n';return 0;}
        }
    }
    cout<<"Yes"<<'\n';
    return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using pint = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pint> p(m);
  rep(i, m) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());

  int ans = 1;
  int t = p[0].first;
  rep(i, m) {
    if (t <= p[i].second) {
      ans++;
      t = p[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX (ll)(1e3 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;
ll mult (ll a, ll b) {
	a = (a + MOD) % MOD;
	b = (b + MOD) % MOD;
	return (a * 1LL * b) % MOD;
}

ll pw (ll a, ll b) {
	ll r = 1;
	while (b) {
		if (b & 1) {
			r = mult (r, a);
		}
		b >>= 1;
		a = mult (a, a);
	}
	return r;
}

int main () {
	ll n, k;
	cin >> n >> k;
	ll ar[n], cc = 0;
	for (ll i = 0; i < n; i++) {
		cin >> ar[i];
		cc += ar[i] < 0;
	}
	sort (ar, ar + n);
	reverse (ar, ar + cc);
	bool fl = 1;
	if (n == k && (cc & 1)) {
		fl = 0;
	}
	if ((cc == n) && (k & 1)) {
		fl = 0;
	}
	if (!fl) {
		ll pr = 1;		
		for (ll i = 0; i < k; i++) {
			pr = mult (pr, ar[i]);
		}
		cout << pr << "\n";
	}
	else {
		ll pr = 1;
		ll pn =  cc - 1, pp = n - 1, co = 0;
		for (ll i = 0; i < k; i++) {
			if (pn >= 0  && (pp < cc || abs (ar[pp]) < abs (ar[pn]))) {
				pr = mult (pr, ar[pn]);
				pn--;
				co++;
			}
			else {
				pr = mult (pr, ar[pp]);
				pp--;
			}
		}
		if (co % 2 == 1) {
			if (co > 1 && pn >= 0 && pp < n - 1 && pp >= cc) {
				ll x = abs (ar[pn]), xx = abs (ar[pn + 1]), y = ar[pp], yy = ar[pp + 1];
				if (y * yy > x * xx) {
					pr = mult (pr, mult (pw (-xx, MOD - 2), y));
				}
				else {
					pr = mult (pr, mult (pw (yy, MOD - 2), -x));
				}
			}
			else if (co > 1 && pp >= cc) {
				ll xx = ar[pn + 1], y = ar[pp];
				pr = mult (pr, mult (pw (xx, MOD - 2), y));
			}
			else {
				ll yy = ar[pp + 1], x = ar[pn];
				pr = mult (pr, mult (pw (yy, MOD - 2), x));
			}
		}
		cout << pr << "\n";
	}
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a<b&&b<c) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if ( A + B > C + D ) {
        cout << "Left " << endl;
    } else if ( A + B < C + D ) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long H;
	cin >> H;
	long long sum = 0;
	for(long long i = 1; H; i <<= 1){
		sum += i;
		H >>= 1;
	}
	cout << sum << endl;

	return 0;
}

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

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

    int n, k; cin >> n >> k;
    int h[n+1];
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    int c[n+1];
    fill_n(c, n+1, INT_MAX);
    c[1] = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = i - k; j < i; j++) {
            if (j >= 1) {
                c[i] = min(c[i], c[j] + abs(h[j] - h[i]));
            }
        }
        
    }
    cout << c[n];

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int l,r;
int main(){
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
		if(a[i]=='A'){
			l=i;
			break;
	}
	for(int i=a.size()-1;i>=0;i--)
		if(a[i]=='Z'){
			r=i;
			break;
	}
	cout<<r-l+1<<endl;
	return 0;
}

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

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

  int ans = 0;
  for (int i=0; i<n; i++) {
    if (h[i] >= k) {
      ++ans;
    }
  }
  cout<<ans<<endl;


}

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

int main() {
	string s; cin >> s;
	bool a = false, b = false;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A')a = true;
		if (s[i] == 'B')b = true;
	}
	cout << (a & b ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            long A = in.nextLong();
            long B = in.nextLong();
            int[] pos = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt() - 1;
                pos[a[i]] = i;
            }

            long[][] dp = new long[n + 1][n + 1];
            for (long[] z : dp) {
                Arrays.fill(z, Long.MAX_VALUE / 2);
            }
            dp[0][0] = 0;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    if (i < n && a[i] == j) {
                        dp[i + 1][j + 1] = Math.min(dp[i + 1][j + 1], dp[i][j]);
                    }
                    if (i < n && a[i] > j) {
                        dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j] + A);
                    }
                    if (i < n && a[i] < j) {
                        dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
                    }
                    if (j < n && pos[j] < i) {
                        dp[i][j + 1] = Math.min(dp[i][j + 1], dp[i][j]);
                    }
                    if (j < n && pos[j] > i) {
                        dp[i][j + 1] = Math.min(dp[i][j + 1], dp[i][j] + B);
                    }
                }
            }

//        System.out.println(Arrays.deepToString(dp));
            out.println(dp[n][n]);
        }

    }
}



Measured memory_bytes: 249356
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	string s;
 	cin>>s;
 	ll cnt=0;
 	map<char,ll>mp;
 	mp['R']=0;
 	mp['G']=1;
 	mp['B']=2;
 	ll p[n+1][3]={0};
 	for(ll i=1;i<=n;i++)
 	{
 		for(ll j=0;j<3;j++)
 		{
 			p[i][j]=p[i-1][j];
 		}
 		p[i][mp[s[i-1]]]++;
 	}
 	for(ll i=0;i<n-2;i++)
 	{
 		for(ll j=i+1;j<n-1;j++)
 		{
 			if(s[i]==s[j])
 				continue;
 			set<char>st;
 			st.insert('R');
 			st.insert('G');
 			st.insert('B');
 			st.erase(s[i]);
 			st.erase(s[j]);
 			char c = *st.begin();
 			cnt+=p[n][mp[c]] - p[j+1][mp[c]];
 			ll d = j-i;
 			if(j+d<n && s[j+d]==c)
 				--cnt;
 		}
 	}	
 	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3736
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int OO = 2e9;

int n,a[N],b[N],c[N];
ll ans;

void init() {



}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    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) {

        cin >> c[i];

    }

    sort(a,a+n);
    sort(c,c+n);

    for(int i=0;i<n;++i) {

        int ca = lower_bound(a,a+n,b[i])-a;
        int cb = n-(upper_bound(c,c+n,b[i])-c);
        ans += 1LL*ca*cb;

    }

    cout << ans << '\n';

    return 0;

}

Measured memory_bytes: 1408
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
lists=[]
lists.append(a)
lists.append(b)
lists.append(c)
lists.append(d)
lists.append(e)
lists.sort()
s=lists[0]
#5分後以降、6にs人送る
import math
k=math.floor((n-1)/s)
print(5+k)

Measured memory_bytes: 3064
import java.util.Scanner;

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

        int H;
        int W;

        while(true) {
            H = sc.nextInt();
            W = sc.nextInt();
            if(H == 0&&W == 0) {
                break;
            }
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 33048