akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

long long int a[13][13] = {};
long long int c[13] = {};
long long int n, m, x;
long long int ans = -1;

bool f[13] = {};

void kansu( long long int p ) {

    if ( p == n ) {

        long long int cnt[13] = {};
        long long int aaa = 0;
        for ( long long int i = 0; i < n; i++ ) {
            if ( !f[i] ) continue;
            aaa += c[i];
            for ( long long int j = 0; j < m; j++ ) {
                cnt[j] += a[i][j];
            }
        }
        for ( long long int i = 0; i < m; i++ ) {
            if ( cnt[i] < x ) return;
        }
        if ( ans == -1 || ans > aaa ) ans = aaa;
        return;

    }

    f[p] = false;
    kansu( p + 1 );
    f[p] = true;
    kansu( p + 1 );

}

int main() {

    cin >> n >> m >> x;

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

    kansu( 0 );

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n;

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

int lcm(int a,int b)
{
    return a/gcd(a,b)*b;
}

int main(int argc, char const *argv[])
{
    while (scanf("%d",&n)!=EOF)
    {
        printf("%d\n", lcm(2,n));
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
  



  

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5){printf("YES\n");}

	else {printf("NO\n");}
	return 0;

}


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

//mod
const int mod = 1e9 + 7;
int powmod(int x, int y) { //x^y
	int rv = 1;
	for (; y > 0; y >>= 1, x = (long long) x * x % mod)
		if (y & 1)
			rv = (long long) rv * x % mod;
	return rv;
}
int inverce(int x) {
	return powmod(x, mod - 2);
}

const int node = 16, parity = 2, x0 = 4; //節数nodeはd次式の時node=d+1
int fi[parity][node] = { { 0, 11, 341, 4598, 39138, 245443, 1232837, 5222552,
		19316488, 63933498, 192839398, 537499132, 399637805, 434820093, 780358,
		793168065 }, { 1, 71, 1346, 14038, 101193, 563447, 2585672, 10198232,
		35588718, 112225058, 324900532, 874246012, 207858088, 274485959,
		996765147, 118878018 } };

int l(int x) {
	int p = (x - x0) % parity;
	int v = 0;
	for (int i = 0; i < node; ++i) {
		int nmr = fi[p][i], dnm = 1;
		for (int j = 0; j < node; ++j) {
			if (j == i)
				continue;
			nmr = (ll) nmr * (x - (x0 + p + parity * j)) % mod;
			dnm = (ll) dnm * (i - j) * parity % mod;
		}
		v = (v + (ll) nmr * inverce(dnm)) % mod;
	}
	return v;
}

int t, n;
int main() {
	cin >> t;
	for (int i = 0; i < t; ++i) {
		cin >> n;
		cout << (n >= 4 ? l(n) : 0) << endl;
	}

}


Measured memory_bytes: 3600
def main():
    N = int(input())
    ans = 0
    for x in range(1, int(N ** 0.5) + 1):
        # x(1+2+3+...+e)
        e = N // x
        ans += x * (e * e + e - x * x)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9404
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 998244353;


ll N,V[50],C[50],ans;

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

	return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
if 2 * K >= B - A + 1:
	for k in range(A, B + 1):
		print(k)
else:
	for i in range(A, A + K):
		print(i)
	for j in range(B - K + 1, B + 1):
		print(j)


Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> to;
vector<int> linear_towns;
int loop_start;
vector<int> loop_towns;

void find_loop_start() {
    int crashed;
    {
        int slow = 0;
        int fast = 0;
        int turn = 0;
        while (turn == 0 || slow != fast) {
            slow = to[slow];
            fast = to[to[fast]];
            turn++;
        }
        crashed = slow;
    }

    int one = 0;
    int other = crashed;
    linear_towns.push_back(0);
    while (one != other) {
        one = to[one];
        other = to[other];
        linear_towns.push_back(one);
    }
    loop_start = one;
}

void find_loop_towns(int cur, const int start) {
    if (!loop_towns.empty() && cur == start) {
        return;
    }
    loop_towns.push_back(cur);
    return find_loop_towns(to[cur], start);
}

int main(void) {
    int N;
    ll K;
    cin >> N >> K;

    to.resize(N, 0);
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        t--;
        to[i] = t;
    }

    find_loop_start();
    
    if (K <= (ll) linear_towns.size() - 1) {
        cout << linear_towns[K] + 1 << endl;
        return 0;
    }

    K -= (ll) linear_towns.size() - 1;
    find_loop_towns(loop_start, loop_start);

    cout << loop_towns[K % (ll) loop_towns.size()] + 1 << endl;
    return 0;
}


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


void solve(long long L){
    double a = L/3.0;
    double b = L/3.0;
    double c = L - a - b;
    // cout << a*b*c << endl;
    printf("%lf", a*b*c);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long L;
    scanf("%lld",&L);
    solve(L);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[505][505], s[2][505][505];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf(" %s", a[i] + 1);
		for (int j = 1; j <= m; j++) {
			s[0][i][j] = s[1][i][j] = a[i][j];
		}
		s[0][i][m + 1] = s[1][i][m + 1] = 0;
	}
	vector<pair<int, int> > vec;
	for (int i = 1, lst = 1; i <= n; i++) {
		int has = 0;
		for (int j = 1; j <= m; j++) {
			if (a[i][j] == '#') has = 1;
		}
		if (!has) {
			if (lst < i) vec.emplace_back(lst, i - 1);
			lst = i + 1;
		}
	}
	int c = 0;
	for (int k = 0; k < (int)vec.size(); k++) {
		for (int i = (k ? (vec[k - 1].first + 1) : (vec[k].first - 1)); i < vec[k].first; i++) {
			s[c][i][1] = s[c][i][m] = '#';
			for (int j = 2; j < m; j++) {
				s[c ^ 1][i][j] = '#';
			}
		}
		for (int i = vec[k].first; i <= vec[k].second; i++) {
			for (int j = 1; j <= m; j++) {
				s[c][i][j] = '#';
			}
			if (i < vec[k].second) c ^= 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		puts(s[0][i] + 1);
	}
	puts("");
	for (int i = 1; i <= n; i++) {
		puts(s[1][i] + 1);
	}
	return 0;
}

Measured memory_bytes: 4436
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <fstream>

using namespace std;

int main(void)
{
	int n;

	cin >> n;

	if ((n / 100) == (n % 10))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i) + [n+2]
b_arr = gets.chomp.split(" ").map(&:to_i)
c_arr = gets.chomp.split(" ").map(&:to_i)

score = 0
a_arr.each_cons(2) do |a1, a2|
  score += b_arr[a1-1]
  score += c_arr[a1-1] if a1 + 1 == a2
end
puts score


Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int c = 0;
		int d = 1;
		int x = 0;
		boolean v = true;
		int e[] = new int[n];
		for (int i = 0; n > i; i++) {
			c = l + d -1;
			d = d+1;
			e[i] = c;
			x = x + c;
			if(c == 0) {
				v  = false;
			}
		}
		if(v == false) {
			System.out.println(x);
		}else {
			if(l >= 0) {
				System.out.println(x - e[0]);
			}else {
				System.out.println(x - e[n-1]);
			}
		}
	}
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
int F(int num) {
  int sum = 0;
  int remain;
  while (num > 0) {
    remain = num % 10;
    sum += remain;
    num = num / 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int ans = N;
  for (int x = 1; x <= N/2; x++) {
    int y = N - x;
    int result = F(x) + F(y);
    if (result < ans) {
      ans = result;
    } 
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
n,m = map( int, input().split())
  
result= {}
input_list = [[] for i in range(n)]


for i in range(m):
  p,y = map(int, input().split())
  input_list[p-1].append((y,i))
  
for i in input_list :
  i.sort()

result = [None]*m

for p,i in enumerate(input_list) :
  for n, (a,b) in enumerate(i):
    result[b] = str(p+1).zfill(6)+str(n+1).zfill(6)
    
print(*result, sep = '\n')


Measured memory_bytes: 37480
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
    };

    // 2次元用の標準入出力
    template<typename T>
    struct inpn {
        std::size_t szi, szj;
        inpn(std::size_t _szi, std::size_t _szj) : szi(_szi), szj(_szj) {}
        operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i)
                for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j];
            return a;
        }
    };

    inp inp1; // input one
}

int main() {

    int n, k;
    cin >> n >> k;
    vector<int> rsp = inp(3);
    string t = inp1;

    vector<vector<char>> hands(k);

    rep(i, n) {
        hands[i % k].emplace_back(t[i]);
    }

    int ans = 0;

    string pat = "rsp";
    
    rep(i, k) {
        size_t sz = hands[i].size();

        int prev = -1;
        for (auto opp : hands[i]) {
            int hand = (pat.find(opp) + 2) % 3;
            if (prev == hand) prev = -1;
            else {
                prev = hand;
                ans += rsp[hand];
            }
        }
    }

    Cout(ans);


    return 0;
}

Measured memory_bytes: 5120
#include<cstdio>

int main(void){
	int N, P[5010]={0}, p[5010], i, j, sum, buf=0;
	scanf("%d", &N);
	if(N==0){return(0);}
	for(i=0; i<N; ++i){ scanf("%d", P+i); }
	for(i=0, sum=1<<30; i<=3; ++i, buf=i){
		for(j=0; j<N; ++j){ p[j]=P[j]; }
		p[0]-=i;
		for(j=0; j<N-1; ++j){
			if(p[j]>0){
				buf+=p[j]*2;
				p[j+1]-=p[j];
				p[j]=0;
			}
		}
		buf+=(p[N-1]>0)?p[N-1]:0;
		sum=(buf<sum)?buf:sum;
	}
	printf("%d\n", sum);	
}


Measured memory_bytes: 2800
use std::cmp::min;

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let input: Vec<i64> = line.split_whitespace().map(|a| a.parse().unwrap()).collect();
    let (n, x, y) = (
        input[0], input[1] - 1, input[2] - 1
    );
    let mut count: Vec<i64> = vec![0; (n as usize)];
    for j in 0..n {
        for i in 0..j {
            if j <= x || y <= i {
                count[(j - i) as usize] += 1
            } else if i <= x && y <= j {
                count[(x - i + j - y + 1) as usize] += 1
            } else if i <= x && x <= j && j <= y {
                count[(x - i + min(j - x, y - j + 1)) as usize] += 1
            } else if x <= i && x <= y && y <= j {
                count[(j - y + min(y - i, i - x + 1)) as usize] += 1
            } else if x <= i && j <= y {
                count[(min(j - i, i - x + y - j + 1)) as usize] += 1
            }
        }
    }
    for i in 1..(n as usize)  {
        println!("{}", count[i]);
    }
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(M)]
ps = list(map(int, input().split()))

bins = []
for i in range(2**N):
    bins.append(format(i,'b').zfill(N))

cnt = 0
for j in range(2**N):
    b = bins[j]
    accept = 0
    for k in range(M):
        Li = List[k]
        ones = 0
        for l in range(Li[0]):
            if b[Li[l+1]-1]=='1':
                ones+=1
        if ones%2==ps[k]:
                accept+=1
    if accept==M:
        cnt+=1

print(cnt)

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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

class UnionFind {
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) std::swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
private:
	std::vector<int> data;
};

int n, m;
bool use[100005];
int langnum;
int main()
{
	std::cin >> n >> m;
	UnionFind uf(m);

	int lfirst;
	for (int i = 0; i < n; ++i) {
		int k;
		std::cin >> k;
		int first;
		for (int j = 0; j < k; ++j) {
			int l;
			std::cin >> l;
			--l;
			if (i == 0 && j == 0)
				lfirst = l;
			if (j == 0)
				first = l;
			else
				uf.unionSet(first, l);

			if (!use[l]) {
				use[l] = true;
				++langnum;
			}
		}
	}

	if (uf.size(lfirst) == langnum)
		std::cout << "YES" << std::endl;
	else
		std::cout << "NO" << std::endl;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
    int n, result = 0;
    cin >> n;
    vector<long> l(n);
    map<long, int> lmap;
    for (int i = 0; i < n; i++) {
        long tmp;
        cin >> tmp;
        lmap[tmp]++;
        l[i] = tmp;
    }

    // a+b>c かつ b+c>a かつ c+a>b
    /*for (auto& [key, value] : lmap) {
        long a = key;
        ite
    }*/

    if (n < 3) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] &&
                    l[k] + l[i] > l[j] && l[i] != l[j] && l[i] != l[k] &&
                    l[j] != l[k]) {
                    result++;
                }
            }
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 3636
def solve(S):
    if S != S[::-1]:
        return "No"
    h = (len(S) - 1)//2
    h2 = (len(S) + 3)//2
    A = S[:h]
    B = S[h2-1:]
    if A != A[::-1]:
        return "No"
    if B != B[::-1]:
        return "No"
    return "Yes"


if __name__ == "__main__":
    S = input()
    print(solve(S))


Measured memory_bytes: 3060
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int c1=0,c2=0;
  string s,t,u;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if(i%2) {
      t.push_back('0');
      u.push_back('1');;
    }
    else {
      t.push_back('1');
      u.push_back('0');
    }
  }
  for(int i=0; i<s.size(); i++) {
    if(s[i]!=t[i]) {
      c1++;
    }
    if(s[i]!=u[i]) {
      c2++;
    }
  }
  cout << min(c1,c2) << endl;
}

Measured memory_bytes: 720
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    
    
    int main(){
        int n;cin>>n;
        int cnt = 0;
        rep(i,n){
            int a;cin>>a;
            if(a%2==1)cnt++;
        }
        cout<<(cnt%2==0? "YES":"NO");
    }
    


Measured memory_bytes: 256
n=int(input())
a=0
w=0
t=0
r=0
for i in range(n):
  b=input()
  if b=="AC":
    a+=1
  elif b=="WA":
    w+=1
  elif b=="TLE":
    t+=1
  elif b=="RE":
    r+=1
print("AC x",a)
print("WA x",w)
print("TLE x",t)
print("RE x",r)

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

#define Bye return 0
#define ll long long
const ll MAX = 1e2;

void solve(){
    int a, b, c; cin>>a>>b>>c;
    printf((c>=a && c<=b) ? "Yes\n":"No\n");
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3728
import numpy as np
import sys
buf = sys.stdin.buffer

h,w = map(int,buf.readline().split())
grid = np.array([list(input()) for _ in range(h)])
grid = np.where(grid == ".", 1, 0)
#print(grid)

L,R,U,D = [np.zeros((h,w)) for _ in range(4)]
for i in range(w):
  L[:,i] = (L[:,i-1] + 1) * grid[:,i]
  R[:,-i-1] = (R[:,-i] + 1) * grid[:,-i-1]
  
for i in range(h):
  D[i,:] = (D[i-1,:] + 1) * grid[i,:]
  U[-i-1,:] = (U[-i,:] + 1) * grid[-i-1,:]

print(int(np.max(L+R+D+U)-3))

Measured memory_bytes: 250368
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll i;
  ll a[n],b[n],c[n];
  for(i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
  ll dp[n][3];
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  for(i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/segtree>
using namespace atcoder; 

int op(int x, int y) { return max(x, y); }
int e() { return 0; }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, k; cin >> n >> k;
  vector<int> a(n); rep (i, n) cin >> a[i];

  segtree<int, op, e> st(600005);

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x_curr = st.get(a[i]);
    int x_now = st.prod(max(a[i]-k, 0), a[i]+k+1) + 1;
    st.set(a[i], max(x_curr, x_now));
    ans = max(max(x_curr, x_now), ans);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 15080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp9
{
    class Program
    {
        public static void Main(string[] args)

        {
            {
                string a = Console.ReadLine(); int b = a.Length;
                for (; b > 0; b--)
                { Console.Write(a[b-1]); }
                Console.WriteLine();
            }
        }
    }
}

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

bool travel(int tt,int xx,int yy){
  if(tt<xx+yy){
    return false;
  }else{
    if((xx+yy-tt)%2==0){
      return true;
    }else{
      return false;
    }
  }
}

int main(){
  int N; cin >> N;
  
  int t,x,y;
  int pret=0,prex=0,prey=0;
  for(int i=0; i<N; i++){
    cin >> t >> x >> y;
    if(travel(t-pret,abs(x-prex),abs(y-prey))==false){
      cout << "No" << endl;
      return 0;
    }
    pret=t; prex=x; prey=y;
  }
  cout << "Yes" << endl;
}

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

int main() {
  long i, num, x, tmp;
  double sq;
  cin >> num;
  sq = sqrt(num);
  tmp = num - 1;
  for (i = 2; i <= sq; i++ ) {
    if (num % i == 0) {
      x = num / i;
      if (i+x-2 < tmp) {
        tmp = i+x-2;
      }
    }
  }
  cout << tmp;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  vector<int> a(n);
  for(i=0;i<n;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  int ma=a.at(n-1);
  vector<int> c(ma+1);
  vector<int> p;
  p.push_back(2);
  for(i=3;i*i<=ma;i+=2){
    bool b=true;
    for(auto z:p){
      if(i%z==0){b=false;break;}
    }
    if(b==true) p.push_back(i);
  }
  for(i=0;i<n;i++){
    for(auto z:p){
      if(a.at(i)==1) break;
      if(a.at(i)%z==0){
        c.at(z)++;
        while(a.at(i)%z==0) a.at(i)/=z;
      }
    }
    if(a.at(i)>1) c.at(a.at(i))++;
  }
  string s="pairwise coprime";
  for(i=2;i<=ma;i++){
    if(c.at(i)==n){
      cout<<"not coprime"<<endl;
      return 0;
    }
    else if(c.at(i)>1) s="setwise coprime";
  }
  cout<<s<<endl;
}

Measured memory_bytes: 11172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while (true) {
			
			String str = scan.next();
			// strArry????????????????????????????´?
			String[] strArry = str.split("");

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

				// strArry[i]?????§??????????°??????????????????????
				// ??????????????????

				if (Character.isUpperCase(strArry[i].charAt(0))) {

					strArry[i] = strArry[i].toLowerCase();

				} else {
					strArry[i] = strArry[i].toUpperCase();
				}

				System.out.print(strArry[i]);

			}
			
			if (scan.hasNext() == false) {
				break;
			}
			
			System.out.print(" ");
		}
		 System.out.println(); 
	}

}

Measured memory_bytes: 28148
class Dice:

    def __init__(self):
        # 初期値がない場合
        # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def __init__(self, t, s, e, w, n, b):
        # 初期値が指定される場合
        self.t = t
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.b = b
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def rot(self, way):
        if way == 0:
            self.t, self.s, self.e, self.w, self.n, self.b = self.n, self.t, self.e, self.w, self.b, self.s
        elif way == 1:
            self.t, self.s, self.e, self.w, self.n, self.b = self.s, self.b, self.e, self.w, self.t, self.n
        elif way == 2:
            self.t, self.s, self.e, self.w, self.n, self.b = self.w, self.s, self.t, self.b, self.n, self.e
        elif way == 3:
            self.t, self.s, self.e, self.w, self.n, self.b = self.e, self.s, self.b, self.t, self.n, self.w
        
        
def main():
    import random

    t,s,e,w,n,b = map(int, input().split())
    dice2 = Dice(t,s,e,w,n,b)
    q = int(input())
    for _ in range(q):
        top, front = map(int, input().split())
        while True:
            if dice2.t == top and dice2.s == front:
                break
            else:
                seed = random.randint(0, 3)
                dice2.rot(seed)
        print(dice2.e)



if __name__ == '__main__':
    main()



Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int map_search_for_goal(int now_h, int now_w, int max_h, int max_w, int goal_h,
                        int goal_w, vector<string> data) {
  // initial value
  int fx[] = {0, 1, 0, -1};
  int fy[] = {1, 0, -1, 0};
  int forward_count = 4;
  char forwardable = '.';
  vector<vector<bool>> visited(max_h, vector<bool>(max_w, false));
  vector<vector<int>> dist(max_h, vector<int>(max_w, 0));
  queue<pair<int, int>> q;

  // start
  q.push(make_pair(now_h, now_w));
  visited[now_h][now_w] = true;

  int move_dist = 0;
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    REP(i, forward_count) {
      int next_h = p.first + fx[i];
      int next_w = p.second + fy[i];
      if (next_h >= 0 && next_h < max_h && next_w >= 0 && next_w < max_w &&
          !visited[next_h][next_w] && data[next_h][next_w] == forwardable) {
        visited[next_h][next_w] = true;
        int next_dist = dist[p.first][p.second] + 1;
        dist[next_h][next_w] = next_dist;
        q.push(make_pair(next_h, next_w));
      }
    }
  }
  return dist[goal_h][goal_w];
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> data;
  int wall_count = 0;
  REP(i, h) {
    string s;
    cin >> s;
    REP(j, w) {
      if (s[j] == '#') wall_count++;
    }
    data.push_back(s);
  }

  int len = map_search_for_goal(0, 0, h, w, h - 1, w - 1, data);
  int ans = (h * w) - (len + 1) - wall_count;
  if (len == 0) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int ans = 0;
    for(int i=0; i<N; i++) {
        if(i % 2 == 1) continue;
        if(A[i] % 2 == 0) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#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>;

int main() {

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

  swap(a, b);
  swap(a, c);

  cout << a << ' ' << b << ' ' << c << endl;  

}



Measured memory_bytes: 256
from math import pi, sin, cos, sqrt

A, B, H, M = map(int, input().split())

x1 = A * cos(2 * pi * (H + M / 60) / 12)
y1 = A * sin(2 * pi * (H + M / 60) / 12)
x2 = B * cos(2 * pi * M / 60)
y2 = B * sin(2 * pi * M / 60)

print(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)))

Measured memory_bytes: 9376
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>
using namespace std;
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
//const double PI = acos(-1) ;
db PI=3.1415926;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     pf("Case %d: %lld\n",z,x)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)


using namespace std;
ll n,m,y,x,h,e,l,o,z;
//int p,n,arr[2100000],ans;

//ll function_(ll p,ll q,ll r);
int main(void)
{
	CIN;

	cin>>n;//map<string,int>mp;
	string s;
	while(n--)
	{
		cin>>s;
		if(s[0]=='A')x++;
		else if(s[0]=='W')y++;
		else if(s[0]=='T')z++;
		else m++;
	}
	pf("AC x %lld\n",x);
	pf("WA x %lld\n",y);
	pf("TLE x %lld\n",z);
	pf("RE x %lld\n",m);


	
}
	


Measured memory_bytes: 3744
//mapの使い方

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  map<string, int> mp;  //集計用
  rep(i,N){
    string s;
    cin >> s;
    sort(all(s));
    mp[s] ++;
  }
  ll ans = 0;
  for (auto &p : mp){
    ll s = p.second;
    ans += s * (s - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m,mod=1e9+7;;
	cin>>n>>m;
	int64_t ans;
	if(n==m)ans=2;
	else if(n-m>1||m-n>1)ans=0;
	else ans=1;
	for(int i=n;i>=1;--i){
		ans*=i;
		ans%=mod;
	}
	for(int i=m;i>=1;--i){
		ans*=i;
		ans%=mod;
	}
	cout<<ans<<"\n"s;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// {{{ Modint
// using mint = modint<1000000007>;
// mint x = 2;
// std::cout << x.a << std::endl;
template <std::int64_t M>
class modint {
 public:
  int64_t a;

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

signed main() {
  ll N;
  string s;
  cin >> N >> s;
  rep(i,2*N) {
    if (i%2 == 0) {
      // ここは必ず反転する
      s[i] = (s[i]=='B') ? 'W' : 'B';
    }
  }

  ll nW=0, nB=0;
  string d;
  rep(i,2*N){
    if (s[i] == 'B') { d += 'R'; nB++; }
    else if (s[i] == 'W') { d += 'L'; nW++; }
  }

  //cout << "s=" << s << endl;
  //cout << "d=" << d << endl;
  if (nW != nB) {
    cout << 0 << endl;
    return 0;
  }

  ll t = 0;
  using mint = modint<1000000007>;
  mint ans(1);
  rep(i,2*N) {
    if (d[i] == 'L') {
      t++;
    } else {
      ans *= mint(t);
      t--;
    }
  }
  for (ll i=1; i<=N; i++) {
    ans *= mint(i);
  }
  cout << ans.value() << endl;
}


Measured memory_bytes: 776
import std.stdio;
import std.conv;
import std.string;
import std.math;

int main(char[][] arg){

	char[] temp;
  	int[100] n;
	int num;
  	float print;

	for(int i=0; ; i++){
      
  	  temp = readln().dup;
      temp = chomp(temp.idup).dup;
      n[i] = to!(int)(temp.idup);
      if(n[i] == 0){
		num = i;
        break;
      }
      
    }
  
	int[100] a;

	a[0] = a[1] = 1;
  	a[2] = a[0] +a[1];
  
  for(int i=3; i<100; i++){
    a[i] = a[i-1] +a[i-2] +a[i-3];
  }

  for(int i=0; i<=num-1; i++){
  	print = a[ n[i] ]/10.0/365.0;
    print = ceil(print);
  	writefln("%d", cast(int)print);
  }
  
	return 0;
}

Measured memory_bytes: 988
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
x, n  = map(int, input().split())
p  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

li = []
for i in range(-1000, 1001):
    if not i in p:
        li.append(i)

ans = 1000
min_ = 1000
for i, l in enumerate(li[::-1]):
    if min_ >= abs(x - l):
        min_ = abs(x - l)
        ans = l

print(ans)


Measured memory_bytes: 9548
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<pair<int, int>> ab(N), cd(N);
	for (int i = 0; i < N; i++) cin >> ab[i].first >> ab[i].second;
	for (int i = 0; i < N; i++) cin >> cd[i].first >> cd[i].second;
	sort(ab.begin(), ab.end(), greater<>());

	vector<int> used(N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int idx = -1;
		for (int j = 0; j < N; j++) {
			if (used[j]) continue;
			if (ab[i].first < cd[j].first && ab[i].second < cd[j].second) {
				if (idx == -1 || cd[idx].second > cd[j].second) idx = j;
			}
		}
		if (idx != -1) {
			used[idx] = 1;
			ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
 
    void solve(){
        long long x,k,d;
        cin>>x>>k>>d;
        x=abs(x);
        if(x>0 && (x/d)>=k){
            long long qq=x/d;
            x=x-(k)*d;
            cout<<x;
            return;
        }
        long long y=x/d;
        x-=y*d;
        k-=y;
        if(k%2==0)
            cout<<abs(x);
        else
            cout<<min(abs(x-d),abs(x+d));
        return;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

using namespace std;
typedef long long ll;
#define FOR(i,n) for(int i=0; i<int(n); i++)
#define FOR1(i,m,n) for(int i=int(m); i<int(n); i++)

const int MAXN = 1e5;
const int MAXL = 1e9;
vector<int> X,W;
int N, L, T;

int main(int argc, char *argv[])
{
    ll sum1=0, sum2=0;
    int over;
    
    cin >> N >> L >> T;
    FOR(i,N) {
        int x, w;
        cin >> x >> w;
        X.push_back(x);
        W.push_back(w);
    }
    
    FOR(i,X.size()) {
        if (W[i] == 1)
            X[i] += T;
        else
            X[i] -= T;
        sum1 += X[i];
        X[i] %= L;
        while(X[i] < 0) X[i] += L;
        sum2 += X[i];
    }

    over = (sum1 - sum2) / L % N;
    while(over < 0) over += N;

    sort(X.begin(), X.end());

    FOR1(i,over,N) cout << X[i] << endl;
    FOR(i,over) cout << X[i] << endl;
    
    return 0;
}


Measured memory_bytes: 2164
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] x = new int[2][n];
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < 2 ; j++){
                x[j][i] = sc.nextInt();
            }
        }
        sc.close();
        double yono = 0;
        for(int i = 0 ; i < n ; i++){
            for(int j = 0 ; j < i ; j++){
                yono += Math.sqrt((x[0][j] - x[0][i]) * (x[0][j] - x[0][i]) + (x[1][j] - x[1][i]) * (x[1][j] - x[1][i]));
            }
        }
        System.out.println(yono * 2 / n);
    }
}

Measured memory_bytes: 35828
N,x = map(int,input().split())
a = list(map(int,input().split()))
b = [a[i]+a[i+1]-x for i in range(N-1)]
ans = 0

for i in range(N-2):
    if b[i] <= 0:
        continue
    c = min(b[i],a[i+1])
    ans += b[i]
    b[i] = 0
    b[i+1] -= c
    a[i+1] -= c

ans += max(b[-1],0)

print(ans)

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

const int m = 2019;

int main()
{
	string s;
	cin >> s;
	reverse(s.begin(), s.end());

	ll sum = s[0] - '0';
	map<ll, ll> cnt;
	cnt[0] = 1;
	ll ans = 0;
	ll x = 10;
	for (int i = 1; i < s.size(); i++) {
		if (cnt.count(sum)) cnt[sum]++;
		else cnt[sum] = 1;
		sum += (s[i] - '0')*x;
		sum %= m;
		x = x * 10 % m;
		ans += cnt[sum];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> Map(n);
    vector<int> dp(n,INF);
    for(int i = 0; i<n; i++)cin >> Map[i];
    dp[0] = 0;
    for(int i = 1; i<n; i++){
        for(int j = 1;j<=k; j++){
            int h = max(0,i-j);
            dp[i] = min(dp[i],dp[h]+abs(Map[i]-Map[h]));
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
h, w = map(int, input().split())
n = h * w
INF = 1 << 30

field = []
for i in range(h):
    field.append(input())

dist = [[INF] * n for _ in range(n)]

for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            continue
        if j + 1 < w and field[i][j+1] != '#':
            dist[i * w + j][i * w + j + 1] = 1
            dist[i * w + j + 1][i * w + j] = 1
        if i + 1 < h and field[i+1][j] != '#':
            dist[i * w + j][(i+1) * w + j] = 1
            dist[(i+1) * w + j][i * w + j] = 1

# Warshall-Floyd 
for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if dist[i][j] == INF:
            continue
        ans = max(ans, dist[i][j])

print(ans)



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

int main()
{
    int a, b;
    cin >> a >> b;
    if ((b - 1) % (a - 1) == 0)
        cout << (b - 1) / (a - 1) << endl;
    else
        cout << (b - 1) / (a - 1) + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define INF ((65536/2)*(65536/2))
#define RT_0to1 2
#define RT_1to0 3
#define RT_INV 4

using namespace std;

int city,rail,year,con[200000][2],node[100000],rctype[200000];
vector<int> dest[100000],from[100000];
queue<int> prc;

int main(void)
{
	cin >> city >> rail >> year;
	for(int i = 0;i < rail;i++)
	{
		cin >> con[i][0] >> con[i][1];
		con[i][0]--;
		con[i][1]--;
		dest[con[i][0]].push_back(con[i][1]);
		dest[con[i][1]].push_back(con[i][0]);
	}
	for(int i = 0;i < 100000;i++)
		node[i] = INF;
	node[0] = 0;
	prc.push(0);
	int t;
	auto itr = dest[0].begin();
	while(!prc.empty())
	{
		t = prc.front();
		prc.pop();
		for(itr = dest[t].begin();itr < dest[t].end();itr++)
		{
			if(node[*itr] > node[t] + 1)
			{
				node[*itr] = node[t] + 1;
				prc.push(*itr);
			}
		}
	}
	for(int i = 0;i < 100000;i++)
	{
		sort(dest[i].begin(),dest[i].end());
	}
	for(int i = 0;i < rail;i++)
	{
		if(node[con[i][0]] + 1 == node[con[i][1]])
		{
			dest[con[i][1]].erase(lower_bound(dest[con[i][1]].begin(),dest[con[i][1]].end(),con[i][0]));
			rctype[i] = RT_1to0;
		}
		else if(node[con[i][0]] == node[con[i][1]] + 1)
		{
			dest[con[i][0]].erase(lower_bound(dest[con[i][0]].begin(),dest[con[i][0]].end(),con[i][1]));
			rctype[i] = RT_0to1;
		}
		else
		{
			dest[con[i][0]].erase(lower_bound(dest[con[i][0]].begin(),dest[con[i][0]].end(),con[i][1]));
			dest[con[i][1]].erase(lower_bound(dest[con[i][1]].begin(),dest[con[i][1]].end(),con[i][0]));
			rctype[i] = RT_INV;
		}
	}
	for(int i = 0;i < 100000;i++)
	{
		for(itr = dest[i].begin();itr < dest[i].end();itr++)
		{
			from[*itr].push_back(i);
		}
	}
	for(int i = 0;i < 100000;i++)
	{
		sort(from[i].begin(),from[i].end());
	}
	//dest[x].elements ?????????????????????????????????
	//from[x].elements ?????????????????\????????????
	for(int i = 0;i < 100000;i++)
	{
		node[i] = 1;
	}
	int result = 0;
	for(int k = 0;k < year;k++)
	{
		cin >> t;
		t--;
		if(rctype[t] != RT_INV)
		{
			if(rctype[t] != RT_0to1)
			{
				dest[con[t][0]].erase(lower_bound(dest[con[t][0]].begin(),dest[con[t][0]].end(),con[t][1]));
				if(binary_search(from[con[t][1]].begin(),from[con[t][1]].end(),con[t][0]))
					from[con[t][1]].erase(lower_bound(from[con[t][1]].begin(),from[con[t][1]].end(),con[t][0]));
				prc.push(con[t][1]);
			}
			else
			{
				if(binary_search(from[con[t][0]].begin(),from[con[t][0]].end(),con[t][1]))
					from[con[t][0]].erase(lower_bound(from[con[t][0]].begin(),from[con[t][0]].end(),con[t][1]));
				dest[con[t][1]].erase(lower_bound(dest[con[t][1]].begin(),dest[con[t][1]].end(),con[t][0]));
				prc.push(con[t][0]);
			}
			while(!prc.empty())
			{
				t = prc.front();
				prc.pop();
				if(from[t].empty() && node[t] == 1)
				{
					result++;
					node[t] = 0;
					for(itr = dest[t].begin();itr < dest[t].end();itr++)
					{
						from[*itr].erase(lower_bound(from[*itr].begin(),from[*itr].end(),t));
						prc.push(*itr);
					}
				}
			}
		}
		cout << result << endl;
	}
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int a, b;
    cin >> a >> b;
    if(a < 6) {
        cout << 0 << endl; 
    } else if(a > 12) {
        cout << b << endl;
    } else {
        cout << b / 2 << endl;
    }
    return 0;
} /*atcoder*/


Measured memory_bytes: 3552