akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

/*
 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} */

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N);
  //vector<vector<int>> data(3, vector<int>(4));
  for (ll i=0; i<N;i++){
    cin >> p[i];
  }

  ll max = 0;
  ll save = 200007;
  ll tmp =0;
  for (ll i=0; i<N-K+1;i++){
    if(i==0){
      for (ll j=0; j<K; j++){
        tmp += p[i+j];
      }
    }else{
      tmp = tmp - p[i-1] + p[i+K-1];
    }
    
    if(tmp > max){
      save = i;
      max = tmp;
    }
  }
  long double ans = 0.0;

  for(ll i=save; i< save + K; i++){
    ans += ((long double)p[i] + 1.0) / 2.0; 
  }

  cout << setprecision(7) << (long double)ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<ll, ll>;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

// d d d ... d を一桁にするのにかかる回数, その値
P rec(ll d, ll c) {
  if (c == 1) {
    return P(0, d);
  }
  auto p = rec(d, c / 2);
  ll cnt = p.first;
  cnt *= 2;
  cnt++;
  ll val = p.second;
  val *= 2;
  while (val / 10) {
    cnt++;
    val = val / 10 + val % 10;
  }
  if (c % 2) {
    cnt++;
    val += d;
    while (val / 10) {
      cnt++;
      val = val / 10 + val % 10;
    }
  }
  return P(cnt, val);
}

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

  int m;
  cin >> m;
  // X = d[0] d[0]...d[0], d[1]..d[1]
  vector<ll> d(m), c(m);
  ll ret = 0;
  queue<ll> que;
  for (int i = 0; i < m; i++) {
    cin >> d[i] >> c[i];
    auto p = rec(d[i], c[i]);
    //cerr << p.first << " " << p.second << endl;
    ret += p.first;
    que.push(p.second);
  }
  while (que.size() > 1) {
    auto x = que.front();
    que.pop();
    auto y = que.front();
    que.pop();
    ret++;
    ll val = x + y;
    while (val) {
      que.push(val % 10);
      val /= 10;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 9;
using Graph = vector<vector<int>>;
const double EPS = 1e-8;
inline int sgn(double a, double b = 0) { return a < b - EPS ? -1 : a > b + EPS ? 1 : 0; }

double p, q;
int a, n;

// i: ???????????£??????
// t: ????????§?????????????????§???
// A: ????????§???????????????
// B: ????????§????????°??????
int dfs(int i, int t, int A, double B) {
    if (sgn(B, p / q) == 0) return 1;
    if (sgn(B, p / q) == 1) return 0;
    if (i >= n) return 0;

    int ret = 0;
    for (int x = t; A * x <= a; x++) {
        // output(i, t, A, x);
        ret += dfs(i + 1, x, A * x, B + 1. / x);
    }
    return ret;
}

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

    int testcase = 0;
    while (cin >> p >> q >> a >> n, n) {
        // cerr << "--- testcase " << ++testcase << " ---" << endl;
        // if (testcase != 1) continue;
        cout << dfs(0, 1, 1, 0) << endl;
    }
}

Measured memory_bytes: 3124
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int n,a,b;
	cin>>n;
	if(n==1){
		cout<<"Hello World"<<endl;
	}
	else{
		cin>>a>>b;cout<<a+b<<endl;
	}
}


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

int main()
{
	auto f = [](int64_t x, vector<int64_t> &as) {
		int64_t r = 0;
		for (auto &a : as)
		{
			r += x ^ a;
		}
		return r;
	};
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	sort(as.begin(), as.end());
	vector<int64_t> puni(61, 0);
	for (int i = 0; i <= 60; i++)
	{
		for (auto &a : as)
		{
			if ((a >> i) & 1)
			{
				puni[i]++;
			}
		}
	}
	int64_t ans = (accumulate(as.begin(), as.end(), 0LL), f(k, as));
	for (int i = 60; 0 <= i; i--)
	{
		if ((k >> i) == 0 || ((k >> i) & 1) == 0)
		{
			continue;
		}
		int64_t x = (k >> (i + 1)) << (i + 1);
		for (int j = i - 1; 0 <= j; j--)
		{
			if (puni[j] <= n / 2)
			{
				x += (1LL << j);
			}
		}
		ans = max(ans, f(x, as));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	String reverse(String s) {
		String ans = "";
		int len = s.length();
		for (int i = 0; i < len; i++)
			ans += s.charAt(len-i-1);
		return ans;
	}
	
	void run() {
		String s = sc.nextLine();
		out.println(reverse(s));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 17128
# Enter your code here. Read input from STDIN. Print output to STDOUT

## take jobs 1,2,3,...
## d[i]
##last day useless
##
##sort by reward and then by days
import heapq 
days=[[] for i in range(10**5+1)]
N,M=list(map(int,input().strip().split(' ')))
for _ in range(N):
    a,b=list(map(int,input().strip().split(' ')))
    days[a]+=[b]

ans=0
possible=[]
for i in range(M+1):
    for x in days[i]:
        heapq.heappush(possible,-x)
    if len(possible)==0:
        continue
    MAX_val=heapq.heappop(possible)
    ans+=-MAX_val
print(ans)
    
    
    




Measured memory_bytes: 71200
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    int N, M; cin >> N >> M;
    int a[N]; 
    rep(i,N) cin >> a[i];

    int sum = 0;
    rep(i,N) sum += a[i];
    int cnt = 0;
    rep(i,N) {
        if (sum <= a[i] * 4 * M) ++cnt;
    }
    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

bool grid[25][25];
LL dp[25][(1LL << 22)];

int main() {
	fastio;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++)
			cin >> grid[i][j];
	}
	SET(dp, 0);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < (1 << n); j++) {
			if (dp[i - 1][j] == 0 || __builtin_popcount(j) != i - 1)
				continue;
			for (int k = 0; k < n; k++) {
				int setted = n - k - 1;
				if (grid[i][k] == 1 && !(j & (1 << setted))) {
					dp[i][j ^ (1 << setted)] = (dp[i][j ^ (1 << setted)] + dp[i - 1][j]) % MOD;
				}
			}
		}
	}
	cout << dp[n][(1 << n) - 1] << endl;
	return 0;
}
		

Measured memory_bytes: 819456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    int n,A[200000][3],dp[200001][3]={0};
    cin>>n;
    rep(i,n)rep(j,3) cin>>A[i][j];
    rep(i,n)rep(j,3) dp[i+1][j]=max(dp[i][(j+1)%3],dp[i][(j+2)%3])+A[i][j];
    sort(dp[n],dp[n]+3);
    cout<<dp[n][2];
}

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s; cin>>s;
	if(s == "ARC")cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
	return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();
        String U = T;
        int count = 0;
        boolean flag = false;
        for (int i = 0; i < S.length(); i++) {
            for (int j = 0; j < S.length(); j++) {
                if (S.charAt(j) == U.charAt(j)) {
                    count++;
                }
            }
            if (count == S.length()) {
                flag = true;
                break;
            }
            count = 0;
            U = U.substring(1) + U.charAt(0);
        }
        System.out.println(flag ? "Yes" : "No");
    }
}

Measured memory_bytes: 22996
from collections import defaultdict
S=input()
D=defaultdict(int)
D[0]=1
n=0
i=0
a=[0]*len(S)
b=1
for s in S[::-1]:
  n+=int(s)*b
  a[i]=n%2019
  i+=1
  b=(b*10)%2019


for i in range(len(a)):
  D[a[i]]+=1

ans=sum([i*(i-1)//2 for i in D.values()])
print(ans)  

Measured memory_bytes: 16792
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt).toIndexedSeq).head
  val A = ls(0)
  val B = ls(1)
  val K = ls(2)
  var count = 0
  var i=Math.min(A,B)
  while(count<K){
    if(A%i==0 && B%i==0) count+=1
    i-=1
  }
  val ret = i+1
  println(ret)
}


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

int main() {
  string s;
  cin >> s;
  cout << string(s.length(), 'x') << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())
    P = [0] * N
    index = [0] * (N + 1)

    for i in range(N):
        P[i] = int(input())
        index[P[i]] = i

    length = 1
    seq = 1
    for i in range(1, N):
        if index[i] < index[i + 1]:
            seq += 1
        else:
            length = max(length, seq)
            seq = 1
            
    length = max(length, seq)

    print(N - length)

sol()


Measured memory_bytes: 21224
def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

kbs = A[0]
for i in range(1,N):
  kbs = kbs*A[i]//gcd(kbs,A[i])
kbs %= mod

ans = 0
for i in range(N):
  ans += pow(A[i],mod-2,mod)
  ans %= mod
print(kbs*ans%mod)    

Measured memory_bytes: 4084
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    if(x>=30) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 3612
def main():
    N = int(input())
    SP = []
    for _ in range(N):
        temp = input().split()
        SP.append((temp[0], int(temp[1])))

    sorted_SP = sorted(SP, key=lambda x: x[1], reverse=True)
    sorted_SP = sorted(sorted_SP, key=lambda x: x[0])

    indices = [SP.index(x)+1 for x in sorted_SP]
    # print(sorted_SP)
    for i in indices:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        cin>>a[i][j];
    }
    vector<vector<int> > dp(n,vector<int> (3,0));
    for(int i=0;i<3;i++)
    dp[0][i]=a[0][i];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j];
        }
    }
    int maxi=0;
    for(int i=0;i<3;i++)
    maxi=max(maxi,dp[n-1][i]);
    cout<<maxi<<endl;
}

Measured memory_bytes: 9796
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
#include<cstring>

#define N 600000

using namespace std;

int tree[N + 2] = { 0, };

void add(int idx, int val)
{
	for (; idx <= N; idx += (idx&-idx))
	{
		tree[idx] += val;
	}
}


int get(int idx)
{
	int rvalue = 0;

	for (; idx; idx -= (idx&-idx))
	{
		rvalue += tree[idx];
	}

	return rvalue;
}

int psum(int l, int r)
{
	return get(r) - get(l);
}

int main()
{
	long long n, d, a;
	vector<pair<long long, long long>> arr;

	scanf("%lld %lld %lld", &n, &d, &a);

	for (long long i = 0; i < n; i++)
	{
		long long input1, input2;

		scanf("%lld %lld", &input1, &input2);

		arr.push_back({ input1,input2 });
	}

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

	long long sol = 0;

	long long ptr = 0;

	for (long long i = 0; i < n; i++)
	{
		long long coord;
		long long stk;

		coord = arr[i].first - d * 2 > 1 ? arr[i].first - d * 2 : 1;

		while (arr[ptr].first < coord)
		{
			ptr++;
		}

		stk = psum(ptr, i);

		long long togo;

		togo = arr[i].second - stk;

		if (togo > 0)
		{
			long long q;

			q = (togo + a - 1) / a;
			add(i + 1, q*a);
			sol += q;
		}
	}

	printf("%lld\n", sol);

	return 0;
}

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

using namespace std;

typedef long long ll;

ll solve(int n,vector<pair<int,ll>> a) {
  sort(a.begin(),a.end());
  ll sol=0;
  priority_queue<ll> pq;
  for (auto &it : a) {
    int i=it.first;
    ll x=it.second;
    if ((int) pq.size()<i) {
      pq.push(-x);
      sol+=x;
    } else {
      ll y=-pq.top();
      if (x>y) {
        pq.pop();
        pq.push(-x);
        sol+=x-y;
      }
    }
  }
  return sol;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t;
  while (t--) {
    int n;
    cin>>n;
    vector<pair<int,ll>> a,b;
    ll sol=0;
    for (int i=1;i<=n;i++) {
      int k,l,r;
      cin>>k>>l>>r;
      if (l>=r) {
        sol+=r;
        a.push_back({k,l-r});
      } else {
        sol+=l;
        if (k!=n) {
          b.push_back({n-k,r-l});
        }
      }
    }
    sol+=solve(n,a);
    sol+=solve(n,b);
    cout<<sol<<"\n";
  }
  return 0;
}


Measured memory_bytes: 9800
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;

int n, d, c=0;

void solve() {
    int x, y;
    for(int i=0; i<n; i++) {
        scanf("%d %d", &x, &y);
        if(d >= sqrt((ll)x*x + (ll)y*y)) c++;
    }
}

int main(void) {
    scanf("%d %d", &n, &d);
    solve();
    printf("%d\n", c);

    return 0;
}

Measured memory_bytes: 2100
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double; using vi = vector<int>;
using ll = int_fast64_t; using ull = uint_fast64_t;
using vl = vector<ll>; using vul = vector<ull>;

// -----------------------------------------------------------------------------

const int N = 100 + 5;
const int INF = 1e9 + 7;
int h, w;
int a[N][N];
int dp[N][N];

void update(int i1, int j1, int i2, int j2) {
    if (i1 < 0 || j1 < 0) return;
    dp[i2][j2] = min(dp[i2][j2], dp[i1][j1] + (!a[i1][j1] & a[i2][j2]));
}

void solve() {
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        string s; cin >> s;
        for (int j = 0; j < w; ++j) {
            if (s[j] == '#') a[i][j] = 1;
            dp[i][j] = INF;
        }
    }
    dp[0][0] = a[0][0];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            update(i - 1, j, i, j);
            update(i, j - 1, i, j);
        }
    }
    cout << dp[h - 1][w - 1] << '\n';
}

int main() {
    fast_io; cin_exception;
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 384
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    String[] s = br.readLine().split(" ");
    int nRows = Integer.parseInt(s[0]);
    int nCols = Integer.parseInt(s[1]);
    int A = Integer.parseInt(s[2]);
    int B = Integer.parseInt(s[3]);
    for (int i=0; i<nRows; i++) {
      for (int j=0; j<nCols; j++) {
        if ((i<B && j<A) || (i>=B && j>=A)) {
          sb.append('0');
        } else {
          sb.append('1');
        }
      }
      sb.append('\n');
    }
    System.out.print(sb);
  }
}


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

int main(void){
  int cnt = 0;
  string s;
  while(cin>>s){
    bool ok = true;
    for(int i = 0 ; i < s.size() / 2 ; i ++){
      //cout<<s[i]<<" "<<s[s.size()-i-1]<<endl;
      if(s[i] != s[s.size() - i-1])ok = false;
    }
    cnt += (ok?1:0);
  }
  cout<<cnt<<endl;
  
}

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

int main(){
	int n, l, r, ans = 0;
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%d %d", &l, &r);
		ans += (r-l)+1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 3e3 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  ll n;
  ll k;
  cin >> n >> k;
  ll a, sum = 0;
  for (int i = 0; i < k; ++i) {
    cin >> a;
    sum += a;
  }
  if(sum >= n) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


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

int main() {
  
  int D;
  cin >> D;
  
  string ans = "Christmas";
  
  if(D<=24) ans += " Eve";
  if(D<=23) ans += " Eve";
  if(D<=22) ans += " Eve";
  
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int n,i;
	cin>>n;
	
	int a[100+1]={0};
	
	for(i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]=1;
	}
	
	int s=0;
	
	for(i=1;i<=100;i++)
	{
		if(a[i]==1) s++;
	}
	
	cout<<s;
	return 0;
}

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

using namespace std;

int main(){

  string in;
  while(cin >> in){
    int suma = 0, sumb = 0;

    for(int i = 0; i < in.length()-2; i++){
      if(in[i] == 'J' && in[i+1] == 'O' && in[i+2] == 'I') suma++;
      if(in[i] == 'I' && in[i+1] == 'O' && in[i+2] == 'I') sumb++;

    }

    cout << suma << endl;
    cout << sumb << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    
    long long h, w;
    scan(h, w);
    if(h == 1 || w == 1){
        print(1);
        return 0;
    }
    print((h*w+1)/2);
    
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }

    int sum = 0;
    for (auto x : mp)
    {
        if (x.second >= 2)
            sum += x.second - 1;
    }
    if (sum % 2 == 0)
        OP(mp.size());
    else
        OP(mp.size() - 1);
    return 0;
}

Measured memory_bytes: 4992
#include <bits//stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
    unsigned int R;
    cin >> R;
    if (R >= 1 and R <= 100) {
        long double ans = 2.0*M_PI*R;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3740
# -*- coding: utf-8 -*-

V, E = list(map(int, input().split()))
weight = []
for i in range(E):
  s, t, w = list(map(int, input().split()))
  weight.append((s,t,w))

weight.sort(key = lambda x: x[2])

parent = [i for i in range(V)]
rank = [0 for i in range(V)]

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

def union(x, y):
  a = find(x)
  b = find(y)
  if rank[a] < rank[b]:
    parent[a] = b
  else:
    parent[b] = a
    if rank[a] == rank[b]:
      rank[a] += 1
  

sum_weight = 0

for i in range(E):
  a, b, c = weight[i]
  if find(a) != find(b):
    union(a, b)
    sum_weight += c
  else:
    continue
  
print(sum_weight)
  


  


Measured memory_bytes: 24232
n = int(input())
a = list(map(int, input().split()))

if n==2:
    print(max(a))
    exit()

dp = [0]*n
ep = [0]*n

dp[1] = max(a[:2])
dp[2] = max(a[:3])

ep[1] = a[0]
ep[2] = max(a[:2])

for i in range(3,n):
    if (i+1)%2==0:
        ep[i] = ep[i-2] + a[i-1]
    else:
        ep[i] = max(ep[i-2]+a[i-1],ep[i-3]+a[i-2])
    dp[i] = max(dp[i-2]+a[i],ep[i])

print(dp[-1])

Measured memory_bytes: 94348
from math import factorial, sqrt

def dist(x1, y1, x2, y2):
    return sqrt((x1 - x2)**2 + (y1 - y2)**2)


N = int(input())
x, y = [0]*N, [0]*N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 0
count = (N-1) * factorial(N) / (N * (N-1) / 2)

for i in range(N-1):
    for j in range(i+1, N):
        ans += dist(x[i], y[i], x[j], y[j]) * count

ans = ans / factorial(N)

print(ans)


Measured memory_bytes: 3064
h, w = map(int, input().split())


def calc(a, b):
    return min([
        b,
        max([
            abs(a // 3 * b - (a - a // 3) * (b // 2)),
            abs(a // 3 * b - (a - a // 3) * (b // 2 + b % 2)),
            (a - a // 3) * (b % 2),
        ]),
        max([
            abs((a // 3 + 1) * b - (a - a // 3 - 1) * (b // 2)),
            abs((a // 3 + 1) * b - (a - a // 3 - 1) * (b // 2 + b % 2)),
            (a - a // 3 - 1) * (b % 2),
        ]),
    ])


if h * w % 3 == 0:
    print(0)
else:
    print(min([calc(h, w), calc(w, h)]))

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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;

int paper[64][64];

void move(int x, int y){
  if(x!=0 && y==0){//yokohoko
    rep(i,64-x){
      rep(j,64){
        paper[i][j]=paper[i+x][j];
        paper[i+x][j]=0;
      }
    }
  }else if(x==0 && y!=0){//yokohoko
    rep(i,64){
      rep(j,64-x){
        paper[i][j]=paper[i][j+y];
        paper[i][j+y]=0;
      }
    }
  }
}
void print(){
  //return;
  prln("----Start");
  rep(i,64){
    rep(j,64){
      cout<<paper[i][j]<<" ";
    }
    cout<<endl;
  }
  prln("---End");
}
int linenum=0;
int main() {
  while(true){
    int2(n,m);
    int2(t,p);
    if(n*m*t*p==0){break;}
    rep(i,64){
      rep(j,64){
        paper[i][j]=0;
      }
    }
    rep(i,n){
      rep(j,m){
        paper[i][j]=1;
      }
    }
    rep(i,t){
      int2(d,c);
      if(d==1){
        for(int i=c-1;i>=0;i--){
          rep(j,m){
            paper[2*c-i-1][j]+=paper[i][j];
            paper[i][j]=0;
          }
	
        }
        move(c,0);
      }else{
        for(int i=c-1;i>=0;i--){
          rep(j,n){
            paper[j][2*c-i-1]+=paper[j][i];
            paper[j][i]=0;
	  
          }
        }
        move(0,c);
      }
    }
    int anal  =0;
    rep(i,p){
      int2(x,y);
      prln(paper[x][y]);
    
    }
  }
}




Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i,a,n) for(int _tmp=n,i=a;i<=_tmp;++i)
#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)
#define re(i,a,n) for(int _tmp=n,i=a;i<_tmp;++i)
#define fec(i,a) for(__typeof a.begin() i=a.begin();i!=a.end();++i)
#define For(i,u) for(int i=H[u];i;i=nxt[i])
#define si(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
using namespace std;
template<class T> inline void read(T&x){char c;bool fu=0;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x*=-1;}
template<class T> inline void read(T&x,T&y){read(x);read(y);}
template<class T> inline void read(T&x,T&y,T&z) {read(x,y);read(z);}
typedef long long ll;
typedef pair<int,int> pii;
const int N=111;
//head
bool f[N][N];
int n,m,q,x[N],y[N];
int main() {
	read(n,m,q);
	rep(_,1,q){
		read(x[_],y[_]);
		int op;read(op);
		if(op==1){
			rep(i,1,x[_])
				rep(j,1,m)f[i][j]=1;
		}else if (op==2){
			rep(i,x[_]+1,n)
				rep(j,1,m)f[i][j]=1;
		}else if (op==3){
			rep(j,1,y[_])
				rep(i,1,n)f[i][j]=1;
		}else {
			rep(j,y[_]+1,m)
				rep(i,1,n)f[i][j]=1;
		}
	}
	int cnt=0;
	rep(i,1,n)rep(j,1,m)if(f[i][j]==0)++cnt;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N;
  cin >> N;

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

  sort(ALL(A), greater<>());
   
  vector<int> v(N);

  int first = 1;
  REP(i, N-1) (first *= 2) %= MOD;

  int plus = 1;
  REP(i, N-2) (plus *= 2) %= MOD;

  v[0] = first;
  FOR(i, 1, N){
    (v[i] += v[i-1]+plus) %= MOD;
  }

  int ans = 0;
  REP(i, N){
    (ans += v[i]*A[i]) %= MOD;
  }
  REP(i, N) (ans *= 2) %= MOD;

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3328
#main
arr = Array.new
while n = gets
  arr << n.to_i
end
arr.each do |n|
  b = Array.new
  until n / 2 == 0
    b << n % 2 
    n = n / 2
  end
  0.upto (b.length - 1) do |i|
    if b[i] == 1
      print "#{2 ** i} "
    end
  end
  puts 2 ** (b.length)
end

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

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

	ll a, b, k;
	cin >> a >> b >> k;

	if(a > k) {
		a -= k;
		k = 0;
	}
	else {
		k -= a;
		a = 0;
	}
	if(b > k) {
		b -= k;
		k = 0;
	}
	else {
		k -= b;
		b = 0;
	}

	cout << a << " " << b << endl;
}



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

int main() {
  string S;
  cin>>S;
  int cnt=0,maximum=0;
  
  for(int i=0;i<3;i++){
    if(S[i]=='R'){
      cnt++;
    }
    else{
      maximum=max(cnt,maximum);
      cnt=0;
    }
  }
  maximum=max(cnt,maximum);
  cout<<maximum<<endl;
}




Measured memory_bytes: 3624
using System;

namespace ITP1_6_A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] input = Console.ReadLine().Split(' ');

            for (int j = (input.Length - 1); j>=0; j--)

                if (j != 0) Console.Write("{0} ", input[j]);
                else Console.Write(input[j]);

            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8844
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    cout<<min(n,k)*x+max(0,n-k)*y<<endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;

ll ext_gcd(ll p,ll q,ll& x, ll& y) { // get px+qy=gcd(p,q)
	if(q==0) return x=1,y=0,p;
	ll g=ext_gcd(q,p%q,y,x);
	y-=p/q*x;
	return g;
}

pair<ll,ll> crt(ll a1,ll mo1,ll a2,ll mo2) { // return (x,y) y=lcm(a1,a2),x%mo1=a1,x%mo2=a2
	ll g,x,y,z;
	g=ext_gcd(mo1,mo2,x,y);
	a1=(a1%mo1+mo1)%mo1;a2=(a2%mo2+mo2)%mo2;
	if(a1%g != a2%g) return pair<ll,ll>(-1,0); // N/A
	__int128_t lcm=mo1*(mo2/g);
	if(lcm<mo1) return pair<ll,ll>(-2,0); // overflow
	
	__int128_t v=a1+((a2-a1)%lcm+lcm)*x%lcm*(mo1/g);
	return make_pair(((v%lcm)+lcm) % lcm,lcm);
}



ll hoge(ll a,ll b) {
	if(__gcd(a,b)!=1) return 1LL<<60;
	
	auto c=crt(0,a,b-1,b);
	if(c.first==0) c.first+=c.second;
	return c.first;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	N=N*2;
	ll ma=1LL<<60;
	for(ll a=1;a*a<=2*N;a++) if(N%a==0) {
		ma=min(ma,hoge(a,N/a));
		ma=min(ma,hoge(N/a,a));
	}
	
	cout<<ma<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#define MAX 10
#define INF 1 << 29
using namespace std;

int cost[MAX][MAX];

void warshall_floyd() {
	for (int k = 0; k < MAX; k++) {
		for (int i = 0; i < MAX; i++) {
			for (int j = 0; j < MAX; j++) {
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
			}
		}
	}
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		for (int i = 0; i < MAX; i++) {
			for (int j = 0; j < MAX; j++) {
				if (i == j) cost[i][j] = 0;
				else cost[i][j] = INF;
			}
		}
		for (int i = 0; i < n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			cost[a][b] = c;
			cost[b][a] = c;
		}
		warshall_floyd();
		int ans = INF;
		int town = -1;
		for (int i = 0; i < MAX; i++) {
			int res = 0;
			for (int j = 0; j < MAX; j++) {
				if (cost[i][j] == INF) continue;
				res += cost[i][j];
			}
			if (res > 0) {
				if (res < ans) {
					ans = res;
					town = i;
				}
			}
		}
		cout << town << ' ' << ans << endl;
	}
}

Measured memory_bytes: 3048
#!/usr/bin/env python3
input()
c = input()
R = c.count("R")
W = c.count("W")
c2 = "R"*R+"W"*W
r = sum(i!=j and i =="W" for i, j in zip(c,c2))
w = sum(i!=j and i =="R" for i, j in zip(c,c2))
print(min(r,w))


Measured memory_bytes: 9536
MOD = 10**9 + 7

n = int(input())

a = list(map(int,input().split()))

sum = [0 for i in range(n+1)]
dp = [0 for i in range(n+1)]

fac = [1 for i in range(n+1)]
finv = [1 for i in range(n+1)]
inv = [1 for i in range(n+1)]

for i in range(2,n+1):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD - inv[MOD%i]*(MOD // i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

for i in range(1,n+1):
    sum[i] = (sum[i-1]+inv[i]) % MOD
sum[0] = 1
for i in range(1,n+1):
    dp[i] = (sum[i]+sum[n+1-i]-1) % MOD

ans = 0
for i in range(1,n+1):
    ans = (ans + dp[i]*a[i-1])% MOD

print((ans * fac[n]) % MOD)

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

//Author: Ashish

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	string str;
	cin>>str;
	vector<int> red,white;
	for(int i=0;i<n;i++) {
		if(str[i]=='R') red.push_back(i);
		else white.push_back(i);
	}
	int answer=0;
	for(int i=red.size()-1,j=0;i>=0&&j<white.size();i--,j++) {
		if(red[i]<white[j]) break;
		answer++;
	}
	cout<<answer;

	return 0;
}

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

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

  std::vector<int> arrive(N + 1);

  for (int i = 0; i < N; ++i) {
    int temp;
    std::cin >> temp;

    arrive[temp] = i;
  }

  for (int i = 1; i < N + 1; ++i) {
    std::cout << arrive[i] + 1 << " ";
  }

  std::cout << std::endl;
  return 0;
}

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

int main()
{
	int N, Y;

	cin >> N >> Y;

	for(int a = 0; a <= N; a++)
	{
		for(int b = 0; b <= N; b++)
		{
			int c = N - a - b;
			if(c < 0)break;

			if(10000*a + 5000*b + 1000*c == Y)
			{
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] orgs) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();

		if(D == 0&&N == 100){
			System.out.println(101);
		}else if(D == 1&&N == 100){
			System.out.println(10100);
		}else if(D == 2&&N ==100){
			System.out.println(1010000);
		}else{
			System.out.println(Math.round(N * Math.pow(100,D)));
		}
	}
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll n; cin>>n;
    vector<ll> x(n),y(n);
    rep(i,n){
        ll a,b; cin>>a>>b;
        x[i]=a; y[i]=b;
    }
    float ans=0;
    rep(i,n){
        rep(j,n){
            ans+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
  	ans/=n;
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int r, g, b;
  cin >> r >> g >> b;
  if((g*10 + b) % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    ll C, D;
    cin>>N>>A>>B>>C>>D;
    --N;
    ll dif = abs(A - B), range = N * (D - C);
    bool yes = false;
    rep(i, N+1){
        ll temp = C*i - (N - i) * D;
        if(temp <= dif && temp + range >= dif) yes = true;
    }
    cout<<(yes ? "YES" : "NO")<<endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int fun(int n)
{
    if(n>0)
        return n;
    else
        return -n;
}
int main()
{
    long long int i,max,min,k,j,s1,s2,n,pi,a[100005],num;
    while(scanf("%lld",&n)==1)
    {
        s1=0,s2=0,pi=1,j=0;
        for(i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
            if(i==0)
                max=a[i];
            if(i!=0)
                max=max>a[i]?max:a[i];
        }
        //printf("%lld ",max);
        if(max%2==0)
        {
            s1=max/2;
            s2=s1+1;
        }
        else
            s1=(max+1)/2;
        //printf("%lld \n",s1);
        min=max;
        for(i=0;i<n;i++)
        {
            if(s2==0)
            {
                if(min>=fun(a[i]-s1)&&a[i]!=max)
                {
                        if(min==fun(a[i]-s1))
                        {
                                k=k>a[i]?a[i]:k;
                        }
                        else
                                k=a[i];
                        min=fun(a[i]-s1);
                        //printf("%lld\n",k);
                }
            }
            else
            {
                    if(a[i]<=s1)
                        num=s1-a[i];
                    if(a[i]>s1)
                        num=a[i]-s2;
                    if(num<=min&&a[i]!=max)
                    {

                        if(min==num)
                            k=k>a[i]?a[i]:k;
                        else
                            k=a[i];
                        min=num;
                    }
            }
        }
        printf("%lld %lld\n",max,k);
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	int N;

	cin >> N;
	
	vector<double> cost(N);
	rep(i, N)
	{
		cin >> cost[i];
	}

	sort(all(cost));

	rep(i, N - 1)
	{
		cost[i + 1] = (cost[i] + cost[i + 1]) / 2.0;
	}

	cout << setprecision(20) << cost[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LLI n,i;cin>>n;
      std::map<LLI, LLI> m;
      fo(i,2,sqrt(n)+1){
        if(n%i==0){
          LLI x=0;
          while(n%i==0) {n/=i;x++;}
          m[i]=x;
        }
      }
      if(n>2) m[n]=1;
      LLI ans=0;
      for(auto x:m){
        LLI r=sqrt(1+8*x.ss);
        r--;
        ans+=r/2;
      }
      cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D,X;
  cin>>N>>D>>X;
  vector<int>A(N);
  vector<int>B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    B.at(i)=(D-1)/A.at(i)+1;
    sum=sum+B.at(i);
  }
  cout<<sum+X<<endl;
}
  


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[20];
int flag=1;
bool fun(int n){
	while(n){
		if(a[n%10]){
			return false;
		}
		n/=10;
	}
	return true;
}
int main(){
	int N,K,x;
	cin>>N>>K;;
	for(int i=0;i<K;i++){
		cin>>x;
		a[x]=1;
	}
	for(int j=N;;j++){
		if(fun(j)){
			cout<<j<<endl;
			break;
		}		
	}
	return 0;
} 

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

int main()
{
  string a,b,c;
  cin >> a >> b >> c;
  int len1 = a.size();
  int len2 = b.size();

  if (a[len1 - 1] == b[0] && b[len2 - 1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
num=[0]*(n+1)
numcnt=[0]*(n+1)
ans=0
cnt=0
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        num[p]+=1
    if s=="AC" and numcnt[p]!=1:
        ans+=num[p]
        cnt+=1
        numcnt[p]=1
print(cnt,ans)


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

int main(){
    int i, c = 0;
    string s;
    cin >> s;
    for(i=0; i<s.size(); i++){
        if(i == 0){
            if(s[i] != 'A'){
                cout << "WA";
                return 0;
            }
        }else if(i > 1 && i < s.size()-1 && s[i] == 'C'){
            c++;
        }else if(s[i] < 'a' || s[i] > 'z'){
            cout << "WA";
            return 0;
        }
    }
    if(c != 1){
        cout << "WA";
      	return 0;
    }
    cout << "AC";
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();

        HashSet<Long> hsA=primeFactor(A);
        HashSet<Long> hsB=primeFactor(B);

        hsA.add(1l);
        hsB.add(1l);

        HashSet<Long> ans = new HashSet<Long>();

        Iterator ite = hsA.iterator();
        while(ite.hasNext()){
            long num = (long)ite.next();
            if(hsB.contains(num)){
                ans.add(num);
            }
        }

        System.out.println(ans.size());
    }

    public static final HashSet<Long> primeFactor(long n) {
		final HashSet<Long> list = new HashSet<Long>();
		if (n < 2) { 
			return list;
		}

		while (n != 1 && n % 2 == 0) { 
			list.add(2l);
			n >>>= 1;
		}

		for (long i = 3; i * i <= n; i += 2) {
			while (n % i == 0) {
				list.add(i);
				n /= i;
			}
		}

		if (n != 1) {
			list.add(n);
		}
		return list;
	}

}

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

int h, w;
int whitenum;
char mem[50][50];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

struct sunuke{
    int x, y, num;
};

int main(){
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> mem[i][j];
            if(mem[i][j] == '.')    whitenum++;
        }
    }

    queue<sunuke> que;
    sunuke st;
    int ans = 100000;
    bool flag = false;
    st.x = 0; st.y = 0; st.num = 0;
    que.push(st);
    while(que.size()){
        sunuke memo;
        memo = que.front();que.pop();
        for(int i = 0; i < 4; i++){
            int nex, ney;
            nex = memo.x + dx[i];
            ney = memo.y + dy[i];
            if(nex >= 0 && nex < h && ney >= 0 && ney < w && mem[nex][ney] != '#'){
                if(nex == h-1 && ney == w-1){
                    ans = min(ans, memo.num+1);
                    flag = true;
                }
                else{
                    sunuke pmemo;
                    pmemo.x = nex;
                    pmemo.y = ney;
                    pmemo.num = memo.num + 1;
                    que.push(pmemo);
                    mem[nex][ney] = '#';
                }
            }
        }
    }
    if(!flag)   cout << "-1\n";
    else    cout << whitenum - ans - 1 << endl;
}

Measured memory_bytes: 256