akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String args[]) {
    	Scanner in = new Scanner(System.in);
    	int n = in.nextInt(), w = in.nextInt();
        
        int[] val = new int[n];
        int[] wt = new int[n];
        for(int i = 0; i < n; i++)
        {
        	wt[i] = in.nextInt();
        	val[i] = in.nextInt();
        }

        // Populate base cases
        long[][] mat = new long[n + 1][w + 1];
//        for (int r = 0; r < w + 1; r++) {
//            mat[0][r] = 0;
//        }
//        for (int c = 0; c < n + 1; c++) {
//            mat[c][0] = 0;
//        }
        
        // Main logic
        for (int item = 1; item <= n; item++) {
            for (int capacity = 1; capacity <= w; capacity++) {
                long maxValWithoutCurr = mat[item - 1][capacity]; // This is guaranteed to exist
                long maxValWithCurr = 0; // We initialize this value to 0
                
                int weightOfCurr = wt[item - 1]; // We use item -1 to account for the extra row at the top
                if (capacity >= weightOfCurr) { // We check if the knapsack can fit the current item
                    maxValWithCurr = val[item - 1]; // If so, maxValWithCurr is at least the value of the current item
                    
                    int remainingCapacity = capacity - weightOfCurr; // remainingCapacity must be at least 0
                    maxValWithCurr += mat[item - 1][remainingCapacity]; // Add the maximum value obtainable with the remaining capacity
                }
                
                mat[item][capacity] = Math.max(maxValWithoutCurr, maxValWithCurr); // Pick the larger of the two
            }
        }
        
        System.out.println(mat[n][w]); // Final answer
    }
}

Measured memory_bytes: 131820
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
		for(int i = 0 ; i < n ; i++) {
			if(map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], 1);
			}
		}
		// value降順ソート
		List<Entry<Integer, Integer>> entry = new ArrayList<>(map.entrySet());
		Collections.sort(entry, new Comparator<Entry<Integer, Integer>>() {
			public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
				return obj2.getValue() - obj1.getValue();
			}
		});
		int ans = 0;
		for(int i = k ; i < entry.size() ; i++) {
			ans += entry.get(i).getValue();
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 89676
#include<bits/stdc++.h>
using namespace std;
const int N=110,V=1e5+10;
long long n,W,i,j,ans;
long long w[N],v[N];
long long dp[N][V];
main(){
    cin>>n>>W;
    for(i=1;i<=n;i++)cin>>w[i]>>v[i];
    for(i=0;i<=n;i++){
        for(j=0;j<=100001;j++)dp[i][j]=1e18;
    }
    dp[0][0]=0;
    for(i=1;i<=n;i++){
        for(j=0;j<=100001;j++){
            if(j >= v[i])dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    for(i=1;i<=100001;i++){
        if(dp[n][i] <= W)ans=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 80128
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int r, g;
    cin >> r >> g;
    cout << 2*g-r << endl;
}

int main()
{
    solve();
    return 0;
}


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

using namespace std;

int main() {
    int N, L;

    cin >> N >> L;

    int sum = 0;
    int min = L;
    for (int i = 0; i < N; i++) {
        sum += L + i;
        if (abs(L + i) < abs(min))
            min = L + i;
    }
    cout << (sum - min) << endl;

    return 0;
}



Measured memory_bytes: 256
var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll>P;

int main(){
  string t;
  cin>>t;
  queue<char>qu;
  rep(i,t.size()){
  	if(t[i]=='P'){qu.push('P');}
    else{qu.push('D');}
  }
  while(!qu.empty()){
  	char x=qu.front();qu.pop();
  	cout<<x;
  }
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

ll func(ll N){
    if(N % 2){
        return ((N+1)/2)%2;
    }else{
        return (N ^ (((N)/2)%2));
    }
}


int main(){
    ll A,B;
    cin >> A >> B;
    cout << (func(A-1) ^ func(B)) << endl;
}

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

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

typedef struct node * Node;
#define NIL NULL

Node root = NIL;

Node treeSearch(Node root, int k) {
	if (root == NIL) return NIL;
	if (root->key == k) return root;
	if (root->key > k) {
		if (root->left != NIL) return treeSearch(root->left, k);
		else return NIL;
	} else {
		if (root->right != NIL) return treeSearch(root->right, k);
		else return NIL;
	}
}

int find(Node root, int k) {
	if (root->key == k) return 1;
	if (root->key < k) {
		if (root->left != NIL) return find(root->left, k);
		else return 0;
	} else {
		if (root->right != NIL) return find(root->right, k);
		else return 0;
		
	}
}

void insert(int k) {
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

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

void inorder(Node u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
	return;
}

void preorder(Node u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
	return;
}

void treeDelete(Node z) {
	Node y;
	Node x;
	return;
}

int main(void) {
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; ++i) {
		scanf("%s", com);
		if ( com[0] == 'f' ) {
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if ( t != NIL ) printf("yes\n");
			else printf("no\n");
		} else if ( com[0] == 'i') {
			scanf("%d", &x);
			insert(x);
		} else if ( com[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		} else if ( com[0] == 'd') {
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		} 
	}
	
	return 0;
}

Measured memory_bytes: 19364
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

bool isDigi(string s){
  rp(i,s.length())
    if(s[i] < '0' || s[i] > '9') return false;
  return true;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll c[n],s[n],f[n];
    rp(i,n-1) cin >> c[i] >> s[i] >> f[i];
    rp(i,n){
      ll curT = 0;
      rep(j,i+1,n){
        if(curT <= s[j-1]){
          curT = s[j-1]+c[j-1];
        } else {
          if(curT%f[j-1] == 0) curT += c[j-1];
          else curT += f[j-1] - (curT%f[j-1]) + c[j-1];
        }
      }
      cout << curT << endl;
    }

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N, D;
    cin >> N >> D;

    int step = 2 * D + 1;
    int cnt = 0;

    for (int i = 0; i < 20; i = i + step)
    {

        if (i >= N)
        {
            break;
        }
        cnt++;
    }
    cout << cnt;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 3000

using namespace std;

ll d[maxn+5][maxn+5][2], v[maxn+5];
bool viz[maxn+5][maxn+5][2];
///d[i][j][0]=diff max dc rezolvam secventa i..j cu Taro la mutare
///d[i][j][1]=diff min i..j Jiro

ll Dp (int l, int r, int wh) {
  if (l > r) return ((wh == 0)? -infl: infl);
  if (viz[l][r][wh]) return d[l][r][wh];
  viz[l][r][wh] = 1;
  if (l == r) d[l][r][wh] = ((wh == 0)? v[l]: -v[l]);
  else {
    if (wh == 0) d[l][r][0] = max(v[l] + Dp(l+1,r,1), v[r] + Dp(l,r-1,1));
    else d[l][r][1] = min(-v[l] + Dp(l+1,r,0), -v[r] + Dp(l,r-1,0));
  }
  return d[l][r][wh];
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  cout << Dp(1,n,0);
  return 0;
}


Measured memory_bytes: 158208
//stay in this moment
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int ans=0;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<3;++i)
	if(s[i]==t[i])
	ans++;
	cout<<ans;
}
void q2(){
	int a,b;
	cin>>a>>b;
	int ans=(b+a-2)/(a-1);
	cout<<ans;
}
void q3(){
	int n;
	cin>>n;
	int arr[n],fre[n];
	for(int i=0;i<n;++i)
	{cin>>arr[n-i-1];fre[i]=1;}
	for(int i=1;i<n;++i)
	if(arr[i]>=arr[i-1])
	fre[i]+=fre[i-1];
	int mx=-1;
	for(int i=0;i<n;++i)
	mx=max(mx,fre[i]);
	cout<<mx-1;
}
void q4(){
	int n;
	cin>>n;
	n*=(n-1);
	cout<<n/2;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q3();
	return 0;
}
	


Measured memory_bytes: 1792
//ここで手段を選ばないゲスな精神が？

//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();

	int A[1001][1000];
	rep1(i, N) {
		rep(j, N - 1) A[i][j] = getint();
		A[i][N - 1] = 0;
	}
	int* k[1001];
	rep1(i, N) k[i] = A[i];
	int k2[1001] = {};
	k2[0] = 1e9;
	vector<int> V;
	rep1(i, N) V.pb(i);

	int kotae = 0;
	while (V.size() && kotae < 80000) {
		kotae++;
		vector<int> kari;
		for (auto v : V) {
			if (k2[v] < kotae) {
				int a = *k[v];
				if (k2[a] < kotae && *k[a] == v) {
					kari.pb(v);
					k[v]++;
					k2[v] = kotae;
					kari.pb(a);
					k[a]++;
					k2[a] = kotae;
				}
			}
		}
		swap(V, kari);
	}

	int OK = 1;
	rep1(i, N) if (k[i] - A[i] != N - 1) OK = 0;
	if (kotae == 80000) printf("%d", N* (N - 1) / 2);
	else if (!OK) printf("-1"); 
	else printf("%d", kotae - 1);

	Would you please return 0;
}

Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {
		
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int s = stdIn.nextInt();
		s += stdIn.nextInt();
		s += stdIn.nextInt();
		s += stdIn.nextInt();
		
		int m = s/60;
		s -= m * 60;
		System.out.println(m+"\n"+s);
	}
}

Measured memory_bytes: 17348
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = ll(1e18);

int main(){
    ll n;
    cin >> n;
    ll ans = INF;
    for(ll i = 1; i * i <= n;i++){
        if(n % i == 0){
            ll j = n / i;
            ans = min(ans,i+j-2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
#define popcount(x) __builtin_popcountll(x)
const int MOD =1e9+7;

mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> istream& operator >> (istream &in,vector<T> &A){ for(auto &x:A) in>>x; return in; };
template<typename T> ostream& operator << (ostream &out,vector<T> &A){ for(auto &x:A) out<<x<<" "; return out; };
template<typename T,typename W> istream& operator >> (istream &in,pair<T,W> &A){ in>>A.fi>>A.se; return in; };
const int N = 100;
// vector<int> g[N];
// bool vis[N];
void solve()
{
	// int n;
	// cin>>n;
	// string a,b;
	// cin>>a>>b;
	// for(int i=0;i<N;i++)
	// {
	// 	g[i].clear();
	// 	vis[i]=false;
	// }
	// for(int i=1;i<n;i++)
	// {
	// 	if(a[i-1]=='Y'&&b[i]=='Y')
	// 	{
	// 		g[i+1].pb(i);
	// 	}
	// 	if(b[i-1]=='Y'&&a[i]=='Y')
	// 	{
	// 		g[i].pb(i+1);
	// 	}
	// }
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=k;i<n;i++)
	{
		if(a[i-k]<a[i])
		{
			cout<<"Yes\n";
		}
		else cout<<"No\n";
	}
}
// (a*b*c...) ()
// (1<<)
int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif

	int t=1;
	// cin>>t;
	for(int _t=1;_t<=t;_t++){
		// cout<<"Case #"<<_t<<": ";
		solve();
	}
} 


Measured memory_bytes: 5220
import numpy as np
import math
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

def dist(i,j):
  return np.sqrt((e[i][0]-e[j][0]) ** 2 + (e[i][1]-e[j][1]) ** 2)

if n == 2:
  print(dist(0,1))
else:
  a = math.factorial(n-1)
  ans=0
  for i in range(n):
    for j in range(n):
      ans += dist(i,j) * a
  ans = ans / math.factorial(n)
  print(ans)


Measured memory_bytes: 12428
N,M = map(int,input().split())
A = list(map(int,input().split()))
c=[2,5,5,4,5,6,3,7,6]

dp = [-1 for _ in range(N+1)]
dp[0] = 0

for i in range(N+1):
    for a in A:
        if i-c[a-1]>=0:
            dp[i] = max(dp[i], dp[i-c[a-1]]*10 + a)

print(dp[-1])


Measured memory_bytes: 14388
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

ll N,K;
ll table[SIZE];

int main(){

	scanf("%lld %lld",&N,&K);

	N++;
	table[0] = 0;
	for(ll i = 1; i <= N; i++){

		table[i] = i;
		table[i] += table[i-1];
	}

	ll ans = 0;

	for(ll num = K; num <= N; num++){

		ll L = table[num];
		ll R = table[N]-table[N-num];

		ans += (R-L+1)%MOD;
		ans %= MOD;
	}

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

	return 0;
}


Measured memory_bytes: 5328
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	vector<ll> d[100001];
	int n, k;
	cin>>n>>k;
	int ind[100001];
	for(int i=0; i<n; i++){
		int t; ll d0;
		cin>>t>>d0; t--;
		d[t].push_back(d0);
		ind[i]=i;
	}
	for(int i=0; i<n; i++){
		if(!d[i].empty()) sort(d[i].begin(), d[i].end(), greater<ll>());
		else d[i].push_back(0);
	}
	sort(ind, ind+n, [&](int i, int j){ return d[i][0]>d[j][0];});
	ll ans=0;
	priority_queue<ll, vector<ll>, greater<ll>> que;
	ll sum=0;
	ll sum2=0;
	for(ll i=1; i<=k; i++){
		if(d[ind[i-1]][0]==0) break;
		sum2+=d[ind[i-1]][0];
		for(int j=1; j<d[ind[i-1]].size(); j++){
			ll x=d[ind[i-1]][j];
			que.push(x);
			sum+=x;
		}
		while(que.size()>k-i){
			sum-=que.top(); que.pop();
		}
		ans=max(ans, sum+sum2+i*i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main() {
	int a = 0;
	int b = 0;
	int c = 0;

	int counter = 0;
	int step = 1;

	cin >> a >> b >> c;
	if (a > c) {
		cout << 0 << endl;
		return 0;
	}
	if (b >= c) {
		counter++;
	}

	int x = a;
	int max = c/2;

	if (c % 2 != 0) {
		step = 2;
		if (a % 2 == 0) {
			x++;
		}
	}
	while ((x <= b) && (x <= max)) {
		if (c % x == 0) {
			counter++;
		}
		x += step;
	}
	cout << counter << endl;
	return 0;
}



Measured memory_bytes: 3108
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main() {
    li n, w;
    cin >> n >> w;

    vector<li> ws(n), vs(n);
    rep(i, n) {
        cin >> ws[i] >> vs[i];
    }

    const li d = 4 * (n + 1);
    li ans = 0;
    vector<vector<vector<li>>> dp(n + 1, vector<vector<li>>(n + 1, vector<li>(d, 0)));
    rep(i, n) {
        rep(j, i + 1) {
            rep(k, d) {
                dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
                ans = max(ans, dp[i + 1][j][k]);
                const int ni = i + 1;
                const int nj = j + 1;
                const int nk = k + ws[i] - ws[0];
                if (nk < d && nj * ws[0] + nk <= w) {
                    dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] + vs[i]);
                    ans = max(dp[ni][nj][nk], ans);
                }
            }
        }
    }

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


Measured memory_bytes: 33152
import Control.Applicative

type Result = (Int, Int, Int)

solve :: [Int] -> Result

solve as
    = (minimum as, maximum as, sum as)

input :: IO [Int]

input
    = do
        getLine
        as <- map read.words <$> getLine
        return as

output :: Result -> IO ()

output (n, m, s)
    = putStrLn $ init $ concat [show x ++ " " | x <- [n, m, s]]
    
main :: IO ()

main = output =<< solve <$> input

Measured memory_bytes: 11308
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iterator>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define gc(x) getchar(x)
#define pc(x) putchar(x)
#define endline pc('\n')

typedef long long LL;

using namespace std;

int
main() {
	int n;
	cin >> n;
	
	bool overflow = false;
	bool has_zero = false;
	LL res = 1LL;
	const LL LIM = (LL)1e9 * (LL)1e9;
	
	for (int i = 0; i < n; i++) {
		LL x;
		cin >> x;
		
		if (x == 0LL) {
			res = 0LL;
			has_zero = true;
		}
		if (overflow || has_zero)
			continue;
		
		if ((long double)x > ((long double)LIM / (long double)res)) {
			res = -1;
			overflow = true;
		} else {
			res *= x;
		}
	}
	
	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define INF (1e8)

int N,K,T;

P dat[(1<<19)];

void compute(int k,P p){
  if(p==P(0,0))return;
  if(dat[k]==P(0,0)){
    dat[k]=p;
  }else if(dat[k].second+1==p.first){
    dat[k].second=p.second;
  }else{
    dat[k]=P(INF,INF);
  }
}

void add(int a,int b,int x,int k=0,int l=0,int r=(1<<18)){
  if(b<=l || r<=a)return;
  if(a<=l && r<=b){
    compute(k,P(x,x));
    return;
  }
  
  
  compute(k*2+1,dat[k]);
  compute(k*2+2,dat[k]);
  dat[k]=P(0,0);
  int m=(l+r)/2;
  add(a,b,x,k*2+1,l,m);
  add(a,b,x,k*2+2,m,r);
}

int main(){
  scanf("%d %d %d",&N,&K,&T);
  for(int i=0;i<T;i++){
    int l,r,x;
    scanf("%d %d %d",&l,&r,&x);
    add(l-1,r,x);
  }
  for(int i=0;i<N;i++){
    add(i,i+1,0);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    int p=i+(1<<18)-1;
    if(dat[p]==P(1,K))ans++;
  }
  printf("%d\n",ans);
  return 0;
}

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

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

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

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

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

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

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

signed main() {
    int n, m, inp; cin >> n >> m;
    int x[100010] = {};
    int num[100010] = {};
    rep(i,0,n) {
        cin >> inp;
        x[inp % m]++;
        num[inp]++;
    }

    int ans = 0;
    rep(i,0,m) {
        int t;
        if(i != 0 && i != m-i) t = min(x[i], x[m-i]);
        else t = x[i] / 2;
        ans += t;
        if(i != 0 && i != m-i) {
            x[i] -= t; x[m-i] -= t;
        }
        else {
            x[i] -= t * 2;
        }
        // cout << ans << endl;
    }

    rep(i,0,m) {
        // printf("x[%lld] : %lld\n", i, x[i]);
        for(int j=i; j<=100000; j += m) {
            if(x[i] < 2) break;
            if(num[j] >= 2) {
                int temp = min(x[i], num[j]);
                ans += temp / 2;
                x[i] -= temp / 2 * 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MOD = 1000000007;

int H, W, A, B;

const int MAXCOMB = 200000 + 10; // NEED TO CHECK
long long Fac[MAXCOMB], InvFac[MAXCOMB];
long long CombMod(long long A, long long B)
{
	long long Ans = Fac[A];
	(Ans *= InvFac[B]) %= MOD;
	(Ans *= InvFac[A - B]) %= MOD;
	return Ans;
}
long long PowerMod(long long Base, long long Exp, long long Mod)
{
	Base %= Mod;
	long long Ret = 1;
	while (Exp)
	{
		if (Exp & 1)
			(Ret *= Base) %= Mod;
		(Base *= Base) %= Mod;
		Exp >>= 1;
	}
	return Ret;
}
void GenFactorial()
{
	Fac[0] = 1;
	for (int i = 1; i < MAXCOMB; i ++)
		Fac[i] = ((long long) Fac[i - 1] * (long long) i) % MOD;
	InvFac[MAXCOMB - 1] = PowerMod(Fac[MAXCOMB - 1], MOD - 2, MOD);
	for (int i = MAXCOMB - 1; i >= 1; i --)
		InvFac[i - 1] = ((long long) InvFac[i] * (long long) i) % MOD;
}

void Work()
{
	GenFactorial();
	scanf("%d%d%d%d", &H, &W, &A, &B);
	long long Ans = 0;
	for (int i = B; i < W; i ++)
	{
		Ans += CombMod(H - A - 1 + i, H - A - 1) * CombMod((H + W - 2) - (H - A - 1 + i) - 1, A - 1) % MOD;
		Ans %= MOD;
	}
	printf("%d\n", (int) Ans);
}

int main()
{
	Work();
	return 0;
}

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

using namespace std;

using ll = long long;

const int maxN = 405;
const ll INF = 1e18 + 7;

vector<vector<ll>> dp(maxN, vector<ll>(maxN, INF)), ans(maxN, vector<ll>(maxN, INF));

int main()
{
    int n;
    cin >> n;
    vector<int> sl(n);
    for(auto &x : sl) cin >> x;
    for(int l = n - 1; l >= 0; l--) {
        for(int r = l; r < n; r++) {
            if(l == r) {
                dp[l][r] = sl[l];
                ans[l][r] = sl[l];
            }
            else {
                for(int in = l; in < r; in++) {
                    if(ans[l][r] > (dp[l][in] + dp[in + 1][r] + (in - l > 0 ? ans[l][in] : 0) + (r - (in + 1) > 0 ? ans[in + 1][r] : 0))) {
                        dp[l][r] = dp[l][in] + dp[in + 1][r];
                        ans[l][r] = dp[l][r] + (in - l > 0 ? ans[l][in] : 0) + (r - (in + 1) > 0 ? ans[in + 1][r] : 0);
                    }
                } 
            }
        }
    }
    cout << ans[0][n - 1];
    return 0;
}


Measured memory_bytes: 6184
#include <iostream>
#define LL long long
#define prim 1000000007
using namespace std;

LL N,M,dp[2][310][310];

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

    int i,j,k; bool l=0;
    dp[0][0][0]=1;
    for (i=M; i>0; i--){
        l=!l;
        for (j=0; j<N; j++)
            for (k=0; k<=j; k++){
                dp[l][j][k]=((N-j)*dp[!l][j-k][0])%prim;
                dp[l][j][k]=(dp[l][j][k]+k*dp[!l][j][k])%prim;
                dp[l][j][k]=(dp[l][j][k]+(j-k)*dp[!l][j][k+1])%prim;
            }
    }

    cout << dp[l][N-1][0] << "\n";

    return 0;
}


Measured memory_bytes: 1664
N, M = map(int, input().split())

A = [list(map(lambda x : 1 if x == '#' else 0, input())) for _ in range(N)]
B = [list(map(lambda x : 1 if x == '#' else 0, input())) for _ in range(M)]

for j in range(N-M+1):
    for i in range(N-M+1):
        result = True
        for y in range(M):
            for x in range(M):
                if A[y+j][x+i] != B[y][x]:
                    result = False
                    break
            if not result:
                break
        if result:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
s=0
n=0
while True:
    try:
        a,b,c = map(int, input().split(","))
    except:
        break
 
    if a == b:
        n+=1
    elif c**2 == a**2 + b**2:
        s+=1
 
print(str(s) + "\n" + str(n))

Measured memory_bytes: 6720
def solve():
    def recur(i, n, total):
        # print("i, n, total", i, n, total)

        if not TABLE[i][n][total] == -1:
            # print('cache!')
            return TABLE[i][n][total]

        if not i < N:
            if n > 0 and total == A * n:
                return 1
            return 0

        ans1 = recur(i + 1, n, total)
        ans2 = recur(i + 1, n + 1, total + XS[i])

        # print(ans1, ans2)

        TABLE[i][n][total] = ans1 + ans2
        return TABLE[i][n][total]

    N, A = tuple(map(int, input().split()))
    XS = tuple(map(int, input().split()))

    TABLE = []
    for _ in range(N + 1):
        lines = [[-1 for x in range(N * 50 + 1)] for y in range(N + 1)]
        TABLE.append(lines)

    return recur(0, 0, 0)


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 58924
k = int(input())

from collections import deque
queue = deque(range(1,10))
count = 0
while count < k:
  count += 1
  tmp = queue.popleft()
  tail = tmp%10
  if tail != 0:
    queue.append(10*tmp+tail-1)
  queue.append(10*tmp+tail)
  if tail != 9:
    queue.append(10*tmp+tail+1)

print(tmp)

Measured memory_bytes: 11956
N,W=map(int,input().split())

w=[]
v=[]
for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp=[[0 for i in range(W+1)] for _ in range(N+1)]

for i in range(0,N):
    for j in range(0,W+1):
        if j-w[i]>=0:
            dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i])
        dp[i+1][j]=max(dp[i][j],dp[i+1][j])

print(dp[N][W])

Measured memory_bytes: 171528
#include <stdio.h>

#define MAXNUM 1000000000000000000

int main(void) {
	unsigned int n;
	unsigned long int a, prod = 1;
	unsigned char flag = 0;
	
	scanf("%u", &n);

	for (size_t i = 0; i < n; i++) {
		scanf("%lu", &a);
		
		unsigned long int q;
		if (a == 0) {
			flag = 0;
			prod = 0;
			break;
		} else if (prod > (q = MAXNUM / a)) {
			flag = 1;
		}
		
		if (flag == 0) {
			prod *= a;
		}
	}

	switch (flag) {
		case 0:
			printf("%lu\n", prod);
			break;
		case 1:
			printf("%d\n", -1);
			break;
		default:
			// nothing to do
			break;
	}

	return 0;

}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int 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();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n);
  vector<int> t(n), x(n), y(n);
  rep(i, n) cin >> t[i] >> x[i] >> y[i];

  int now = 0, nowx = 0, nowy = 0;
  rep(i, n) {
    int dt = t[i] - now;
    int dm = abs(x[i] - nowx) + abs(y[i] - nowy);
    if (dt % 2 != dm % 2 || dt < dm) {
      cout << "No" << endl;
      return;
    }
    now = t[i];
    nowx = x[i];
    nowy = y[i];
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int cnt[41][2];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n; ll k;
	cin >> n >> k;
	
	vector<ll> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	
	for (int bit = 39; bit >= 0; bit--) {
		for (int i = 0; i < n; i++)
			cnt[bit][(A[i] >> bit) & 1]++;
	}
	
	
	ll ans = 0;
	for (int i = 0; i < n; i++) ans += (A[i] ^ k);
	
	for (int st = 39; st >= 0; st--) if ((k >> st) & 1) {
		ll sum = 0;
		for (int i = st - 1; i >= 0; i--) {
			sum += max(cnt[i][0], cnt[i][1]) * (1ll << i);
		}
		for (int i = 39; i > st; i--) {
			sum += cnt[i][((k >> i) & 1) ^ 1] * (1ll << i);
		}
		sum += cnt[st][1] * (1ll << st);
		ans = max(ans, sum);
	}
	cout << ans << "\n";		
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

char a, b, c, d;
int e[4];
vector<char> v;
void dfs(int N, int T){
    if (N==4){
        if (T!=7) return;
        fox(l, 4){
            if (l!=0)
            cout << v[l];
            cout << e[l];
        }
        cout << "=7";
        exit(0);
    }
    v.pb('+');
    dfs(N+1, T+e[N]);
    v.pop_back();
    if (N==0) return;
    v.pb('-');
    dfs(N+1, T-e[N]);
    v.pop_back();
}
int main(){
    cin >> a >> b >> c >> d;
    e[0]=a-'0'; e[1]=b-'0'; e[2]=c-'0'; e[3]=d-'0';
    dfs(0, 0);

    return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

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

    queue<pair<string, int>> queue;
    rep(i, 0, n) {
        string name;
        int time;
        cin >> name >> time;
        queue.emplace(name, time);
    }

    int sum = 0;
    while (!queue.empty()) {
        pair<string, int> p = queue.front(); queue.pop();
        if (p.second <= q) {
            sum += p.second;
            cout << p.first << " " << sum << endl;
        }
        else {
            sum += q;
            p.second -= q;
            queue.push(p);
        }
    }

    return 0;
}


Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // [9,223,372,036,854,775,807 to -9.....808] 19 digits
typedef long double ld;
#define inc(i, a, b) for (long long int i = a; i <= b; i++)
#define dec(i, a, b) for (long long int i = a; i >= b; i--)
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define lv vector<ll>
#define cv vector<char>
#define dv vector<ld>
#define rall(c) (c).rbegin(), (c).rend()
#define lpr pair<ll, ll>
#define mp make_pair
#define cin(c) \
    ll c;      \
    cin >> c;
#define lmap unordered_map<ll, ll>
#define vinp(a, n) \
    inc(i, 1, n)   \
    {              \
        cin(k);    \
        a.pb(k);   \
    }
#define LIM 1000000007
#define F first
#define S second
#define fr(i, n) inc(i, 0, n - 1)
#define fri(n, a) \
    inc(i, 0, n - 1) { cin >> a[i]; }
#define debug(p) cout << p;
#define umap unordered_map
#define uset unordered_set
#define fill(a, val, n) \
    inc(i, 0, n - 1) { a[i] = val; }
void i_love_Accepted()
{
    ll n, m ,ms;
        cin>>n>>m>>ms;
    ll A[n],B[m];
        for(ll A_i = 0; A_i < n; A_i++){
            cin>>A[A_i];
        }
        for(ll B_i = 0; B_i < m; B_i++){
           cin>>B[B_i];
        }

        ll sum = 0;
        ll x = 0, y = 0;

        while (x < n && sum + A[x] <= ms) {
            sum += A[x++];
        }

        ll ans = x;

        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0) {
                sum -= A[--x];
            }

            if (sum <= ms && ans < x + y) {
                ans = x + y;
            }
        }

        cout<<ans;
}   
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        i_love_Accepted();
        //cout<<"\n";
    } 
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a + b < 10) {
  	cout << a + b << endl;
  } else {
  	cout << "error" << endl;
  }
}


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

const double pi = acos(-1);
const double eps = 0.0000000001;
const double zer = 0.0;

double b, a, x = zer, y = zer;
int ans;

double rads (double degs) {
	return degs * pi / 180.0;
}

bool eq (double n, double m) {
	return (n >= m - eps && n <= m + eps);
}

signed main () {
	scanf("%lf", &b);
	a = b + 90.0;
	while (!ans || !eq(x, zer) || !eq(y, zer)) {
		++ans;
		x += cos(rads(a));
		y += sin(rads(a));
		a += b;
		if (a >= 360.0)
			a -= 360.0;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 4188
#include <stdio.h>

int main(void){
  int count = 0;
  int n = 0;
  char s[3];
  scanf("%s", &s);
  while (n < 3){
    if(s[n] == '1'){
      count = count + 1;
    }
    n = n + 1;
  }
  printf("%d",count);
  return 0;
}

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

int main() {
    string s;
    int64_t k;
    cin >> s >> k;
    int64_t ans = 0;
    vector<int> cnt_same = {1};
    REP(i, s.size() - 1) {
        if(s[i] == s[i + 1]) {
            cnt_same.back() ++;
        } else {
            cnt_same.push_back(1);
        }
    }
    if(cnt_same.size() == 1){
        cout << cnt_same.front() * k / 2 << endl;
        return 0;
    }
    int cnt_front = cnt_same.front();
    int cnt_back = cnt_same.back();
    bool flag = false;
    if(s[0] == s.back()) {
        flag = true;
        cnt_same.front() += cnt_same.back();
        cnt_same.pop_back();
    }
    REP(i, cnt_same.size()) ans += cnt_same[i] / 2;
    ans *= k;
    if(flag) {
        ans -= cnt_same.front() / 2;
        ans += cnt_front / 2 + cnt_back / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define int long long
#define puts(x) cout<<x<<endl
#define inf 243000000000000001
#define minf -243000000000000001



signed main(){
    int n;
    cin>>n;
    vector<int>v(n);
    vector<int>ans(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    ans[0]=0;
    ans[1]=abs(v[1]-v[0]);
    for(int i=2;i<=n-1;i++){
        ans[i]=min(ans[i-2]+abs(v[i-2]-v[i]),ans[i-1]+abs(v[i-1]-v[i]));
    }
    puts(ans[n-1]);
}
  

Measured memory_bytes: 4792
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
ans = 0
j = 0
m = 0
for i in range(N):
    if T[i] > m or j == C - 1:
        j = 0
        m = T[i] + K
        ans += 1
    else:
        j += 1
print(ans)

Measured memory_bytes: 8280
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
//#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)
     
using namespace std;
      
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<ll> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<ll> > vvi;
typedef vector<char> vc;
      
const ll INF = 1e9 + 228;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
static const int maxn = 2e5 + 228;;
const ld eps = 1e-7;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);
     
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef DEBUG
//      freopen("haybales.in", "r", stdin);
//      freopen("haybales.out", "w", stdout);
    #endif
}

vi g[maxn];

void solve(){
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	queue<int> q;
	vb used(n);
	vi p(n, -1);
	p[0] = 0;
	q.push(0);
	used[0] = true;
	int cnt = 0;
	while(!q.empty()){
		int v = q.front();
		q.pop();
		cnt++;
		for(int i:g[v]){
			if(!used[i]){
				used[i] = true;
				p[i] = v+1;
				q.push(i);
			}
		}
	}
	if(cnt!=n){
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
	for(int i=1; i<n; i++){
		cout << p[i] << endl;
	}

		
}

signed main(){
        fast_io();
	srand(time(NULL));
//	cout << fixed << setprecision(12);
	int q = 1;
//	cin >> q;
	while(q--)
		solve();
     
}





Measured memory_bytes: 15324
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N, K;
  long int h[110000];
  cin >> N >> K;
  rep(i,N) cin >> h[i];

  long int dp[110000];

  memset(dp, INF, sizeof(dp));
  dp[0] = dp[1] = 0;

  FOR(i, 2, N) {
    rep(j, K) {
      if(i-(j+1)<0) break;
      dp[i] = min(dp[i], dp[i-(j+1)] + abs(h[i-1] - h[i-(j+1)-1]));
    }
  }

  //  rep(i,N+1) cout  << dp[i] << endl;                                        

  cout << dp[N] << endl;
}


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

HL, WL = [0]*H, [0]*W
B = []

for _ in range(M):
  h, w = map(lambda x:int(x)-1, input().split())
  B.append((h, w))
  HL[h] += 1
  WL[w] += 1

HM, WM = max(HL), max(WL)
K = HL.count(HM) * WL.count(WM)

cnt = 0
for h, w in B:
  if HL[h] == HM and WL[w] == WM:
    cnt += 1

if K > cnt:
  print(HM+WM)
else:
  print(HM+WM-1)

Measured memory_bytes: 106044
/**
 * Created by hiramekun at 23:04 on 2019-10-29.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll a, b;
    cin >> a >> b;
    if (a > 9 || b > 9) cout << -1 << '\n';
    else cout << a * b << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,w;
    cin>>n>>w;
    ll val[n],wt[n];
    for(ll i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    ll dp[n+1][w+1];
    for(ll i=0;i<=n;i++){
        dp[i][0]=0;
    }
    for(ll i=0;i<=w;i++){
        dp[0][i]=0;
    }
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=w;j++){
            if(wt[i-1]>j){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j],val[i-1] + dp[i-1][j-wt[i-1]]);
            }
        }
    }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 200000;

int main(){
  int n, a, b, ans;
  cin >> n >> a >> b;
  ans = min(a*n, b);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	int a[N+1];
	for (int i = 1; i < N+1; ++i)
	{
		cin >> a[i];
	}
	int currentNum = 1;
	int currentStep = 1;
	for (int i = 0; i < N+1; ++i)
	{
		if(a[currentNum] == 2){
			cout << currentStep << endl;
			return 0;
		}
		currentNum = a[currentNum];
		currentStep++;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

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

  if(a < b){
    if(b < c){
      printf("%d %d %d\n", a, b, c);
    }else
      if(a < c){
	printf("%d %d %d\n", a, c, b);
      }else
	printf("%d %d %d\n", c, a, b);
  }else
    if(b < c){
      if(a < c){
	printf("%d %d %d\n", b, a, c);
      }else
	printf("%d %d %d\n", b, c, a);
    }else
      printf("%d %d %d\n", c, b, a);
  return 0;
}

Measured memory_bytes: 596