akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
    int n, num[3] = {0}, i, j;
    
    scanf("%d", &n);
    scanf("%d %d", &num[0], &num[1]);
    if (n == 2) {
        for (i = 1; i < num[0] / 2 || i < num[1] / 2; i++) {
            if (num[0] % i == 0 && num[1] % i == 0) {
                printf("%d\n", i);
            }
        }
    }else{
        for (i = 1; i < num[0] /2 || i < num[1] / 2 || i < num[2]; i++) {
            if (num[0] % i == 0 && num[1] % i == 0) {
                printf("%d\n", i);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <math.h>
 
 
main()
{
int a,b,d;
char c;
while(1){
    scanf("%d %c %d",&a,&c,&b);
    if(c=='?')break;
    if(c=='+')d=a+b;
    if(c=='-')d=a-b;
    if(c=='*')d=a*b;
    if(c=='/')d=a/b;
    printf("%d\n",d);
}
}


Measured memory_bytes: 2704
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  string s;
  cin >> s;
  

  auto f = [](ll x) { return x * (x + 1) / 2; };

  if (s[0] == '>') s = '<' + s;
  if (s[s.size() - 1] == '<') s = s + '>';
  ll n = s.size();

  vll lst;
  int now = 0;
  char lol[2] = {'<', '>'};

  ll cnt = 0;
  rep(i, n) {
    if (s[i] != lol[now]) {
      lst.push_back(cnt);
      cnt = 1;
      now = 1 - now;
    } else
      cnt++;
  }
  lst.push_back(cnt);

  ll ans = 0;
  assert(lst.size() % 2 == 0);
  rep(i, (ll)lst.size() / 2) { ll a = lst[2 * i], b = lst[2 * i + 1];
    if (a < b) swap(a, b);
    ans += f(a) + f(b - 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int alpha[26];
const int INF = 10000000;

int main(){
    int n; 
    cin >> n;
    vector<string> S(n);
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    for(int i = 0; i < 26; i++){
        alpha[i] = INF;
    }
    
    for(char c = 'a'; c <= 'z'; c++){
        if(alpha[c - 'a'] == 0)     continue;
        
        for(int i = 0; i < n; i++){
            int cnt = 0;
            for(int j = 0; j < S[i].length(); j++){
                if(S[i][j] == c){
                    cnt++;
                }
            }
            alpha[c - 'a'] = min(alpha[c - 'a'], cnt);
        }
    }
    
    string ans = "";
    for(char c = 'a'; c <= 'z'; c++){
        int temp = alpha[c - 'a'];
        while(temp > 0){
            ans += c;
            temp--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,vector<ll> > P;
typedef pair<P,ll>Q;
 

int main(void){
    int n,q;
    cin>>n>>q;
    vector<ll>a(n);
    for(int i=0;i<n;i++)cin>>a[i];

    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        ll sum = 0;
        ll right =0;
        ll ans = 0;
        for(ll left = 0;left<n;left++){
            while(right<n && sum+a[right]<=x){
                sum+=a[right];
                right++;
            }
            ans+=right-left;
            if(right==left)right++;
            else sum-=a[left];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3568
import sys
sys.setrecursionlimit(10 ** 6)

D,G=map(int,input().split())
pc=[list(map(int,input().split())) for _ in range(D)]

def solve(bit):
  if bit >= (1<<D):
    return 1000
  p_sum=0
  num=0
  
  for i in range(D):
    if bit & (1<<i):
      p_sum += pc[i][1] + pc[i][0] * 100*(i+1)
      num += pc[i][0]
  if p_sum >= G:
    return min(num,solve(bit+1))
  else:
    for i in reversed(range(D)):
      if bit & 1<<i:
        continue
      for j in range(pc[i][0]):
        if p_sum >= G:
          break
        p_sum += 100*(i+1)
        num += 1
      else:
        return solve(bit+1)
    return min(num,solve(bit+1))

print(solve(0))

Measured memory_bytes: 9896
// Hacheylight
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void upd(T &a, T b) { a = (1ll * a + b) % MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }
template <class T> T read() {
    int f = 1 ; T x = 0 ;
    char ch = getchar() ;
    while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
    while (isdigit(ch)) { x = x * 10 + ch -'0' ; ch = getchar() ; }
    return x * f ;
}

int n, m, s, t ;
vi e[N] ;
int vis[N][3], dis[N][3] ;
queue <pii> q ;

signed main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, m) {
		int x, y ; scanf("%d%d", &x, &y) ;
		e[x].pb(y) ;
	}
	scanf("%d%d", &s, &t) ;
	rep(i, 1, n) rep(j, 0, 2) dis[i][j] = iinf ;
	q.push(mp(s, 0)) ;
	while (!q.empty()) {
		pii now = q.front() ; q.pop() ;
		if (vis[now.fi][now.se % 3]) continue ;
		vis[now.fi][now.se % 3] = true ;
		dis[now.fi][now.se % 3] = now.se ;
		rep(i, 0, siz(e[now.fi]) - 1) {
			int to = e[now.fi][i] ;
			q.push(mp(to, now.se + 1)) ;
		}
	}
	if (!vis[t][0]) puts("-1") ;
	else printf("%d\n", dis[t][0] / 3) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/





Measured memory_bytes: 8064
fun main(args: Array<String>) {
    val (n, m) = getInts()
 
    val a = IntArray(n) { it }
    repeat(m) {
        val (x, y) = getInts().map { it - 1 }
        val p1 = parentOf(x, a)
        val p2 = parentOf(y, a)
        if (p1 < p2) {
            a[p2] = p1
        } else {
            a[p1] = p2
        }
    }
 
    val k = HashMap<Int, Int>()
    a.indices.forEach {
        val p = parentOf(it, a)
        k[p] = (k[p] ?: 0) + 1
    }
    println(k.map { it.value }.max())
}
 
fun parentOf(k: Int, a: IntArray) : Int {
    if (a[k] == k) return k
    else return parentOf(a[k], a).also {
        a[k] = it
    }
}
 
fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

Measured memory_bytes: 66908
import java.util.Scanner;

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

        double[] incomingDouble = new double[3];
        int first = scLine.indexOf(" ");
        int second = scLine.lastIndexOf(" ");
        double current = 0;

        incomingDouble[0] = Double.parseDouble(scLine.substring(0, first));
        incomingDouble[1] = Double.parseDouble(scLine.substring(first + 1, second));
        incomingDouble[2] = Double.parseDouble(scLine.substring(second + 1));

        if(Math.ceil(incomingDouble[0]/incomingDouble[2]) <= incomingDouble[1]){
            System.out.println("Yes");
        }
        else{
        	System.out.println("No");
        }
	}
}


Measured memory_bytes: 35780
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000000
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}



//=============================================ASIFAZAD==============================================//
const int N = 500050;
vi col(N), tree(4*N);

void upd(int cur, int strt, int en, int ind, int val)
{
    if(strt == en)
        tree[cur] = val;
    else
    {
        int mid = (strt + en)/2;
        if(ind <= mid)
            upd(2*cur, strt , mid, ind, val);
        else
            upd(2*cur + 1, mid + 1, en, ind, val);
        tree[cur] = tree[2*cur] + tree[2*cur+1];
    }
}

int dif(int cur, int strt, int en, int l, int r)
{
    if(strt > r || en < l)
        return 0;
    if(strt >= l && en <= r)
        return tree[cur];
    int mid = (strt + en)/2;
    return dif(2*cur, strt, mid, l, r) + dif(2*cur + 1, mid + 1, en, l, r);
}

int32_t main()
{
    io;
    int n, q;
    cin>>n>>q;
    for(int i = 1; i<= n;i++)
        cin>>col[i];

    vector<pair<int, pii> > qr;
    for(int i = 1; i<= q; i++)
    {
        int l, r;
        cin>>l>>r;
        qr.pb({r, {l, i}});
    }
    sort(qr.begin(), qr.end());

    vi ans(q+1), lst(n+1, -1);

    for(int i = 1, actq = 0; i<= n; i++)
    {
        if(lst[col[i]] == -1)
        {
            lst[col[i]] = i;
            upd(1,1, n, i, 1);
        }
        else
        {
            upd(1,1,n, lst[col[i]], 0);
            lst[col[i]] = i;
            upd(1,1,n, i, 1);
        }

        while(qr[actq].first == i)
        {
            int l  = qr[actq].second.first, r = qr[actq].first, ind = qr[actq].second.second;
            ans[ind] = dif(1,1,n, l, r);
            actq++;
        }
    }

    for(int i = 1; i<= q; i++)
        cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 23292
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main(){
	int n;	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)	cin>>a[i];
	vector<int> end=a;	sort(end.begin(),end.end());
	vector<int> odd;
	set<int> oddend;
	for(int i=0;i<n;i++){
		if(i%2){
			odd.push_back(a[i]);
			oddend.insert(end[i]);
		}
	}
	int ret=0;
	for(int i=0;i<odd.size();i++){
		if(oddend.find(odd[i])==oddend.end()){
			ret++;
		}
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 3580
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):	
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10050:
				ans[v]+=1
for i in range(n):
	print(ans[i+1])


Measured memory_bytes: 9108
from collections import defaultdict

h, w, m = map(int, input().split())
HW = [list(map(int, input().split())) for _ in range(m)]
dicHW = defaultdict(set)

for h, w in HW:
  dicHW[h].add(w)

hd = defaultdict(int)
wd = defaultdict(int)

for i, j in HW:
  hd[i] += 1
  wd[j] += 1

hd = list(hd.items())
wd = list(wd.items())

hd.sort(key=lambda x: -x[1])
wd.sort(key=lambda x: -x[1])

kouhoh = []
kouhow = []

for i, j in hd:
  if j < hd[0][1]:
    break
  else:
    kouhoh.append(i)

for i, j in wd:
  if j < wd[0][1]:
    break
  else:
    kouhow.append(i)

for i in kouhoh:
  for j in kouhow:
    if j not in dicHW[i]:
      ans = hd[0][1] + wd[0][1]
      print(ans)
      exit()

ans = hd[0][1] + wd[0][1] - 1  
print(ans)


Measured memory_bytes: 307184
<?php
//https://atcoder.jp/contests/abc146/submissions/8638442
$N = trim(fgets(STDIN));
//list($A,$B,$X) =  explode(" ",trim(fgets(STDIN)));

$g = array();
$ans = array();

for($i=0;$i<$N-1;$i++) {
  list($a,$b) = explode(" ",trim(fgets(STDIN)));
  $a--;$b--;
  $g[$a][]=new Edge($b,$i);
  $g[$b][]=new Edge($a,$i);
}
dfs(0);
printf("%d\n",max($ans));
for($i=0;$i<$N-1;$i++) {
  printf("%d\n",$ans[$i]);
}

Class Edge {
  public $to;
  public $id;
  function __construct($t,$i) {
    $this->to = $t;
    $this->id = $i;
  }
}

function dfs($v,$c=-1,$p=-1)
{
  global $g,$ans;
  $k = 1;
  $cnt=0;
  if (isset($g[$v])) {
    $cnt = count($g[$v]);
  }
  for($i=0;$i<$cnt;$i++) {
    $u = $g[$v][$i]->to;
    $ei = $g[$v][$i]->id;
    if ($u == $p) continue;
    if ($k == $c) ++$k;
    $ans[$ei]=$k;++$k;
    dfs($u,$ans[$ei],$v);
  }
}


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

using namespace std;
int main(){
    int n,a=0;
    cin >> n;
    vector<int> p(n);
    for (int i=0;i<n;i++){
        cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    for(int i=0;i<n;i+=2){
        a+=p.at(i);
    }
    for(int i=1;i<n;i+=2){
        a-=p.at(i);
    }
    cout << a << endl;



}


Measured memory_bytes: 256
import java.util.*;

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

    if(n%2 == 1){
      System.out.println("No");
      return;
    }
    
    String sub1 = s.substring(0,n/2);
    String sub2 = s.substring(n/2, n);
    
    if(sub1.equals(sub2)){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}


Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

        
    
int main(){
  int n, m; cin >> n >> m;  ll a[n]; ll sum = 0;
  rep(i, n){
    cin >> a[i]; a[i]--;
  }
  ll ans[2*m] = {}; ll ato[n-1] = {};
  rep(i, n-1){
    if(a[i+1]-a[i]==1){
      sum++; continue;
    }
    ans[(a[i]+2)]++;
    ato[i] = a[i+1]+1;
    if(a[i+1]<a[i]) ato[i]+=m;
    ans[ato[i]]--;
    sum+=(a[i+1]-a[i]+m)%m;
    //cout << sum << endl;
  }
  //rep(i, 2*m){
    //cout << ans[i] << " ";
  //}
  //cout << endl;
  rep(i, 2*m-1){
    ans[i+1]+=ans[i];
  }
  //rep(i, 2*m){
    //cout << ans[i] << " ";
  //}
  //cout << endl;//単純imos完了！
  rep(i, n-1){
    ans[ato[i]]-=(a[i+1]-a[i]-1+m)%m;
    //cout << (a[i+1]-a[i]-1+m)%m << endl;
  }
  //rep(i, 2*m){
    //cout << ans[i] << " ";
  //}
  //cout << endl;
  rep(i, 2*m-1){
    ans[i+1]+=ans[i];
  }
   //rep(i, 2*m){
    //cout << ans[i] << " ";
  //}//あとは合わせるだけの段階
  //cout << endl;
  rep(i, m){
    ans[i]+=ans[i+m];
  }
  ll tmp = -longinf;
  rep(i, m){
    tmp = max(tmp, ans[i]);
  }
  cout << sum-tmp << endl;
}

Measured memory_bytes: 6724
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
#pragma endregion

int main()
{
  init_main();

  string s, t;
  cin >> s >> t;
  Yes(s == t.substr(0, s.length()));
  return 0;
}


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

int main() {
  int n,k;

  cin >> n >> k;

  vector<int> h(n,0);
  vector<int> dp(n,1e9);

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

  dp[0] = 0;

  for(int i=0;i<n;i++) {
    for(int j=0;j<k+1;j++) {
      if(i+j<=n) {
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        //        cout << dp[i] << endl;
      }
      else continue;
    }
  }

  // for(int i=0;i<n;i++) {
  //   cout << dp[i] << endl;
  // }


  cout << dp[n-1] << endl;

  return 0;
}


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

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

    int p[n];
    int expensive=0;
    int total=0;
    for(int i=0; i<n; i++){
        cin >> p[i];
        if(expensive<p[i]){
            expensive=p[i];
        }
        total+=p[i];
    }

    cout << total-expensive/2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		int ans = t / a * b;
		out.println(ans);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 21204
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split(' ');
  var x = Number(inputs[0]);
  var y = Number(inputs[1]);

console.log(x*y,(x+y)*2);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15504
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var n = a[0];
            var m = a[1];
            var aa = Console.ReadLine().Trim().Split(' ').Select(int.Parse).OrderBy(_ => _).ToArray();
            var bc = new List<int[]>();
            for (int i = 0; i < m; i++)
            {
                bc.Add(Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray());
            }

            var j = Hoge(bc).GetEnumerator();
            for (int i = 0; i < aa.Length; i++)
            {
                if(!j.MoveNext())
                {
                    break;
                }
                if (aa[i] < j.Current)
                {
                    aa[i] = j.Current ;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(aa.Sum(_ => (long)_));

        }

        static IEnumerable<int> Hoge(List<int[]> bc)
        {
            foreach (var item in bc.OrderByDescending(_ => _[1]))
            {
                for (int i = 0; i < item[0]; i++)
                {
                    yield return item[1];
                }
            }
        }
    }
}


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

int main(void) {
  string tmp;
  
  while (cin >> tmp) {
    int num[10];
    for (int i = 0; i < 10; i++) {
      num[i] = tmp[i] - '0';
    }

    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9 - i; j++) {
        num[j] = num[j] + num[j+1];
      }
    }
    num[0] %= 10;

    cout << num[0] << endl;
  }

  return 0;
}

Measured memory_bytes: 1180
#include<iostream>

using namespace std;

int main(void){
  int m,a[8],b[8],g,n,dp[8][1001];

  while(cin >> m,m){

    for(int i=0;i<8;i++){
      for(int j=0;j<1001;j++){
	dp[i][j]=0;
      }
    }

    for(int i=0;i<m;i++)
      cin >> a[i] >> b[i];
    
    for(int j=0;j<=b[0];j++){
      dp[0][a[0]*j]++;
    }
    
    
    for(int i=0;i<m-1;i++){
      for(int j=0;j<1001;j++){
	for(int k=0;k<=b[i+1];k++){
	  if(j+(a[i+1]*k)<1001)
	    dp[i+1][j+(a[i+1]*k)]+=dp[i][j];
	}
      }
    }
    
    cin >> g;
    while(g--){
      cin >> n;
      cout << dp[m-1][n] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

    int n, k;
    cin >> n >> k;

    int count = 0;
    while (n)
    {
        n /= k;
        count++;
    }
    if (count == 0)
        count = 1;
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	ll mx=(n-1)*(n-2)/2;
	if(k>mx){
		puta(-1);
		return 0;
	}
	vector<pll> e;
	rep(i,n-1){
		e.emplace_back(i+1,n);
	}
	mx-=k;
	range(i,1,n)range(j,i+1,n){
		if(mx){
			e.emplace_back(i,j);
			mx--;
		}else{
			i=j=n;
			break;
		}
	}
	puta(e.size());
	for(auto&edge:e)puta(edge.fs, edge.sc);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c, d, e; scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
	printf("%d\n", c * 60 + d - (a * 60 + b) - e);
}


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

int main() {
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  int jump1=abs(h[n-1]-h[n-2]),jump2=0;
  int ans=jump1;
  for(int i=n-3;i>=0;i--)
  {
    ans = min( abs(h[i]-h[i+1])+jump1,abs(h[i]-h[i+2])+jump2 );
    tie(jump1,jump2) = make_tuple(ans,jump1);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
import sys
from collections import Counter
input = sys.stdin.readline

n = int(input())
s = []
memo = []
ans = ''
check = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
check_cnt = [50] * 26
for i in range(n):
    s.append(list(input().rstrip('\n')))
    s[i].sort()
    memo.append(list(Counter(s[i]).items()))

for i in range(n):
    for check_m in range(26):
        flg = False
        for j in range(len(memo[i])):
            if check[check_m] == memo[i][j][0]:
                if check_cnt[check_m] > memo[i][j][1]:
                    check_cnt[check_m] = memo[i][j][1]
                flg = True
                break
        if flg:
            continue
        else:
            check_cnt[check_m] = 0

for i in range(26):
    for j in range(check_cnt[i]):
        ans += check[i]
print(ans)


Measured memory_bytes: 3444
#include<stdio.h>
#define name 10
#define N 100005
typedef struct{
 char s[name];
  int time;
}R;
R a[N+1];
int head,tail;
void Enqueue(R );
R Dequeue(void);
int main()
{
  int i,n,q,T=0;
  R y;
  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s%d",y.s,&y.time);
    Enqueue(y);
  }
  while(n!=0){
    y=Dequeue();
    if(y.time>q){
      y.time=y.time-q; 
      T+=q;
      Enqueue(y);
    } 
    else{
      T=T+y.time;
      printf("%s %d\n",y.s,T);
      n--;
    }
  }
  return 0;
}
 
void Enqueue(R Y){
  if(N==tail) tail=0; 
    a[tail]=Y;
    tail++;
}
 
R Dequeue(void){
  if(head==N) head=0;
  return a[head++];
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define sz(c) int(c.size())
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define vlong long long

int main() {
	string x;
	cin >> x;
	string s = "";
	for (int i = 0; i < sz(x); ++i) {
		if(i % 2 == 0)s += x[i];
	}
	cout << s << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,X;cin>>N>>X;
  std::vector<int> ans;
  while(N||X){
    std::vector<int> v(X);
    for(int i=0;i<X;i++)cin>>v[i];
    sort(v.begin(),v.end());
    if(v[0]){
      int res=0,tmp=0;
      for(int i=1;i<X;i++){
        if(v[i]==v[i-1]+1){tmp++;res=max(res,tmp);}
        else tmp=0;
      }
      ans.push_back(res+1);
    }
    else{
      int res=0,tmp=0,tmp2=0;
      for(int i=2;i<X;i++){
        if(v[i]==v[i-1]+1){
          tmp++;tmp2++;res=max(tmp2,res);
          res=max(res,tmp+1);
        }
        else if(v[i]==v[i-1]+2){
          tmp2=tmp+2;
          tmp=0;
          res=max(res,tmp2);
        }
        else{tmp=tmp2=0;}
      }
      if(X>=2&&res<=1)res=1;
      ans.push_back(res+1);
    }
    cin>>N>>X;
  }
  for(int p:ans)cout<<p<<endl;
}



Measured memory_bytes: 3352
import fractions as f
n=int(input())
t=int(input())
ans=0
if n==1:
    print(t)
else:
    for i in range(n-1):
        s=int(input())
        t=s*t//f.gcd(t,s)
        if ans<t:
            ans=t
        #print(ans)
    print(ans)

Measured memory_bytes: 5304
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(L,R);
    if(R%2019>L%2019){
        // 全て使える
        if(R/2019>L/2019){
            cout << 0 << nn;
            return 0;
        }else{
            int ans = 2019 + 1;
            for(int i=L%2019;i<=R%2019;i++){
                for(int j=i+1;j<=R%2019;j++){
                    ans = min(ans,(i*j)%2019);
                }
            }
            cout << ans << nn;
            return 0;
        }
    }else{
        cout << 0 << nn;
        return 0;
    }
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    set<string> bag;
    int n; cin >> n;
    while(n--) {
        string s; cin >> s;
        bag.insert(s);
    }
    cout << bag.size() << endl;
    return 0;
}



Measured memory_bytes: 19136
#include <stdio.h>
#include <math.h>

typedef long long ll;

int main() {

	ll x;
	double xx;

	scanf("%lld",&x);

	xx = (double)x;

	ll ans = (ll)floor(xx/5.5);

	if (x % 11 == 6 || x % 11 == 0) {
		printf("%lld\n", ans);
	}
	else {
		printf("%lld\n",ans+1ll);
	}

	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

int N,M,K,L,R,H,W;
//long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;

int dp[201][201][201][3];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N;
	string s;
	cin>>s;
	vector<int>v;
	int one=0,two=0,zero=0;
	for(auto i:s){
		if(i=='R'){
			v.push_back(0);
			zero++;
		}
		else if(i=='G'){
			v.push_back(1);
			one++;
		}
		else {
			v.push_back(2);
			two++;
		}
	}
	if(zero>(N+1)/2||one>(N+1)/2||two>(N+1)/2){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<=200;i++)for(int j=0;j<=200;j++)for(int k=0;k<200;k++)for(int l=0;l<3;l++)dp[i][j][k][l]=MOD;
	vector<pair<int,int>>oneP;
	vector<pair<int,int>>twoP;
	vector<pair<int,int>>zeroP;
	vector<int>oneplace;
	vector<int>twoplace;
	vector<int>zeroplace;
	int a=0,b=0,c=0;
	for(int i=0;i<N;i++){
		if(v[i]==1){
			oneP.push_back({c,b});
			oneplace.push_back(i);
			a++;
		}
		else if(v[i]==2){
			twoP.push_back({c,a});
			twoplace.push_back(i);
			b++;
		}
		else{
			zeroP.push_back({a,b});
			zeroplace.push_back(i);
			c++;
		}
	}
	if(one)dp[0][1][0][1]=oneplace[0];
	if(two)dp[0][0][1][2]=twoplace[0];
	if(zero)dp[1][0][0][0]=zeroplace[0];
	for(int i=0;i<=zero;i++){
		for(int j=0;j<=one;j++){
			for(int k=0;k<=two;k++){
				if(!i&&!j&&!k)continue;
				for(int l=0;l<3;l++){
					if(l!=0&&i<zero){
						dp[i+1][j][k][0]=min(dp[i+1][j][k][0],dp[i][j][k][l]+zeroplace[i]+max(0,j-zeroP[i].first)+max(0,k-zeroP[i].second)-i-j-k);
					}
					if(l!=1&&j<one){
						dp[i][j+1][k][1]=min(dp[i][j+1][k][1],dp[i][j][k][l]+oneplace[j]+max(0,i-oneP[j].first)+max(0,k-oneP[j].second)-i-j-k);
					}
					if(l!=2&&k<two){
						dp[i][j][k+1][2]=min(dp[i][j][k+1][2],dp[i][j][k][l]+twoplace[k]+max(0,i-twoP[k].first)+max(0,j-twoP[k].second)-i-j-k);
					}
				}
			}
		}
	}
	for(int i=0;i<=zero;i++){
		for(int j=0;j<=one;j++){
			for(int k=0;k<=two;k++){
				for(int l=0;l<3;l++){
				//	cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<dp[i][j][k][l]<<endl;
				}
			}
		}
	}
	int ans=MOD;
	for(int i=0;i<3;i++)ans=min(ans,dp[zero][one][two][i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 98396
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
 
class Node{
public:
    int location;
    int p,l,r;
    Node(){}
};
 
class Point{
public:
    int id,x,y;
    Point(){}
    Point(int id,int x,int y):id(id),x(x),y(y){}
    bool operator <(const Point &p)const{
        return id<p.id;
    }
 
    void print(){
        printf("%d\n",id);
    }
};
 
static const int MAX=1000000;
static const int NIL=-1;
 
int N;
Point P[MAX];
Node T[MAX];
int np;
 
bool lessX(const Point &p1,const Point &p2){
    return p1.x<p2.x;
}
 
bool lessY(const Point &p1,const Point &p2){
    return p1.y<p2.y;
}
 
int makeKDTree(int l,int r,int depth){
    if(l>=r)return NIL;
    int mid=(l+r)/2;
    int t=np++;
    if(depth%2==0){
        sort(P+l,P+r,lessX);
    }else{
        sort(P+l,P+r,lessY);
    }
    T[t].location=mid;
    T[t].l=makeKDTree(l,mid,depth+1);
    T[t].r=makeKDTree(mid+1,r,depth+1);
    return t;
}
 
void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
    int x=P[T[v].location].x;
    int y=P[T[v].location].y;
    if(sx<=x && x<=tx && sy<=y && y<=ty){
        ans.push_back(P[T[v].location]);
    }
    if(depth%2==0){
        if(T[v].l!=NIL){
            if(sx<=x)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[v].r!=NIL){
            if(x<=tx)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
        }
    }else{
        if(T[v].l!=NIL){
            if(sy<=y)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[v].r!=NIL){
            if(y<=ty)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
        }
    }
}
 
int main(void){
    int x,y;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d %d",&x,&y);
        P[i]=Point(i,x,y);
        T[i].l=T[i].r=T[i].p=NIL;
    }
    np=0;
    int root=makeKDTree(0,N,0);
 
    int q;
    scanf("%d",&q);
    int sx,tx,sy,ty;
    vector<Point> ans;
    for(int i=0;i<q;i++){
        scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
        ans.clear();
        find(root,sx,tx,sy,ty,0,ans);
        sort(ans.begin(),ans.end());
        for(int j=0;j<ans.size();j++){
            ans[j].print();
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 15848
#include <stdio.h>
int main(void){
    
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);
    if(a == 5 && b == 5 && c == 7){
        puts("YES");
    }else if(a == 5 && b == 7 && c == 5){
        puts("YES");
    }else if(a == 7 && b == 5 && c == 5){
        puts("YES");
    }else{
        puts("NO");
    }


    return 0;
}

Measured memory_bytes: 1620
N, A, B, C, D = map(int, input().split())
S = input()

flag = True
if "##" in S[A+1:max(C, D)]:
    flag = False
if C > D:
    if "..." not in S[B-2:D+1]:
        flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3572
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int N, M;
bool visited[50];
bool graph[50][50];
bool ALL;

void DFS(int v){
  visited[v] = true;
  rep(v2, N){
    if(!(graph[v][v2])) continue;
    if(visited[v2]) continue;
    DFS(v2);
  }
}
  


int main(){
  cin >> N >> M;
  int a[M], b[M];
  rep(i, 51){
    graph[i][i]=false;
  }
  rep(i, M){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]]=true;
    graph[b[i]][a[i]]=true;
  }
  int cnt = 0;
  rep(i, M){
    ALL = true;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    for (int j = 0;j< N; ++j) visited[j] = false;
    DFS(0);
    rep(j, N){
      if(!(visited[j])) {ALL=false; }
    }
      if(!(ALL)) cnt++;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  cout << cnt << endl;
}

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

int main(void){
  int N, cnt;
  bool ans = false;
  cin >> N;
  for(int i = 0; i < 3; i++){
    cnt = N % 10;
    if(cnt == 7){
      ans = true;
      break;
    }
    N = N / 10;
  }
  if(ans) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3584
import sys
input = sys.stdin.readline
mod=10**9+7

N,M = map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))

DP=[[0]*(N+1) for i in range(M+1)]
#DP[0][0]=1
SUM=[[0]*(N+1) for i in range(M+1)]
SUM[0]=[1]*(N+1)
for i in range(M+1):
    SUM[i][0]=1

for j in range(1,M+1):
        
    for i in range(1,N+1):
        if S[i-1]==T[j-1]:
            DP[j][i]=SUM[j-1][i-1]

    S2=0
    for i in range(1,N+1):
        S2=(S2+DP[j][i])%mod
        SUM[j][i]=(SUM[j-1][i]+S2)%mod
    

ANS=0
for i in range(M+1):
    ANS=(ANS+sum(DP[i]))%mod

print((ANS+1)%mod)

Measured memory_bytes: 105692
#include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
     
    int main() {
     
        int n;
        scanf("%d", &n);
        int a;
        for (int i = 0; i < n; i++) {
            scanf("%d", &a);
            if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
                printf("DENIED");
                return 0;
            }
        }
        printf("APPROVED");
     
        return 0;
     
    }

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

int main()
{
    int n,x;
    std::cin >> n >> x;
    std::vector<int>  l(n+1);
    for(int i  = 1 ; i <= n;i++){
        std::cin >> l[i];
    }
    int cur = 0,cnt = 0;
    for(int i = 0;i <= n; i++){
        cur += l[i];
        if(cur <= x)cnt++;
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 256
from collections import defaultdict
MOD = 10 ** 9 + 7

n = int(input())
alst = list(map(int, input().split()))
dd = defaultdict(int)
ans = 0
for a in alst:
    ans += pow(a, MOD - 2, MOD)
    ans %= MOD
    num = a
    for i in range(2, int(a ** 0.5) + 1):
        cnt = 0
        while num % i == 0:
            num //= i
            cnt += 1
        if cnt > 0:
            dd[i] = max(dd[i], cnt)
    if num != 1:
        dd[num] = max(dd[num], 1)
for key, value in dd.items():
    ans *= pow(key, value, MOD)
    ans %= MOD
print(ans)

    

Measured memory_bytes: 10572
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main(){
   int N;
   std::cin >> N;
   std::vector<int> s(N);
   for (int i=0; i<N; ++i){
      std::cin >> s.at(i);
   }
   std::sort(s.begin(), s.end());
   int sum = std::accumulate(s.begin(), s.end(), 0);
   if (sum % 10 != 0){
      std::cout << sum << std::endl;
   } else{
      for (int i=0; i<N; i++){
         int sum2 = sum - s.at(i);
         if (sum2 % 10 != 0){
            std::cout << sum2 << std::endl;
            break;
         } else if (i == N-1){
            std::cout << 0 << std::endl;
         }
      }
   }


}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <climits>
using namespace std;
 
int main() {
    int mask = 0;
    int cnt = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        a /= 400;
        if (a > 7) {
            ++cnt;
        } else {
            mask |= (1 << a);
        }
    }
 
    int res = 0;
    for (int i = 0; i < 8; ++i) {
        if (mask & (1 << i)) ++res;
    }
    cout << max(1, res) << " " << res + cnt;
 
	return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var nw=arr.shift().split(" ").map(Number);
   if(nw.join(" ")=="0 0")break;
   var n=nw[0];
   var w=nw[1];
   var V=[];
   for(var i=0;i<n;i++)V.push(arr.shift()-0);
   V.sort(function(a,b){return a-b;});
   var p=[];
   var len=(V[V.length-1]-(V[V.length-1]%w))/w;
   for(var i=0;i<len+1;i++)p.push(0);
   V.forEach(function(v){
      p[(v-(v%w))/w]++;
   });
   var d=Math.max.apply(null,p);
   var ans=0;
   p.forEach(function(v,i){
      ans+=(len-i)/len*v/d;
   });
   console.log((ans+0.01).toFixed(6));
}

Measured memory_bytes: 15988
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 17:22:34 2020

@author: shinba
"""
import sys 
n,a,b = map(int,input().split())

if (b-a) % 2 == 0:
    print((b-a)//2)
    sys.exit()
    
k = (a+b-1)//2

print(min(k,n-k))



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char a[4];
	cin>>a;
	if (a[0]!=a[1]&&a[1]!=a[2]&&a[2]!=a[0])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n, a, b;
    cin >> n >> a >> b;
    Int f, s, t;
    f = s = t = 0;
    for (Int i = 0; i < n; i++) {
        Int p;
        cin >> p;
        if (p <= a) f++;
        else if (a < p && p <= b) s++;
        else t++;
    }
    dump(min(f, min(s, t)));
    return 0;  
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,i,j,l,t,sum=0;
  while(scanf("%d",&n)!=EOF){
    for(i=0;i<=9;i++){
      for(j=0;j<=9;j++){
	for(l=0;l<=9;l++){
	  for(t=0;t<=9;t++){
	    if(i+j+l+t==n){
	      sum++;
	    }
	  }
	}
      }
    }
    printf("%d\n",sum);
    sum=0;
  }
  return 0;
}

Measured memory_bytes: 0