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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 2000 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void READ() {
	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
}

int H, W, toleft[M][M], toright[M][M], up[M][M], down[M][M], cnt, ans, x;
char grid[M][M];
int main() {
//	READ();
	OUTPUT();
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; j++) {
			cin >> grid[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		cnt = 0;
		for (int j = 0; j < W; j++) {
			if (grid[i][j] == '#')
				cnt = 0;
			else
				cnt++;
			toleft[i][j] = cnt;
		}
	}
	for (int i = 0; i < H; i++) {
		cnt = 0;
		for (int j = W - 1; j >= 0; j--) {
			if (grid[i][j] == '#')
				cnt = 0;
			else
				cnt++;
			toright[i][j] = cnt;
		}
	}
	for (int i = 0; i < W; i++) {
		cnt = 0;
		for (int j = 0; j < H; j++) {
			if (grid[j][i] == '#')
				cnt = 0;
			else
				cnt++;
			down[j][i] = cnt;
		}
	}
	for (int i = 0; i < W; i++) {
		cnt = 0;
		for (int j = H - 1; j >= 0; j--) {
			if (grid[j][i] == '#')
				cnt = 0;
			else
				cnt++;
			up[j][i] = cnt;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (grid[i][j] == '.')
				x = toleft[i][j] + toright[i][j] + up[i][j] + down[i][j] - 3;
			ans = max(ans, x);
		}
	}
	cout<<ans;
	return 0;

}


Measured memory_bytes: 67200
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, s, a[105];
int main() {
	int i;
	cin>>n;
	for(i=0; i<n; i++) cin>>a[i], s += a[i];
	sort(a, a+n);
	for(i=0; i<n && a[i]%10==0; i++);
	cout<<(s%10 ? s : i<n ? s-a[i] : 0);
	return 0;
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
typedef long long ll;

const int maxn = 200200;
const int MAX = 1e9;
int a[maxn], n, k;
int dp[maxn];

void solve()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    dp[0] = 0;
    
    for (int i = 1; i < n; ++i){
        dp[i] = MAX;
        for (int j = 1; j <= k && i - j >= 0; ++j){
            dp[i] = min(dp[i - j] + abs(a[i] - a[i - j]), dp[i]);
        }
    }
    cout << dp[n - 1] << endl;
}

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





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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double kaku;
    kaku = abs(30 * h + 0.5 * m - 6 * m);
    if(kaku > 180) kaku = 360 - kaku;
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(kaku * (pai / 180)));
    printf("%.15f", ans);
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  string s;
  while(cin>>s){
    if(s=="-")break;
    ll n;cin>>n;
    rep(i,0,n){
      ll k;cin>>k;
      string t=s.substr(k,s.size()-k);
      t+=s.substr(0,k);
      s=t;
    }
    out(s);
  }


  return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>
int main(){
	int N;
	scanf("%d", &N);
	if(N%1000==0){
		puts("0");
	}else{
		printf("%d\n",((N/1000)+1)*1000-N);
	}

//	while( n>0){
	
//		n= n-1000;
			
//	printf("%d\n", n*-1);
	
	return 0;
}

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

int main(){
	int k, a, b;
	cin >> k >> a >> b;
	for(int i = a / k; i * k <= b; ++i){
		if(a <= i * k){
			puts("OK");
			return 0;
		}
	}
	puts("NG");
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

vl factor(ll n) {
  vl res;
  for(ll i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      ll j = n / i;
      res.push_back(i);
      if(i != j) res.push_back(j);
    }
  }
  res.push_back(n);
  return res;
}

int main() {
  ll n;
  cin >> n;
  if(n == 2) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 0;
  vl f = factor(n);
  for(auto v : f) {
    ll x = n;
    while(x % v == 0) {
      x /= v;
    }
    if(x % v == 1) ans++;
  }
  vl f2 = factor(n - 1);
  ans += f2.size();
  cout << ans << endl;
}

Measured memory_bytes: 384
import itertools
n = int(input())
p = ''.join(input().split())
q = ''.join(input().split())
ans = 0
for i, a in enumerate(itertools.permutations('12345678' [:n], n)):
    s = ''.join(a)
    if p == s:
        ans += i
    if q == s:
        ans -= i
print(abs(ans))


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

#define MOD ((long long)(1E9+7))

using namespace std;

long long exp(long long b, long long i){
    if(i == 0) return 1;
    long long ret = 1;
    if(i % 2 == 1) ret *= b;
    long long e = exp(b, i / 2);
    ret *= e;
    ret %= MOD;
    ret *= e;
    ret %= MOD;
    return ret;
}

long long fact(long long n){
    static long long memo[3000001] = {0};
    if(memo[0] == 0){
        memo[0] = 1;
        for(int i = 1; i <= 300000; i++) memo[i] = (i * memo[i - 1]) % MOD;
    }
    return memo[n];
}

long long inv(long long n){
    return exp(n, MOD - 2);
}

long long comb(long long n, long long k){
    long long ret = fact(n);
    ret *= inv(fact(n - k));
    ret %= MOD;
    ret *= inv(fact(k));
    ret %= MOD;
    return ret;
}

long long gcd(long long x, long long y){
    if(y == 0) return x;
    return gcd(y, x % y);
}

int main(void){
    long long dummy = fact(1);
    long long N, A, B, C;
    cin >> N >> A >> B >> C;
    long long g;
    g = gcd(A, B);
    A /= g;
    B /= g;
    long long h = 100;
    g = gcd(C, h);
    C /= g;
    h /= g;
    long long a, b, c;
    a = A * inv(A + B);
    a %= MOD;
    b = B * inv(A + B);
    b %= MOD;
    c = C * inv(h);
    c %= MOD;
    // cout << a << endl << b << endl << c << endl;
    long long ans = 0;
    for(long long i = 0; i < N; i++){
        long long sub = N + i;
        sub *= exp(a, N);
        sub %= MOD;
        sub *= exp(b, i);
        sub %= MOD;
        sub *= comb(N + i - 1, N - 1);
        sub %= MOD;
        // cout << sub << endl;
        ans += sub;
        ans %= MOD;
    }
    for(long long i = 0; i < N; i++){
        long long sub = N + i;
        sub *= exp(b, N);
        sub %= MOD;
        sub *= exp(a, i);
        sub %= MOD;
        sub *= comb(N + i - 1, N - 1);
        sub %= MOD;
        // cout << sub << endl;
        ans += sub;
        ans %= MOD;
    }

    ans *= inv((MOD + 1 - c) % MOD);
    ans %= MOD;
    cout << ans << endl;
    // cout << (7 * inv(2)) % MOD << endl;
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
  char buf[4] = {};
  cin >> buf >> buf + 1 >> buf + 2;

  istringstream ss(buf);
  int64_t n;
  ss >> n;

  if (n % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    A, B = Scanner.map_int()
    print(A * B)


def main():
    # sys.stdin = open("sample.txt")
    # print('YNEOS'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10648
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    M = 0
    A = 0
    R = 0
    C = 0
    H = 0
    for _ in range(N):
        s = input().rstrip()
        if s[0]=='M':
            M += 1
        if s[0]=='A':
            A += 1
        if s[0]=='R':
            R += 1
        if s[0]=='C':
            C += 1
        if s[0]=='H':
            H += 1
    res = 0
    l = [M, A, R, C, H]
    for a, b, c in combinations(l, 3):
        res += a*b*c
    print(res)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

#include <ext/rope> //header with rope
using namespace std;
using namespace __gnu_cxx; //namespace with rope and some additional stuff
using namespace __gnu_pbds;

#define rep(i, a, b) for(int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int, int> ii;

const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;




int main(){
		
	int a, b; cin >> a >> b; 
	string s; getline(cin, s);
	getline(cin, s);
	
	if(s.size()==a+b+1 && s[a]=='-'){
		rep(i, 0, s.size()){
			if(i==a || (s[i]>='0' && s[i]<='9')) continue;
			puts("No");
			return 0;
		}
	}else{
		puts("No");
		return 0;
	}
	
	puts("Yes");

	
	return 0;
	
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def fun(n,a,k):
 dp=[0]*n
 for i in range(1,n):
  dp[i]=min([dp[j]+abs(a[i]-a[j]) for j in range(max(0,i-k),i)])
 print(dp[len(dp)-1])
if __name__ == '__main__':
 n,k = map(int, input().split())
 a=list(map(int,input().split()))
 fun(n,a,k)
 


Measured memory_bytes: 14012
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	int n;
	scanf("%d", &n);
	vector<long long> v(n); 
	long long base = 0;
	int basei;
	for (int i = 0; i<n; ++i) {
		scanf("%lld", &v[i]);
		if (base < v[i]) {
			base = v[i];
			basei = i;
		}		
	}
	long long mid = base*5;
	long long d = base*10 - mid + 1;
	long long top;
	for (int i = 0; i<n; ++i) {
		if (i != basei) {
			long long curd = abs(v[i]*10 - mid);
			if (curd < d) {
				d = curd;
				top = v[i];
			}
		}
	}
	printf("%lld %lld\n", base, top);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	string s;
	cin >> s;
	for (char &ch : s)
		if (ch == '?')
			ch = 'D';
	cout << s << endl;
}


Measured memory_bytes: 3772
#include<stdio.h>
int main(void) {
	int n;
	int num[100000];
	int min;
	int max;
	long int total=0;
	int i;
	int t;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		scanf("%d", &num[i]);
	}

	for (t = 1; t <= n; t++) {
		if (t == 1) {
			min = num[t];
			max = num[t];
		}
		total = total + num[t];
		if (min > num[t]) {
			min = num[t];
		}
		if (max < num[t]) {
			max = num[t];
		}
	}
	printf("%d %d %ld\n", min, max, total);
	return 0;
}

Measured memory_bytes: 644
#include "bits/stdc++.h"
using namespace std;
const long long int SP = 8192;
int main() {
	long long int N, K;long long int  X0; cin >> N >> K >> X0;
	if (!X0)cout << 0 << endl;
	else {
		unsigned long long int x = X0;
		if (N < 1e6) {

			vector<long long int>nums(N);
			for (int i = 0; i < N; ++i) {
				long long int ax = static_cast<long long int>(x);
				nums[i] = ax;
				x ^= x << 13;
				x ^= x >> 7;
				x ^= x << 17;
			}
			sort(nums.begin(), nums.end());
			cout << nums[K - 1] << endl;
		}
		else {
			int num = static_cast<int>(K * SP / N);
			int minnum = max(0, num - 32);
			int maxnum = min(static_cast<int>(SP), num + 32);
			vector<long long int>nums;
			int lower = 0;
			for (int i = 0; i < N; ++i) {
				long long int ax = static_cast<long long int>(x);
				long long int d = -(LLONG_MAX)+(ULLONG_MAX / SP * minnum);
				long long int u = -(LLONG_MAX)+(ULLONG_MAX / SP * maxnum);
				if (maxnum == SP)u = LLONG_MAX;
				if (minnum == 0)d = -LLONG_MAX;
				if (ax < d) {
					lower++;
				}
				else if (ax <= u) {
					nums.push_back(ax);
				}

				x ^= x << 13;
				x ^= x >> 7;
				x ^= x << 17;
			}

			sort(nums.begin(), nums.end());
			if (0 > K - 1 - lower || K - 1 - lower >= nums.size())cout << 0 << endl;
			else {

				cout << nums[K - 1 - lower] << endl;
			}
		}
	}

	return 0;
}

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

const int N = 2e5 + 5;
typedef long long ll;

int n, ans;
string s[N];

int main() {
	cin>>n;
	ans = n;
	for(int i = 1; i <= n; i++) 
		cin>>s[i];
	sort(s + 1, s + n + 1);
	for(int i = 2; i <= n; i++)
		if(s[i] == s[i - 1]) ans--;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n, k, p;
	int result[101];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> k >> p;
		if (k <= p) {
			result[i] = k;
		}else if (k%p == 0){
			result[i] = p;
		}else{
			result[i] = k%p;
		}
	}
	for (int i = 0; i < n; i++){
		cout << result[i] << endl;
	}
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i+=2)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
 string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  ll a[5];
for(ll j=0;j<5;j++)
{
  cin>>a[j];
  x = a[j]%10;
  x  = (10 - x)%10;
  a[j]+=x;
  ans = max(x,ans);

}
for (int i = 0; i < 5; ++i)
{
c+=a[i];
}
c -=ans;
c(c); 
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
def getNeighboringNumbers(numbers):
    cnt = 0
    flag = False
    pre = -100
    for n in numbers:
        if flag:
            if pre + 1 != n:
                cnt += 1
                flag = False
        else:
            if pre + 1 == n:
                flag = True
            else:
                cnt += 1
        pre = n
    return cnt

n = int(input())
height = list(map(int, input().split()))
M = max(height)
ans = 0
for i in range(M, 0, -1):
    indexes = [k for k, x in enumerate(height) if x == i]
    cont = getNeighboringNumbers(indexes)
    ans += cont
    for k in indexes:
        height[k] -= 1
print(ans)


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

int main() {
  string str1, str2;
  bool chk = false;
  int index = 0;
  
  cin >> str1 >> str2;
  
  sort(str1.begin(), str1.end());
  sort(str2.begin(), str2.end(), greater<int>());
  
  if(str1 < str2) cout << "Yes";
  else cout << "No";
  /*
  index = min(str1.size(), str2.size());
  for(int i = 0; i < index; i++){
    if(str1.at(i) < str2.at(i)){
      chk == true;
    }else if(str1.at(i) > str2.at(i)){
      chk == false;
      break;
    }else{
      if(str1.size() < str2.size()){
        chk = true;
      }
    }
  }
  
  if(chk == true){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
  */
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    *P,=map(int, input().split())
    P=[-1]+P
    uf=UnionFindTree(N+1)
    for _ in range(M):
        x,y=map(int, input().split())
        uf.union(P[x],P[y])
    ans=0
    for i in range(1,N+1):
        if uf.same(P[i], i): ans+=1
    print(ans)

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

    def same(self, x, y): return self.find(x) == self.find(y)
    def size(self, x): return -self.parent[self.find(x)]

if __name__ == '__main__':
    main()

Measured memory_bytes: 61584
#include<stdio.h>
#include<string.h>
int main(){
    int n, p, i, r, data[51]={}, nokori=0;
    for(;scanf("%d%d", &n, &p);){
        if( n == 0 && p == 0 ){
            break;
        }
        for( i = 0, nokori = p;; i++ ){
            if( nokori != 0 ){
                data[i] = data[i] + 1;
                nokori = nokori - 1;
            }else{
                nokori = data[i];
                data[i] = 0;
            }
            if( data[i] == p ){
                printf("%d\n", i);
                break;
            }
            if( i == n - 1 ) i = -1;
        }
        for( i = 0; i < 51; i++ ){
            data[i] = 0;
        }
    }
    return 0;
}

Measured memory_bytes: 600
import sys

def is_half_euler_graph(node_list):
    for node in node_list:
        isBool = True
        for dic_key, dic_value in node.items():
            if dic_key != 1 and dic_key != 2:
                if dic_value % 2 != 0:
                    isBool = False
                    break
            else :
                if dic_value % 2 == 0:
                    isBool = False
                    break
        if isBool :
            print("OK")
        else :
            print("NG")



if __name__ == '__main__' :
    from collections import defaultdict
    data_list = []

    for line in sys.stdin:
        data_list.append(list(map(int, line.split())))


    node_data_lists = []
    tmp_list = []
    count_lists = []
    tmp_dic = {}
    tmp_dic = defaultdict(int)

    for i in range(0, len(data_list)):
        if data_list[i][0] == 0 and data_list[i][1] == 0:
            node_data_lists.append(tmp_list[:])
            tmp_list.clear()
        else :
            tmp_list.append(data_list[i])

    for node_data_list in node_data_lists :
        tmp_dic.clear()
        for i in range(0, len(node_data_list)):
            tmp_dic[node_data_list[i][0]] += 1
            tmp_dic[node_data_list[i][1]] += 1

        count_lists.append(tmp_dic.copy())

    is_half_euler_graph(count_lists)



Measured memory_bytes: 6044
#include<stdio.h>

  int main(void){

    int r,g,b;
    int total;
    scanf("%d%d%d",&r,&g,&b);
    
    if( 1<=r && r<=9 && 1<=g && g<=9 && 1<=b && b<=9 ){
      r = r*100;
      g = g*10;
      total = r+g+b;
        if( total%4 == 0 ){
          printf("YES");
        }else{
          printf("NO");
         }
    } 
 
  }

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct Team{
	int no;
	int ac_n;
	int ac_t;
	int times[11];

	bool operator <(const Team& t)const{
		if(ac_n == t.ac_n){
			if(ac_t == t.ac_t){
				return no < t.no;
			}
			return ac_t > t.ac_t;
		}
		return ac_n < t.ac_n;
	}

	bool operator ==(const Team& t)const{
		return ac_n == t.ac_n && ac_t == t.ac_t;
	}
};

int main() {
	int contest_time, team_n, progrom_n, submit_n;
	while(cin >> contest_time >> team_n >> progrom_n >> submit_n, contest_time|team_n|progrom_n|submit_n){
		vector<Team> team(team_n);
		REP(i, team_n) team[i].no = i+1;
		REP(i, submit_n){
			int time, team_no, progrom_no, judge;
			cin >> time >> team_no >> progrom_no >> judge;
			team_no--;
			if(judge == 0){
				team[team_no].ac_n++;
				team[team_no].ac_t += time;
				team[team_no].ac_t += team[team_no].times[progrom_no]*20;
			}else{
				team[team_no].times[progrom_no]++;
			}
		}

		RSORT(team);

		cout << team[0].no;
		FOR(i, 1, team_n){
			cout << (team[i] == team[i-1] ? '=' : ',') << team[i].no;
		}
		cout << endl;
	}

}

Measured memory_bytes: 1200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ABC125C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var zeroStartCount = 0;
            var oneStartCount = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0)
                {
                    if (S[i] != '0')
                    {
                        zeroStartCount++;
                    }
                    else
                    {
                        oneStartCount++;
                    }
                }
                else
                {
                    if (S[i] != '1')
                    {
                        zeroStartCount++;
                    }
                    else
                    {
                        oneStartCount++;
                    }
                }
            }
            if (oneStartCount > zeroStartCount)
            {
                Console.WriteLine(zeroStartCount);
            }
            else
            {
                Console.WriteLine(oneStartCount);
            }
        }
    }
}

Measured memory_bytes: 13280
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
signed main() {
	int H, W; cin >> H >> W;
	vector<string> v(H); input(v);
	rep(i, 2 * H) {
		rep(j, W) {
			cout << v[i / 2][j];
		}
		cout << endl;
	}
	system("pause");
}

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

int main(){
	int N, K;
	cin >> N >> K;
	char S[N];
	for(int i=0; i<N; i++){
		cin >> S[i];
		if(i == K-1){
			if(S[i] == 'A') S[i] = 'a';
			if(S[i] == 'B') S[i] = 'b';
			if(S[i] == 'C') S[i] = 'c';
		}
	}
	for(int i=0; i<N; i++) cout << S[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
typedef long double ld;
int n, k;
ld d[100001];
ld f(int x){
    if(x==0)return 0;
    if(x>=k)return 1;
    return d[x]=f(x*2)/2;
}
int main(void){
    ld a=0;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        d[i]=-1;
    }
    for(int i=1;i<=n;i++){
        a+=f(i);
    }
    cout<<fixed<<setprecision(20)<<a/((ld)n)<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010];
map<ll,ll>m;
vector<ll>v;
string s,q;

int main()
{
   ll t,n,i,j,k,l,r,mn=0, mx=0;
   sl(k);
   cin>>s;
   if(s.size()>k)
    {string ss= s.substr(0, k);
   ss+="...";
   cout<<ss;
   }
   else
    cout<<s;


}




Measured memory_bytes: 3664
import java.math.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double m = sc.nextDouble();
        double a[] =new double[n];
        for(int i=0;i<n;i++)
            a[i] = sc.nextDouble();
        double all = 0;
        for(int i=0;i<n;i++)
            all+=a[i];
        double und = all / (4 * m);
            int ans =0;
        for(int i=0;i<n;i++){
            if(a[i]>=und){
                ans++;
            }
        }
            if(ans>=m){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
        }
    }

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    ll ans = (H - h) * (W - w); 
    cout << ans << endl;
}

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

#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%lld",&x)
#define read2(x,y) scanf("%lld%lld",&x,&y)
#define write(x) printf("%lld\n",x)
#define lson k*2,l,mid
#define rson k*2+1,mid+1,r

const int maxn=1e5+5;
const ll inf=1e16;

ll n,m,k,q,a[maxn],b[maxn],ok,flag,sum,ans1,ans2,ans,l,r;
string s,t,s1,s2;

int main()
{
    read(n);
    for(int i=0;i<n;i++)
    {
        read(a[i]);
    }
    sort(a,a+n);
    int per=0,i;
    while(per<n)
    {
        ans=0;
        for(i=per+1;i<n;i++)
        {
            if(a[i]==a[per])ans++;
            else break;
        }
        if(ans%2==0)ans1++;
        per=i;
    }
    write(ans1);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
using namespace std;
map<string,int>M;
string s;
int id;
int f();
int g()
{
	if(s[id]=='(')
	{
		id++;
		int now=f();
		id++;
		return now;
	}
	else if(s[id]>='A')
	{
		string t="";t+=s[id];
		if(s[id+1]>='a')
		{
			id++;
			t+=s[id];
		}
		id++;
		if(M.find(t)==M.end())return -1;
		else return M[t];
	}
}
int f()
{
	int ans=0;
	while(s[id]>='A'||s[id]=='(')
	{
		int x=g();
		if(x<0)return -1;
		if(s[id]>='0'&&s[id]<='9')
		{
			int r=s[id]-'0';
			if(s[id+1]>='0'&&s[id+1]<='9')
			{
				r=r*10+s[id+1]-'0';
				id++;
			}
			id++;
			x*=r;
		}
		ans+=x;
	}
	return ans;
}
main()
{
	string t;
	while(cin>>t,t!="END_OF_FIRST_PART")
	{
		int a;cin>>a;
		M[t]=a;
	}
	while(cin>>s,s!="0")
	{
		id=0;
		int ans=f();
		if(ans<0)cout<<"UNKNOWN"<<endl;
		else cout<<ans<<endl;
	}
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int x, y;
  cin >> x >> y;
  if (x * 500 >= y) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int64_t ans = 1;
    rep(i, n) {
        if (i == 0) ans *= k;
        else ans *= (k-1);
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  for (int a = 1; a <= 9; ++a) {
    for (int b = 1; b <= 9; ++b) {
      if (a*b == n) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        int C = Integer.parseInt(st.nextToken());
        int D = Integer.parseInt(st.nextToken());

        System.out.println(Math.max(A*B, C*D));
    }
}


Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] = s[k - 1] - 'A' + 'a';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

long table[1000010];
long h[100010];
long N,K;

long solve(long goal, long K)
{
    std::vector<long> temporary;
    if(table[goal]==LONG_MAX){
        for(long i=1; i<=K;i++){
            if(goal-i>=0){
                temporary.push_back(solve(goal-i,K)+abs(h[goal]-h[goal-i]));
            }
        }
        std::sort(temporary.begin(),temporary.end());
        table[goal]=temporary[0];
    }
    return table[goal];
}


int main()
{
    std::cin >> N >> K;
    for(long i=0; i<N; i++){
        std::cin >> h[i];
        table[i]=LONG_MAX;
    }
    table[0]=0;
    table[1]=abs(h[1]-h[0]);
    std::cout << solve(N-1,K) << std::endl;
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<math.h>
//#include<string.h>
using namespace std;
//cout << "Yes" << endl;
//cout << "No" << endl;
int seiyaku_check(double i,int Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	double a,b,c,d;
	c = 0.5;
	
	cin >> a;
	
	seiyaku_check(a,1,100);
	
	if(fmod(a,2) == 0)cout << c << endl;
	
	if(fmod(a,2) != 0){
		int j=0;
		for(int i=a;i>0;){
			if(i%2 == 1)j++;
			i -= 1;
		}
		//cout << j << endl;
		cout << j/a << endl;
	}	
	
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
  ll x, y; cin>>x>>y;
  if(x==0){
    if(y>0) cout<<y<<endl;
    else cout<<-y+1<<endl;
    return 0;
  }else if(y==0){
    if(x>0) cout<<x+1<<endl;
    else cout<<-x<<endl;
    return 0;
  }
  if(0<x && x<y){
    cout<<y-x<<endl;
  }else if(0<y && y<x){
    cout<<x-y+2<<endl;
  }else if(x<y && y<0){
    cout<<y-x<<endl;
  }else if(y<x && x<0){
    cout<<x-y+2<<endl;
  }else{
    cout<<abs(abs(x)-abs(y))+1<<endl;
  }
    
 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
#define ljc2 (998244354/2) 
using namespace std;
/*
*/
#ifdef emm
#define gc getchar
#endif
#ifndef emm
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
inline ll fast_pow(ll a,ll b,ll p){
	ll t=1;
	while (b){
		if (b&1ll) t=t*a%p;
		b>>=1;a=a*a%p; 
	}
	return t;
}
inline void FWT(ll *f,ll lim,ll id){
	for (int len=1;len<lim;len<<=1){
		for (int i=0;i<lim;i+=len<<1){
			ll *f1=f+i,*f2=f1+len;
			for (int j=0;j<len;j++){
				ll x=f1[j],y=f2[j];
				f1[j]=(x+y)*(~id?1:ljc2)%ljc;
				f2[j]=(x-y+ljc)*(~id?1:ljc2)%ljc;
			}
		}
	}
}
ll n,lim,a[1048577],S,b[1048577];
signed main(){
	n=read(),lim=1<<n;
	for (int i=0;i<lim;i++) a[i]=read(),S+=a[i];
	S=fast_pow(S%ljc,ljc-2,ljc);
	for (int i=1;i<lim;i++) b[i]=ljc-1;
	b[0]=lim-1;
	for (int i=1;i<lim;i++) a[i]=a[i]*S%ljc;
	a[0]=(a[0]*S%ljc+ljc-1)%ljc;
	FWT(b,lim,1),FWT(a,lim,1);
	for (int i=1;i<lim;i++) a[i]=fast_pow(a[i],ljc-2,ljc)*b[i]%ljc;
	a[0]=0;
	FWT(a,lim,-1);
	ll tmp=a[0];
	for (int i=0;i<lim;i++){
		printf("%lld\n",(a[i]-tmp+ljc)%ljc);
	}
	return 0;
}

Measured memory_bytes: 7924
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n, C, K, ans, a[N];

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

    cin >> n >> C >> K;

    forn(i, 1, n) {
        cin >> a[i];
    }

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

    int mx = a[1] + K, cnt = 1;
    forn(i, 2, n) {
        if (mx < a[i] || cnt == C) {
            ++ans;
            cnt = 0;
            mx = a[i] + K;
        }
        ++cnt;
    }
    ++ans;

    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
//選択ソート
int selectionSort(int A[],int N){
    int i,j,t,sw=0,minj; //tはswapのための変数
    for(i=0;i<N-1;i++){
        minj=i;
        for(j=i;j<N;j++){
            if(A[j] < A[minj]) minj = j; //ここで最小値を探している
        }
        t = A[i]; A[i] = A[minj]; A[minj] = t; //swap処理,A[i]は未ソート部分の先頭要素
        if(i != minj) sw++;
    }
    return sw;
}

int main(){
    int A[100];
    int N,i,sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);
    //ソートした結果
    for(i=0;i<N;i++){
        if(i>0)printf(" "); //この定型文なるほど！って感じ
        printf("%d",A[i]);
    }
    putchar('\n');
    printf("%d\n",sw);

    return 0;
}


Measured memory_bytes: 2144
n=int(input())
t=[int(input())for _ in range(n)]
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
ans=t[0]
for i in t[1:]:ans=lcm(ans,i)
print(ans)

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

int mo[10000]={};

int main(void)
{
	int d=0,m=0;
	cin>>d>>m;
	for(int i=1;i<=d;i++)
	{
		cin>>mo[i];
		m-=mo[i];
	}
	
	int count=d; 
	sort(mo+1,mo+d+1);
	
/*	for(int i=1;i<=d;i++)
	{
		if(mo[1]>=m)
		{
			count++;
			m-=mo[1];
		}
		else
			break;
	}*/
	count+=m/mo[1];
	cout<<count<<endl;
	return 0;
}

 

Measured memory_bytes: 256
n,k=map(int,input().split())
xy=[]
for i in range(n):
    tmp=[int(j) for j in input().split()]
    xy.append((tmp[0],tmp[1]))
from operator import itemgetter
xy.sort(key=itemgetter(1))
xy.sort(key=itemgetter(0))
xy=tuple(xy)
l=tuple(enumerate(xy))
ans=10**100
for i,(a,b) in l[:n-k+1]:
    for j,(c,d) in l[i+k-1:]:
        l1=sorted(y for x,y in xy[i:j+1])
        l2=l1[k-1:]
        for p,q in zip(l1,l2):
            if p<=b and q>=d:
                ans=min(ans,(c-a)*(q-p))
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int H = sc.nextInt();
        int a[] = new int[N];
        int b[] = new int[N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        int amax = a[a.length-1];
        int cnt=0;
        int sum =0;
        while(N-1-cnt>=0&&b[N-1-cnt]>=amax) {
            sum += b[N-1-cnt];
            cnt++;
            if(sum>=H){
              System.out.println(cnt);
              return;  
            } 
        }
        cnt += (H-sum+amax-1)/amax;
        System.out.println(cnt);
    }
}


Measured memory_bytes: 84928
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    ll h, w;
    scanf("%lld%lld", &h, &w);

    if (h > w) swap(h, w);
    if (h == 1) {
        printf("1\n"); return;
    }

    if (h % 2 == 0 || w % 2 == 0) {
        printf("%lld\n", h*w / 2);
    }
    else {
        printf("%lld\n", ((h + 1) / 2) * ((w + 1) / 2) + (h / 2)*(w / 2));
    }
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ll N; cin>>N;
  ll ans=0;
  for(ll p=1;p*p<N;p++){
    if(N%p!=0) continue;
    ll m=N/p-1;
    if(p<m) ans+=m;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,place = 1,l = 0;
  cin >> N;
  vector<int> a (N);
  vector<bool> did (N);
  for (int i = 0;i < N;i++)
    cin >> a.at(i);
   while(1){
     if(place == 2) break;
     l++;
     place = a.at(place - 1);
     if(did.at(place - 1) == 1){
       l = -1;
       break;
     }else{
       did.at(place - 1) = 1;
     }
   }
  cout << l << endl;
}

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

using namespace std;

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

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

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

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

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

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

void solve() {
    string s;
    cin >> s;
    reverse(all(s));
    ll n = s.size();
    ll ten = 1;
    ll now = 0;
    unordered_map<ll, ll> mp{make_pair(0, 1)};
    rep(i, n) {
        now = (now + (s[i] - '0') * ten) % 2019;
        ten *= 10;
        ten %= 2019;
        mp[now]++;
    }
    ll ans = 0;
    each(e, mp) {
        ans += e.second * (e.second - 1) / 2;
    }
    cout << ans << '\n';
}

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

Measured memory_bytes: 3712
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    int N,i;

    cin >> N ;

    for (i=1; i<10; i++){
        if (i * 111 + 1 > N){
            cout << i * 111 << endl;
            break;
        }
    }

 }

Measured memory_bytes: 256