akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() <= k) {
        cout << s << newl;
    } else {
        cout << s.substr(0, k) << "..." << newl;
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int N;
  int a[100];
  int alice = 0;
  int bob = 0;

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

  sort(a, a + N, greater<int>());

  for(int i = 0; i < N; i++) {
    if(i % 2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }

  cout << alice - bob << endl;
}


Measured memory_bytes: 256
(let ((a (read))
      (b (read))
      (k (read)))
  (defun lp (q)
    (cond ((oddp q) (if (oddp a) (setq a (1- a)) nil) (setq a (/ a 2)) (setq b (+ a b)))
          ((evenp q) (if (oddp b) (setq b (1- b)) nil) (setq b (/ b 2)) (setq a (+ a b)))))
  (loop :for w :from 1 :upto k do(lp w))
  (format t "~A ~A" a b))

Measured memory_bytes: 14816
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define oo (int)1e9
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e3 + 5, M = 2 * N + 5;

int n, m, lim;
int a[N], sz[N], c[N][15];
int dp[1 << 12][N];

int solve(int msk, int i){
    if(i == m)
        return ((msk == lim) ? 0 : oo);
    int &ret = dp[msk][i];
    if(~ret)return ret;
    ret = oo;
    ret = min(ret, solve(msk, i + 1));
    int nmsk = msk;
    for(int j = 0 ; j < sz[i] ; ++j)
        nmsk |= (1 << c[i][j]);
    ret= min(ret, solve(nmsk, i + 1) + a[i]);
    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0 ; i < m ; ++i){
        scanf("%d%d", a + i, sz + i);
        for(int j = 0 ; j < sz[i] ; ++j){
            scanf("%d", &c[i][j]);
            --c[i][j];
        }
    }
    lim = (1 << n) - 1;
    memset(dp, -1, sizeof dp);
    int ans = solve(0, 0);
    if(ans >= oo)ans = -1;
    printf("%d\n", ans);
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
const int maxn = 1e5;
vector< II > arr[maxn];
LL n,m;
int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	cin>>n>>m;
	int p,y;
	rep(i,0,m){
		cin>>p>>y;
		p--;
		arr[p].PB(MP(y, i));
	}
	vector< vector<char> > res(m);
	rep(i,0,n){
		if(SZ(arr[i]) > 0){
			sort(ALL(arr[i]));
			// give names
			vector<char> ans(6, '0');
			LL t = i+1;
			int ind = 5;
			while(t){
				LL rem = t % 10;
				ans[ind] = rem + '0';
				t /= 10;
				ind--;
			}
			rep(j,0,SZ(arr[i])){
				rep(k,0,6)
				res[arr[i][j].S].PB(ans[k]);

				t = j + 1;
				vector< char > temp(6, '0');
				ind = 5;
				while(t){
					LL rem = t % 10;
					temp[ind] = rem + '0';
					t /= 10;
					ind--;
				}
				rep(k,0,6)
				res[arr[i][j].S].PB(temp[k]);
			}
		}
	}
	rep(i,0,m){
		rep(j, 0, 12)
		cout<<res[i][j];
		cout<<"\n";
	}
  	return 0;
}

Measured memory_bytes: 14224
#include<iostream>
using namespace std;
int main(){
  int n;
  int i;
  int card[4][13]={{}};
  cin >> n;
  char a;
  int b;
  for(i=0;i<n;i++) {
    cin >> a >> b;
    switch(a){
    case 'S':
      card[0][b-1]=1;
      break;
    case 'H':
      card[1][b-1]=1;
      break;
    case 'C':
      card[2][b-1]=1;
      break;
    case 'D':
      card[3][b-1]=1;
      break;
    }
  }
  for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1 << endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    string s;
    cin>>s;
    n = s.size();
    bool ok = false;
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            ok = true;
            x = i+1;
            y = i+2;
            break;
        }
    }
    for(int i=0;i<n-2;i++){
        if(s[i]==s[i+2]){
            ok = true;
            x = i+1;
            y = i+3;
            break;
        }
    }
    if(ok){
        cout<<x<<" "<<y;
    }
    else{
        cout<<"-1 -1";
    }



    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n,h,w; cin>>n>>h>>w;
    cout<<(1+n-h)*(1+n-w)<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << "[" << pa.first << ", " << pa.second << "]";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  os << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "}";
  return os;
}

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

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

  std::string s;
  ll k;
  std::cin>>s>>k;

  std::vector<ll> temp;

  ll n=s.size();

  ll cnt=1,ans=0;

  char prv=s[0];
  rep(i,1,n){
    if(s[i]==prv){
      cnt++;
    }else{
      temp.push_back(cnt);
      cnt=1;
    }
    prv=s[i];
  }

  temp.push_back(cnt);

  if(temp[0]==n){
    std::cout<<n*k/2;
    return 0;
  }

  if(k==1){
    for(ll i:temp)ans+=i/2;
    std::cout<<ans;
    return 0;
  }

  if(s[0]!=s[n-1]){
    for(ll i:temp)ans+=i/2;
    std::cout<<ans*k;
    return 0;
  }

  ll front=0,last=n-1;

  rep(i,1,n){
    if(s[i]!=s[0])break;
    else front=i;
  }

  for(ll i=n-2;i>=0;i--){
    if(s[i]!=s[n-1])break;
    else last=i;
  }

  std::vector<ll> temp2;

  prv=s[0];
  cnt=1;
  rep(i,front+1,last){
    if(s[i]==prv){
      cnt++;
    }else{
      temp2.push_back(cnt);
      cnt=1;
    }
    prv=s[i];
  }

  if(cnt>1)temp2.push_back(cnt);

  for(ll i:temp2)ans+=k*(i/2);
  ans+=(k-1)*((n+1+front-last)/2);

  ans+=(n-last)/2+(front+1)/2;

  std::cout<<ans;

  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

// utils
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func abs(a, b int) int {
	return int(math.Abs(float64(a) - float64(b)))
}

//data types

type pair struct {
	first  int
	second int
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	set := make(map[int]struct{})

	for i := 0; i < n; i++ {
		a := nextInt()
		if _, ok := set[a]; ok {
			fmt.Print("NO")
			return
		}
		set[a] = struct{}{}
	}

	fmt.Print("YES")
}


Measured memory_bytes: 7296
#include <cstdio>
#include <cstring>
#include <algorithm>

typedef struct {
    int dx;
    int money;
} State;

using namespace std;

int main(void)
{
    State map[51];
    int mx[4];
    int x, y, z;
    int n, e, a;
    int i, j, k;
    static double dp[51][5001];
	double res;
    
    while (1){
        scanf("%d%d%d", &x, &y, &z);
        
        if (x + y + z == 0){
            break;
        }
        
        for (i = 0; i < x; i++){
            scanf("%d", &mx[i]);
        }
        for (i = 0; i <= 50; i++){
			map[i].dx = map[i].money = 0;
        }
        for (i = 0; i < z; i++){
            scanf("%d%d%d", &n, &e, &a);
            
            if (e == 1){
                map[n].dx = a;
            }
            else if (e == 2){
                map[n].money = a;
            }
            else {
                map[n].money = -a;
            }
        }
        
        for (i = 0; i <= 50; i++){
			for (j = 0; j <= 5000; j++){
				dp[i][j] = 0;
			}
        }
		dp[0][0] = 1.0;
		
        for (i = 0; i < y; i++){
			for (j = 0; j <= 5000; j++){
				int tx, tm;
				for (k = 0; k < x; k++){
					tx = min(i + mx[k], y);
					tm = max(0, map[tx].money + j);
					tx = max(0, min(tx + map[tx].dx, y));
					
					dp[tx][tm] += dp[i][j] * (1.0 / x);
				}
			}
        }
		res = 0;
		for (i = 0; i <= 5000; i++){
			res += dp[y][i] * i;
		}
		
		printf("%d\n", (int)res);
    }
    
    return (0);
}

Measured memory_bytes: 3020
a,b,c,x,y=map(int,input().split())
ans=[]
ans.append(a*x+b*y)
ans.append(2*c*max(x,y))
s=min(x,y)
ans.append(min(x,y)*c*2+a*(x-s)+b*(y-s))
print(min(ans))

Measured memory_bytes: 3060
N = int(input())
X = input()

def f(x):
    ret = 0
    c = bin(x).count("1")
    while c > 0:
        x %= c
        c = bin(x).count("1")
        ret += 1
    return ret

MOD = 10 ** 9 + 7
origin_pop = X.count("1")
one_pop = origin_pop - 1
zero_pop = origin_pop + 1
one_mod = 0
zero_mod = 0

for i in X:
    if one_pop > 0:
        one_mod = one_mod * 2 + int(i)
        one_mod %= one_pop
    zero_mod = zero_mod * 2 + int(i)
    zero_mod %= zero_pop

for i, x in enumerate(X):
    if x == "0":
        tmp = zero_mod + pow(2, N-1-i, zero_pop)
        tmp %= zero_pop
        print(f(tmp)+1)
    else:
        if one_pop == 0:
            print(0)
        else:
            tmp = one_mod - pow(2, N-1-i, one_pop)
            tmp = (tmp + one_pop) % one_pop
            print(f(tmp)+1)


Measured memory_bytes: 85264
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll n, ans=0;
void dfs(ll x, int mask) {
    if(x > n) return;
    if(mask==7) ans++;
    dfs(10*x+3, mask|1);
    dfs(10*x+5, mask|2);
    dfs(10*x+7, mask|4);
}

int main() {
    cin >> n;
    dfs(0, 0);
    cout << ans << endl; 
}


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

const int mxN=3e3;
int n;
long double p[mxN], dp[mxN+1][mxN+1], ans;

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

	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> p[i];
	dp[0][0]=1;
	for(int i=0; i<n; ++i)
		for(int j=0; j<=i; ++j) {
			dp[i+1][j+1]+=dp[i][j]*p[i];
			dp[i+1][j]+=dp[i][j]*(1-p[i]);
		}
	for(int j=(n+1)/2; j<=n; ++j)
		ans+=dp[n][j];
	cout << fixed << setprecision(16) << ans;
}

Measured memory_bytes: 139136
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;

int main() {
	int N, X;
	scanf("%d %d", &N, &X);
	int *L = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}
	int x = 0;
	for (int i = 0; i < N; i++) {
		if (x <= X) {
			x += L[i];
		}
		else {
			printf("%d", i);
			return 0;
		}
	}
  	if(x<=X){
      printf("%d", N + 1);
    }else{
      printf("%d", N );
    }
	return 0;
}

Measured memory_bytes: 256
// 5/22
// ANT2-5-1. 二部グラフ判定
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LLP = pair<ll, ll>;

using Graph = vector<vector<int>>;

// 1か0。-1で初期化。
vector<int> color;

bool dfs(Graph &G, int v, int c) {
    color[v] = c;

    for (auto nv : G[v]) {
        // もし同じ色に塗られていたらfalse。
        if (color[nv] == c) return false;

        // もし塗られていなかったら、違う色で塗る。
        if (color[nv] == -1 && !dfs(G, nv, 1 - c)) return false;
    }

    return true;
}

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

    Graph G(N);

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    color.assign(N, -1);

    bool binary = dfs(G, 0, 0);

    if (binary) {
        ll num = 0;
        rep(i, N) {
            if (color[i] == 0) num++;
        }

        ll ans = num * (N - num) - M;
        cout << ans << endl;
    } else {
        ll ans = N * (N - 1) / 2 - M;
        cout << ans << endl;
    }
}


Measured memory_bytes: 6528
import math

def gcd(x,y):
  M=max(x,y)
  m=min(x,y)
  while(M%m!=0):
      r=M%m
      M=m
      m=r
  return m



def f(x,y):
  z=int(x//y)
  return z


a,b,c,d=map(int,input().split())
g=gcd(c,d)
p=a-f(a,c)-f(a,d)+f(a,int(c*d/g))
q=b-f(b,c)-f(b,d)+f(b,int(c*d/g))
if(a%c!=0 and a%d!=0):
  print(q-p+1)
else:
  print(q-p)

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

int findshop(pair<string,int> ashop, vector<pair<string,int>> nums){
    for( int i = 0; i < nums.size(); i++ ){
        if(nums[i] == ashop){
            return i;
        }
    }
}

int main(){
    int N; cin >> N;
    vector<pair<string,int>> shop(N),nums(N);
    string S; int P;
    for( int i = 0; i < N; i++ ){
        cin >> S >> P;
        shop[i] = make_pair(S,-P);
        nums[i] = make_pair(S,-P);
    }
    
    sort(shop.begin(),shop.end());

    for( int i = 0; i < N; i++ ){
        cout << 1 + findshop(shop[i],nums) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;
typedef pair<ll,ll> pll;

ll XX[100000], YY[100000];
ll X[100000], Y[100000];
ll sumx[100001], sumy[100001];

int n;

pll mid(ll *A) {
  sort(A,A+n);
  return pll(A[(n-1)/2],A[n/2]);
}
ll calc2(ll s, ll *A) {
  ll res = 0;
  REP(i,n) {
    res += 2*abs(A[i]-s);
  }
  return res;
}
pll calc(pll p, ll *A) {
  return pll(calc2(p.first,A), calc2(p.second,A));
}

ll solve(pll p, pll a, ll s, ll &x) {
  ll t1 = a.first - abs(p.first-s);
  ll t2 = a.second - abs(p.second-s);
  if (t1 <= t2) {
    x = p.first;
    return t1;
  } else {
    x = p.second;
    return t2;
  }
}

int main() {
  int w,h;
  cin >> w >> h;
  cin >> n;
  REP(i,n) {
    cin >> X[i] >> Y[i];
    XX[i] = X[i], YY[i] = Y[i];
  }

  pll px = mid(X);
  pll py = mid(Y);
  pll ax = calc(px,X);
  pll ay = calc(py,Y);
  
  ll ans = 1LL<<50;
  ll ansx,ansy;
  
  REP(i,n) {
    ll tmp = 0;
    ll x,y;
    tmp += solve(px,ax,XX[i],x);
    tmp += solve(py,ay,YY[i],y);
    if (tmp < ans) {
      ans = tmp;
      ansx = x;
      ansy = y;
    } else if (tmp == ans && pii(x,y) < pii(ansx,ansy)) {
      ansx = x;
      ansy = y;
    }
  }
  
  cout << ans << endl;
  cout << ansx << " " << ansy << endl;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 6e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000000006;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 316;
 
string s;
bool st;

int main(){
//	cout<<fixed<<setprecision(10);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>s;
    for(auto i:s){
    	if(!st)cout<<i;
    	st^=1;
	}
	cout<<endl;
    return 0;
}

Measured memory_bytes: 592
#include <stdio.h>

int a[100][100], n;

void djk(){
  int minv, d[100], c[100], i, j, u;

  for(i = 0; i < n; i++){
    d[i] = 1000000;
    c[i] = 0;
  }

  d[0] = 0;
  c[0] = 1;
  while(1){
    minv = 1000000;
    u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && c[i] != 2){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    c[u] = 2;
    for(j = 0; j < n; j++){
      if(c[j] != 2 && a[u][j] != 1000000){
	if(d[j] > d[u] + a[u][j]){
	  d[j] = d[u] + a[u][j];
	  c[j] = 1;
	}
      }
    }
  }
  for(i = 0; i < n; i++){
    printf("%d ", i);
    if(d[i] != 1000000) printf("%d\n", d[i]);
  }
}


int main(){
  int i, j, u, k, v, c;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      a[i][j] = 1000000;
    }
  }
  
  for(i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    for(j = 0; j < k; j++){
      scanf("%d %d", &v, &c);
      a[u][v] = c;
    }
  }

    djk();

  return 0;
}
  

Measured memory_bytes: 636
// #include<iostream>
// #include<cstdio>
// #include<cstring>
// #include<string>
// #include<stack>
// #include<queue>
// #include<set>
// #include<map>
// #include<vector>
// #include<list>
// #include<cmath>
// #include<algorithm>
// #include<bitset>
// #define lson node<<1,st,mid
// #define rson node<<1|1,mid+1,ed
// #define mem(a,x) memset(a,x,sizeof(a))
// #define me(a) memset(a,0,sizeof(a))
// #define IOS ios::sync_with_stdio(false)
// #define lowbit(x) x&(-x)
// #define up(i,x,y) for(long long i=x;i<y;i++)
// #define down(i,x,y) for(long long i=x;i>=y;i--)
// #define in freopen("in.txt","r",stdin)
// #define out freopen("out.txt","w",stdout)   
// typedef long long ll;
// const ll mod = 998244353;
// const ll INF = 0x3f3f3f3f;
// const ll maxn = 1e6 + 5;
// const double pi = acos(-1.0);
// const double eps=1e-9;
// using namespace std;
// ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
// int main(){
// 	// in;
// 	// out;
// 	ll a,b,c;
// 	cin>>a>>b>>c;
	
// }


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
int a[100]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	// in;
	// out;
	ll n,m;
	cin>>n>>m;
	if(m==1||n==1){
		cout<<"1"<<endl;
		return 0;
	}
	ll x=n*m;
	if(x%2==0) cout<<x/2<<endl;
	else cout<<x/2+1<<endl;
}

Measured memory_bytes: 256
a=int(input())
if a<40:
    a=40
    
b=int(input())
if b<40:
    b=40
    
c=int(input())
if c<40:
    c=40
    

d=int(input())
if d<40:
    d=40
    

e=int(input())
if e<40:
    e=40
    

print(int((a+b+c+d+e)/5))


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int n,m,q,l,r,c[501][501];
int main(){
  cin>>n>>m>>q;
  for(int i=0;i<m;++i){
    cin>>l>>r;
    for(int j=r;j<501;++j) c[l][j]++;
  }
  
  for(int i=0;i<q;++i){
    int ans=0;
    cin>>l>>r;
	for(int j=l;j<=r;++j) ans+=c[j][r];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;

const ll INF = 1LL<<60;

vector<ll> dijkstra(int n, int s, vector<vector<P>> G) {
  priority_queue<P, vector<P>, greater<P> > que;
  vector<ll> d(n,INF);
  d[s] = 0;
  que.push(P(0,s));
  while(!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    // if (v >= n) continue;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); ++i) {
      int to = G[v][i].first;
      // if (to >= n) continue; 
      ll cost = G[v][i].second;
      if (d[to] > d[v] + cost) {
        d[to] = p.first + cost;
        que.push(P(d[to], to));
      }
    }
  }
  return d;
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<vector<P> > G(n);
  rep(i,n-1) {
    G[i].push_back(P(i+1,1));
    G[i+1].push_back(P(i,1));
  }
  G[x].push_back(P(y,1));
  G[y].push_back(P(x,1));
  vector<ll> cnt(n,0);
  for (int m = n; m >= 1; --m) {
    vector<ll> dist = dijkstra(n, m-1, G);
    rep(i,m) {
      cnt[dist[i]]++;
    }
  }
  for(int i = 1; i < n; ++i) {
    cout << cnt[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())


int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) cin >> A[i];
  ll max = 0, ans = 0;
  rep(i,N) {
    if (A[i]>max) {
      max = A[i];
    } else {
      ans += max-A[i];
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
struct P {
	int x, y;
	P(int x, int y) : x(x), y(y) {}
};

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

int mp[50][50][50][50];

int main()
{
	int W, H, lsx, lsy, rsx, rsy, lgx, lgy, rgx, rgy;
	while (cin >> W >> H, W | H) {
		vector<string> Rl(H), Rr(H);
		for (int i = 0; i < H; i++) {
			cin >> Rl[i] >> Rr[i];
			for (int j = 0; j < W; j++) {
				if (Rl[i][j] == 'L') {
					lsx = i;
					lsy = j;
				}
				else if (Rl[i][j] == '%') {
					lgx = i;
					lgy = j;
				}
			}
			for (int j = 0; j < W; j++) {
				if (Rr[i][j] == 'R') {
					rsx = i;
					rsy = j;
				}
				else if (Rr[i][j] == '%') {
					rgx = i;
					rgy = j;
				}
			}
		}
		queue<pair<P, P>> q;
		q.push(pair<P, P>(P(lsx, lsy), P(rsx, rsy)));
		mp[lsx][lsy][rsx][rsy] = 1;
		while (!q.empty()) {
			auto p = q.front(); q.pop();
			int lx = p.first.x, ly = p.first.y, rx = p.second.x, ry = p.second.y;
			for (int i = 0; i < 4; i++) {
				int ltx = lx + dx[i], lty = ly - dy[i], rtx = rx + dx[i], rty = ry + dy[i];
				if (ltx >= 0 && ltx < H && lty >= 0 && lty < W && Rl[ltx][lty] != '#' && rtx >= 0 && rtx < H && rty >= 0 && rty < W && Rr[rtx][rty] != '#') {
					if ((Rl[ltx][lty] == '%') == (Rr[rtx][rty] == '%') && mp[ltx][lty][rtx][rty] == 0) {
						mp[ltx][lty][rtx][rty] = 1;
						q.push(pair<P, P>(P(ltx, lty), P(rtx, rty)));
					}
				}
				else if (ltx >= 0 && ltx < H && lty >= 0 && lty < W && Rl[ltx][lty] != '#') {
					if (Rl[ltx][lty] != '%' && mp[ltx][lty][rx][ry] == 0) {
						mp[ltx][lty][rx][ry] = 1;
						q.push(pair<P, P>(P(ltx, lty), P(rx, ry)));
					}
				}
				else if (rtx >= 0 && rtx < H && rty >= 0 && rty < W && Rr[rtx][rty] != '#') {
					if (Rr[rtx][rty] != '%' && mp[lx][ly][rtx][rty] == 0) {
						mp[lx][ly][rtx][rty] = 1;
						q.push(pair<P, P>(P(lx, ly), P(rtx, rty)));
					}
				}
			}
		}
		cout << (mp[lgx][lgy][rgx][rgy] ? "Yes" : "No") << endl;
		for (int i = 0; i < 50; i++) {
			for (int j = 0; j < 50; j++) {
				for (int k = 0; k < 50; k++) {
					for (int l = 0; l < 50; l++) {
						mp[i][j][k][l] = 0;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 28304
#include<iostream>
#include<deque>
#include<string>

using namespace std;
deque<int> dq;

int n, k;
string str;
int main(){
  cin >> n >> k;
  cin >> str;
  int flip = 0;
  for(int i = 0;i < n;i++){
    if(str[i] == 'A')dq.push_back(0);
    else dq.push_back(1);
  }
  int t = min(1080000, k);
  k -= t;
  if(k % 2 == 1)k--,t++;
  for(int i = 0;i < t;i++){
    if(flip == dq[0]){//A
      dq[0] ^= 1;
      continue;
    }
    else{//B
      dq.pop_front();
      flip ^= 1;
      dq.push_back(flip);
    }
  }
  for(int i = 0;i < n;i++){
    if(dq[i] == flip)cout << 'A';
    else cout << 'B';
  }cout << endl;
}

Measured memory_bytes: 1540
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;
using ll = long long;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  vector<int> a(3);
  for(int i=0; i<3; ++i) cin >> a[i];

  sort(a.rbegin(), a.rend());
  int mx = a[0], mid = a[1];
  int dif = mx - mid;
  int cnt = 0;
  for(int i=0; i<dif; ++i){
    a[1]++;
    a[2]++;
    cnt++;
  }
  int dif2 = a[0] - a[2];
  if(dif2%2==1){
    a[0]++;
    a[1]++;
    cnt++;
  }
  int dif3 = a[0]-a[2];
  for(int i=0; i<dif3/2; ++i){
    a[2] += 2;
    cnt++;
  }
  cout <<cnt << endl;

}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n;
signed main() {
	while (cin >> n, n) {
		stack<pair<short, int>>st;
		for0(i, n) {
			short t; cin >> t;
			if (i % 2 == 0) { if (st.size() == 0 || st.top().first != t)st.push(make_pair(t, i)); }
			else if (st.top().first != t) { st.pop(); if (st.size() == 0)st.push(make_pair(t, (int)0)); }
		}
		int ans = 0;
		while (st.size()) {
			if (st.top().first == 0)ans += n - st.top().second;
			n = st.top().second;
			st.pop();
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3020
/*
	*	Created By: 'Present_Sir'
	*	Created On: Thursday 27 August 2020 02:31:31 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

class Solver{
    public:
        void test(){
            //int t; cin>>t; for(int i=1; i<=t; ++i)
            {
                //cout<<"Case #"<<i<<": ";
                this->solve();
            }
        }
        void solve(){
           int x,y;
           cin>>x>>y;
           int k = (4*x-y);
            int k2 = y-2*x;
           if( ( (k)%2 == 0 and (k)/2 >= 0  and (x-k) >= 0)){
               cout<<"Yes"<<endl;
                return;
           }
            if( (k2)%2 == 0 and (k2)/2 >=0 and (x-k2) >= 0 ){
                cout<<"Yes"<<endl;
                return;
            }
           cout<<"No"<<endl;
        }
};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define sf scanf
#define pf printf
#define pi acos(-1)
#define time_save ios_base::sync_with_stdio(false); cin.tie(NULL);

ll vis[200005],n,m,mx,cnt=0;
vector<ll>vec[200005];
void dfs(ll src)
{
    vis[src]=1;
    cnt++;
    for(ll i=0;i<vec[src].size();i++)
    {
        ll v=vec[src][i];
        if(vis[v]==0)
        {
            vis[v]=1;
            //cnt++;
            dfs(v);
        }
    }
}
int main()
{
    //time_save;
    sf("%lld%lld",&n,&m);
    ll x,y;
    for(ll i=0;i<m;i++)
    {
        sf("%lld%lld",&x,&y);
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    for(ll i=1;i<=n;i++)
    {
        cnt=0;
        if(vis[i]==0)
        {
            dfs(i);
            mx=max(mx,cnt);
        }
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 22432
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    ll n; cin>>n;
    ll temp=0;
    ll ans=0;
    for(int i=1;; i++){
        //cout<<temp<<endl;
        temp+=i;
        if(temp>=n){ans=i;break;}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <sstream>
using namespace std;

int main()
{
  string exp;
  while (getline(cin, exp)) {
    string s;
    stack<double> stk;
    istringstream iss(exp);
    while (iss >> s) {
      if (s == "+" || s == "-" || s == "*" || s == "/") {
	double d2 = stk.top();
	stk.pop();
	double d1 = stk.top();
	stk.pop();
	if (s == "+")
	  stk.push(d1+d2);
	else if (s == "-")
	  stk.push(d1-d2);
	else if (s == "*")
	  stk.push(d1*d2);
	else if (s == "/")
	  stk.push(d1/d2);
      } else {
	stk.push(atof(s.c_str()));
      }
    }
    printf("%.6f\n", stk.top());
  }
  return 0;
}

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

int n, size;
int memo[5010][5010];

#define MOD 1000000007

long long pow_mod(long long n, long long m){
  int ans = 1;
  while(m > 0){
    if(m & 1) ans = (ans * n) % MOD;
    n = (n*n) % MOD;
    m >>= 1;
  }
  return ans;
}

long long dfs(int i, int s){
  if(memo[i][s] != -1) return memo[i][s];
  if(i == n){
    if(s == size){
      return 1;
    }else{
      return 0;
    }
  }

  return memo[i][s] = (dfs(i+1,min(s+1,5000))*2 + dfs(i+1,max(s-1,0))) % MOD;
}

int main(){
  cin >> n;
  string s;
  cin >> s;
  size = s.size();

  memset(memo,-1,sizeof(memo));
  cout << (dfs(0, 0) * pow_mod(pow_mod(2,size),MOD-2)) % MOD << endl;
  return 0;
}


Measured memory_bytes: 98560
from collections import defaultdict
n, t = map(int, input().split())
A = list(map(int, input().split()))

MAX_S = []
max_tmp = 0
for a in A[::-1]:
    if max_tmp < a:
        max_tmp = a
    MAX_S.append(max_tmp)
MAX_S = MAX_S[::-1]
cnt = defaultdict(int)
for a, s in zip(A, MAX_S):
    cnt[s-a] += 1

c = [(k, v) for k, v in cnt.items()]
c.sort(reverse=True)
print(c[0][-1])


Measured memory_bytes: 25436
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,a[11111],sum=0,min=1111111,max=-1111111;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum=sum+a[i];
    if(a[i]<min){
      min=a[i];
    }
    if(a[i]>max){
      max=a[i];
    }
  }
  cout<<min<<' '<<max<<' '<<sum<<endl;
  return(0);
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c =='e' || c =='o')cout << "vowel" << endl;
    else cout << "consonant" << endl;
}   

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

int main() {
  int N , A , x;
  cin >> N >> A;
  x = N % 500;//まずNを５００円玉で割ったあまり
  if (x <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  


Measured memory_bytes: 256
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll                    long long
#define debug(x)            { cerr << #x << " = " << x << endl; }
#define MOD                    1000000007
#define MAX                    1e9
#define MIN                 -1e9
#define vi                    vector<int>
#define vii                    vector<vi>
#define max(x,y)            (x>y)?x:y
#define mid(s,e)            (s+(e-s)/2)
#define MAXND                11
using namespace std;

int main() {
    ios::sync_with_stdio(false);
     cin.tie(0);
    int n,d;
    cin>>n>>d;
    int points[MAXND][MAXND];
    for(int i=0; i<n ;i++) {
        for(int j=0; j<d; j++) {
            cin>>points[i][j];
        }
    
    }
    int cnt = 0;

    for(int i=0; i<n-1; i++) {
        for(int j=i+1; j<n; j++) {
            double sum = 0;
            for(int k=0; k<d; k++) {
                sum += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]) ;
            }
            double sqrttt = sqrt(sum);
            if(floor(sqrttt) == ceil(sqrttt))
                cnt++;
        }
        
    }

    cout<<cnt;
    return 0;
}



Measured memory_bytes: 256
// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("[%s = %d]\n", #x, x)

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	char s[10];
	scanf("%s", s);
	bool res = true;
	for (int i = 0; i < 3; i++) if (s[i] == s[i + 1]) { res = false; break; }
	if (res) printf("Good\n"); else printf("Bad\n");
}

Measured memory_bytes: 128
def sol():
    h,w=map(int,input().split())
    l=[]
    d=set()
    for i in range(h):
        s=list(input())
        for j in range(w):
            if s[j]=="#": d.add((i,j))
        l.append(s)
    ans=-1
    for i in range(2000):
        if len(d)==0: break
        ans+=1
        t=set()
        for j in d:
            if 0<=j[0]+1<h and l[j[0]+1][j[1]]==".":
                l[j[0]+1][j[1]]="#"
                t.add((j[0]+1,j[1]))
            if 0<=j[0]-1<h and l[j[0]-1][j[1]]==".":
                l[j[0]-1][j[1]]="#"
                t.add((j[0]-1,j[1]))
            if 0<=j[1]+1<w and l[j[0]][j[1]+1]==".":
                l[j[0]][j[1]+1]="#"
                t.add((j[0],j[1]+1))
            if 0<=j[1]-1<w and l[j[0]][j[1]-1]==".":
                l[j[0]][j[1]-1]="#"
                t.add((j[0],j[1]-1))
        d=t
    print(ans)

if __name__ == "__main__":
    sol()


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

const int MAX_V=100005;
vector<pair<int,ll>> G[MAX_V];
ll d[MAX_V];

void dijkstra(int s){
  priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> que;
  d[s]=0;
  que.emplace(0,s);

  while (!que.empty()) {
    pair<ll,int> p=que.top(); que.pop();
    int v=p.second;
    if (d[v]<p.first) continue;
    for (auto e: G[v]) {
      if (d[e.first]>d[v]+e.second) {
	d[e.first]=d[v]+e.second;
	que.emplace(d[e.first],e.first);
      }
    }
  }
}

int main() {
  int n;
  cin>>n;
  rep(i,n-1) {
    int a,b,c;
    cin>>a>>b>>c;
    a--; b--;
    G[a].emplace_back(b,c);
    G[b].emplace_back(a,c);
  }
  int q,k;
  cin>>q>>k;
  k--;
  rep(i,n) d[i]=1e18;
  dijkstra(k);
  rep(i,q) {
    int x,y;
    cin>>x>>y;
    x--; y--;
    cout<<d[x]+d[y]<<endl;
  }
  return 0;
}

Measured memory_bytes: 11120
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    pair<int,int> a[N];
	void main()
	{
	    int n=qread(),k=qread(),s=qread();
	    fo(i,1,k) write1(s);fo(i,k+1,n) write1(s==1e9?1e9-1:1e9);
	}
};//(ans+MOD)%MOD
signed main()
{
//	freopen("z.txt","r",stdin);
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
    int n, cnt = 0;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; i++) cin >> A[i];
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int j = n-1; j > 0; j--){
            if (A[j] < A[j-1]){
                int a = A[j]; A[j] = A[j-1]; A[j-1] = a;
                flag = 1; cnt++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i == n-1) cout << endl;
        else cout << " ";
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        long long a; scanf("%lld", &a);
        char p[55];
        scanf("%s", &p);
        long long c = 0;
        for(int i = 0; i < strlen(p); i++) {
            if(p[i] == '.') continue;
            c = c * 10 + p[i] - '0';
        }
        long long ans = a * c;
        string res;
        while(ans) {
            res += ans % 10 + '0';
            ans /= 10;
        }
        reverse(res.begin(), res.end());
        if(res.size() <= 2) puts("0");
        else {
            res.pop_back();
            res.pop_back();
            printf("%s\n", res.c_str());
        }
    }
    return 0;
}

Measured memory_bytes: 3692
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int main() {
  std::string s;
  std::cin >> s;
  std::string s1,s2;
  s1 = s.substr(0,2);
  s2 = s.substr(2,2);
  int n[2];
  n[0] = std::stoi(s1);
  n[1] = std::stoi(s2);
  int mc=0;
  _for(i,2) {
    if(n[i]<=12&&n[i]!=0) mc++;
  }
  if(mc==2) std::cout<<"AMBIGUOUS"<<std::endl;
  else if(mc==1) {
    if(n[0]<=12&&n[0]!=0) std::cout<<"MMYY"<<std::endl;
    else std::cout<<"YYMM"<<std::endl;
  }
  else if(mc==0) std::cout<<"NA"<<std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<stdio.h>
#define N 200005
int a[N],b[N];
using namespace std;
int main(){
	int c,d,e,f;
	cin>>e>>f;
	for(int i=0;i<f;i++){
		cin>>c>>d;
		if(c==1) a[d]=1;
		if(d==e) b[c]=1;
	}
	for(int j=1;j<e;j++){
		if(a[j]==1&&b[j]==1){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}	
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n; cin >> n;
    string s; cin >> s;
    int k; cin >> k;
    char c = s[k - 1];

    REP(i, n)
        if (s[i] != c) cout << '*';
        else cout << s[i];
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC157C3
//
#include <iostream>
#include<algorithm> // reverseを使う
#include<vector> // vectorを使う
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using P=pair<int,int>;
int main(int argc, const char * argv[]) {
    int N,M;
    cin>>N>>M;
    vector<P>t(M);
    rep(i,M){
        cin>>t[i].first>>t[i].second;
    }
    // 0から999まで試してみる
    rep(x,1000){
        int nx=x;
        vector<int>d(1);
        d[0]=nx%10;
        nx=nx/10;
        while(nx){
            d.push_back(nx%10);
            nx=nx/10;
        }
        if(d.size()!=N) continue; // 桁数が違うとき
        reverse(d.begin(), d.end());
        bool ok=true;
        rep(i,M){
            if (d[t[i].first-1]!=t[i].second) {
                ok=false;
            }
        }
        if(ok){
            cout<<x<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        string s = ReadLine();
        for(int i = 0; i < s.Length - 1; i++)
        {
            if(s[i] == s[i + 1])
            {
                WriteLine("Bad");
                return;
            }
        }
        WriteLine("Good");
    }
}

Measured memory_bytes: 13140
N, M, C = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
ans = 0
for i in range(N):
    A = [int(n) for n in input().split()]
    t = 0
    for a,b in zip(A, B):
        t += a*b
    if t+C > 0:
        ans += 1
print(ans)


Measured memory_bytes: 9088