akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;

  vector<int> x(N);
  for (auto &a : x) {
    cin >> a;
  }

  int ans = INF;
  for (int i = 1; i <= 100; i++) {
    int cost = 0;
    for (auto a : x) {
      cost += (a - i) * (a - i);
    }
    ans = min(cost, ans);
  }

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double r,pi;
		r=sc.nextDouble();
		pi=Math.PI;
		System.out.println(String.format("%.8f", (pi*r*r)) +" "+ String.format("%.8f",(2*pi*r)));
	}
}



Measured memory_bytes: 28216
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    int times;
    if (N % X == 0) {
        times = N/X;
    } else {
        times = N / X + 1;
    }
    cout << times * T << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int D; //365
    cin >> D;
    int c[26];
    rep(i, 0, 26) {
        cin >> c[i];
    }
    int s[D][26];
    rep(i, 0, D) {
        rep(j, 0, 26) {
            cin >> s[i][j];
        }
    }

    int t[D];
    rep(i, 0, D) {
        srand(time(NULL));
        t[i] = rand() % 26;
    }

    /*ll mx_score = -1;
    while (1) {

        ll score[D] = {};
        vector<int> last_day(26, -1);
        rep(i, 0, D) {
            if (i != 0) score[i] = score[i - 1];
            score[i] += s[i][t[i]];
            last_day[t[i]] = i;
            int decrease = 0;
            rep(j, 0, 26) {
                decrease += c[j] * (i - last_day[j]);
            }
            score[i] -= decrease;
        }
        if (mx_score > score[D - 1]) {

        }
    }*/

    rep(i, 0, D) cout << t[i] << endl;

    return 0;
}


Measured memory_bytes: 3680
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    int N;
    cin >> N;
    map<string, int> test;
    test["AC"] = 0;
    test["WA"] = 0;
    test["TLE"] = 0;
    test["RE"] = 0;
    for (int i = 0; i < N; i++) {
        string temp;
        cin >> temp;
        test[temp]++;
    }
    cout << "AC x " << test["AC"] << endl;
    cout << "WA x " << test["WA"] << endl;
    cout << "TLE x " << test["TLE"] << endl;
    cout << "RE x " << test["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3632
import math
N = int(input())

dp = [10**7 for i in range(100010)]
dp[0] = 0

for i in range(1,N+1):
    dp[i] = min(dp[i-1]+1,min([dp[i-pow(6,j)]+1 for j in range(int(math.log(i,6)+1))]),min([dp[i-pow(9,j)]+1 for j in range(int(math.log(i+10**(-10),9))+1)]))

print(dp[N])

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
	if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += MOD-a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// calculates nCr (1 <= r <= n <= 1e7)
const int MAX = 1e7;
long long f[MAX], finv[MAX], inv[MAX];
// initializes nCr
void initnCr() {
	f[0] = f[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		f[i] = f[i-1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

ll nCr(int n, int r) {
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return f[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main() {
	initnCr();
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	sort(ALL(v));
	mint sumx = 0;
	mint sumn = 0;
	for (int i = k-1; i < n; i++) {
		sumx += nCr(i, k-1) * v[i];
	}
	sort(ALL(v), greater<>());
	for (int i = k-1; i < n; i++) {
		sumn += nCr(i, k-1) * v[i];
	}
	cout << sumx - sumn << endl;
}

Measured memory_bytes: 237980
#include "bits/stdc++.h"

using namespace std;

int main(void){
	int dp[210][210],a[210],b[210],c[210],t[210],d,n,i,j,k,ans=0;
	fill(dp[0],dp[210],0);
	cin >> d >> n;
	for(i=0; i<d; i++){
		cin >> t[i];
	}
	for(j=0; j<n; j++){
		cin >> a[j] >> b[j] >> c[j];
	}
	for(k=1; k<d; k++){

		for(i=0; i<n; i++){
			if(a[i]<=t[k] && b[i]>=t[k]){

				for(j=0; j<n; j++){
					if(a[j]<=t[k-1] && b[j]>=t[k-1]){
						dp[k][i] = max(dp[k][i],dp[k-1][j]+abs(c[i]-c[j]));
					}
				}

			}
		}

	}
	for(i=0; i<n; i++){
		ans = max(ans,dp[d-1][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3264
use std::cmp::{min, Ordering};
use std::collections::VecDeque;
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let even = n / 2;
    let odd = n - even;
    let x = odd as f64 / n as f64;
    println!("{}", x);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll sum = 0;
    map<ll,ll> Map;
    rep(i,N){
    	ll num = A[i];
    	Map[num]++;
    	sum += num;
    }


    int Q;
    cin >> Q;
    rep(i,Q){
    	ll B, C;
    	cin >> B >> C;
    	ll cnt = Map[B];
    	//cout << "cnt: " << cnt << endl;
    	sum = sum + cnt*(C-B);
    	cout << sum << endl;

    	Map[C] += cnt;
    	Map[B] = 0;
    }

}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repS(s,n) for(int (s) = 0; s < 1 << (n); ++(s))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1 << 30);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


int N,a,idx,m = 0;
queue<pair<int,int>> ope;

void solve(){
	
	rep(i,N){ ope.push({idx+1,i+1}); }
	
	if(m > 0){
		rep(i,N-1) ope.push({i+1,i+2});
	}else{
		rep(i,N-1) ope.push({N-i,N-i-1});
	}
	
	cout<< N * 2 - 1 <<endl;
	while(!ope.empty()){ cout<<ope.front().fir<<' '<<ope.front().sec<<endl; ope.pop(); }
	
	return;
}

void input(){
	
	cin>>N;
	
	rep(i,N){
		cin>>a;
		if(abs(m) < abs(a)){ idx = i; m = a; }
	}
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const double PI = acos(-1);

int main (){
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N  =  2e5 + 5, MOD  =  1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> v;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b;
    cin>>a>>b;
    if(a >= 13)  cout<<b;
    else if(a >= 6 and a <= 12) cout<<b/2;
    else                        cout<<0;

    return 0;
}


Measured memory_bytes: 256
<?php
  
  list($s) = explode(" ", trim(fgets(STDIN)));

  $s = strrev($s);

  $len = strlen($s);

  $ten = 1;
  $amari_count = array_fill(0, 2019, 0);
  $amari = 0;
  $amari_count[0]++;
  $ans = 0;
  for($i=0; $i<$len; $i++){
    $amari = ($s[$i] * $ten + $amari) % 2019;
    $ans += $amari_count[$amari];
    $amari_count[$amari]++;
    $ten = $ten * 10 % 2019;
  }

  echo $ans;

Measured memory_bytes: 16680
let () =
  let n,m = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let ab_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d %d " (fun a b -> a,b)) in
  let cd_lst = Array.to_list @@ Array.init m (fun i -> Scanf.scanf "%d %d " (fun a b -> (i+1,(a,b)))) in

  let tmp = List.map (fun (a,b) -> 
      let l = List.map (fun (i,(c,d)) -> (i, ((abs @@ c-a) + (abs @@ d-b)))) cd_lst |>
              List.stable_sort (fun (i1,d1) (i2,d2) -> compare d1 d2) 
      in 
      let (i,_) = List.hd l in i
    ) ab_lst
  in
  List.iter (fun x -> Printf.printf "%d\n" x) tmp


Measured memory_bytes: 896
mod = 10**9+7
def main():
    s = list(input())
    n = len(s)
    dp = [[0 for _ in range(13)] for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(n):
        if s[i] != '?':
            s[i] = int(s[i])
            for k in range(13):
                index = (k*10+s[i])%13
                dp[i+1][index] += dp[i][k]
        else:
            for j in range(10):
                for k in range(13):
                    index = (k*10+j)%13
                    dp[i+1][index] += dp[i][k]
        for j in range(13):
            dp[i+1][j] %= mod
    print(dp[n][5])

if __name__ == "__main__":
    main()

Measured memory_bytes: 74888
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        Integer [] list = new Integer[num];
        int Alice = 0;
        int Bob = 0;

        for(int i = 0; i < num; i++) {
            list[i] = scan.nextInt();
        }
        Arrays.sort(list, Collections.reverseOrder());
        for(int i = 0; i < num; i++){
            if(i % 2 == 0){
                Alice += list[i];
            }
            else{
                Bob += list[i];
            }
        }
        System.out.println(Alice - Bob);
    }
}

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

int main(){
    ll W,H,x,y; cin >> W >> H >> x >> y;
    cout << H*W/2.0 << " ";
    if(H%2 == 0 || W%2 == 0){
        if(2*x == W && 2*y == H){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
void March() {
	ll N;
	cin >> N;
	char c[5] = { 'M','A','R','C','H' };
	map<char, ll> m;
	for (int i = 0; i < 5; i++) m[c[i]] = 0;
	for (size_t i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		m[s[0]]++;
	}
	ll res = 0;
	for (size_t i = 0; i < (1 << 5); i++)
	{
		int count = 0;
		ll tm = 1;
		for (int j = 0; j < 5; j++)
		{
			if ((1 << j) & i) {
				count++;
				tm *= m[c[j]];
			}
		}
		if (count != 3) continue;
		res += tm;
	}
	cout << res << endl;
}
int main() {
	March();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main ()
{
    int N, X;
    std::cin >> N >> X;

    int m[N];
    int m_min = 1000;
    int m_sum = 0;
    for(int i=0; i<N; i++)
    {
        std::cin >> m[i];
        m_min = std::min(m_min, m[i]); // 一番省エネなドーナツの m
        m_sum += m[i]; // N種類を1個ずつ作るときに消費する m の合計
    }

    int X_rest = X - m_sum; // 省エネなドーナツを量産するための粉の m ． 
    int num = X_rest / m_min; // 省エネなドーナツを作れる余分な個数．

    std::cout << N+num << std::endl;
}

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

int main()
{
    vector<string> a={"dream", "dreamer", "erase", "eraser"};
    for(auto& e: a) e={rbegin(e), rend(e)};

    string s; cin>>s;
    s={rbegin(s), rend(s)};
    for(int i=0; i<s.size(); ) {
        bool found=false;
        for(auto& e: a) {
            int n=e.size();
            if (!found && (found=(s.substr(i, n)==e))) i+=n;
        }
        if (!found) return cout<<"NO"<<endl, 0;
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 512
import sys
import time
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, A, B = map(int, readline().split())
    if (B-A)%2==0:
        ans = (B-A)//2
    else:
        left = A-1
        right = N-B
        if left<=right:
            l = left + 1
            ans = l + (B-l)//2
        else:
            r = right + 1
            ans = r + (N-(A+r))//2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;
    vector<int> cnt;

    UnionFind(int N){ //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par.push_back(i);
            rank.push_back(0);
            cnt.push_back(1);
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        
        if(rank[rx] < rank[ry]){
            cnt[ry] += cnt[rx];
            par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        }
        else{
            cnt[rx] += cnt[ry];
            par[ry] = rx;
            if(rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int count(int x){
        return cnt[root(x)];
    }

};

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

    UnionFind tree(N);

    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        tree.unite(A - 1, B - 1);
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, tree.count(i));
    }

    cout << ans << endl;
}

Measured memory_bytes: 5744
H, W, A, B = [int(_) for _ in input().split()]
mod = 10**9 + 7
 
X = [i for i in range(H + W + 1)]
X[0] = 1
for i in range(2, H + W + 1):
    X[i] = X[i - 1] * i % mod
 
Y = X.copy()
Y[-1] = pow(Y[-1], mod - 2, mod)
for i in range(H + W, 1, -1):
    Y[i - 1] = i * Y[i] % mod
 
 
def comb(x, y):
    return X[x] * Y[y] * Y[x - y] % mod
 
 
ans = 0
for i in range(B, min(B + H - A, W)):
    ans += comb(H - A + B - 1, i) * comb(W + A - B - 1, W - i - 1)
    ans %= mod
print(ans)

Measured memory_bytes: 18968
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s;
    cin >> s;
    bool ans=true;
    //cout << s.length();
    for(int i=0;i<s.length();i++){
        if(i%2 == 0){
            if(s[i]=='R' ||s[i]=='U' ||s[i]=='D'){
                //cout << s[i];
                continue;
            }else{
                ans=false;
                break;
            } 
        }else if(i%2 == 1){
            if(s[i]=='L' ||s[i]=='U' ||s[i]=='D'){
                //cout << s[i];
                continue;
            }else{
                ans=false;
                break;
            } 
        }
    }
    if(ans == false)cout << "No";
    else if(ans==true)cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> p(m), y(m);
    vector<vector<int>> yd(n+1);
    for (int i = 0; i < m; ++i) 
    {
        cin >> p[i] >> y[i];
        yd[p[i]].push_back(y[i]);
    }

    for (int i = 0; i < n; ++i) sort(yd[i + 1].begin(), yd[i + 1].end());
    vector<P> res(m);    // res[i] ... i=cityid, first=p, second=order
    for (int i = 0; i < m; ++i)
    {
        res[i].first = p[i];
        res[i].second = 
        std::distance(yd[p[i]].begin(), std::lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i])) + 1;
    }

    for (int i = 0; i < m; ++i)
    {
        cout << setfill('0') << std::right << std::setw(6) << res[i].first;
        cout << setfill('0') << std::right << std::setw(6) << res[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 8576
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n, k;
	long long int a[100001], sum1[100001]={}, sum1p[100001]={}, sum2p[100001]={};
	scanf("%d %d", &n, &k);
	for(int i=1; i<=n; i++){
		scanf("%lld", &a[i]);
		sum1[i]=sum1[i-1]+a[i];
		if(a[i]>0){
          sum1p[i]=sum1p[i-1]+a[i];
        }else{
          sum1p[i]=sum1p[i-1];
        }
          
	}
	for(int i=1; i<=n; i++){
		if(a[n+1-i]>0){
          sum2p[i]=sum2p[i-1]+a[n+1-i];
        }else{
          sum2p[i]=sum2p[i-1];
        }
	}
	long long int ans;
	if(sum1[k]>0){
		ans=sum1[k]+sum2p[n-k];
	}else{
		ans=sum2p[n-k];
	}
	for(int i=1; i<=n-k; i++){
		if(sum1[i+k]-sum1[i]>0){
			if(ans<sum1p[i]+sum2p[n-k-i]+sum1[i+k]-sum1[i]){
				ans=sum1p[i]+sum2p[n-k-i]+sum1[i+k]-sum1[i];
			}
		}else{
			if(ans<sum1p[i]+sum2p[n-k-i]){
				ans=sum1p[i]+sum2p[n-k-i];
			}
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/jsc2019_qual_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

/**
 * 繰り返し自乗法
 * http://satanic0258.hatenablog.com/entry/2016/04/29/004730
 */
ll powMod(ll n, ll p, const int mod = MOD) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    ll t = powMod(n, p / 2);
    return t * t % MOD;
  } else {
    return n * powMod(n, p - 1) % MOD;
  }
}

/**
 * 余剰Combination
 * nCk≡n! * (k!)^M−2 * ((n−k)!)^M−2 (modM)
 */
ll combMod(ll n, ll k, const int mod = MOD) {
  ll nCk = 1;
  k = min(k, n - k);

  repi(i, 1, k + 1) {
    nCk = nCk * (n - i + 1) % MOD;
    nCk = nCk * powMod(i, mod - 2) % MOD;
  }
  return nCk;
}
int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, K;
  cin >> N >> K;
  
  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  ll n = 0;
  ll m = 0;
  rep(i, N) {
    repi(j, i, N) {
      if (c[i] > c[j]) n++;
    }
    rep(j, i) {
      if (c[i] > c[j]) m++;
    }
  }
  ll ans = K * n % MOD;
  ans += combMod(K, 2) * (n + m) % MOD;
  ans %= MOD;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int main() {
    char s[10];
    vector<char> v;
    cin >> s;
    for (int i = 0; i < strlen(s); i++) {
        if (s[i] != 'B') v.push_back(s[i]);
        else if (!v.empty()) v.erase(v.end() - 1);
    }
    for (int i = 0; i < v.size(); i++) cout << v[i];
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n)-1;i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

ll h,w;
vector<vector<char>> s(100,vector<char>(100));

int main(){
    cin>>h>>w;
    rep(i,1,h+1) rep(j,1,w+1) cin>>s[i][j];
    bool flag=true;
    rep(i,1,h+1){
        rep(j,1,w+1){
            if(s[i][j]=='#'){
                if(s[i-1][j]!='#' && s[i+1][j]!='#' && s[i][j-1]!='#' && s[i][j+1]!='#') flag=false;
            }
        }
    }
    if(flag) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			if(str.length() > 1200) {
				
			}
			StringBuilder b1 = new StringBuilder(str);

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

				if( Character.isUpperCase(str.charAt(i))){ //Upper
				    b1.replace(i,i+1,String.valueOf(str.charAt(i)).toLowerCase() );
				}
				else {//Lower
				   b1.replace(i,i+1,String.valueOf(str.charAt(i)).toUpperCase() );
				}
			}
			String t = b1.toString();
			System.out.println(t);

		}catch(IOException e) {
			System.out.println("Exception : " + e);
		}
	}
}


Measured memory_bytes: 24624
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define MOD 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)

using namespace std;

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> vec(n,0);
    for(int i = 0;i < n;++i)cin >> vec[i];
    int c = 0;
    for(int i = 0;i < n - 2;++i){
        if((vec[i] < vec[i + 1] && vec[i + 1] < vec[i + 2]) || (vec[i] > vec[i + 1] && vec[i + 1] > vec[i + 2]))++c;
    }
    cout << c << endl;
}




Measured memory_bytes: 888
#include <iostream>
using namespace std;
int ans=0;
int main(){
	int i,j,k,n,a,b,c,l,x;
	cin>>a>>b>>c>>x;
	for(i=0;i<=a;i++)
	for(j=0;j<=b;j++)
	for(l=0;l<=c;l++)
	if(500*i+100*j+50*l==x)ans++,l=c+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 20;

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  Pt operator+(const Pt pt) const { return Pt(x + pt.x, y + pt.y); }
  Pt operator-() const { return Pt(-x, -y); }
  Pt operator-(const Pt pt) const { return Pt(x - pt.x, y - pt.y); }
  Pt operator*(T t) const { return Pt(x * t, y * t); }
  Pt operator/(T t) const { return Pt(x / t, y / t); }
  T dot(Pt v) { return x * v.x + y * v.y; }
  T cross(Pt v) { return x * v.y - y * v.x; }
  Pt mid(const Pt pt) { return Pt((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt(c * x - s * y, s * x + c * y);
  }

  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }
  
  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
};

typedef Pt<double> pt;

/* global variables */

int n;
pt hpt, dpt;
pt pts[MAX_N + 1];
bool used[MAX_N + 1];
double ddists[MAX_N + 1], pdists[MAX_N + 1][MAX_N + 1];

/* subroutines */

bool rec(int k, int i, double t) {
  //printf("rec(%d, %d, %f\n", k, i, t);
  if (t >= ddists[i]) return false;
  if (k >= n) return true;

  for (int j = 0; j <= n; j++)
    if (! used[j] && t + pdists[i][j] >= ddists[j]) return false;
  
  for (int j = 0; j <= n; j++)
    if (! used[j]) {
      used[j] = true;
      if (rec(k + 1, j, t + pdists[i][j])) return true;
      used[j] = false;
    }

  return false;
}

/* main */

int main() {
  for (;;) {
    cin >> n >> hpt.x >> hpt.y >> dpt.x >> dpt.y;
    if (n == 0) break;

    pts[0] = hpt;
    for (int i = 1; i <= n; i++) cin >> pts[i].x >> pts[i].y;

    for (int i = 0; i <= n; i++) {
      ddists[i] = (pts[i] - dpt).d();
      pdists[i][i] = 0.0;
      for (int j = i + 1; j <= n; j++)
	pdists[i][j] = pdists[j][i] = (pts[i] - pts[j]).d();
    }

    memset(used, false, sizeof(used));
    used[0] = true;
    
    int tf = rec(0, 0, 0.0);
    cout << (tf ? "YES" : "NO") << endl;
  }

  return 0;
}

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

int main() {
  long double ans=0,n,m,d;
  cin >> n >> m >> d;

  if(d==0) {
    ans=(m-1)/n;
  } else {
    ans=(n-d)*2*(m-1)/n/n;

  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define DEBUG 0

map<lli,vector<lli> > v;
signed main(){
    lli n,m;
    cin>>n>>m;

    for(lli i=0;i<n;i++){
        lli a,b;
        cin>>a>>b;
        v[a].push_back(b);

    }
    lli sum=0;
    priority_queue<lli> q;
    for(lli i=0;i<=m;i++){
        for(lli j=0;j<v[i].size();j++){
            q.push(v[i].at(j));
            if(DEBUG)cout<<v[i].at(j)<<endl;
        }

        if(q.size()==0)continue;
        sum+=q.top();
        if(DEBUG)cout<<q.top()<<endl;
        q.pop();
    }
    cout<<sum<<endl;

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N=S.size();
  if(N<26){
    vector<bool> alp(26,false);
    for(int i=0;i<N;i++){
      alp[S[i]-'a']=true;
    }
    for(int i=0;i<=25;++i){
      if(alp[i]){
        continue;
      }
      else{
        S+=(char)((int)'a'+i);
        break;
      }
    }
    cout << S << endl;
    return 0;
  }
  int next=25;
  int flag=-1;
  int change=-1;
  set<int> set;
  for(int i=0;i<26;i++){
    if(S[i]-'a'==next){
      set.insert(S[i]-'a');
      while(set.count(next)){
        --next;
      }
    }
    else{
      flag=i;
      set.insert(S[i]-'a');
      change=S[i]-'a';
      while(set.count(change)){
        ++change;
      }
    }
  }
  if(flag==-1){
    cout << -1 << endl;
    return 0;
  }
  vector<bool> seen(26,false);
  string T="";
  for(int i=0;i<flag;i++){
    seen[S[i]-'a']=true;
    T+=S[i];
  }
  T+=(char)(change+(int)'a');
  seen[change]=true;
  cout << T << endl;
  return 0;
}

Measured memory_bytes: 3612
balls = [1,0,0]

while 1:
    try:
        a,b = input().split(',')
        i1 = ord(a) - ord("A")
        i2 = ord(b) - ord("A")
        balls[i1],balls[i2] = balls[i2],balls[i1]
    except:
        break
for i in range(0,3):
    if balls[i]:
        print(chr(i + ord("A")))


Measured memory_bytes: 5560
gets

op = ocl = 0
o = gets.chomp
o.each_char do |c|
    if op == 0 and c == ')'
        ocl += 1
    elsif op > 0 and c == ')'
        op -= 1
    else
        op += 1
    end
end

puts "#{'('*ocl}#{o}#{')'*op}"

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

//D
int main(void) {
	ll n;
	cin >> n;
	vector<ll> a = vector<ll>(n);
	rep(i, 0, n)cin >> a[i];
	ll ub = min(a[0], a[n - 1]) * 2;
	ll lb = -1;
	vector<ll> mountain = vector<ll>(n, 0);
	rep(i, 0, n) mountain[0] += pow(-1, i) * a[i];
	rep(i, 1, n) {
		mountain[i] = 2 * a[i - 1] - mountain[i-1];
	}
	rep(i, 0, n - 1) {
		cout << mountain[i] << " ";
	}
	cout << mountain[n - 1] << endl;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    ll temp = (n + 1) / 2;
    if (k <= temp) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int a,b,t;
	cin>>a>>b>>t;
	
	cout<<t/a*b<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main ()
{
    /*/
    int i = 0, j = 1;
    cout << i;
    int *ptr = &i;
    cout << i;

    i = 2;
    cout << i;
    *ptr = 3;
    ptr = &j;
    j = i;
    cout << i;
    *ptr = 4;
      /*/
    
    int n , ctn=0 ,arr;
    cin >> n ;
    for (int i = 1; i <=n ; ++i) {
        cin >> arr;
        
        if ((i%2!=0)&&(arr%2!=0))ctn++;
       
    }
    cout<<ctn <<endl;
    

}

Measured memory_bytes: 3628
#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> ;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        if(i%3 == 0 || i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {

  long long int a, b, c;
  cin >> a >> b >> c;

  if ( a == b && b == c ) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, b, c);

  cout << max(c - (a - b), 0) << endl;

  return 0;
}

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

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        pw.println(readInt() >= 30 ? "Yes" : "No");
        pw.close();
    }
}


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

typedef pair<int,int>pii;
#define MOD 1000000007
#define MAXN 200005
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define pb push_back
#define f first
#define s second
#define debug(x) cout << "debug 1: " << x << "\n";
#define debug2(x, y) cout << "debug 2: " << x << " " << y << "\n";
#define debug3(x, y, z) cout << "debug 3: " << x << " " << y << " " << z << "\n";
int n;
ll d,a,x,h,ans;
ll c[MAXN];
vector<pii>ar;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>d>>a;

    for(int i=0;i<n;i++){
        cin>>x>>h;
        ar.pb({x,h});
    }
    sort(ar.begin(),ar.end());

    for(int i=0,j=0;i<n;i++){
        while(j<n && ar[j].f<=ar[i].f+2*d){
            j++;
        }

        ll best=max((ar[i].s-c[i]*a+a-1)/a,0ll);

         //debug3(i,j,best);
         //debug(c[i]);
        ans+=best;
        c[i]+=best;
        c[j]-=best;
        c[i+1]+=c[i];
    }

    cout<<ans;
    }

Measured memory_bytes: 3568
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int n = sc.nextInt();
            
            	if(n == 0)break;
            
            int[] student = new int[n];
            
            for(int i=0;i<n;i++){
                student[i] = sc.nextInt();
            }
            
            double sum = 0;
            double avg = 0;
            for(int i=0;i<n;i++){
                avg += student[i];
            }
            avg /= n;
            for(int i=0;i<n;i++){
                sum += Math.pow((student[i] - avg),2);
            }
            System.out.println(Math.sqrt(sum /= n));
        }
        sc.close();
    }
}


Measured memory_bytes: 31384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double a[];
		
		while(scan.hasNext()){
			a = new double[6];
			
			for(int i=0;i<6;i++){
				a[i]=scan.nextDouble();
			}
			
			double d = a[0]*a[4]-a[1]*a[3];
			double x = (a[4]*a[2]-a[1]*a[5])/d;
			double y = (a[0]*a[5]-a[2]*a[3])/d;
			if(x==0)x=0;
			if(y==0)y=0;
			
			System.out.printf("%.3f %.3f\n", x, y);
		}
	}
}

Measured memory_bytes: 28352
N, M = gets.split.map &:to_i
Ss = M.times.map{
  k, *s = gets.split.map &:to_i
  s.map(&:pred)
}
P = gets.split.map &:to_i

p (0...2**N).count{|bits|
  Ss.map.with_index(0).all?{|s, i|
    sum = s.map{|z| bits[z] }.inject(:+)
    sum % 2 == P[i]
  }
}

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

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  vector<int> X(N),Y(N),A(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i) >> Y.at(i) >> A.at(i);
  }
  vector<vector<bool>> ans(H,vector<bool>(W,false));//falseは白
  for(int i=0;i<N;i++){
    if(A.at(i)==1){
      for(int j=0;j<H;j++){
        for(int k=0;k<X.at(i);k++){
          ans.at(j).at(k)=true;
        }
      }
    }
    else if(A.at(i)==2){
      for(int j=0;j<H;j++){
        for(int k=X.at(i);k<W;k++){
          ans.at(j).at(k)=true;
        }
      }
    }
    else if(A.at(i)==3){
      for(int j=0;j<Y.at(i);j++){
        for(int k=0;k<W;k++){
          ans.at(j).at(k)=true;
        }
      }
    }
    else{
      for(int j=Y.at(i);j<H;j++){
        for(int k=0;k<W;k++){
          ans.at(j).at(k)=true;
        }
      }
    }
  }
  int count=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(!ans.at(i).at(j)){
        count++;
      }
    }
  }
  cout << count << endl;
} 

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

main() {
    int N; cin >> N; int V[N],C[N]; int ans=0;
    rep(i,N){
        cin >> V[i];
    }
    rep(i,N){
        cin >> C[i];
    }
    rep(i,N){
        if(V[i]-C[i]>0) ans+=V[i]-C[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,d =  list(map(int,input().split(" ")))
dots = [list(map(int,input().split(" ")))  for _ in range(n)]

sqs = [i ** 2 for i in range(100000)]

ans = 0
for i in range(n):
    for j in range(i+1,n):
        d1 = dots[i]
        d2 = dots[j]
        temp = 0
        for dd1,dd2 in zip(d1,d2):
            temp += (dd1 - dd2) ** 2
        if temp in sqs:
            ans += 1



print(ans)



Measured memory_bytes: 7064
#include <iostream>
using namespace std;
int main(){
  int a,b,c,sum,i,j,k,cc;
  cin>>a>>b>>c;
  string s[a];
  for(sum=i=0;i<a;i++)cin>>s[i];
  for(i=0;i<a;i++)
    for(j=0;j<=b-c;j++){
      for(cc=0,k=0;k<c;k++)if(s[i][j+k]=='#')cc++;
      if(!cc)sum++;
    }
  for(i=0;i<=a-c;i++){
    for(j=0;j<b;j++){
      for(k=i,cc=0;k<i+c;k++)if(s[k][j]=='#')cc++;
      if(!cc)sum++;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3136
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;

  std::vector<int> a(n);

  for (auto&& ai : a) std::cin >> ai;

  int max1 = 0;
  int max2 = 0;
  for (auto&& ai : a) {
    if (ai > max1) {
      max2 = max1;
      max1 = ai;
    } else if (ai > max2) {
      max2 = ai;
    }
  }

  for (auto&& ai : a) std::cout << (ai == max1 ? max2 : max1) << '\n';
  std::cout << std::endl;
}

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

int main(){

  int w, a, b;

  cin>>w>>a>>b;

  if((a<=b&&b<=a+w)||(b<=a+w&&a+w<=b+w)) cout<<0<<endl;
  else cout<<min(abs(b-a+w), abs(a-b+w))<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, k, p;

int main()
{
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &k);
        scanf("%d", &p);
        
        int r = 0;
        
        while(k--)
        {
            r++;
            
            if(r > p) { r = 1; }
        }
        
        printf("%d\n", r);
    }

    return 0;
}

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

long long a,b,c;

int main () {
    cin >> a >> b >> c;
    long long bb = c - a - b;
    if (bb > 0 && (a * b * 4) < bb * bb) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

template<typename integer>
integer __lcm(integer a, integer b) {
  return (a * b) / __gcd(a, b);
}

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;

  vector<int> nw(n);
  fill(nw.begin(), nw.end(), 0);

  vector<int> ne(n);
  fill(ne.begin(), ne.end(), 0);

  rep (i, n) {
    if (s[i] == 'W') {
      if (i == 0) nw[i] = 1;
      else nw[i] = nw[i-1] + 1;
    }
    else {
      if (i == 0) nw[i] = 0;
      else nw[i] = nw[i-1];
    }
  }

  reverse(s.begin(), s.end());
  rep (i, n) {
    if (s[i] == 'E') {
      if (i == 0) ne[i] = 1;
      else ne[i] = ne[i-1] + 1;
    }
    else {
      if (i == 0) ne[i] = 0;
      else ne[i] = ne[i-1];
    }
  }
  reverse(ne.begin(), ne.end());

  int ans = 1001001001;
  rep (i, n) {
    if (i == 0) ans = min(ans, ne[i+1]);
    else if (i == n) ans = min(ans, nw[i-1]);
    else ans = min(ans, nw[i-1] + ne[i+1]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3076
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintStream so = System.out;
	public static void main(String[] args) throws InterruptedException {

		String s = sc.next();
		
		String[] a = {"dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"};
		int idx = 0;
		
		outer: while (true) {
			for (String elem: a) {
				if (s.startsWith(elem, idx)) {
					idx += elem.length();
					if (idx == s.length()) {
						so.println("YES");
						return;
					}
					continue outer;
				}
			}
			
			so.println("NO");
			return;
		}
	}
}


Measured memory_bytes: 24148
# -*- coding: utf-8 -*-
import math
n,h = map(int, input().split())
al = []
bl = []
for i in range(n):
    a,b = map(int, input().split())
    al.append(a)
    bl.append(b)
max_a = max(al)

bbl = []
for i in range(n):
    if bl[i]>max_a:
        bbl.append(bl[i])
bbl.sort(reverse=True)

res = 0
for b in bbl:
    h -= b
    res += 1
    if h<=0:
        break

if h>0:
    print(res+math.ceil(h/max_a))
else:
    print(res)


Measured memory_bytes: 12108
#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 Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
#define oset tree<int, null_type,greater<int>, rb_tree_tag,tree_order_statistics_node_update>


int main()
{
    int n, k;
    cin >> n >> k;
    vector<lli> pos, neg;
    pos.push_back(0);
    neg.push_back(0);
    lli x;
    for(int i=0; i<n; i++){
        cin >> x;
        if(x<0LL){
            neg.push_back(-x);
        }
        else{
            pos.push_back(x);
        }
    }
    sort(neg.begin(), neg.end());
    sort(pos.begin(), pos.end());

    lli mn = 1e17;
//    for(int f: neg){
//        cout << f << " ";
//    }
//    cout << endl;
//    for(int f: pos){
//        cout << f << " ";
//    }
//    cout << endl;

    int i = min(k, (int)neg.size()-1), j;
    for(; i>=0; i--){
        j = max(k-i, 0);
        j = min(j, (int)pos.size()-1);
        if(i+j < k){
            break;
        }
        mn = min(mn, neg[i]+pos[j]*2);
    }

    i = min(k, (int)pos.size()-1);
    for(; i>=0; i--){
        j = max(k-i, 0);
        j = min(j, (int)neg.size()-1);
        if(i+j < k)
            break;

        mn = min(mn, pos[i]+neg[j]*2);
    }

    cout << mn << "\n";

    return 0;
}


Measured memory_bytes: 1656
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
const int N = 1005;
int n;
ll dp[N],pri[N];

int main(){
	fast_io();
	cin >> n;
	ll a[n+1];
	fu(i,1,n)cin >> a[i];
	fu(i,1,n){
		dp[i] = a[i];
		for(int j = i-2; j > 0 ; j-=2){
			if(dp[j] + a[i] > dp[i]){
				dp[i] = dp[j] + a[i];
				pri[i] = j;
			}
		}
	}
	int bestind = 0;
	ll bestval = -INF;
	fu(i,1,n){
		if(dp[i] > bestval){
			bestval = dp[i];
			bestind = i;
		}
	}
	vector<int> taken;
	while(bestind != 0){
		taken.pb(bestind);
		bestind = pri[bestind];
	}
	reverse(all(taken));
	vector<int> moves;
	fd(i,n,taken.back() + 1)moves.pb(i);
	cu(i,1,taken.front()){moves.pb(1);}
	cu(i,0,taken.size() - 1){
		int m = (taken[i+1] + taken[i])/2;
		int cnt = (taken[i+1] - taken[i])/2;
		int lt = 0;
		while(cnt--){
			moves.pb(m-taken[i]-lt+1);
			++lt;
		}
	}
	cout << bestval << '\n';
	cout << moves.size() << '\n';
	for(int a: moves){
		cout << a << '\n';
	}
}



Measured memory_bytes: 256
N = gets.to_i

dist = Hash.new { |h, k| h[k] = {} }

(N - 1).times do
  a, b, c = gets.chomp.split.map(&:to_i)
  dist[a][b] = c
  dist[b][a] = c
end

Q, K = gets.chomp.split.map(&:to_i)

check_list = Hash.new

queue = [[K, 0]]

until queue.empty?
  node = queue.shift

  next if check_list[node.first]
  check_list[node.first] = true

  dist[K][node.first] = node.last
  dist[node.first][K] = node.last

  dist[node.first].each do |k, v|
    queue << [k, node.last + v]
  end
end

Q.times do
  x, y = gets.chomp.split.map(&:to_i)
  puts dist[x][K] + dist[K][y]
end


Measured memory_bytes: 76152