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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < (EPS))

#define COUNTER_CLOCKWISE (1)
#define CLOCKWISE (-1)
#define ONLINE_BACK (2)
#define ONLINE_FRONT (-2)
#define ON_SEGMENT (0)

struct Point 
{
  double x, y;
  
  Point() {}
  
  Point(double x, double y) : x(x), y(y) {}
  
  void input() { scanf("%lf %lf", &x, &y); }
  void output() { printf("%.10f %.10f\n", x, y); }
  double abs() { return (sqrt(norm())); }
  double norm() { return (x * x + y * y); }
  
  Point operator + (Point d) { return (Point(x + d.x, y + d.y)); }
  Point operator - (Point d) { return (Point(x - d.x, y - d.y)); }
  Point operator - () { return (Point(-x, -y)); }
  Point operator * (double a) { return (Point(x * a, y * a)); }
  Point operator / (double a) { return (Point(x / a, y / a)); }
  
};

struct Segment
{
  Point p1, p2;
  
  Segment() {}
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}

  void input() { p1.input(); p2.input(); }
  
};

typedef Point Vector;
typedef vector < Point > Polygon;
typedef Segment Line;

double dot(Vector a, Vector b)
{
  return (a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
  return (a.x * b.y - a.y * b.x);
}

Point project(Line l, Point p)
{
  Vector base = l.p2 - l.p1;
  return (l.p1 + base * (dot(p - l.p1, base) / base.norm()));
}

Point reflect(Line l, Point p)
{
  return (-p + project(l, p) * 2.0);
}


int ccw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0, b = p2 - p0;
  
  if(cross(a, b) > EPS) return (COUNTER_CLOCKWISE);
  if(cross(a, b) < -EPS) return (CLOCKWISE);
  if(dot(a, b) < -EPS) return (ONLINE_BACK);
  if(a.norm() < b.norm()) return (ONLINE_FRONT);
  
  return (ON_SEGMENT);
}

bool intersect(Point p1, Point p2, Point p3, Point p4)
{
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

bool intersect(Segment s1, Segment s2)
{
  return (intersect(s1.p1, s1.p2, s2.p1, s2.p2));
}

double getDistanceLP(Line l, Point p)
{
  return (abs(cross(l.p2 - l.p1, p - l.p1) / (l.p2 - l.p1).abs()));
}

double getDistanceSP(Segment s, Point p)
{
  if(dot(s.p2 - s.p1, p - s.p1) < 0.0) return ((p - s.p1).abs());
  if(dot(s.p1 - s.p2, p - s.p2) < 0.0) return ((p - s.p2).abs());
  return (getDistanceLP(s, p));
}

double getDistance(Segment s1, Segment s2)
{
  double ans;

  if(intersect(s1, s2)) {
    ans = 0.0;
  } else {
    ans = min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2));
    ans = min(ans, min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)));
  }

  return (ans);
}

Point getCrossPoint(Segment s1, Segment s2)
{
  double d1 = getDistanceLP(s2, s1.p1);
  double d2 = getDistanceLP(s2, s1.p2);
  
  return (s1.p1 + (s1.p2 - s1.p1) * (d1 / (d1 + d2)));
}

main()
{
  int n;

  cin >> n;
  for(int i = 0; i < n; i++) {
    Segment s1, s2;
    s1.input(); s2.input();
    getCrossPoint(s1, s2).output();
  }

  return (0);
}

Measured memory_bytes: 3208
n = int(input())
a = []
b = []
c = []
for i in input().split():
    a.append(int(i)-1)
for i in input().split():
    b.append(int(i))
for i in input().split():
    c.append(int(i))
    
ans = 0
for i in range(len(a)):
    ans += b[a[i]]
    if i < len(a)-1 and a[i+1] == a[i]+1:
        ans += c[a[i]]
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int N,K,a,b,q;
long long sol;
int main()
{
    cin>>N>>K;
    for(b=K+1;b<=N;b++)
    {
        q=(N+1)/b -1;
        sol=sol+(q+1)*(b-K);
        a=(q+1)*b+K;
        if(a<=N) sol=sol+min(N-a+1,b-K);
    }
    if(K==0) sol-=N;
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
while(True):
    try:
        n, m = map(int, input().split())
        ab = [list(map(int, input().split())) for _ in range(n)]
        cd = [list(map(int, input().split())) for _ in range(m)]
    except EOFError:
        exit()
    for a, b in ab:
        dist = [abs(a - c) + abs(b - d) for c, d in cd]
        print(dist.index(min(dist)) + 1)



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




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<ll,ll>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	ll n;
	cin >> n;
	if (n % 2 == 1) {
		
			cout << n * 2 << endl;
		
	}
	else {
		cout << n << endl;
	}

	return 0;
}













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

#define rep(i, n) for(int i = 0;i < (n);i++)
#define all(c) (c).begin(),(c).end()
#define min(a, b) ((a) <= (b) ? (a) : (b))
#define max(a, b) ((a) >= (b) ? (a) : (b))

typedef unsigned int uint;

using namespace std;

int main() {
  while(true) {
    int n;
    cin >> n;
    if(n == 0) break;

    map<char, char> table;
    rep(i, n) {
      char k, v;
      cin >> k >> v;
      table[k] = v;
    }

    int m;
    cin >> m;
    rep(i, m) {
      char c;
      cin >> c;
      if(table.find(c) != table.end()) {
        cout << table[c];
      }
      else {
        cout << c;
      }
    }
    cout << endl;
  }

  return 0;
}

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

//????????????????????¨????????????????????????

//????????¨????§???????(Point?????????)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b))<EPS)
class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a*x, a*y); }
	Point operator / (double a) { return Point(x / a, y / a); }

	double Abs() { return sqrt(norm()); }
	double norm() { return x*x, y*y; }

	bool operator < (const Point &p)const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator == (const Point &p)const {
		return fabs(x - p.x) < EPS&&fabs(y - p.y) < EPS;
	}
};

//?????????????????¨????§???????????????????????????????
typedef Point Vector;

//?§????p1??¨??????p2?????????
struct Segment { Point p1, p2; };

//??????
typedef Segment Line;

//???
class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};

//????§???¢
typedef vector<Point> Polygon;

//?????????????????????????????§??????
double norm(Vector a) {
	return a.x*a.x + a.y*a.y;
}
double sqrt(Vector a) {
	return sqrt(norm(a));
}

//????????????a??¨b?????????
double dot(Vector a, Vector b) {
	return a.x*b.x + a.y*b.y;
}

//????????????a??¨b?????????
double cross(Vector a, Vector b) {
	return a.x*b.y - a.y*b.x;
}

//????????????a??¨b?????´?????????
bool isOrtogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}
bool isOrtogonal(Point a1, Point a2, Point b1, Point b2) {
	return isOrtogonal(a1 - a2, b1 - b2);
}
bool isOrtogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 -s2.p1), 0.0);
}

//????????????a??¨b???????????????
bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2) {
	return isParallel(a1 - a2, b1 - b2);
}
bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

//??????s????????????p????°???±
Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base*r;
}

int main() {
	double xp1, yp1, xp2, yp2;
	cin >> xp1 >> yp1 >> xp2 >> yp2;
	Point p1 = { xp1,yp1 }, p2 = { xp2,yp2 };
	Segment s = { p1,p2 };
	int n;
	cin >> n;
	double a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		Point p = { a,b };
		Point ans = project(s, p);
		cout << fixed << setprecision(10) << ans.x <<" "<<ans.y <<endl;
	}
}

Measured memory_bytes: 3272
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
res = 0
ave = 1000000000
for i in range(len(H)):
    temp = T-H[i]*0.006
    if ave>abs(A-temp):
        res=i+1
        ave=abs(A-temp)
print(res)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       String line = sc.nextLine();
       String []array = line.split("");
       array[3] = "8";
       
       for(int i = 0; i < array.length; i++){
           if(i == array.length){
               System.out.println(array[i]);
           }else{
               System.out.print(array[i]);
           }
           
       }
    }
}


Measured memory_bytes: 20812
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> map = new TreeMap<>();
		for (int i = 1; i <= n; i++) {
			int a = sc.nextInt();
			map.put(a, i);
		}
		
		map.entrySet().stream().map(e -> e.getValue() + " ").forEach(System.out::print);
		System.out.println();
	}
}


Measured memory_bytes: 73988
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String line1 = sc.next();
        String line2 = sc.next();
        
        if(line1.charAt(0) == line2.charAt(2) &&
           line1.charAt(1) == line2.charAt(1) &&
           line1.charAt(2) == line2.charAt(0)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23124
const call = function (n) {
    var out = '';
    for (var i = 1; i <= n; i++) {
        if (i % 3 === 0 ) {
            out += ' ' + i;
            continue;
        }
        for (var x = i; x > 0; x = Math.floor(x /10)) {
            if ( x % 10 === 3 ) {
                out += ' ' + i;
                break;
            }
        }
    }
    console.log(out);
};

const chunk = require('fs').readFileSync('/dev/stdin', 'utf8');
call(Number(chunk));

Measured memory_bytes: 17500
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

const int M_N=200001;

struct UnionFind{
    int par[M_N];

    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }

    void unite(int x,int y){
        if(x>y){
            par[x]=y;
        }
        else{
            if(par[y]==y) return;
            unite(x,par[y]);
        }
    }

};

map<int,int> mp;

int main(){
    LL N;
    cin >> N;
    vector<LL> a;
    for(int i=0;i<N;i++){
        int s;
        cin >> s;
        a.push_back(s);
        mp[s]=i;
    }
    UnionFind uf,ruf;
    uf.init(N+1);
    ruf.init(N+1);
    for(int i=0;i<N-1;i++){
        uf.unite(a[i+1],a[i]);
    }
    for(int i=N-1;i>0;i--){
       ruf.unite(a[i-1],a[i]);
    }
    LL ans=0;
    for(int i=0;i<N;i++){
        LL l,r;
        l=i-mp[uf.par[a[i]]]-1;
        r=mp[ruf.par[a[i]]]-i-1;
        if(a[i]==uf.par[a[i]]){
            l=i;
        }
        if(a[i]==ruf.par[a[i]]){
            r=N-i-1;
        }
        ans+=a[i]*((r+l+1LL)*(r+l+2LL)/2LL-l*(l+1LL)/2LL-r*(r+1LL)/2LL);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__);
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n, m);
    vector<int> ans(n, 0);
    Rep(2*m){
        Cin(int, k);
        ans[k-1] ++;
    }
    for(auto e : ans) Cout(e);
}

Measured memory_bytes: 256
mod = 10**9 + 7
n = int(input())
lx = list(map(int, input().split()))

d = 0
ans = 0

for i in range(1, n):
  f = 1 if i == 1 else f * (i-1) % mod
  d = (d * i + f) % mod
  ans = (ans * i + (lx[i] - lx[i-1]) * d) % mod

print(ans)

Measured memory_bytes: 62576
package main

import (
	"fmt"
)

func solution(h, w, n int) int {
	max := max(h, w)
	var ans int = 1
	for max*ans < n {
		ans++
	}
	return ans
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	var h, w, n int
	fmt.Scan(&h, &w, &n)
	fmt.Println(solution(h, w, n))
}


Measured memory_bytes: 512
'use strict';

const main = input => {
  input = input.split('\n');
  const N = Number(input[0]);
  const A = input[1].split(' ').map(Number);
  selectionSort(A, N);
};

function selectionSort(A, N) {
  let count = 0;
  for (let i = 0; i < N - 1; ++i) {
    let minj = i;
    for (let j = i; j < N; ++j) {
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    if (i !== minj) {
      const tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
      ++count;
    }
  }
  console.log(A.join(' '));
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 15556
#include<iostream>

using namespace std;

int main(){
  char a[3];
  cin>>a;
  //for(int i=0;i<3;i++){cout<<a[i]<<endl;}
  int cnt=0;
  for(int i=0;i<3;i++){if(a[i]=='1'){cnt++;}}
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
A = list(map(int, input().split()))

B = [0] * (N-1)
minA = A[0]
for i in range(1, N):
    if A[i] < minA:
        minA = A[i]
    B[i-1] = A[i] - minA
B.sort(reverse=True)
ans = 0
for i in B:
    if i == B[0]:
        ans += 1
    else:
        break
print(ans)

Measured memory_bytes: 15020
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1

if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)


Measured memory_bytes: 9204
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

struct OwnVector2
{
	double x, y;
	OwnVector2(double x, double y) :x(x), y(y) {}
	OwnVector2() :OwnVector2(0, 0) {}
	OwnVector2 operator+(const OwnVector2& v)const
	{
		return OwnVector2(x + v.x, y + v.y);
	}
	OwnVector2 operator-(const OwnVector2& v)const
	{
		return OwnVector2(x - v.x, y - v.y);
	}
	OwnVector2 operator*(const double v)const
	{
		return OwnVector2(x*v, y*v);
	}
	bool operator==(const OwnVector2& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const OwnVector2& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const OwnVector2& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const OwnVector2& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return x*x + y*y;
	}
};

OwnVector2 vertices[100];

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

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		double x, y;
		cin >> x >> y;
		vertices[i] = OwnVector2(x, y);
	}

	bool isConvex = true;
	for (int i = 0; i < q; i++)
	{
		OwnVector2 front, back;
		front = vertices[(i + 1) % q] - vertices[i];
		back = vertices[(i + q - 1) % q] - vertices[i];

		if (front.cross(back) < 0)
		{
			isConvex = false;
			break;
		}
	}

	printf(isConvex ? "1\n" : "0\n");
	
	return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>
    #include <string.h>
    #include <algorithm>
    #include <vector>
     
    using namespace std;
     
    int x[1001], n;
    vector<int> child[1001];
     
    int d[1001];
    int up[1001];
    int dd[2][5001];
     
    void dfs(int u) {
    	if (child[u].empty()) {
    		up[u] = 0;
    		return;
    	}
    	for (int i = 0; i < child[u].size(); i++)
    		dfs(child[u][i]);
    	dd[1][0] = 0;
    	int from = 1, to = 0;
    	for (int i = 0; i < child[u].size(); i++) {
    		int w1 = up[child[u][i]], w2 = x[child[u][i]];
    		for (int j = 0; j <= x[u]; j++) {
    			dd[to][j] = (1 << 29);
    			if (j >= w1 && dd[to][j] > dd[from][j - w1] + w2) dd[to][j] = dd[from][j - w1] + w2;
    			if (j >= w2 && dd[to][j] > dd[from][j - w2] + w1) dd[to][j] = dd[from][j - w2] + w1;
    		}
    		from ^= 1; to ^= 1;
    	}
    	int ret = (1 << 30);
    	for (int j = 0; j <= x[u]; j++) if (dd[from][j] < ret) ret = dd[from][j];
    	up[u] = ret;
    }
     
    int main() {
    	scanf("%d", &n);
    	for (int i = 2; i <= n; i++) {
    		int p;
    		scanf("%d", &p);
    		child[p].push_back(i);
    	}
    	for (int i = 1; i <= n; i++)
    		scanf("%d", &x[i]);
    	memset(d, -1, sizeof(d));
    	dfs(1);
    	if (up[1] == (1 << 29)) puts("IMPOSSIBLE");
    	else puts("POSSIBLE");
    	return 0;
    }

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		System.out.println((H-h)*(W-w));
		sc.close();
	}

}

Measured memory_bytes: 23508
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		int count = 0;
		for (; a<=b; a++) {
			if (isDivisor(a, c)) {
				count++;
			}
		}
		System.out.println(count);
	}

	static boolean isDivisor(int a, int c) {
		if (c % a == 0) {
			return true;
		}

		return false;
	}
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	for(int i = 0; i < s.size()-8; i++) {
		cout << s.at(i);
	}
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var dts = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var d = dts[0];
        var t = dts[1];
        var s = dts[2];

        Console.WriteLine(t * s >= d ? "Yes" : "No");
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/29  Problem: 071_abc_b / Link: https://abc071.contest.atcoder.jp/tasks/abc071_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	VI a(26,0);
	string s; cin >> s;
	FOR(i, 0, SZ(s)) {
		a[s[i] - 'a']++;
	}
	FOR(i, 0, 26) {
		if (a[i] == 0) {
			cout << (char)('a' + i) << endl;
			return 0;
		}
	}
	cout << "None" << "\n";

	return 0;
}


Measured memory_bytes: 512
A, B = map(int, input().split())
ans = 0
flag = False
if A%2 == 1:
    flag = True
    A += 1
diff = B-A+1
if diff%4 == 0:
    ans = 0
elif diff%4 == 1:
    ans = B
elif diff%4 == 2:
    ans = 1
else:
    ans = B^1
if flag: ans = ans^(A-1)
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <stdint.h>

int N,W;

int ws[101];
int vs[101];
int64_t cheap[100001];

int main(){
  scanf("%d %d",&N,&W);
  for(int i=0;i<N;i++){
    scanf("%d %d",&ws[i],&vs[i]);
  }
  for(int i=0;i<N;i++){
    for(int j=W;j>=ws[i];j--){
      cheap[j]=std::max(cheap[j],cheap[j-ws[i]]+vs[i]);
    }
  }
  printf("%ld\n",cheap[W]);
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main(){
	int coin[]={1,5,10,50,100,500};
	int answer=0;
	int num;
	for(int i=0;i<6;++i){
		cin>>num;
		answer+=coin[i]*num;
	}
	cout<<(answer>=1000)<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#define N 200000
void hashclear(void);
void hash_inc(long int);
long int hash_getc(long int);

typedef struct {
    long int value;
    long int count;
} kv;

kv mmm[2*N];

void hash_clear(){
    long int t;
    for(t=0;t<2*N;t++){
        mmm[t].count=0;
        mmm[t].value=-1;
    }
}

void hash_inc(long int q){
    long int x=q%(N-1);
    while(mmm[x].value!=-1&&mmm[x].value!=q){
        x++;
    }
    if (mmm[x].value==-1){
        mmm[x].value=q;
        mmm[x].count=1;
    }else{
        mmm[x].count++;
    }
}

long int hash_getc(long int q){
    long int x=q%(N-1);
    while(mmm[x].value!=q){
        if(mmm[x].value==-1) return(0);
        x++;
    }
    return(mmm[x].count);
}

int main(){
    long int n;
    long int a[N];

    long int i,j,c;

    hash_clear();

    scanf("%ld",&n);
    for(i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }

    c=0;
    for(i=0;i<n-1;i++){
            hash_inc(a[i]+i);
    }

    for(j=1;j<n;j++){            
            if(j-a[j]>0) c+=hash_getc(j-a[j]);
    }

    printf("%ld\n",c);



}




Measured memory_bytes: 9540
from random import randint
import sys
input = sys.stdin.readline


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    """
    contest_last_opened = [0]*26  # コンテストiを前回開催した日
    score = 0
    for d, t in enumerate(T, start=1):
        get_score = S[d-1][t-1]
        score += get_score
        contest_last_opened[t-1] = d
        loss_score = 0
        for i in range(26):
            ld = contest_last_opened[i]
            loss_score += C[i]*(d-ld)
        score -= loss_score
    return score


def local_search():
    pass


def main(D, C, S):
    T = []
    for d in range(1, D+1):
        # d日目に一番満足度が高いコンテストを開催する 1-indexed
        # S[d-1]で最大のコンテストiを選ぶ　→ 0点！w
        # d日目にコンテストiを選んだ時に一番スコアが高くなるiを選ぶ
        today_score = calc_score(D, C, S, T + [1])
        today_contest = 1
        for i in range(2, 26 + 1):
            tmp_score = calc_score(D, C, S, T + [i])
            if today_score < tmp_score:
                today_score = tmp_score
                today_contest = i
        T.append(today_contest)
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    T = main(D, C, S)
    print(*T, sep="\n")


Measured memory_bytes: 78948
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int n, m, c, a[20][20], b[20], r = 0;
	scanf("%d%d%d", &n, &m, &c);
	REP(i, m) scanf("%d", &b[i]);
	REP(i, n)REP(j, m) scanf("%d", &a[i][j]);
	REP(i, n) {
		int t = c;
		REP(j, m) t += a[i][j] * b[j];
		if (t > 0) r++;
	}
	printf("%d", r);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define INF (int) 2e9
#define MOD (int) 1e9 + 7

int main(){
    int n;
    while(cin >> n){
        int cnt = 0;
        rep(a, 10){
            rep(b, 10){
                rep(c, 10){
                    rep(d, 10){
                        if(a+b+c+d == n) cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll mod=1e9+7;

//二分累乗法
ll mult(ll n,ll m){//n^m%modを求める
    if(m==1){
        return n%mod;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%mod;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%mod;
    }
}

template <class T>
T comb_mod(T n,T k){
    T ans=1;
    T r=min(k,n-k);
    FOR(i,n-r+1,n+1){
        ans*=(i%mod);
        ans%=mod;
    }
    FOR(i,1,r+1){
        ans*=mult(i,mod-2);
        ans%=mod;
    }
    return ans;
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    map<ll,ll> a=prime_factor(m);
    ll ans=1;
    for(auto itr:a){
        ans=ans*comb_mod(itr.second+n-1,n-1);
        ans=ans%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, begin, end) for (int i = int(begin); i < int(end); i++)
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H), ans(H + 2);
  loop(i, H) cin >> a.at(i);

  loop(i, 2) {
    loop(j, W + 2) ans.at(i * (H + 1)) += '#';
  }

  loop(i, H) {
    ans.at(i + 1) += '#';
    ans.at(i + 1) += a.at(i);
    ans.at(i + 1) += '#';
  }

  loop(i, H + 2) cout << ans.at(i) << endl;;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

int main(){
    string s;
    cin>>s;
    int ans1=0,ans2=0;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='0') ans1++;
        }
        if(i%2==1){
            if(s[i]=='1') ans1++;
        }
    }
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='1') ans2++;
        }
        if(i%2==1){
            if(s[i]=='0') ans2++;
        }
    }
    cout <<min(ans1,ans2)<<endl;
    return 0;
}

Measured memory_bytes: 512
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
        Scanner sc=new Scanner(System.in);
        int h,a;
        h=sc.nextInt();
        a=sc.nextInt();
        int y=h/a;
        if(y*a==h)
        {
            System.out.println(y);
        }else
        {
            System.out.println(y+1);
        }
        
        
	}
}

Measured memory_bytes: 21844
N = int(input())
P = list(map(int,input().split()))

inf = 10 ** 9

Q = [inf] * N

m = inf

con = 0

for i in range(0,N):
  if P[i] <= m:
    m = P[i]
  Q[i] = m
  if P[i] <= Q[i]:
    con += 1

print(con)

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

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

void logic()
{
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    for(int i=0;i<n;++i)
    {
        int x,y;
        cin>>x>>y;
        v.emplace_back(x,y);
    }
    for(int i=2;i<n;++i)
    {
        bool flag=0;
        for(int j=i;j>=i-2;--j)
        {
            if(v[j].first==v[j].second) continue;
            else
            {
                flag=1;
                break;
            }
        }
        if(!flag)
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
    cout<<"\n";
    //incase of wrong answer...stress test your code...do not stress test yourself
    //overflow,bounds,size,constraints
    //sample tests,corner case/special case(n==0 or n==1 or negative numbers...),some hand written tests
    //read statement carefully
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


Measured memory_bytes: 3656
class Node:
    def __init__(self, n, parent=None, child=None):
        self.n = n
        self.p = parent
        self.child = child

    @property
    def parent(self):
        return self.p

    @parent.setter
    def parent(self, v):
        self.p = v

    @property
    def depth(self):
        count = 0
        p = self.parent
        while p is not None:
            count += 1
            p = p.parent
        return count

    @property
    def type(self):
        if self.parent is None:
            return "root"
        elif not self.child:
            return "leaf"
        else:
            return "internal node"

    def __str__(self):
        if self.parent is None:
            parent = -1
        else:
            parent = self.parent.n

        return "node {}: parent = {}, depth = {}, {}, {}".format(
            self.n, parent, self.depth, self.type, self.child
        )


n = int(input())
nodes = []
for i in range(n):
    nodes.append(Node(i))

for i in range(n):
    l = [int(i) for i in input().split()]
    id_ = l[0]
    k = l[1]
    nodes[id_].child = l[2:]
    if k != 0:
        for li in l[2:]:
            nodes[li].parent = nodes[id_]

for n in nodes:
    print(n)


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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
    if (l>=r) return;
    int root=pre[pos++];
    int m=distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m+1, r);
    post.push_back(root);
}

void solve() {
    pos = 0;
    rec(0, pre.size());
    for(int i=0; i<n; i++){
        if(i) cout<<" ";
        cout << post[i];
    }
    cout<<endl;
}

int main(){
    int k;
    cin>>n;
    
    for(int i=0; i<n; i++){
        cin>>k;
        pre.push_back(k);
    }
    
    for (int i=0;i<n;i++){
        cin>>k;
        in.push_back(k);
    }
    solve();
    
    return 0;
}


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

char s[100005];
int k;

int main() {
    scanf(" %s", s);
    int n;
    n = strlen(s);
    scanf("%d", &k);
    FO(i,0,n) {
        int dst = ('z'-s[i]+1) % 26;
        if (dst <= k) {
            k -= dst;
            s[i] = 'a';
        }
    }
    if (k) {
        int v = s[n-1]-'a';
        v += k;
        v %= 26;
        s[n-1] = v+'a';
    }
    printf("%s\n", s);
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
	char c[2][4];
	scanf("%s",c[0]);
	scanf("%s",c[1]);
	if(c[0][0]==c[1][2] && c[0][1]==c[1][1] && c[0][2]==c[1][0])printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
int n,C,K;
int A[100010];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,C,K);
  for(int i=1;i<=n;++i) read(A[i]);
  sort(A+1,A+n+1);
  int res=0;
  for(int i=n;i;--i) {
    ++res;
    int p=i; while(i-p+1!=C&&p!=1&&A[i]-A[p-1]<=K) --p;
    i=p;
  }
  printf("%d\n",res); 
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] ary = new int[n];
		
		
		for (int i = 0; i < n; i++) {
			ary[i] = scan.nextInt();
		}
		for (int i = n - 1; i >= 0; i--) {
			
			if (i != 0) {
				System.out.print(ary[i] + " ");
			} else {
				System.out.println(ary[i]);
			}
			
		}
	}
}

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

using namespace std;

bool has_only_allowed(int num, set<int> &allowed) {
	while (num > 0) {
		if (allowed.find(num % 10) == allowed.end()) {
			return false;
		}
		num /= 10;
	}
	return true;
}
int main() {
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	set<int> allowed;
	for (int i = 0; i < 10; i++) {
		allowed.insert(i);
	}
	for (int i = 0; i < k; i++) {
		int a;
		cin >> a;
		allowed.erase(a);
	}
	while (true) {
		if (has_only_allowed(n, allowed)) {
			cout << n;
			break;
		}
		n++;
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <stack>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 
int tenp(int n){
  int ret = 1;
  REP(i,n)
    ret *= 10;
  return ret;
}

int cal(){
  stack<int> st;
  int ope=0;
  int num;
  while(true){
    char c = getchar();
    if(c == '(' || ('0'<=c && c<= '9') ) {
      if(c == '(') num = cal();
      else{
        int dig=0;
        int numd[10]={0};
        numd[0] = (c - '0');
        while(true){
          c = getchar();
          if(!('0'<=c&&c<='9')) break;
          dig++;
          numd[dig] = (c - '0');
        }
        num = 0;
        for(int i=dig; i>=0; i--)
          num+=numd[dig-i] * tenp(i);
      }
      if(ope==0){
        st.push(num);
      }else if(ope == 1){
        st.push(-num);
        ope = 0;
      }else if(ope == 2){
        int tmp = st.top();
        st.pop();
        st.push(tmp * num);
        ope = 0;
      }else if(ope == 3){
        int tmp = st.top();
        st.pop();
        st.push(tmp / num);
        ope = 0;
      }
    }
    if(c == ')' ) break;
    if(c == '=' ){
      getchar();
      break;
    }
    if(c == '+') ope = 0;
    if(c == '-') ope = 1;
    if(c == '*') ope = 2;
    if(c == '/') ope = 3;
  }
  int sum=0;
  while(!st.empty()){
    sum += st.top();
    st.pop();
  }
  return sum;
}

int main(void){  
  int n;
  cin >> n;
  getchar();
  REP(i,n)
    cout << cal() << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

template <std::uint_fast64_t MOD> class ModInt {
  using u64 = std::uint_fast64_t;

public:
  ModInt(const u64 val = 0) { value = val % MOD; }

  ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }

  ModInt &operator+=(const ModInt rhs) {
    value += rhs.value;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator-=(const ModInt rhs) {
    if (value < rhs.value) {
      value += MOD;
    }
    value -= rhs.value;
    return *this;
  }

  ModInt &operator*=(const ModInt rhs) {
    value = value * rhs.value % MOD;
    return *this;
  }

  ModInt &operator/=(ModInt rhs) {
    *this *= rhs.inv();
    return *this;
  }

  ModInt &operator++(int n) {
    value++;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator--(int n) {
    if (value == 0) {
      value += MOD;
    }
    value--;
    return *this;
  }

  ModInt inv() { return ModInt::pow(*this, MOD - 2); }

  static ModInt pow(ModInt base, long long int n) {
    ModInt res = ModInt(1);
    while (n) {
      if (n & 1) {
        res *= base;
      }
      base *= base;
      n /= 2;
    }
    return res;
  }

  static ModInt comb(ModInt n, ModInt r) { return comb(n.value, r.value); }

  static ModInt comb(int n, int r) {
    if (n < r)
      return ModInt(0);
    ModInt res = ModInt(1);
    ModInt el = ModInt(1);
    for (int i = 1; i < n + 1; i++) {
      res *= el;
      el++;
    }

    ModInt inv = ModInt(1);
    el = ModInt(1);
    for (int i = 1; i < r + 1; i++) {
      inv *= el;
      el++;
    }
    el = ModInt(1);
    for (int i = 1; i < n - r + 1; i++) {
      inv *= el;
      el++;
    }
    res *= inv.inv();
    return res;
  }

  u64 getValue() const { return value; }

private:
  u64 value;
};

// ここを問題ごとのMODに書き換える
using mint = ModInt<1000000007>;

std::ostream &operator<<(std::ostream &out, const mint &m) {
  out << m.getValue();
  return out;
};

std::istream &operator>>(std::istream &in, mint &m) {
  uint_fast64_t i;
  in >> i;
  m = mint(i);
  return in;
}

mint ncr(int n, int a) {
  mint ans(1);
  REP(i, a) { ans *= mint(n - i); }
  REP(i, a) { ans /= mint(a - i); }
  return ans;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = mint::pow(mint(2), n);
  ans -= mint(1);
  ans -= ncr(n, a) + ncr(n, b);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    xy = []
    for i in range(n):
        a = int(input())
        xy.append([tuple(map(int, input().split())) for _ in range(a)])

    c = 0
    for i in range(1 << n):
        popcnt = bin(i).count('1')
        if popcnt <= c:
            continue
        all_honest = True
        for j in range(n):
            if (1 << j) & i != 0:
                for x, y in xy[j]:
                    x -= 1  # 人の番号をひとつずらす
                    if ((1 << x) & i) >> x != y:
                        all_honest = False
                        break
            if not all_honest:
                break
        if all_honest:
            if popcnt > c:
                c = popcnt

    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ALL(v)   v.begin(),v.end()
int main()
{
	speed
	ll n,m,k;
	cin >> n >> m >> k;
	cout << min(k, n*m);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    vector<ll> x(n), y(n);
    for (int i = 0; i < n; i++) {
        ll a,b;cin >> a >> b;
        x[i] = a + b;
        y[i] = a - b;
    }
    sort(ALL(x));
    sort(ALL(y));
    cout << max(abs(x.front() - x.back()), abs(y.front() - y.back())) << endl;
    return 0;
}


Measured memory_bytes: 6420
#include<iostream>
using namespace std;
int main(){
	int k;
	int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>k;
	cout<<a[k-1];
	return 0;
}

Measured memory_bytes: 256