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

using ll = long long;
using pii = pair<int, int>;

template <typename T> constexpr T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;
template <> constexpr double inf<double> = 1e18;

template<typename T>
std::vector<T> table(int n, T v) { return std::vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return std::vector<decltype(val)>(n, std::move(val));
}

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> l(C), c(N), w(N);
    for(int i = 0; i < C; ++i) {
        cin >> l[i];
    }
    priority_queue<pii> que;
    for(int i = 0; i < N; ++i) {
        cin >> c[i] >> w[i];
        que.emplace(w[i], c[i] - 1);
    }

    ll ans = 0;
    while(!que.empty() && M > 0) {
        auto v = que.top(); que.pop();
        if(l[v.second] > 0) {
            l[v.second]--;
            ans += v.first;
            M--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4900
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;


int main(){
    int c;
    cin >> c;
    cout <<  (c<1200?"ABC" :"ARC") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
      ll a,b,c,d;
      cin>>a>>b>>c>>d;
      ll mx1,mx2,mn1,mn2;
      mx1=a*c;
      mx2=b*c;
      mn1=a*d;
      mn2=b*d;
      cout<<max(mx1,max(mx2,max(mn1,mn2)))<<endl;
      return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

vector<P> node[100001];
vector<ll> c(100001, -1);

ll inv(ll val) {
	if (val == 1) return 0;
	else return 1;
}

void calc(ll color, ll pos, ll weight) {
	ll next_pos, next_weight;

	if (c[pos] == -1) {
		if (weight % 2 == 0) {
			c[pos] = color;
		}
		else {
			c[pos] = inv(color);
		}
		rep(i, node[pos].size()) {
			next_pos = node[pos][i].first;
			next_weight = node[pos][i].second;
			calc(c[pos], next_pos, next_weight);
		}
	}
}

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

	ll N, K;
	ll score = 0;
	ll times = 0;
	double ans = 0.0F;

	cin >> N;

	ll u, v, w;
	rep(i, N-1) {
		cin >> u >> v >> w;
		node[u].emplace_back(v, w);
		node[v].emplace_back(u, w);
	}

	ll next;
	ll weight;
	rep(i, N) {
		if (c[i+1] == -1 && node[i+1].size() == 1) {
			c[i+1] = 0;
			calc(c[i+1], node[i+1][0].first, node[i+1][0].second);
		}
	}

	rep(i, N) {
		cout << c[i+1] << "\n";
	}
	return 0;
}

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


#define INF 1000000000000


signed main()
 {
  int n;
  cin>>n;
  rep(i,26){
    rep(j,15){
      if(i*4+j*7==n){cout<<"Yes";exit(0);}
    }
  }
  cout<<"No";
 }


Measured memory_bytes: 256
A,B = map(int,input().split())

print(100,100)
L=[]
for i in range(50):
    L.append(["#" for j in range(100)])
for i in range(50):
    L.append(["." for j in range(100)])

A-=1

for i in range(50):
    for j in range(25):
        if A>0:
            L[i*2][j*2] = "."
            A -=1
B-=1

for i in range(50):
    for j in range(25):
        if B>0:
            L[51 + i*2][j*2] = "#"
            B-=1
for i in range(100):
    print("".join(L[i]))

Measured memory_bytes: 39024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


#line 1 "lib/segment_tree.hpp"



#include <vector>
#include <algorithm>
#include <functional>

template<typename Monoid>
class SegmentTree {
public:
    using Operator = std::function<Monoid(Monoid, Monoid)>;

    SegmentTree(int n, const Operator &op, const Monoid init)
        : op(op), init(init) {

        num = 1;
        while (num < n) num *= 2;
        dat.resize(2 * num, init);
    }

    SegmentTree(const std::vector<Monoid> &m,
        const Operator &op, const Monoid init)
        : SegmentTree(m.size(), op, init) {

        int n = m.size();
        for (int i = 0; i < n; i++) {
            dat[num - 1 + i] = m[i];
        }
        for (int i = num - 2; i >= 0; i--) {
            dat[i] = op(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }

    // Update the k-th value (0-indexed) to a.
    void update(int k, Monoid a) {
        k += num - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    // Get the value of the range [a, b).
    // k: The index of the node.
    // [left, right): The range corresponds to the k-th node.
    // Call like getval(a, b).
    Monoid getval(int a, int b, int k = 0, int left = 0, int right = -1) {
        if (right < 0) right = num;
        if (right <= a || b <= left) return init;
        if (a <= left && right <= b) return dat[k];
        Monoid vleft = getval(
            a, b, 2 * k + 1, left, left + (right - left) / 2);
        Monoid vright = getval(
            a, b, 2 * k + 2, left + (right - left) / 2, right);
        return op(vleft, vright);
    }

private:
    int num;
    std::vector<Monoid> dat;
    const Operator op;
    const Monoid init;
};

// Example: Range-Minimum Point-Update Segment Tree
SegmentTree<int> make_rmpu_segment_tree(const std::vector<int> &init) {
    const int INF = 1e9 + 2;
    auto op = [](int a, int b) { return std::min(a, b); };
    return SegmentTree<int>(init, op, INF);
}


int main() {
    int n, m; std::cin >> n >> m;
    std::vector<int> a(m), b(m), id(m);
    for (int i = 0; i < m; i++) std::cin >> a[i] >> b[i];
    std::iota(id.begin(), id.end(), 0);
    std::sort(id.begin(), id.end(), [&](int i, int j) {
        return b[i] < b[j];
    });
    SegmentTree<int> seg(n + 2, [](int i, int j) {return i && j; }, 1);
    int ans = 0;
    for (int i : id) {
        int r = seg.getval(a[i] + 1, b[i] + 1);
        ans += r;
        if (r) seg.update(b[i], 0);
    }
    std::cout << ans << std::endl;
    return 0;
}

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

int main() {
  int n,a,b; 
  cin >>n>>a>>b;
  long long sum=0;
  for(int i=1;i<=n;i++){
    int x=i;
    int wa=0;
    while(x){
      wa+=x%10;
      x=x/10;
    }
    if(wa>=a&&wa<=b)sum+=i;
  }
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;

const int nax = 3e5 + 12;

vector<pair<pair<int, int>, int>>v, rv;
int from1[nax], toN[nax], dist[nax];

int main()
{
  ios_base::sync_with_stdio (0);
  cin.tie (0);
  int n, m, p;
  cin >> n >> m >> p;
  for (int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    v.push_back ({{x, y}, -c + p});
    rv.push_back ({{y, x}, -c + p});
  }
  for (int i = 1; i <= n - 1; i++) {
    toN[i] = 1e9;
  }
  for (int i = 1; i <= n; i++) {
    for (auto j : rv) {
      int x = j.first.first;
      if (toN[x] == 1e9) {
        continue;
      }
      int y = j.first.second;
      int cost = j.second;
      if (toN[y] > toN[x] + cost) {
        toN[y] = toN[x] + cost;
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    from1[i] = 1e9;
  }
  for (int i = 1; i <= n; i++) {
    for (auto j : v) {
      int x = j.first.first;
      if (from1[x] == 1e9) {
        continue;
      }
      int y = j.first.second;
      int cost = j.second;
      if (from1[y] > from1[x] + cost) {
        from1[y] = from1[x] + cost;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    dist[i] = from1[i];
  }
  for (int i = 1; i <= n; i++) {
    for (auto j : v) {
      int x = j.first.first;
      if (dist[x] == 1e9) {
        continue;
      }
      int y = j.first.second;
      int cost = j.second;
      if (dist[y] > dist[x] + cost) {
        dist[y] = dist[x] + cost;
      }
    }
  }
  bool ok = (dist[n] != 1e9);
  for (int i = 1; i <= n; i++) {
    if (dist[i] < from1[i] && toN[i] != 1e9) {
      ok = false;
      break;
    }
  }
  if (ok == false) {
    cout << -1 << '\n';
    return 0;
  }
  cout << max (0, -dist[n]) << '\n';
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N;
    Map<String,Long> groupMap;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      groupMap = new HashMap<>();
      for(int i = 0; i < N; i++) {
        String ns = normed(sc.next());
        Long count = groupMap.get(ns);
        if ( count == null ) {
          count = 0L;
        }
        count++;
        groupMap.put(ns, count);
      }
    }
    long answer = 0;
    for(Long count : groupMap.values()) {
      if ( count > 1 ) {
	    answer += count * (count - 1) / 2;
      }
    }
    System.out.println(answer);
  }
  
  private static String normed(String s) {
    if ( s == null ) {
      return null;
    }
    char[] ca = s.toCharArray();
    Arrays.sort(ca);
    return new String(ca);
  }

}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        if((s[2]==s[3])&&(s[4]==s[5])) out.println("Yes");
        else out.println("No");
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &x: a) cin >> x;

    int cur = a[0];
    ll ans = 0;
    for (int i = 1; i < n; i++)
        if (a[i] < cur) ans += (ll)(cur - a[i]);
        else cur = a[i];
    cout << ans;
    return 0;
}


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

int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if (H==0 && W==0){
            break;
        }
        for (int i=0; i<H; i++){
            for (int j=0; j<W; j++){
                if ((i+j)%2==0){
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2608
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

#define N 262144
const double pi = 3.141592653589793;
typedef struct{
	double re, im;
} comp;
comp csum(comp a, comp b){
	comp res;
	res.re = a.re + b.re;
	res.im = a.im + b.im;
	return res;
}
comp cprod(comp a, comp b){
	comp res;
	res.re = a.re * b.re - a.im * b.im;
	res.im = a.re * b.im + a.im * b.re;
	return res;
}
void dft(comp f[], int n){
	if(n == 1)return;
	comp f0[n/2], f1[n/2], zeta, pow_zeta;
	for(int i=0; i<n/2; i++){
		f0[i] = f[2*i + 0];
		f1[i] = f[2*i + 1];
	}
	dft(f0, n/2);
	dft(f1, n/2);
	zeta.re = cos(2.0 * pi / (double)n);
	zeta.im = sin(2.0 * pi / (double)n);
	pow_zeta.re = 1.0;
	pow_zeta.im = 0.0;
	for(int i=0; i<n; i++){
		f[i] = csum(f0[i % (n/2)], cprod(pow_zeta, f1[i % (n/2)]));
		pow_zeta = cprod(zeta, pow_zeta);
	}
}
void idft(comp f[], int n){
	if(n == 1)return;
	comp f0[n/2], f1[n/2], zeta, pow_zeta;
	for(int i=0; i<n/2; i++){
		f0[i] = f[2*i + 0];
		f1[i] = f[2*i + 1];
	}
	idft(f0, n/2);
	idft(f1, n/2);
	zeta.re = cos(2.0 * pi / (double)n);
	zeta.im = -sin(2.0 * pi / (double)n);
	pow_zeta.re = 1.0;
	pow_zeta.im = 0.0;
	for(int i=0; i<n; i++){
		f[i] = csum(f0[i % (n/2)], cprod(pow_zeta, f1[i % (n/2)]));
		pow_zeta = cprod(zeta, pow_zeta);
	}
}

int main(){
	int n;
	ll m;
	scanf("%d%lld", &n, &m);
	comp a[N], b[N];
	for(int i=0; i<N; i++){
		a[i].re = 0.0; a[i].im = 0.0; b[i].re = 0.0; b[i].im = 0.0;
	}
	for(int i=1; i<=n; i++){
		int j;
		scanf("%d", &j);
		a[j].re += 1;
	}
	dft(a, N);
	for(int i=0; i<N; i++)b[i] = cprod(a[i], a[i]);
	idft(b, N);
	ll c[N];
	for(int i=0; i<N; i++){
		c[i] = (ll)(b[i].re / (double)N + 0.334);
	}
	ll ans = 0;
	int i = N - 1;
	while(m){
		ll tmp = min(m, c[i]);
		if(tmp > 0){
			ans += tmp * i;
			m -= tmp;
		}
		i--;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 19968
#include <cstdio>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int,int> mp;

mp mpadd(mp a,mp b){
	return make_pair(a.first+b.first,a.second+b.second);
}
mp mpsub(mp a,mp b){
	return make_pair(a.first-b.first,a.second-b.second);
}

int main(void){
	for(;;){
		
		int m,n;
		mp lookf[205];
		mp dat[1005];
		
		scanf("%d",&m);
		if(m==0)break;
		for(int i=0;i<m;i++){
			scanf("%d%d",&(lookf[i].first),&(lookf[i].second));
		}
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d%d",&(dat[i].first),&(dat[i].second));
		}
		
		for(int i=0;i<n;i++){
			mp diff=mpsub(lookf[0],dat[i]);
			
			for(int j=1;j<m;j++){
				for(int k=0;k<n;k++){
					if(lookf[j]==mpadd(dat[k],diff)){
						goto nextj;
					}
				}
				goto nexti;
nextj:;
			}
			printf("%d %d\n",-diff.first,-diff.second);
			break;
nexti:;
		}
	}
	return 0;
}
		
			

Measured memory_bytes: 1036
import bisect
def roller_coaster(n, k, hli):

    hli.sort()

    lenght = len(hli)

    ans = lenght - bisect.bisect_left(hli, k)

    return ans

def main():
    n, k = map(int, input().split())
    hli = list(map(int, input().split()))
    print(roller_coaster(n, k, hli))

if __name__ == '__main__':
    main()

Measured memory_bytes: 11908
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        System.out.println(c - a - b > 0 && 0 < a * a - 2 * a * b + b * b - 2 * b * c + c * c - 2 * c * a ? "Yes" : "No");
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n)cin >> a[i];
    int ans = 1;
    int mitei = true;
    int up = false, down = false;    
    rep(i, n - 1){
        if(mitei){
            if(a[i] == a[i + 1])continue;
            else if(a[i] > a[i + 1]){
                down = true;
                mitei = false;
            }
            else{
                up = true;
                mitei = false;
            }
        }
        else if(down){
            if(a[i] >= a[i + 1])continue;
            else{
                ans++;
                mitei = true;
                down = false;
            }
        }
        else if(up){
            if(a[i] <= a[i + 1])continue;
            else{
                ans++;
                mitei = true;
                up = false;
            }
        }
    }
    cout << ans << endl;
}

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
string alpha = "abcdefghijklmnopqrstuvwxyz" ;

 
/*CODE START HERE*/
int main() {
  int a,b;
  cin >> a >> b;
  forn(i,20000){
    int c,d;
    c = i*0.08;
    d = i * 0.10;
    if ( c == a && d == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N = (1 << 18) + 5;
int n, a[N], m, f[N], g[N];
signed main() {
	#ifdef aome
	in("aome.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	m = (1 << n);
	fw (i, 0, m) cin >> a[i];
	/*
	We can change the query into (i | j) == k.
	i and j both have to be subsets of k. Then, just save f[i] and g[i]: 2 maximum values of all
	a[subset of i]. Answering for each k then takes O(1)
	*/
	fw (i, 0, m) {
		f[i] = i, g[i] = -1;
	}
	fw (i, 0, m) {
		fw (j, 0, n) if (i & (1 << j)) {
			if (a[f[i ^ (1 << j)]] > a[f[i]]) f[i] = f[i ^ (1 << j)];
		}
	}
	fw (i, 0, m) {
		if (f[i] != i) g[i] = i;
		fw (j, 0, n) if (i & (1 << j)) {
			if (f[i ^ (1 << j)] == f[i]) {
				if (g[i ^ (1 << j)] != -1 && (g[i] == -1 || a[g[i ^ (1 << j)]] > a[g[i]]))
					g[i] = g[i ^ (1 << j)];
				continue;
			}
			if (g[i] == -1 || a[f[i ^ (1 << j)]] > a[g[i]]) g[i] = f[i ^ (1 << j)];
		}
	}
	int lst = 0;
	fw (i, 1, m) {
		int ans = max(lst, a[f[i]] + a[g[i]]);
		//cout << "f["<<i<<"] = "<<f[i]<<", g="<<g[i]<<"\n";
		cout << ans << "\n";
		lst = ans;
	}
	return 0;
}

Measured memory_bytes: 6144
N, K = map(int,input().split())
pn = list(map(int,input().split()))
num = [0]*(N-K+1)
num[0] = sum(pn[0:K])
for n in range(1,N-K+1):
  num[n] = num[n-1] - pn[n-1] + pn[n+K-1]
print(0.5*(K + max(num)))

Measured memory_bytes: 25060
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <assert.h>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
    
    vector<string> ansz;
    string s,t;
    cin>>s;
    cin>>t;

    if(s.size()<t.size()){
        return cout<<"UNRESTORABLE"<<endl,0;
    }
    
    string a;
    for(int pos=0;pos<s.size()-t.size()+1;pos++){
        string subs=s.substr(pos,t.size());
        cerr<<subs.size()<<" "<<t.size()<<endl;
        cerr<<subs<<" "<<t<<endl;
        
        assert(subs.size()==t.size());

        REP(i,t.size()){
            if(subs[i]==t[i]||subs[i]=='?'){
                subs[i]=t[i];
            }
            else{
                goto NEXT;
            }
        }
        debug(s.substr(0,pos));
        debug(s.substr(pos+t.size(),s.size()-pos-t.size()));
        a=s.substr(0,pos)+subs+s.substr(pos+t.size(),s.size()-pos-t.size());
        debug(a);
        REP(i,a.size()){
            if(a[i]=='?'){
                a[i]='a';
            }
        }
        ansz.push_back(a);
        NEXT:;
    }

    if(ansz.size()==0){
        return cout<<"UNRESTORABLE"<<endl,0;
    }

    sort(ansz.begin(),ansz.end());
    cout<<ansz[0]<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String line = br.readLine();
        boolean res = false;
        if (line.contains("keyence")) {
            String p = line.replace("keyence", "@");
            if (p.startsWith("@") || p.endsWith("@")) {
                res = true;                
            }
        } else if (line.contains("keyenc")) {
            String p = line.replace("keyenc", "@");
            if (p.startsWith("@") && p.endsWith("e")) {
                res = true;                
            }
        } else if (line.contains("keyen")) {
            String p = line.replace("keyen", "@");
            if (p.startsWith("@") && p.endsWith("ce")) {
                res = true;                
            }
        } else if (line.contains("keye")) {
            String p = line.replace("keye", "@");
            if (p.startsWith("@") && p.endsWith("nce")) {
                res = true;                
            }
        } else if (line.contains("key")) {
            String p = line.replace("key", "@");
            if (p.startsWith("@") && p.endsWith("ence")) {
                res = true;                
            }
        } else if (line.contains("ke")) {
            String p = line.replace("ke", "@");
            if (p.startsWith("@") && p.endsWith("yence")) {
                res = true;                
            }
        } else if (line.contains("k")) {
            String p = line.replace("k", "@");
            if (p.startsWith("@") && p.endsWith("eyence")) {
                res = true;                
            }
        }
        out.println(res ? "YES" : "NO");
        out.close();
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	double a,b;
	cin>>a>>b;
	printf("%.10lf\n",a / b);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();

		int max = a + b;

		if(a-b > max) {
			max = a - b;
		}

		if ( a*b > max ){
			max = a * b;
		}

		System.out.println(max);

		sc1.close();
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7
#define LD long double

int main(){
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    for(int i = a; i <= b; ++i){
        if(i % n == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3636
S = list(input())

s1 = S[0] + S[1]
s2 = S[2] + S[3]

if 0<int(s1) and int(s1) <= 12:
    if 0<int(s2) and int(s2) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0<int(s2) and int(s2) <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B < C){
        cout << 2 * B + A  + 1 << endl;
    }
    else {
        cout << C + B << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

vector <int> edges[100000];
vector <int> reverse_edges[100000];
int dp[100000];

int rec(int v){
    if(dp[v] >= 0){
        return dp[v];
    }
    int max_length = 0;
    for(int i = 0; i < edges[v].size(); i++){
        max_length = max(rec(edges[v][i]) + 1, max_length);
    }
    dp[v] = max_length;
    return max_length;
}

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

    int x;
    int y;
    for(int i = 0; i < M; i++){
        cin >> x >> y;
        edges[x-1].push_back(y-1);
        reverse_edges[y-1].push_back(x-1);
    }


    vector <int> sources;
    for(int i = 0; i < N; i++){
        if(reverse_edges[i].size() <= 0){
            sources.push_back(i);
        }
    }

    for(int i = 0; i < N; i++){
        dp[i] = -1;
    }
    
    int ans = 0;
    for(int i = 0; i < sources.size(); i++){
        ans = max(ans, rec(sources[i]));
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 16256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define For(i,x,y) for(int i = x; i <= y; ++i)
#define FOR For
#define rev_For(i,x,y) for(int i = x; i >= y; --i)
#define REV_FOR rev_For
#define ll long long
#define Size(v) ((int)v.size())
#define _section "\n--------------------\n"
#define fi first
#define se second
#define pb push_back
using namespace std;
// using namespace __gnu_pbds;


string s, t;
const int nax = 3005;
const int INF = nax * nax;
int n, m;
int dp[nax][nax];

void input() {
	cin >> s >> t;
	n = Size(s), m = Size(t);
	s = ' ' + s, t = ' ' + t;

	FOR (i, 0, nax - 1) {
		FOR (j, 0, nax - 1) {
			dp[i][j] = -1;
		}
	}
}

int calc(int i, int j) {
	if (dp[i][j] != -1) return dp[i][j];

	if (i <= 0 || j <= 0) return 0;

	int ret = -INF;

	if (s[i] == t[j]) ret = max(ret, calc(i - 1, j - 1) + 1);
	else {
		ret = max(ret, calc(i - 1, j));
		ret = max(ret, calc(i, j - 1));
	}

	return (dp[i][j] = ret);
}

void solve() {
	deque<char> res;
	
	int i = n, j = m;

	while (i >= 1 && j >= 1) {
		if (s[i] == t[j]) {
			res.push_front(s[i]);
			--i;
			--j;
		}
		else {
			if (calc(i - 1, j) > calc(i, j - 1)) {
				--i;
			}
			else {
				--j;
			}
		}
	}

	for (char &c : res) cout << c;
}

signed main() {
#ifdef _DEBUG
	// freopen("INPUT.inp", "r", stdin);
	//freopen("OUTPUT.out", "w", stdout);
	clock_t start, end;
	start = clock();
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------------------------------------------
//----------------------------------MAIN PROGRAM--------------------------------------
	int t = 1;
	while (t--) {
		input();
		solve();
	}
//--------------------------------------END-------------------------------------------
//------------------------------------------------------------------------------------
#ifdef _DEBUG
	end = clock();
	cerr << "\n----------\nTime Elapsed: " << fixed << double(end - start) / double(CLOCKS_PER_SEC) << setprecision(6) << '\n';
#endif
	return 0;
}

Measured memory_bytes: 35840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }

  vector<vector<char>> map(H+1,vector<char>(W+1,'.'));
  for(int i=0;i<N;i++){
    if(a.at(i)==1){
      for(int h=0;h<H+1;h++){
        for(int w=x.at(i)-1;w>=0;w--){
          map.at(h).at(w)='*';
        }
      }
    }
    else if(a.at(i)==2){
      for(int h=0;h<H+1;h++){
        for(int w=x.at(i)+1;w<W+1;w++){
          map.at(h).at(w)='*';
        }
      }
    }
    else if(a.at(i)==3){
      for(int h=y.at(i)-1;h>=0;h--){
        for(int w=0;w<W+1;w++){
          map.at(h).at(w)='*';
        }
      }
    }
    else if(a.at(i)==4){
      for(int h=y.at(i)+1;h<H+1;h++){
        for(int w=0;w<W+1;w++){
          map.at(h).at(w)='*';
        }
      }
    }
  }

  int ans=0;
  for(int h=0;h<H;h++){
    for(int w=0;w<W;w++){
      if(map.at(h).at(w)=='.'&&map.at(h+1).at(w)=='.'&&map.at(h).at(w+1)=='.'&&map.at(h+1).at(w+1)=='.')  ans++;
    }
  }
  cout << ans << endl;
/*  for(int h=0;h<H+1;h++){
    for(int w=0;w<W+1;w++){
      cout << map.at(h).at(w);
    }
    cout << endl;
  }
*/

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N,M;
ll d[100000];
vector<int> E[100000];
int x,y;
bool dfs(int l, int k){
    if(k==x) return true;
    bool t=false;
    rep(i,0,2){
        if(E[k][i]!=y&&E[k][i]!=l) t|=dfs(k,E[k][i]);
    }
    return t;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    rep(i,0,M){
        ll a,b;
        cin>>a>>b;
        d[a-1]++;
        d[b-1]++;
        E[a-1].pb(b-1);
        E[b-1].pb(a-1);
    }
    int a=0,b=0;
    vector<int> v;
    rep(i,0,N){
        if(d[i]%2){
            cout <<"No"<<"\n";
            return 0;
        }
        if(d[i]==4){
            a++;
            v.pb(i);
        }
        if(d[i]>=6) b++;
    }
    if(b) cout <<"Yes"<<"\n";
    else if(a>2) cout <<"Yes"<<"\n";
    else if(a<2) cout <<"No"<<"\n";
    else {
        x=v[0], y=v[1];
        bool t=false;
        rep(i,0,4){
            if(E[x][i]!=y) t|=dfs(x,E[x][i]);
        }
        cout <<(t?"Yes":"No")<<"\n";
    }
}

Measured memory_bytes: 7680
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        int[] num = new int[6];
        for (int i = 0; i < num.length; i ++)
            num[i] = input.nextInt();
        String op = input.next();
        char[] opr = op.toCharArray();
        for (int j = 0; j < opr.length; j ++)
            operation(opr[j], num);
        System.out.println(num[0]);
    }
    
    public static void operation(char o, int[] n){
        int temp = 0;
        switch (o) {
            case 'N' :
                temp = n[0];
                n[0] = n[1];
                n[1] = n[5];
                n[5] = n[4];
                n[4] = temp;
                break;
            case 'S' :
                temp = n[0];
                n[0] = n[4];
                n[4] = n[5];
                n[5] = n[1];
                n[1] = temp;
                break;
            case 'W' :
                temp = n[0];
                n[0] = n[2];
                n[2] = n[5];
                n[5] = n[3];
                n[3] = temp;
                break;
            case 'E' :
                temp = n[0];
                n[0] = n[3];
                n[3] = n[5];
                n[5] = n[2];
                n[2] = temp;
                break;
            default :
                break;
        }
    }
}


Measured memory_bytes: 26292
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}
 

void solve() {
    int n;
    ll c;
    cin >> n >> c;
    vector<ll> x(n + 1, 0);
    vector<ll> v(n + 1);
    REP1(i, n) cin >> x[i] >> v[i];
    vector<ll> a(n + 1, 0);
    vector<ll> sa(n + 1, 0);
    REP1(i, n) {
        a[i] = a[i - 1] + v[i] - (x[i] - x[i - 1]);
        sa[i] = max(sa[i - 1], a[i]);
    }
    vector<ll> b(n + 1, 0);
    vector<ll> sb(n + 1, 0);
    ll p = c;
    REP1(i, n) {
        b[i] = b[i - 1] + v[n + 1 - i] - (p - x[n + 1 - i]);
        sb[i] = max(sb[i - 1], b[i]);
        p = x[n + 1 - i];
    }
  
    x.push_back(c);
    ll mx = 0;
    REP(i, n + 1) {
        //chmax(mx, sa[i] - v[i] + sb[n - i]);
        //chmax(mx, sa[i] + sb[n - i] - (c - v[n - i]));
        //chmax(mx, sb[i] - (c - v[n - i]) + sa[n - i]);
        //chmax(mx, sb[i] + sa[n - i] - v[n - i]);
        chmax(mx, sa[i] - x[i] + sb[n - i]);
        chmax(mx, sb[i] - (c - x[n + 1 - i]) + sa[n - i]);
    }
    cout << mx << EOL;
}


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        char[][] chars  = {
                {},
                {'.',',','!','?',' '},
                {'a','b','c'},
                {'d','e','f'},
                {'g','h','i'},
                {'j','k','l'},
                {'m','n','o'},
                {'p','q','r','s'},
                {'t','u','v'},
                {'w','x','y','z'}
        };

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for(int i=0; i<n; i++){
            String result = "";
            String s = scan.next();
            for(int j=0; j<s.length(); j++){
                char c = s.charAt(j);
                if(c == '0'){
                    continue;
                }
                int count = 1;
                for(int k=1; ;k++){
                    if(s.charAt(j+k) == c){
                        count += 1;
                    } else {
                        break;
                    }
                }
                int number = Integer.parseInt(""+s.charAt(j));
                j += count-1;
                int tmp = count%chars[number].length;
                if(tmp != 0){
                    count = tmp;
                } else{
                    count = chars[number].length;
                }
                result += chars[number][count-1];
            }
            System.out.println(result);
        }
    }
}

Measured memory_bytes: 24260
K = int(input())
total = 0
 
def gcd(a, b):
    if(a > b):
        a, b = b, a
 
    while(b > 0):
        r = a % b
        a = b
        b = r
 
    return a
 
 
for a in range(1, K+1):
    for b in range(1, K+1):
        res = gcd(a, b)
        for c in range(1, K+1):
           total += gcd(res, c)
 
 
print(total)

Measured memory_bytes: 68312
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, ans = 0;
    cin >> n;
    vll a(n);
    for(i = 0; i < n; i++)
        cin >> a[i];
    sort(all(a));
    ans = a[n - 1];
    ll cur = 0, in = n - 2;
    for(i = n - 3; i >= 0; i--)
    {
        if(cur == 2)
            cur = 0, in--;
        ans += a[in];
        cur++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4776
#include <stdio.h>
#include <math.h>
#include <string.h>
int main (void){
        int A,B,C,D;
          scanf("%d",&A);
          scanf("%d",&B);
          scanf("%d",&C);
          scanf("%d",&D);
          if (A<=C||B<=D) {
              printf("0\n");
              return 0;
          }
        printf("%d\n",(A-C)*(B-D) );
        return 0;

}


Measured memory_bytes: 128
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<62;
const int MOD=1000000007;
const double EPS=1e-8;

int N,K;

vi x,y;

vi rectx(2),recty(2);

int ans=INF;
int sum;

signed main(){
    io();
    cin>>N>>K;
    x.resize(N+1);y.resize(N+1);
    rep(i,N) cin>>x[i]>>y[i];

    rep(i,N){
        REP(j,i+1,N){
            rep(k,N){
                REP(l,k+1,N){
                    rectx[0]=x[i];
                    rectx[1]=x[j];
                    recty[0]=y[k];
                    recty[1]=y[l];
                    sort(all(rectx));
                    sort(all(recty));
                    sum=0;
                    rep(m,N){
                        if(rectx[0]<=x[m]&&x[m]<=rectx[1]&&recty[0]<=y[m]&&y[m]<=recty[1]){
                            sum++;
                        }
                    }
                    if(sum>=K){
                        //show(rectx[1]-rectx[0]);
                        //show(recty[1]-recty[0]);
                        //show(abs((rectx[1]-rectx[0])*(recty[1]-recty[0])));
                        ans=min(ans,abs((rectx[1]-rectx[0])*(recty[1]-recty[0])));
                    }
                }
            }
        }
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())

count = 0
d = 1
mat = [[0] * 10 for _ in range(10)]
for a in range(1, n+1):
    # a = x***y
    if a >= 10 ** d: d += 1
    x = a // (10 ** (d - 1))
    y = a % 10
    mat[x][y] += 1

for i in range(10):
    # 対角要素
    count += mat[i][i] ** 2

    # 非対角要素
    for j in range(i+1, 10):
        count += mat[i][j] * mat[j][i] * 2

print(count)


Measured memory_bytes: 3064
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

N, M = [int(x) for x in input().split()]

S = [[0] * N for _ in range(M)]
for m in range(M):
    s = [int(x) for x in input().split()]
    for s1 in s[1:]:
        S[m][s1 - 1] = 1

P = [int(x) for x in input().split()]

cnt = 0
for i in range(2 ** N):
    tmp = True
    for j in range(M):
        c = 0
        for k in range(N):
            if i & (1 << k):
                c += S[j][k]

        if c % 2 != P[j]:
            tmp = False

        # bit = format(i, "08b")
        # print("i(bit):{}, j:{}, c:{},c%2:{}, P[j]:{}".format(bit, j, c, c % 2, P[j]))
    # print("---")

    if tmp == True:
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include <cmath>
#include <algorithm>
#include <iostream>
#include <array>
#include <complex>
#include <vector>
#include <tuple>
using namespace std;

const double EPS = 1e-10;
template<class T>
bool eq(const T& a, const T& b) {return abs(a - b) < EPS;}

typedef complex<double> point;
double cross(const point& a, const point& b) {
	return imag(conj(a)*b);
}
double dot(const point& a, const point& b) {
	return real(conj(a)*b);
}

typedef array<point, 2> line;
struct circle {point p; double r;};

point projection(const line& l, const point& p) {
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
double distanceLP(const line& l, const point& p) {
	return abs(p - projection(l, p));
}

/*
 * 円の接線
 *
 * t は交点と円の中心を通る直線と、接線のなす角
 */
line tangent(circle c, double t){
	point p = c.p + polar(c.r, t);
	point d = polar(c.r, t) * point(0, 1);
	return {{p - d, p + d}};
}

vector<line> common_tangents(circle c1, circle c2) {
	vector<line>  ret;
	double t = arg(c2.p - c1.p);
	double d = acos((c1.r - c2.r) / abs(c2.p - c1.p));
	double dst = abs(c2.p - c1.p);

	if(abs(c2.r - c1.r) < dst) {
		//外接線
		ret.push_back(tangent(c1, t - d));
		ret.push_back(tangent(c1, t + d));
	}
	d = acos((c1.r + c2.r) / abs(c2.p - c1.p));
	if(abs(c2.r + c1.r) < dst){
		//内接線
		ret.push_back(tangent(c1, t - d));
		ret.push_back(tangent(c1, t + d));
	}
	return ret;
}

vector<tuple<circle, int>> jewels;

long get_count(const circle& a, const circle& b) {
	long cnt = 0;
	vector<line> ct = common_tangents(a, b);
	for (const auto& l : ct) {
		cnt = max(cnt, count_if(jewels.begin(), jewels.end(), [&](const tuple<circle, int>& t){
			double dist = distanceLP(l, get<0>(t).p);
			return dist + EPS > get<0>(t).r && dist < get<0>(t).r + get<1>(t) + EPS;
		}));
	}
	return cnt;
}

int main() {
	int n;
	while (cin >> n, n) {
		jewels.clear();
		for (int i = 0; i < n; i++) {
			int x, y, m;
			double r;
			cin >> x >> y >> r >> m;
			jewels.emplace_back(circle({point(x, y), r}), m);
		}
		long ans = 1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				auto a = jewels[i];
				auto b = jewels[j];
				ans = max(ans, get_count(get<0>(a), get<0>(b)));
				circle am = {get<0>(a).p, get<0>(a).r + get<1>(a)};
				circle bm = {get<0>(b).p, get<0>(b).r + get<1>(b)};
				ans = max(ans, get_count(am, bm));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1392