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

int main(){
    int N, M;
    cin >> N >> M;
    int H[N], ma[N];
    for (int i = 1; i <= N; i++){
        cin >> H[i];
        ma[i] = 0;
    }
    for (int i = 1; i <= M; i++){
        int a, b;
        cin >> a >> b;
        ma[a] = max(ma[a], H[b]);
        ma[b] = max(ma[b], H[a]);
    }
    int ans = 0;
    for (int i = 1; i <= N; i++){
        ans += H[i] > ma[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4324
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N, M = map(int, readline().split())
    H_ex = list(map(int, readline().split()))
    m = map(int, read().split())
    AB = zip(m, m)
    l = [[]for _ in range(N+1)]
    ans = 0
    H = [0]
    H.extend(H_ex)
    for A, B in AB:
        l[A].append(B)
        l[B].append(A)
    for i in range(1,N+1):
        for j in l[i]:
            if H[i] <= H[j]:
                break
        else:
            ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()


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

int main(){
	int n, d;
	cin >> n >> d;
	vector<vector<int> > v(n, vector<int> (d, 0));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < d; j++){
			cin >> v[i][j];
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int k = i+1; k < n; k++){
			double check = 0;
			for(int j = 0; j < d; j++){
				check += abs(v[i][j] - v[k][j]) * abs(v[i][j] - v[k][j]);
			}
			check = sqrt(check);
			if(check - (double)(int)check == 0.00)
			ans++; 
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int A, B;
  cin >> A >> B;
  cout << max({A + B, A - B, A * B}) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.next().split("");
        String res = "Yes";

        for(int i=0;i<a.length;i++){
            if(i%2==1){
                if(a[i].equals("R"))res="No";
            }
            else{
                if(a[i].equals("L"))res="No";
            }
        }
        System.out.println(res);

    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    if(b <= a+2){
        cout << k+1 << "\n";
        return 0;
    }
    ll ans = 0;
    ans += min(k, a-1);
    k -= ans;
    ans += (b-a)*(k/2);
    cout << ans+k%2+1 << "\n";
    return 0;
}


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

#define pb push_back
#define ppp pop_back
#define fi first
#define se second
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    bool odd = 0;
    for (int i=1; i<=n; i++) {
        int cur;
        cin >> cur;
        if (cur & 1) odd = 1;
    }
    if (odd) cout << "first\n";
    else cout << "second\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#define int long long
using namespace std;
signed main() {
	int n, t, ans = 10000; cin >> n >> t;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		if (b <= t)ans = min(ans, a);
	}
	if (ans == 10000)cout << "TLE\n";
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> ans(n);
    if(s != 1000000000){
        REP(i, k)
            ans[i] = s;
        FOR(i, k, n)
            ans[i] = s+1;
    }
    else{
        REP(i, k){
            ans[i] = s;
        }
        FOR(i, k, n)
            ans[i] = 1;
    }

    REP(i, n)
        cout << (i==0?"":" ") << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
n = int(input())
p = [list(map(int,input().split())) for _ in range(n)]

X = sorted([(i, xy[0]) for i, xy in enumerate(p)], key=lambda x: x[1])
Y = sorted([(i, xy[1]) for i, xy in enumerate(p)], key=lambda x: x[1])
dX = sorted([[X[i][0], X[i+1][0], X[i+1][1]-X[i][1]] for i in range(n-1)], key=lambda x: x[2])
dY = sorted([[Y[i][0], Y[i+1][0], Y[i+1][1]-Y[i][1]] for i in range(n-1)], key=lambda x: x[2])

def root(x):
    if parent[x] == x:
        return x
    else:
        return root(parent[x])

def connected(x, y):
    return root(x) == root(y)

parent = [i for i in range(n+1)]
depth = [1 for i in range(n+1)]

ans = 0
i, j = 0, 0
while i < n-1 and j < n-1:
    if dX[i][2] < dY[j][2]:
        a, b, d = dX[i]
        i += 1
    else:
        a, b, d = dY[j]
        j += 1
    ra, rb = map(root, [a,b])
    if ra != rb:
        if depth[ra] < depth[rb]:
            a, b = b, a
            ra, rb = rb, ra
        parent[rb] = ra
        depth[ra] = max(depth[ra], depth[rb]+1)
        ans += d
print(ans)


Measured memory_bytes: 73364
R, G, B, N = map(int, input().split())
a = N // R
t = 0
for i in range(a + 1):
    b = N - R*i
    c = b // G
    for l in range(c + 1):
        d = b - G*l
        if d % B == 0:
            t += 1
print(t)

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

int main()
{
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
        cin >> p[i];
    sort(p.begin(), p.end());
    for (int i = 0; i < K; i++)
        ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3604
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)


n, a, b = inp_list()
q = n // (a + b)
n -= q * (a + b)

ans = q * a + min(a, n)
print(ans)


Measured memory_bytes: 5200
N,K=map(int,input().split())

A=list(map(int,input().split()))
L=[0]*N
R=[0]*N

for i in range(N):
    for j in range(N):
        if j<i and A[j]<A[i]:
            L[i]+=1
        if j>i and A[j]<A[i]:
            R[i]+=1
ans = 0
K1=((1+K)*K//2)%(10**9+7)
K2=(K*(K-1)//2)%(10**9+7)

for i in range(N):
    ans +=(R[i]*K1+L[i]*K2)%(10**9+7)

ans =ans%(10**9+7)

print(int(ans))



Measured memory_bytes: 3316
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll N;
    cin >> N;
    V<ll> P(N), Q(N);
    for (ll &e : P) cin >> e;
    for (ll &e : Q) cin >> e;
    V<ll> perm(N);
    iota(ALL(perm), 1ll);
    ll a = -1, b = -1, idx = 0;
    do {
        if (perm == P) a = idx;
        if (perm == Q) b = idx;
        idx++;
    } while (next_permutation(ALL(perm)));

    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bitset>
#include<iostream>
#include<string>
#include<utility>
#include<tuple>
#include<cmath>
#include<cstdio>
using namespace std;

typedef tuple<bool, int, int> P;

bitset<32> hex2binary(string& hex)
{
  unsigned long long v = stol(hex, nullptr, 16);
  return bitset<32>(v);
}

P kongo(const bitset<32>& binary)
{
  int v1 = 0;
  for(int i = 7; i < 31; i++)
    v1 += (int)pow(2, i - 7) * (int)binary[i];
  
  double v2 = 0;
  for(int i = 0; i < 7; i++)
    v2 += pow(0.5, 7 - i) * (int)binary[i];
  v2 *= 10000000;
  return P(binary[31], v1, (int)v2);
}

int main()
{
  int n; 
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    auto p = kongo(hex2binary(s));
    auto v1 = get<1>(p);
    auto v2 = get<2>(p);
    cout << (get<0>(p) ? "-" : "") << v1 << ".";
    for(int j = 0; j < 6 - (int)log10(v2); j++)
      cout << "0";
    while(v2 > 0 && !((int)v2 % 10))
      v2 /= 10;
    cout << v2 << endl;
  }
}

Measured memory_bytes: 1280
n=input()[::-1]
n+="0"
L=len(n)
ans=0
chk=0
flg=0
for i in range(L):
  chk=int(n[i])
  chk+=flg
  if chk==5:
    if int(n[i+1])>=5:
      ans+=5
      flg=1
    else:
      ans+=5
      flg=0
  elif chk>5:
    ans+=10-chk
    flg=1
  else:
    ans+=chk
    flg=0
print(ans+flg)

Measured memory_bytes: 5492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sca = new Scanner(System.in);
		int n = sca.nextInt();
		int a = (int)(n/1.08);
		int x1 = (int)(a*1.08);
		int x2 = (int)((a+1)*1.08);
		if((x1 == n) && (x2 == n)) {
			System.out.println(a);
		}
		else if(x1 == n){
			System.out.println(a);
		}
		else if(x2 == n) {
			System.out.println(a+1);
		}
		else {
			System.out.println(":(");
		}
	}
}


Measured memory_bytes: 23764
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int size = 15000;
		int m = scanner.nextInt();
		int n = scanner.nextInt();
		int[] manju = new int[m];
		for (int i = 0; i < m; i++)
			manju[i] = scanner.nextInt();
		int[] dp = new int[size+2];
		Arrays.fill(dp, 1 << 30);
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			int c = scanner.nextInt();
			int e = scanner.nextInt();
			for (int j = size; j >= c; j--) {
				dp[j] = Math.min(dp[j], dp[j - c] + e);
			}
		}
		for (int i = size; i >= 0; i--)
			dp[i] = Math.min(dp[i], dp[i + 1]);
		Arrays.sort(manju);
		int ans = 0;
		int sum = 0;
		for (int i = 0; i < m; i++) {
			sum += manju[m - i - 1];
			ans = Math.max(ans, sum - dp[i + 1]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 37812
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll mem[111][111];

ll C(ll n, ll k) {
  if(n<k||n<0||k<0) return 0;
  if(k==0) return 1;
  if(n==k) return 1;
  if(mem[n][k]!=-1) return mem[n][k];
  return mem[n][k]=C(n-1, k)+C(n-1, k-1);
}


int main(void) {
  ll i, j, k, l;
  
  memset(mem, -1, sizeof(mem));
  
  ll N, A, B;
  cin >> N >> A >> B;
  ll v[55];
  
  for(i=0; i<N; i++) cin >> v[i];
  sort(v, v+N);
  reverse(v, v+N);
  
  ll ans=0;
  ll s=0, t=0;
  for(i=0; v[i]!=v[A-1]; ans+=v[i], i++, s++);
  for(i=0; i<N; i++) if(v[i]==v[A-1]) t++;
  
  ans+=v[A-1]*(A-s);
  printf("%.10f\n", (double)ans/A);
  
  if(s) {
    pt(C(t, A-s));
  }else {
    ll c=0;
    for(i=A; i<=min(B, t); i++) c+=C(t, i);
    pt(c);
  }
  
  
  
}




Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<P> V;
typedef map<PP, V> Cache;
const int MAX_SIZE = 50;
const int MAX_TASK_SIZE = 1000;

vector<P> dfs(char f[MAX_SIZE][MAX_SIZE], P src, P des, int R, int C) {
  vector<P> v;
  if (src == des) {
    v.push_back(des);
    return v;
  }
  f[src.first][src.second] = '@';
  int dr[] = {-1, 1, 0, 0};
  int dc[] = {0, 0, -1, 1};
  for (int k = 0; k < 4; ++k) {
    int i = src.first  + dr[k];
    int j = src.second + dc[k];
    if (i + 1 && j + 1 && i < R && j < C && f[i][j] == '.') {
      v = dfs(f, P(i, j), des, R, C);
      if (v.size()) {
        v.insert(v.begin(), src);
        break;
      }
    }
  }
  f[src.first][src.second] = '.';
  return v;
}

int calc(int R, int C, int M, char f[][MAX_SIZE], int costs[][MAX_SIZE][MAX_SIZE], P tasks[]) {
  Cache cache;
  int p[MAX_SIZE][MAX_SIZE] = {};
  int t = 0;
  int i0 = tasks[0].first, j0 = tasks[0].second;
  int a = costs[1][i0][j0] + costs[2][i0][j0];
  p[i0][j0] = ++t;
  for (int i = 0; i < M - 1; ++i) {
    P src = tasks[i], des = tasks[i + 1];
    V v;
    Cache::iterator find = cache.find(PP(src, des));
    if (find != cache.end()) {
      v = find->second;
    } else {
      v = dfs(f, src, des, R, C);
      cache.insert(pair<PP, V>(PP(src, des), v));
    }
    for (V::iterator vit = ++v.begin(); vit != v.end(); ++vit) {
      ++t;
      int r = vit->first, c = vit->second;
      int prev = p[r][c];
      int cost = costs[1][r][c] + costs[2][r][c];
      a += cost;
      if (prev) {
        int d = (t - prev) * costs[0][r][c] - cost;
        if (d < 0) a += d;
      }
      p[r][c] = t;
    }
  }
  return a;
}

int main() {
  int n;
  int R, C, M;
  char f[MAX_SIZE][MAX_SIZE];
  int costs[3][MAX_SIZE][MAX_SIZE];
  P tasks[MAX_TASK_SIZE];
  char s[MAX_SIZE + 1];
  cin >> R >> C >> M;
  for (int i = 0; i < R; ++i) {
    cin >> s;
    for (int j = 0; j < C; ++j) {
      f[i][j] = s[j];
    }
  }
  for (int k = 0; k < 3; ++k) {
    for (int i = 0; i < R; ++i) {
      for (int j = 0; j < C; ++j) {
        cin >> n;
        costs[k][i][j] = n;
      }
    }
  }
  for (int i = 0; i < M; ++i) {
    int r, c;
    cin >> r >> c;
    tasks[i] = P(r, c);
  }
  cout << calc(R, C, M, f, costs, tasks) << endl;
}

Measured memory_bytes: 1968
#include <bits/stdc++.h>
int const N=1e5+5;
bool prime[N];
using namespace std;
int main() {

  long long  a,b;
  cin>>a>>b;
  map <long long,long long > mp;
  for(long long i=1;i*i<=a;i++)
  {
      if(a%i==0)
      {mp[i]++;
            if(a/i!=i)
          mp[a/i]++;
      }
     // cout<<mp[1];
  }
    for(long long i=1;i*i<=b;i++)
    {

        if(b%i==0)
        {if(mp[i])
            mp[i]++;
            if(b/i!=i&&mp[b/i])
            {mp[b/i]++;}
        }
    }
    vector <long long> vec;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(it->second==2)
            vec.push_back(it->first);

    }
   // cout<<mp[1];
    vector <long long> ans;
    for(long long  j=0;j<vec.size();j++)
    {
        long long  cont=0;
        for(long long  i=2;i*i<=vec[j];i++)
        {if(vec[j]%i==0)
            cont++;

        }
        if(cont==0)
            ans.push_back(vec[j]);
    }
  cout<<ans.size();

}

Measured memory_bytes: 768
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (c it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(x...) " [" #x ": " << (x) << "] "

using ld = long double;
using ll = long long;

constexpr int mod = 1000 * 1000 * 1000 + 7;
constexpr int odw2 = (mod + 1) / 2;

void OdejmijOd(int& a, int b) { a -= b; if (a < 0) a += mod; }
int Odejmij(int a, int b) { OdejmijOd(a, b); return a; }
void DodajDo(int& a, int b) { a += b; if (a >= mod) a -= mod; }
int Dodaj(int a, int b) { DodajDo(a, b); return a; }
int Mnoz(int a, int b) { return (ll) a * b % mod; }
void MnozDo(int& a, int b) { a = Mnoz(a, b); }
int Pot(int a, int b) { int res = 1; while (b) { if (b % 2 == 1) MnozDo(res, a); a = Mnoz(a, a); b /= 2; } return res; }
int Odw(int a) { return Pot(a, mod - 2); }
void PodzielDo(int& a, int b) { MnozDo(a, Odw(b)); }
int Podziel(int a, int b) { return Mnoz(a, Odw(b)); }
int Moduluj(ll x) { x %= mod; if (x < 0) x += mod; return x; }

template <typename T> T Maxi(T& a, T b) { return a = max(a, b); }
template <typename T> T Mini(T& a, T b) { return a = min(a, b); }

int Dig(int x) {
  int r = 0;
  while (x) {
    r += x % 10;
    x /= 10;
  }
  return r;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int wyn = numeric_limits<int>::max();
  for (int a = 1; a < n; a++) {
    Mini(wyn, Dig(a) + Dig(n - a));
  }
  cout << wyn << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jul  5 21:23:55 JST 2020
 **/

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

signed main() {
    Int H, W, K;
    std::cin >> H >> W >> K;
    std::vector<std::string> c(H);
    REP(i, H) std::cin >> c[i];
    Int ans = 0;
    REP(S, 1 << H) {
        REP(T, 1 << W) {
            Int cnt = 0;
            REP(i, H) REP(j, W) { cnt += c[i][j] == '#' && (S >> i & 1) && (T >> j & 1); }
            ans += cnt == K;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int h, w;
char p[50 + 5][50 + 5], cnt[50 + 5][50 + 5];

int ok(int i,int j){
	if(i<0||j<0||i>=h||j>=w)return 0;
	return p[i][j]=='.';
}

int main() {
	int dr[8]={-1,-1,-1,0,0,1,1,1};
	int dc[8]={-1,0,1,-1,1,-1,0,1};
	scanf("%d%d", &h, &w);
	getchar();
	int i,j,k;
	for (i = 0;i < h;i++)gets(p[i]);
	memset(cnt,0,sizeof(cnt));
	for(i=0;i<h;i++){
		for(j=0;j<w;j++)if(p[i][j]=='#'){
			cnt[i][j]='#';
			for(k=0;k<8;k++)if(ok(i+dr[k],j+dc[k])){
				cnt[i+dr[k]][j+dc[k]]++;
			}
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++)
		if(p[i][j]=='#')printf("#");
		else printf("%d",cnt[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (u == s) {
    a--;
  } else {
    b--;
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>   
using namespace std;

int main(){
int a[6],ans = 0;
cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
if(a[0] + a[1] * 5 + a[2] * 10 + a[3] * 50 + a[4] * 100 + a[5] * 500 >= 1000) ans = 1;
cout << ans << endl;
}

Measured memory_bytes: 1164
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

int main() {

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

	Int H, W;
	cin >> H >> W;

	vector<vector<Int>> A(H+1, vector<Int>(W+1));
	vector<vector<Int>> B(H+1, vector<Int>(W+1));
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			cin >> B[i][j];
		}
	}

	auto dp = make_vec(H+1, W+1, 13000, false);
	dp[0][0][abs(A[0][0]-B[0][0])] = true;

	
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			for (Int k = 0; k < 13000; k++) {
				if (dp[i][j][k]) {
					dp[i + 1][j][k + abs(A[i + 1][j] - B[i + 1][j])] =true;
					dp[i + 1][j][abs(k - abs(A[i + 1][j] - B[i + 1][j]))] = true;//kが負になる場合は正に切り返す

					dp[i][j + 1][k + abs(A[i][j + 1] - B[i][j + 1])] = true;
					dp[i][j + 1][abs(k - abs(A[i][j + 1] - B[i][j + 1]))] = true;//kが負になる場合は正に切り返す

				}
			}
		}
	}

	Int ans;
	for (Int k = 0; k < 13000; k++) {
		if (dp[H-1][W-1][k]) {
			cout << k << "\n";
			return 0;
		}
	}

}



Measured memory_bytes: 11264
program five_antennas
  implicit none
  integer :: a, e, k
  read(*,*) a
  read(*,*) e
  read(*,*) e
  read(*,*) e
  read(*,*) e
  read(*,*) k
  write(*,'(a)') trim(merge(":(  ","Yay!",e-a > k))
end program five_antennas

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

using namespace std;

bool solve(vector<int> &counti) {
	for (int i = 0; i < 26; i++) {
		if (counti[i] % 2) {
			return false;
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	string w;
	cin >> w;
	vector<int> counti(26);
	for (char c : w) {
		counti[c - 'a']++;
	}
	if (solve(counti)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
A, B = list(map(int, input().split()))
Amin, Amax, Bmin, Bmax = A/0.08, (A+1)/0.08, B/0.1, (B+1)/0.1
min_price = int(max(Amin, Bmin))
if min_price != max(Amin, Bmin):
    min_price += 1
max_price = int(min(Amax, Bmax))
if max_price == min(Amax, Bmax):
    max_price -= 1
if min_price > max_price:
    print("-1")
else:
    print(min_price)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new ArrayList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	}

	
}

Measured memory_bytes: 26216
n=int(input())
s=input()

def main():
  left=0
  right=0
  for char in s:
    if char=="(":
      right+=1
    else:#")"
      if right>0:
        right-=1
      else:
        left+=1
  return (left,right)
      

l,r=main()
print("("*l+s+r*")")


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main()
{
	int n = 0; unsigned long long  z = 0; int k = 0; int p = 0;
	unsigned long long dp[21][105] = { 0 };
	cin >> n;
	cin >> k;
		dp[k][0] = 1;
	for (int i = 1; i < n-1; i++) {
		cin >> p;
		for (int j = 0; j < 21; j++) {
			if (j - p >= 0)dp[j][i] += dp[j - p][i - 1];
			if (j + p<= 20)dp[j][i]+= dp[j + p][i - 1];
		}
	}
	cin >> p;
	cout << dp[p][n-2] << endl;

    return 0;
}


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

int main() {
  char a, b;
  cin >> a >> b;
  if (a > b) {
    cout << '>' << endl;
  } else if (a < b) {
    cout << '<' << endl;
  } else {
    cout << '=' << endl;
  }
}

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

signed main() {
    int n, d, x[10][10], a, ans=0;
    
    cin >> n >> d;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < d; j++ ) {
            cin >> x[i][j];
        }
    }
    
    for ( int i = 0; i < n-1; i++ ) {
        for ( int j = i+1; j < n; j++ ) {
            a = 0;
            
            for ( int k = 0; k < d; k++ ) {
                a += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            
            for ( int k = 1; k*k <= a; k++ ) {
                if ( k*k == a ) {
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;
    return (0);
}

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

int main()
{   
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    char i='a';
    int ia=0,ib=0,ic=0;
    while(1){
        if(i=='a'){
            if(ia==sa.size()){
                cout<<"A"<<endl;
                return 0;
            }
            i=sa[ia];
            ia++;
        }
        else if(i=='b'){
            if(ib==sb.size()){
                cout<<"B"<<endl;
                return 0;
            }
            i=sb[ib];
            ib++;
        }
        else{
            if(ic==sc.size()){
                cout<<"C"<<endl;
                return 0;
            }
            i=sc[ic];
            ic++;
        }
    }

  
   
}

Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

int32_t N;
int64_t A[271828];

int64_t sum[271828];

void asumisu(int64_t res[4], int64_t hosei, const int64_t* data, int32_t size) {
	if (data[0] - hosei > data[size - 1] - data[0]) {
		res[0] = res[2] = data[0] - hosei;
		res[1] = res[3] = data[size - 1] - data[0];
	} else if (data[size - 2] - hosei <= data[size - 1] - data[size - 2]) {
		res[0] = res[2] = data[size - 2] - hosei;
		res[1] = res[3] = data[size - 1] - data[size - 2];
	} else {
		int32_t le = 0, greater = size - 2;
		while (le + 1 < greater) {
			int32_t mid = le + (greater - le) / 2;
			if (data[mid] - hosei <= data[size - 1] - data[mid]) le = mid; else greater = mid;
		}
		res[0] = data[le] - hosei;
		res[1] = data[size - 1] - data[le];
		res[2] = data[greater] - hosei;
		res[3] = data[size - 1] - data[greater];
	}
}

int main(void) {
	int32_t i;
	int64_t answer = -1;
	if (scanf("%" SCNd32, &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &A[i]) != 1) return 1;
	}
	sum[0] = A[0];
	for (i = 1; i < N; i++) {
		sum[i] = sum[i - 1] + A[i];
	}

	for (i = 2; i < N - 1; i++) {
		int64_t tomatu[4], sumipe[4];
		int j, k;
		asumisu(tomatu, 0, sum, i);
		asumisu(sumipe, sum[i - 1], sum + i, N - i);
		for (j = 0; j < 2; j++) {
			for (k = 0; k < 2; k++) {
				int64_t kitaeri[4];
				int64_t min, max, candidate;
				int l;
				kitaeri[0] = tomatu[j * 2 + 0];
				kitaeri[1] = tomatu[j * 2 + 1];
				kitaeri[2] = sumipe[k * 2 + 0];
				kitaeri[3] = sumipe[k * 2 + 1];

				min = max = kitaeri[0];
				for (l = 1; l < 4; l++) {
					if (kitaeri[l] < min) min = kitaeri[l];
					if (kitaeri[l] > max) max = kitaeri[l];
				}
				candidate = max - min;
				if (answer < 0 || candidate < answer) answer = candidate;
			}
		}
	}

	printf("%" PRId64 "\n", answer);
	return 0;
}

/*

#-----*------------#
------*-#--#--------

*----#-------------#
*-------#-------#---

*/


Measured memory_bytes: 3712
n = int(input())
s = input()

e = 1
w = 1
count_e = [0] * n
count_w = [0] * n
for i in range(n):
    if i == 0:
        if s[i] == 'E':
            count_e[i] = e
            e += 1
        else:
            count_w[i] = w
            w += 1
        continue
    if s[i] == 'E':
        count_e[i] = e
        count_w[i] = count_w[i-1]
        e += 1
    else:
        count_w[i] = w
        count_e[i] = count_e[i-1]
        w += 1

ans = 10 ** 9
for i in range(n):
    if s[i] == 'E':
        e = count_e[-1] - count_e[i]
        w = count_w[i]
    else:
        e = count_e[-1] - count_e[i]
        w = count_w[i] - 1
    ans = min(ans,e+w)
print(ans)

Measured memory_bytes: 17568
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  ll x, y; cin >> x >> y;
  ll n = x;
  ll ans = 0;
  while(n <= y){
    ans++;
    n*=2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

string n;

int main() {
    cin >> n;
    for(int i = 0; i < n.length(); ++i) {
        if(n.at(i) == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static long[][] dp = new long[105][100000 + 5];
    static PrintWriter pw = new PrintWriter(System.out);

    public static long f(int[] arr, int[] w, int n, int sum, int W) {
        if (n == arr.length)
            return 0;
        if (dp[n][sum] != -1)
            return dp[n][sum];
        if (w[n] + sum <= W) {
            return dp[n][sum] = Math.max(arr[n] + f(arr, w, n + 1, sum + w[n], W), f(arr, w, n + 1, sum, W));
        }
        return dp[n][sum] = f(arr, w, n + 1, sum, W);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int W = sc.nextInt();
        int[] arr = new int[n];
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            arr[i] = sc.nextInt();
        }
        for (int i = 0; i < dp.length; i++)
            for (int j = 0; j < dp[i].length; j++)
                dp[i][j] = -1;
        pw.println(f(arr, w, 0, 0, W));
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 127056
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int n, m;

int main()
{
    cin>>n;
    double f=2.0*3.1415926535897;
    printf("%.2f",f*n);
	return 0;
}


Measured memory_bytes: 3772
from functools import reduce
from operator import mul

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

  
def cmb(n, r):
    """
    組み合わせの数 nCr
    :param n:
    :param r:
    :return:
    """
    r = min(n - r, r)
    if r == 0:
        return 1
    return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))
  
  
N,M = map(int, input().split())
m_factorized = factorize(M)
mod = 10 ** 9 + 7

ans = 1

    
for i in m_factorized:
  k = i[1] 
  ans *= cmb(N-1+k,k)
  ans %= mod
print(ans)


Measured memory_bytes: 3572
#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 watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll h,w,n; cin>>h>>w>>n;
	cout<<min(ceil((ld)n/h), ceil((ld)n/w))<<'\n';
	
	return 0;
}


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

const int N = 200005;
int n;
long long k;
int spt[N][64];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>spt[i][0];
	}
	
	for(int j=1;j<=63;j++){
		for(int i=1;i<=n;i++){
			spt[i][j] = spt[spt[i][j-1]][j-1];
		}
	}
	
	int x = 1;
	for(long long j=0;j<63;j++){
		//cout<<k<<" "<<(1ll<<j)<<" "<<(k&(1<<j))<<endl;
		if(k & (1ll<<j)){
			x = spt[x][j];
			//cout<<x<<endl;
		}
	}
	cout<<x;
	
	
	return 0;
}


Measured memory_bytes: 53532
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define fi first
#define se second
string s;
int k;
set<string> ss;
signed main(){
	cin >> s >> k;
	for(int i = 0 ; i < s.size() ; i ++){
		string prep = "";
		for(int j = 0 ; j < min(k, (int)s.size() - i) ; j ++){
			prep += s[i + j];
			ss.insert(prep);
		}
	}
	set<string>::iterator it = ss.begin();
	for(int i = 1 ; i < k ; i ++) it ++;
	cout << *it;
	
}


Measured memory_bytes: 1664
z[2002],*a=z,*b=z+1001,m,i,j,t;main(n){for(;scanf("%d",&n),i=n;printf("%d\n",m))for(memset(a,m=0,4004);i--;t=a,a=b,b=t)for(j=scanf(" ");j++<n;)m=fmax(m,b[j]=getchar()-42?1+fmin(fmin(b[j-1],a[j-1]),a[j]):0);}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
   int n;
   cin >> n;
   vector<int> a(n+1);
   for (int i=0; i<n+1; i++) cin >> a[i];
   int ap = 0;
   long long ans = 0;
   for (int i=0; i<n; i++) {
       int b;
       cin >> b;
       ans += min(ap+b, a[i]);
       a[i] = max(a[i]-ap, 0);
       ap = max(b-a[i], 0);
   }
   ans += min(ap, a[n]);

   cout << ans << endl;
}


Measured memory_bytes: 888
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i

ary = [b,c,d,e]
cnt = 0

ary.each do |x|
  cnt += 1 if x > (a+k)
end

if cnt == 0
  puts "Yay!"
else
  puts ":("
end

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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] strArray = br.readLine().split(" ");
        int a = Integer.parseInt(strArray[0]);
        int b = Integer.parseInt(strArray[1]);
        int c = Integer.parseInt(strArray[2]);
        int count = 0;

        for(int i=a; i <= b; i++) {
        	if(c%i == 0) {
        		count++;
        	}
        }
        System.out.println(count);
	}
}

Measured memory_bytes: 24464
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)


Measured memory_bytes: 9008
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n,m;
pair<ll,ll> ab[100100];

int main(){
	cin>>n>>m;
	ll ans=0;
	for(int i=0;i<n;i++){
		int t,s;
		cin>>t>>s;
		ab[i]=make_pair(t,s);
	}
	sort(ab,ab+n);
	for(int i=0;i<n;i++){
		if(ab[i].second<=m){
			ans+=ab[i].first*ab[i].second;
			m-=ab[i].second;
		}else{
			ans+=ab[i].first*m;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll int factorial(ll int n)
{
    // single line to find factorial
    return (n==1 || n==0) ? 1: n * factorial(n - 1);
}
int main()
{
    //cout<<factorial(6)<<endl;
ll int n,i,j;
long double ans ,x[100],y[100] ,sum,p,a,b;
sum=0;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>x[i]>>y[i];
}
for(i=0;i<n;i++)
{
    for(j=0;j<n;j++)
    {
        a=(x[i]-x[j]);
        b=(y[i]-y[j]);
        if(b<0)
        {
            b=-b;
        }
        if(a<0)
        {
            a=-a;
        }
        p=(a*a)+(b*b);
        p=sqrt(p);
        sum=sum+p;
       // cout<<p<<" ";
    }
}
//cout<<endl;
//cout<<"total: "<<sum<<endl;
ans=sum/(n);
//cout<<fixed();
cout<<std::fixed;
cout<<std::setprecision(8);
cout<<ans<<endl;
//cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
 int A=0;
 std::string S;
 std::cin >> S;
 if(S[0]!='C')
  A++;
if(S[1]!='O')
  A++;
if(S[2]!='D')
  A++;
if(S[3]!='E')
  A++;
if(S[4]!='F')
  A++;
if(S[5]!='E')
  A++;
if(S[6]!='S')
  A++;
if(S[7]!='T')
  A++;
if(S[8]!='I')
  A++;
if(S[9]!='V')
  A++;
if(S[10]!='A')
  A++;
if(S[11]!='L')
  A++;
if(S[12]!='2')
  A++;
if(S[13]!='0')
  A++;
if(S[14]!='1')
  A++;
if(S[15]!='6')
  A++;
std::cout << A << std::endl;
}

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

using namespace std;
using Graph = vector<vector<int>>;

int main(void) {
    int n, m;
    cin >> n >> m;
    Graph g = Graph(n+1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> q;
    vector<int> bfr(n+1, -1);
    bfr[1] = 0;
    q.push(1);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int nv : g[v]) {
            if (bfr[nv] != -1) {
                continue;
            }
            bfr[nv] = v;
            q.push(nv);
        }
    }
    cout << "Yes\n";
    for (int i = 2; i < n+1; i++) {
        cout << bfr[i] << "\n";
    }
}


Measured memory_bytes: 10164
#include "bits/stdc++.h"
using namespace std;

long long int gcd(long long int a, long long int b) {
  if(a < b) gcd(b, a);
  long long int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
  long long int n,x;
  cin>>n>>x;
  vector<long long int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  long long int ans=abs(a[0]-x);
  for(int i=1;i<n;i++){
    ans=gcd(ans,abs(a[i]-a[i-1]));
  }
  cout<<ans<<endl;
}


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

long long fact(long long n){
    if(n == 0 || n == 1) return 0;
    return n * (n-1) / 2;
}

int main(){
    long long n;
    cin >> n;
    vector<long long> A(n);
    for(long long i=0;i<n;++i) cin >> A[i];
    // 要素ごとの登場数をカウント
    map<long long,long long> counter;
    for(int i=0;i<n;++i) counter[A[i]]++;
    // 全要素でのcombの和
    long long total = 0;
    for (auto i = counter.begin(); i != counter.end(); ++i) {
        long long value = i->second;
        if(value < 2) continue;
        total += fact(value);
    }
    // 要素を1個ずつ除外
    for(int i=0;i<n;++i){
        long long tmp = total;
        long long count = counter[A[i]];
        //除外する要素分の減算
        tmp = tmp - fact(count) + fact(count-1);
        cout << tmp << endl;
    }
    return 0;
}


Measured memory_bytes: 11008
using System;

namespace kyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] p = Array.ConvertAll(str, int.Parse);
            int kotae = 0;
            for(int i = 0;i < (n - 2); i++)
            {
                if(p[i ] < p[i + 1] && p[i + 1] < p[i + 2] || p[i] > p[i + 1] && p[i + 1] > p[i + 2])
                {
                    kotae = kotae + 1;
                }
            }
            Console.WriteLine(kotae);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

char N[1234567];
int size;

#if 0
int rleft[1234567], rright[1234567];
#else
int memo[1234567][2];

int search(int pos, int nyan) {
	int answer = 1111111111, candidate;
	if (pos < 0) return nyan * 2;
	if (memo[pos][nyan]) return ~memo[pos][nyan];

	/* 必要分だけ支払う */
	candidate = search(pos - 1, 0) + (N[pos] - '0') + nyan * 2;
	if (candidate < answer) answer = candidate;
	/* 繰り上げる */
	candidate = search(pos - 1, 1) + (9 - (N[pos] - '0'));
	if (candidate < answer) answer = candidate;

	return ~(memo[pos][nyan] = ~answer);
}

#endif

int main(void) {
#if 0
	int i;
#endif
	int kotae = 1111111111;
	if (scanf("%1234565s", N + 1) != 1) return 1;
	N[0] = '0';
	for (size = 0; N[size] != '\0'; size++);
	while (size > 0 && N[size - 1] == '\0') size--;

#if 0
	rleft[0] = N[0] - '0';
	for (i = 1; i < size; i++) {
		rleft[i] = rleft[i - 1] + (N[i] - '0');
	}
	rright[size - 1] = 9 - (N[size - 1] - '0');
	for (i = size - 1 - 1; i >= 0; i--) {
		rright[i] = rright[i + 1] + (9 - (N[i] - '0'));
	}
#else
	kotae = search(size - 1, 0);
#endif

	printf("%d\n", kotae);
	return 0;
}


Measured memory_bytes: 57088
#include<bits/stdc++.h>
using namespace std;
int n,m,k,u,v,fix[100005],length[100005],ans;
vector<int>V[100005];
int go(int u){
	
	if(fix[u]) return length[u];
	fix[u]=1;
	for(int i=0;i<V[u].size();i++){
		length[u]=max(length[u],go(V[u][i])+1);
	}
	return length[u];
}
int main(){
	cin>>n>>m;
	for(k=1;k<=m;k++){
		cin>>u>>v;
		V[v].push_back(u);
	}
	
	for(k=1;k<=n;k++){
		if(fix[k]==0){
			go(k);
		}
		ans=max(ans,length[k]);
	}
	cout<<ans;
	
}

Measured memory_bytes: 11008
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long

int a[1000010];
int rui[1000010] = {};

int yta[1000010] = {};
int tmp[1000010] = {};

set<int> st;

set<int> tset;
vector<int> vec;

int n, q;
int get(int num){
    int ans = 0;
    int old = 0;
    int now = 0;
    for(auto idx = st.begin(); idx != st.end();idx++){
        now = *idx;
        int tmp = lower_bound(vec.begin(), vec.end(), vec[now]-num) - vec.begin();
        ans += rui[now+1]-rui[max(old, tmp)];
        old = now+1;
    }

    return ans;
}



signed main(){

    cin >> n >> q;


    vec.push_back(-1);
    tset.insert(-1);

    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(tset.find(a[i]) == tset.end()){
            tset.insert(a[i]);
            vec.push_back(a[i]);
        }
    }

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


    for(int i = 0;i < n;i++){
        int idx = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin();
        tmp[idx]++;
    }

    for(int i = 1;i < vec.size();i++){
        rui[i+1] = rui[i] + tmp[i];
    }

    string s;
    int num;
    for(int p = 0;p < q;p++){
        cin >> s >> num;
        if(s == "ADD"){
            num--;
            int idx = lower_bound(vec.begin(), vec.end(), a[num]) - vec.begin();
            if(yta[idx] == 0){
                st.insert(idx);
            }
            yta[idx]++;
        }else if(s == "REMOVE"){
            num--;
            int idx = lower_bound(vec.begin(), vec.end(), a[num]) - vec.begin();
            yta[idx]--;
            if(yta[idx] == 0){
                st.erase(idx);
            }
        }else{
            int l = -1, r = 2000000000;
            if(get(r) < n-num){
                cout << "NA" << endl;
            }else{
                while(r - l > 1){
                    int mid = (r+l)/2;
                    if(get(mid) >= n-num){
                        r = mid;
                    }else{
                        l = mid;
                    }
                }
                cout << r << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 82868
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    S=str(input())
    cnt=0
    b=0
    for i in S:
        if i=='B':
            b+=1
        else:
            cnt+=b
    print(cnt)

resolve()

Measured memory_bytes: 40176
import math
N, K = map(int, input().split())
P = list(map(int, input().split()))

INDEX = 0
total = 0
for i in range(K):
    total += P[i]

tmp = total
for i in range(N - K):
    tmp = tmp - P[i] + P[i + K]
    
    if tmp > total:
        total = tmp
        INDEX = i+1


# MA = 0
# for i in range(N - K + 1):
#     M = 0
#     for j in range(K):
#         M += P[i + j]
    
#     if M > MA:
#         MA = M
#         INDEX = i

ans = 0
for i in range(K):
    ans += P[i+INDEX] * (P[i+INDEX]+1) / (2*P[i+INDEX])

print("{:.12f}".format(ans))


Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int n,T;//如果最多的蛋糕有n个，T是原题变量 
	cin>>n>>T;//输入 
	int k=0;//k就不用多说了吧，原题的变量 
	for(int i=1;i<=T;++i) //通过循环来尝试得出k的正确值 
	{
		int a;//要用另一个变量 
		cin>>a;//这个也是要输入的 
		k=max(k,a);//看看哪个大，把大的赋值给k 
	}
	cout<<max(k-1-(n-k),0)<<endl;//使用公式
	return 0; 
}

Measured memory_bytes: 256
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
a = [[] for h in range(n)]
s = 0
ans = 0
for i in range(n):
  a[i] = list(map(int, input().split()))
  for j in range(m):
    s += a[i][j]*b[j]
  if s + c > 0:
    ans += 1
  s = 0
print(ans)

Measured memory_bytes: 9196