akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		vvi a(n+1,vi(n+1));
		rep(i,n){
			rep(j,n){
				cin>>a[i][j];
				a[i][n]+=a[i][j];
				a[n][j]+=a[i][j];
			}
		}
		a[n][n]=accumulate(allof(a[n]),0);
		rep(i,a.size()){
			rep(j,a[i].size())
				cout<<setw(5)<<a[i][j];
			cout<<endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 0
# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

# nの約数のlist
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


# 素数判定
def is_prime(q):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False
    return pow(2, q-1, q) == 1


a, b = map(int, input().split())
d_a = set(prime_factorize(a))
d_b = set(prime_factorize(b))
matched_list = list(d_a & d_b)
matched_list.sort()

count = 0

for i in matched_list:
    if is_prime(i):
        count += 1

print(count+1)


Measured memory_bytes: 38512
import sys
N, M = map(int, input().split())
m = set()
m2 = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        m.add(b)
    if b == N:
        m2.add(a)
for me in m:
    if me in m2:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')

Measured memory_bytes: 18936
#include <iostream>
#include <string>
#define rep(i,n) (int i = 0; i < n; i++)
using namespace std;

int main() {
	int a = 1, b = 0, c = 0;
	string manip;

	while (cin >> manip) {
		if (manip == "A,B" || manip == "B,A") swap(a, b);
		if (manip == "B,C" || manip == "C,B") swap(b, c);
		if (manip == "A,C" || manip == "C,A") swap(c, a);
	}

	if (a)cout << 'A' << endl;
	if (b)cout << 'B' << endl;
	if (c)cout << 'C' << endl;

	return 0;

}

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

#define M 100005
#define N 105
#define Mod 1000000007

int m[N][M];

int main() {
    int n, k;

    cin >> n >> k;

    int a[n];

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

    for (int i = 0;i <= a[0];i++) {
        m[0][i] = 1;
    }

    for (int i = 1;i < n;i++) {
        for (int j = 0;j <= k;j++) {
            if (j == 0) m[i][j] = m[i - 1][j];
            else if (j - a[i] - 1 < 0) {
                 m[i][j] = m[i][j - 1] + m[i - 1][j];
                 m[i][j] %= Mod;
            } else {
                 m[i][j] = m[i][j - 1] - m[i - 1][j - a[i] - 1] + m[i - 1][j];
                 m[i][j] %= Mod;
            }
            if (m[i][j] < 0) m[i][j] += Mod;
        }
    }

    /*
    for (int i = 0;i < n;i++) {

        cout << "i: " << i << "      ";

        for (int j = 0;j <= k;j++) {
            cout << m[i][j] << " ";
        }

        cout << endl;
    }
    */
    cout << m[n - 1][k];
}

Measured memory_bytes: 41216
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll H, W, A, B;

int main(){
  COMinit();
  cin >> H >> W >> A >> B;
  ll all = comb(H+W-2, H-1);
  ll bad = 0;
  rep(i, A){
    bad += comb((H-A+i)+(B-1), B-1) * comb((A-1-i)+(W-B-1), W-B-1) % MOD;
    bad %= MOD;
  }
  all -= bad;
  all += MOD;
  all %= MOD;
  cout << all << endl;

}


Measured memory_bytes: 4992
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> a(n);
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}

	int partial = 0;
	for (int i = 1; i < n; i += 2) {
		partial += a[i];
	}

	long long x1 = sum - 2 * partial;
	vector<int> rain(n);
	rain[0] = x1;
	for (int i = 1; i < n; ++i) {
		rain[i] = 2 * a[i - 1] - rain[i - 1];
	}

	cout << rain;

	return 0;

}

Measured memory_bytes: 2176
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define _D(p) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p)<<std::endl;
#define _D2(p,q) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p) << ", " #q " = "<<(q)<<std::endl;
#define _DN(v) std::cout<<"L"<<__LINE__<<" : " #v " = ["; rep(i,(v).size()) {std::cout<<v[i]<<(i==v.size()-1?"":", ");}std::cout<<"]"<<std::endl;
#define _DNN(v) std::cout<<"L"<<__LINE__<<" : " #v " = [" << std::endl; rep(i,(v).size()) {std::cout<<"    [";rep(j,(v)[0].size()){std::cout<<v[i][j]<<(j==v[0].size()-1?"":", ");}std::cout<<"],"<<std::endl;}std::cout<<"]"<<std::endl;
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-5;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(int argc, char const *argv[]) {
    double N;
    cin >> N;

    for (double h = 1; h <= 3500; ++h) {
        for (double n = 1; n <= 3500; ++n) {
            // 4/N = 1/h + 1/n + 1/w
            // 4 = N/h + N/n + N/w
            // 4 - N/h - N/n = N/w
            // 1 / (4 - N/h - N/n) = w/N
            // N / (4 - N/h - N/n) = w
            if (fabs(4.0 - N/h - N/n) <= EPS) continue;
            double k = N / (4.0 - N/h - N/n);
            int kk = (int)(k + EPS);
            if (fabs(k - kk) <= EPS) {
                cout << h << " " << n << " " << kk << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
#ifdef _WIN32
#define DEBUG	1
#endif

#define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;

#ifdef DEBUG
#include "include.h"
#else
inline void wait(){}
inline void dout(const char *arg, ...){}
#endif

template<typename T>inline void swap(T a, T b){T t = a; a = b; b = t;}

#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define max(a, b) a > b ? a : b;
#define min(a, b) a > b ? b : a;
#define Sin(deg) sin((deg)*MATH_PI/180)
#define Cos(deg) cos((deg)*MATH_PI/180)
#define Tan(deg) tan((deg)*MATH_PI/180)
#define Rad(deg) ((deg)*MATH_PI/180)
#define ff(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define gi(p) Scanf("%d", p)
#define gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define gll(p) Scanf("%lld", p)
#define gll2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define gll3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define gll4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define gf(p) Scanf("%f", p)
#define gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;
signed main() {

	int ii, jj, kk, ll;
	int N;
	int ret = 0;
	int flag = 0;
	char cbuf[8192];

	gc(cbuf);

	if (cbuf[0] == 'A') ans("T");
	if (cbuf[0] == 'T') ans("A");
	if (cbuf[0] == 'G') ans("C");
	if (cbuf[0] == 'C') ans("G");
	wait();

	return 0;
}

Measured memory_bytes: 256
#import operator
n = int(input())
l = set()
cnt = 1
d = {}
o = {}
for i in range(n):
    s,p = input().split()
    p = int(p)
    d[(s, p)] = cnt
    if s in o:
        x = o[s]
        x.append(p)
        o[s] = x

    else:
        o[s] = [p]

    l.add(s)
    cnt = cnt+1

w = list(l)
w.sort()
k = []
#print("  ")
for i in w:
    m = o[i]
    m.sort(reverse = True)
    for j in m:
        #print(i,j,d[(i,j)])
        k.append(d[(i,j)])

for h in k:
    print(h)

Measured memory_bytes: 62324
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 1000000000000000007LL

int a, b, c, d;

int main ()
{
  R2(a, b);
  R2(c, d);
  int ttw = c / b + !!(c % b);
  int atw = a / d + !!(a % d);
  printf("%s\n", ttw <= atw ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 3764
let N = Int(readLine()!)!
var product = 1
let nums: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let threshold = 1000000000000000000

if nums.contains(0) {
  print(0)
} else {
  for i in 0..<N {
    if Double(nums[i]) > Double(threshold) / Double(product) {
      product = -1
      break
    }
    product *= nums[i]
    if product > threshold {
      product = -1
      break
    }
  }
  print(product)
}

Measured memory_bytes: 15044
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int x,t;
    cin>>x>>t;
    cout<<max(0,x-t)<<endl;
    return 0;
}

Measured memory_bytes: 256
dice = input().split()
dice.insert(4, dice.pop(3))
right = []


def rightSearch(up, front):
    index_up = dice.index(up)
    index_front = dice.index(front)
    if 1 <= index_up <= 4 and 1 <= index_front <= 4:
        if index_up == 4 and index_front == 1:
            return dice[0]
        if index_up == 1 and index_front == 4:
            return dice[5]
        if index_up < index_front:
            return dice[0]
        else:
            return dice[5]
    elif (index_front == 0 or index_front == 5) and (index_up != 0 or index_up != 5):
        if index_front == 0:
            if index_up == 1:
                return dice[4]
            else:
                return dice[index_up - 1]
        else:
            if index_up == 4:
                return dice[1]
            else:
                return dice[index_up + 1]
    else:
        if index_up == 0:
            if index_front == 4:
                return dice[1]
            else:
                return dice[index_front + 1]
        else:
            if index_front == 1:
                return dice[4]
            else:
                return dice[index_front - 1]


number = int(input())
for i in range(number):
    up, front = input().split()
    right.append(rightSearch(up, front))

for r in right:
    print(r)


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

int main(){
    int n;
    int ans,cnt;
    while(1){
        cnt = 0;
        cin >> n;
        if(n == 0) break;
        for(int i=1;i<n;i++){
            ans = i;
            for(int j=i+1;j<n;j++){
                if(ans > n) break;
                ans += j;
                if(ans == n){
                    cnt++;
                    break;
                }
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(10);
    long double a;
    cin >> a;
    a = a / 3;
    cout << a * a * a << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1,n):
            a = [l[i],l[j],l[k]]
            if len(set(a))!=3:
                continue
            a.sort()
            ans += a[0]+a[1]>a[2]
print(ans)

Measured memory_bytes: 68468
N, K = list(map(int, input().split()))
h = []
for i in range(N):
    h.append(int(input()))
else:
    h.sort()

hi = []
i = 0
while i + (K - 1) < N:
    hi.append(int(h[i + (K - 1)] - h[i]))
    i += 1

print(min(hi))


Measured memory_bytes: 11212
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Building B[]=new Building[4];
        for(int i=0;i<4;i++)B[i]=new Building();
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        while(n-->0){
            B[sc.nextInt()-1].updateResidents(sc.nextInt()-1,sc.nextInt()-1,sc.nextInt());
        }
        for(int i=0;i<4;i++){
            if(i!=0)System.out.println("####################");
            B[i].output();
        }
    }
}

class Building{
//    private int residents[][];
    private int floor=3;
    private int room=10;
    private int residents[][]=new int[floor][room];
    void Buidling(){
//        this.residents=new int[this.floor][this.room];
        for(int i=0;i<this.floor;i++){
            for(int j=0;j<this.room;j++){
                this.residents[i][j]=0;
            }
        }
    }
    public void updateResidents(int f,int r,int v){
        this.residents[f][r]+=v;
    }
    public void output(){
        for(int i=0;i<this.floor;i++){
            for(int j=0;j<this.room;j++){
                System.out.printf(" %d",this.residents[i][j]);
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 30968
N, M = map(int, input().split())
P = [tuple(map(int, input().split())) for i in range(M)]

A = [-1] * N
ans = 0
for si, ci in P:
    si -= 1
    if si == ci == 0 and N >= 2:
        ans = -1
        break
    if A[si] == -1:
        A[si] = ci
    elif A[si] != ci:
        ans = -1
        break
if ans == 0:
    if A[0] == -1:
        A[0] = 0 if N == 1 else 1
    for i in range(1, N):
        if A[i] == -1:
            A[i] = 0
    ans = ''.join(list(map(str, A)))
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;



public class Main {
	
	int d[];
	boolean used[];
	int g[][];
	final int INF = 1 << 28;
	
	int die(int s, int e, int n){
		used = new boolean[n];
		d = new int[n];
		for(int j=0; j<n; ++j){ d[j] = INF; }
		
		d[s] = 0;
		while(true){
			int u = -1;
			for(int v=0; v<n; ++v){
				if(!used[v] && (u==-1 || d[v] < d[u])){
					u = v;
				}
			}
			if(u==-1){ break; }
			used[u] = true;
			for(int v=0; v<n; ++v){
				if(d[v] > d[u] + g[u][v]){
					d[v] = d[u] + g[u][v];
				}
			}
		}
		
		return d[e];
	}
	
	void io(){
		java.util.Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()){
			final int n = Integer.parseInt(sc.nextLine())+1;
			g = new int[n][n];
			for(int i=0; i<n; ++i){
				for(int j=0; j<n; ++j){
					g[i][j] = i==j ? 0 : INF;
				}
			}
			final int m = Integer.parseInt(sc.nextLine());
			for(int i=0; i<m; ++i){
				String str[] = sc.nextLine().split(",");
				int data[] = new int[str.length];
				for(int j=0; j<str.length; ++j){
					String str2[] = (str[j] + " ").split(" ");
					data[j] = Integer.parseInt(str2[0]);
				}
				final int a = data[0];
				final int b = data[1];
				final int c = data[2];
				final int d = data[3];
				
				g[a][b] = c;
				g[b][a] = d;
			}
			String str[] = sc.nextLine().split(",");
			int data[] = new int[str.length];
			for(int j=0; j<str.length; ++j){
				data[j] = Integer.parseInt(str[j]);
			}
			final int x1 = data[0];
			final int x2 = data[1];
			final int y1 = data[2];
			final int y2 = data[3];
			
			System.out.println(y1 - y2 - (die(x1, x2, n) + die(x2, x1, n)));
		}
	}
	
	public static void main(String[] args) {
		new Main().io();
	}
}

Measured memory_bytes: 12000
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(const ii &a, const ii &b)
{
	ll lena = a.se-a.fi; ll lenb = b.se-b.fi;
	if(lena!=lenb) return lena>lenb;
	else return a.fi<b.fi;
}

ll pref[5011][5111];
ll suf[2][5111];

void amin(ll &a, ll b)
{
	a=min(a,b);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	if(n==1){cout<<0<<'\n'; return 0;}
	vector<ii> vec;
	for(int i=0;i<n;i++)
	{
		ll l,r; cin>>l>>r;
		vec.pb({-l,r});
	}
	sort(vec.begin(),vec.end(),cmp);
	/*
	for(int i=0;i<n;i++)
	{
		cerr<<vec[i].fi<<' '<<vec[i].se<<'\n';
	}
	*/
	ll ans = ll(2e18);
	for(int l=(n-1)/2;l<=n/2;l++)
	{
		int r=n-1-l;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<=n;j++)
			{
				pref[i][j]=ll(1e18);
			}
		}
		for(int i=0;i<2;i++)
		{
			for(int j=0;j<=n;j++)
			{
				suf[i][j]=ll(1e18);
			}
		}
		pref[0][0]=vec[0].se;
		pref[0][1]=-vec[0].fi;
		for(int i=0;i+1<n;i++)
		{
			for(int j=0;j<=n;j++)
			{
				if(pref[i][j]<ll(1e18))
				{
					ll v=pref[i][j];
					ll L=vec[i+1].fi; ll R=vec[i+1].se;
					//go left
					amin(pref[i+1][j], v+R+ll(i+1-j)*(R-L));
					//go right
					amin(pref[i+1][j+1], v-L+ll(j)*(R-L));
				}
			}
		}
		suf[(n-1)&1][0]=vec[n-1].se+ll(l-1)*(vec[n-1].se-vec[n-1].fi);
		suf[(n-1)&1][1]=-vec[n-1].fi+ll(r-1)*(vec[n-1].se-vec[n-1].fi);
		for(int i=max(n-2,0);i<n;i++)
		{
			//segment i is fixed
			ll constant = vec[i].se*r-vec[i].fi*l;
			for(int j=0;j<=r;j++)
			{
				ll lef = 0; 
				ll ri = 0;
				if(i==0)
				{
					if(j!=0) lef=ll(1e18);
				}
				else lef=pref[i-1][j];
				if(i==n-1)
				{
					if(r-j!=0) ri=ll(1e18);
				}
				else ri=suf[(i+1)&1][r-j];
				//cerr<<i<<' '<<j<<' '<<constant<<' '<<lef<<' '<<ri<<'\n';
				ans = min(ans, constant+lef+ri);
			}
		}
		for(int i=n-1;i>0;i--)
		{
			int cur=(i+1)&1; int pre=cur^1;
			for(int j=0;j<=n;j++) suf[cur][j]=ll(1e18);
			for(int j=0;j<=n;j++)
			{
				if(suf[pre][j]<ll(1e18))
				{
					ll v=suf[pre][j];
					ll L=vec[i-1].fi; ll R=vec[i-1].se;
					//go left
					amin(suf[cur][j], v+R+ll(l-1-((n-1-i)+1-j))*(R-L));
					//go right
					amin(suf[cur][j+1], v-L+ll(r-1-j)*(R-L));
				}
			}
			{
				int i2=i-2;
				if(i2<0) continue;
				ll constant = vec[i2].se*r-vec[i2].fi*l;
				for(int j=0;j<=r;j++)
				{
					ll lef = 0; 
					ll ri = 0;
					if(i2==0)
					{
						if(j!=0) lef=ll(1e18);
					}
					else lef=pref[i2-1][j];
					if(i2==n-1)
					{
						if(r-j!=0) ri=ll(1e18);
					}
					else ri=suf[cur][r-j];
					//cerr<<i<<' '<<j<<' '<<constant<<' '<<lef<<' '<<ri<<'\n';
					ans = min(ans, constant+lef+ri);
				}
			}
		}
	}
	
	cout<<ans<<'\n';
}


Measured memory_bytes: 200192
<?php
fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%s", $c);
$cc = str_split($c);
$s = array_count_values($cc);
$r = $s["R"] ?? 0;
$t = substr($c, 0, $r);
$s2 = array_count_values(str_split($t));
$w = $s2["W"] ?? 0;
printf("%d", $w);


Measured memory_bytes: 41124
#include <stdio.h>
int main(){

  int n,x,r,i,j,k;

  while(1){

    scanf("%d %d",&n,&x);
	  
    if (n != 0 || x != 0){

      r=0;
      
      for(i = 0; i < n; i++){
	
	for(j = 0; j < i; j++){
	  
	  for(k = 0; k < j; k++){
	    
	    if (i+j+k+3 == x){
	      
	      r++;
	      
	    }
	    
	  }
	  
	}
	
      }
      
      printf("%d\n",r);
      
    } else {
      
      break;

    }
    
  }

  return 0;

}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll MAX = 1000001;
const ll mod = 1000000007;
ll po(ll x, ll n ){ 
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//reopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	ll r;
	cin>>r;
	
	cout<<setprecision(20)<<2*M_PI*r;

	return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){

    int n,k;cin>>n>>k;
    // int a[n];
    vi a(n+1,0);
    inputarr(a,n);
    // vi last(n+1,0);
    int diff[n+100];
    // vi diff(n+10,0)
    memset(diff,0,sizeof(diff));
    rep0(k){
        // last=a;
        vi last(a);
        memset(diff,0,sizeof(diff));
        for(int i=0;i<n;i++){
            int mi=max(0,i-a[i]);
            int ma=min(n,i+a[i]+1);
            diff[mi]+=1;
            diff[ma]-=1;
        }
        a[0]=diff[0];
        for(int i=1;i<n;i++) a[i]=a[i-1]+diff[i];
        if(last==a) break;
    }
    for(int i=0;i<n;i++) cout<<a[i]<<" ";


    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 7952
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
 
int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
    ll n;
    cin >> n;
    vl a(n + 1);
    vl b(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll c = min(a[i], b[i]);
        ans += c;
        a[i] -= c;
        b[i] -= c;
 
        c = min(a[i + 1], b[i]);
        ans += c;
        a[i + 1] -= c;
        b[i] -= c;
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll x[1000];
ll y[1000];
ll z[1000];
ll tmp[1000];
ll a[8];
int main() {
  ll n,m;
  cin >> n >> m;
  rep(i, n){
    cin >> x[i] >> y[i] >> z[i];
  }
  rep(i, n)
    tmp[i] = x[i] + y[i] + z[i];
  sort(tmp, tmp + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[0] += tmp[i];
  }
  rep(i, n)
    tmp[i] = x[i] + y[i] - z[i];
  sort(tmp, tmp + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[1] += tmp[i];
  }
  rep(i, n)
    tmp[i] = x[i] - y[i] - z[i];
  sort(tmp, tmp + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[2] += tmp[i];
  }
  rep(i, n)
    tmp[i] = x[i] - y[i] + z[i];
  sort(tmp, tmp + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[3] += tmp[i];
  }
  rep(i, n)
    tmp[i] = (x[i]*-1) + y[i] + z[i];
  sort(tmp, tmp + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[4] += tmp[i];
  }
  rep(i, n)
    tmp[i] = (x[i]*-1) + y[i] - z[i];
  sort(tmp, tmp + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[5] += tmp[i];
  }
  rep(i, n)
    tmp[i] = (x[i]*-1) - y[i] + z[i];
  sort(tmp, tmp + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[6] += tmp[i];
  }
  rep(i, n)
    tmp[i] = (x[i]*-1) - y[i] - z[i];
  sort(tmp, tmp + n);
  for(int i = n - 1; i > n - m - 1; i--){
    a[7] += tmp[i];
  }
  sort(a, a + 8);
  cout << a[7] << endl;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
if K % 2 == 1:
  p = N // K
  p *= p * p
  print(p)
else:
  p = N // K
  p *= p * p
  q = (N - K // 2) // K + 1
  q *= q * q
  print(p + q)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mk make_pair
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL );
#define N (ll)(1e5+2)


int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  a=abs(a);
  ll k=a/c;
  if(k>=b)
  {
    cout<<abs(a-b*c)<<endl;
  }
  else
  {
    if(k%2!=0)
    {
      if(b%2!=0)
      {
        cout<<abs(a-k*c)<<endl;
      }
      else
      {
        cout<<min(abs(a-k*c+c),abs(a-k*c-c))<<endl;
      }
    }
    else
    {
      if(b%2==0)
      {
        cout<<abs(a-k*c)<<endl;
      }
      else
      {
        cout<<min(abs(a-k*c+c),abs(a-k*c-c))<<endl;
      }
    }
  }

}


Measured memory_bytes: 3592
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S, T = sl()
    ret = []
    for n in range(N):
        ret.append(S[n])
        ret.append(T[n])
    print("".join(ret))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define INF 100000000

using namespace std;

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

  vector<int> h(n);
  vector<long> dp(n,INF);

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

  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for(int i = 2;i < n;i++){
    dp[i] = min(
                dp[i - 2] + abs(h[i] - h[i - 2]),
                dp[i - 1] + abs(h[i] - h[i - 1])
                );
  }
  
  cout << dp[n -1] << endl;
  return 0;
}


Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();

		while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		}

		for(int result: list){

			System.out.println(result);

		}
	}
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;

int gcd(int a, int b) {
  if (b==0) return a;
  return gcd(b, a%b);
}

int main() {
  int a, b;
  scanf("%d%d ", &a, &b);
  int res = (a >= b) ? gcd(a, b) : gcd(b, a);
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 1192
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict
from bisect import bisect_left

s = readline().rstrip().decode()
t = readline().rstrip().decode()
al = defaultdict(list)
for i, ss in enumerate(s):
    al[ss].append(i + 1)
cnt = 0
tmp = 0
memo = 0
for tt in t:
    memo = bisect_left(al[tt], tmp + 1)
    if not al[tt]:
        print(-1)
        exit()
    if memo == len(al[tt]):
        memo = 0
        cnt += len(s)
    cnt += al[tt][memo] - tmp
    tmp = al[tt][memo]
print(cnt)


Measured memory_bytes: 7912
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var 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 int
var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, res int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	D, _ := strconv.Atoi(read())
	x := make([][]int, N)

	for i := 0; i < N; i++ {
		x[i] = make([]int, D)
		for j := 0; j < D; j++ {
			x[i][j], _ = strconv.Atoi(read())
		}
	}

	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			cnt = 0
			for k := 0; k < D; k++ {
				cnt += pow(abs(x[i][k]-x[j][k]), 2)
			}
			ans := math.Sqrt(float64(cnt))
			if ans == math.Floor(ans) {
				res++
			}
		}
	}
	fmt.Println(res)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }

func abs(x int) int   { return int(math.Abs(float64(x))) }
func floor(x int) int { return int(math.Floor(float64(x))) }
func ceil(x int) int  { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] > a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdint>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 1000000007;

typedef long long ll;



template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<1000000007>;

int main() {
    vector<mint> fact(2000005);
    fact[0] = 1;
    for (int i = 1; i < fact.size(); ++i) {
        fact[i] = fact[i - 1] * i;
    }
    const auto comb = [&fact](int n, int r) {
        return fact[n] / fact[r] / fact[n - r];
    };
    ll n,m,k; cin >> n >> m >> k;
    mint t = 0, tt = 0;
    for(int i=1;i<m;i++) t = t + mint(n) * mint(n) * (mint(m)-mint(i)) * mint(2*i);
    for(int i=1;i<n;i++) tt = tt + mint(m) * mint(m) * (mint(n)-mint(i)) * mint(2*i);
  //  cout << tt.a << endl;
    t = comb(k,2) * fact[m*n-2]  * t / fact[k] / fact[m*n-2 - (k-2)];
    tt = comb(k,2) * fact[m*n-2] / fact[m*n-2 - (k-2)] * tt / fact[k];
    cout << (t+tt).a << endl;
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int dp[100005][2];
int n;
vector<int> v;
int solve(int p,int s){
    if(s<0){
        return (p%2?0:1);
    } 
    if(dp[s][p%2]!=-1)return dp[s][p%2];
    int ans=0;
    if(p%2==0){
        int c=0;
        rep(j,0,n){
           c+=solve(p+1,s-v[j]);
        }
        if(c>0)ans=1;
    }
    else{
        int c=0;
        rep(j,0,n){
            c+=(solve(p+1,s-v[j])==0);
        }
        if(c>0)ans=0;
        else ans=1;
    }
    dp[s][p%2]=ans;
    return ans;
}
int32_t main(){
   int k; cin>>n>>k;
    clr(dp,-1);
    rep(i,0,n){
        int t; cin>>t;
        v.pub(t);
    }
    if(solve(0,k))cout<<"First\n";
    else cout<<"Second\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 11400
#include<stdio.h>
int main(void)
{
	int m,n,i,j,x;
	int kyori[100001],kyori2[100001];
	int nittei[100000];
	int sum,idou,p;
	
	scanf("%d %d",&n,&m);
	kyori[1]=0;
	for(i=2;i<=n;i++)	scanf("%d",&kyori[i]);
	for(i=0;i<m;i++) scanf("%d",&nittei[i]);
	sum=0;
	for(i=1;i<=n;i++){
		sum=sum+kyori[i];
		kyori2[i]=sum;
//printf("kyori2=%d\n",kyori2[i]);
	}
	p=1;
	idou=0;
	for(i=0;i<m;i++){
		x=nittei[i];
//printf("x=%d\n",x);
		if(x>=0)	idou=idou+(kyori2[p+x]-kyori2[p]);
		else idou=idou+(kyori2[p]-kyori2[p+x]);
		idou=idou%100000;
//printf("idou=%d\n",idou);
		p=p+x;
//printf("p=%d\n",p);
	}
	printf("%d\n",idou);
	return 0;
}

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

int main(){
	ll n,m;
	cin >> n >> m;
	ll sum = 0;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		sum += a[i];
	}
	sort(a.rbegin(),a.rend());
	int count = 0;
	rep(i,n){
		if(a[i] * 4 * m >= sum) count++;
	}
	if(count >= m){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            var ans = 0;
            foreach (var s in S)
            {
                if (s == '+') ans++;
                else ans--;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
def main():
  x, n = map(int, input().split())
  if n:
    p = list(map(int, input().split()))
    i = 0
    while True:
      if not x-i in p:
        print(x-i)
        break
      elif not x+i in p:
        print(x+i)
        break
      i += 1
  else:
    print(x)
      
if __name__ == "__main__":
  main()

Measured memory_bytes: 9200