akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ put . sol . get

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines

put = C.pack . show

sol [[n,m],xs,ys] = f n xs*f m ys `mod` p

f n = fst . foldl' (\(a,i) x -> ((a+x*(2*i-n-1)) `mod` p,i+1)) (0,1)

p = 10^9+7 ::Int

Measured memory_bytes: 29052
import sys
input = sys.stdin.readline


def main():
    h, w, m = map(int, input().split())
    bomb = [tuple(map(int, input().split())) for _ in range(m)]
    
    bom_h = [0]*h
    bom_w = [0]*w
    
    for i in range(m):
        x, y = bomb[i]
        bom_h[x-1] += 1
        bom_w[y-1] += 1
    
    max_h = max(bom_h)
    max_w = max(bom_w)
    
    ans = bom_h.count(max_h)*bom_w.count(max_w)
    for i in range(m):
        x, y = bomb[i]
        if bom_h[x-1] == max_h and bom_w[y-1] == max_w:
            ans -= 1
    
    print(max_h+max_w+bool(ans)-1)
    
    
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 53932
#include <stdio.h>
#include <string.h>

int main(){
    char indata[1000],load[1000];
    int i,j,in,ln,state;
    
    scanf("%s",indata);
    scanf("%s",load);
    in=strlen(indata);
    ln=strlen(load);
    
    //printf("in = %d , ln = %d\n",in,ln);
    for(i=0;i<in;i++){
        state=1;
        if(indata[i]==load[0]){
            state=0;
            for(j=0;j<ln;j++){
                if(indata[i+j]!=load[j])state=1;
            }
        }
        if(state==0)printf("%d\n",i);
    }
    
    
    return 0;
    
}

Measured memory_bytes: 540
H,W=map(int,input().split())
a=[]
for i in range(H):
    a.append([aij%2==1 for aij in list(map(int,input().split()))])

f=False # 奇数の山が奇数回か
ans=[]
for i in range(H):
    if i%2==0:
        for j in range(W):
            f=f!=a[i][j]
            if f:
                if j<W-1:
                    ans.append((i+1,j+1,i+1,j+2))
                elif i<H-1:
                    ans.append((i+1,W,i+2,W))

    else:
        for j in reversed(range(W)):
            f=f!=a[i][j]
            if f:
                if j>0:
                    ans.append((i+1,j+1,i+1,j))
                elif i<H-1:
                    ans.append((i+1,1,i+2,1))

print(len(ans))
for t in ans:
    print(*t)

Measured memory_bytes: 74844
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 2e5 + 10;
const int INF = 1e9 + 10;

int main(){
	int n;
	scanf("%d", &n);
	int a = n % 10;
	int b = n / 10;
	if(a == 9 || b == 9) {
		puts("Yes");
	} else {
		puts("No");
	}
	return 0;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long maxS = 1e9 + 7;

int main(){
    string a , b;
    cin>>a>>b;
    int ans = b.size();
    for(int i = 0; i <= a.size() - b.size(); i++){
        int count = 0;
        for(int j = 0; j < b.size(); j++){
            if(a[i + j] !=  b[j]){
                count++;
            }
        }
        ans = min(count , ans);
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let s = read_as_string();
    let t = read_as_string().chars().collect::<Vec<char>>();
    let mut ans = std::u64::MAX;
    for begin in 0..(s.len() - t.len() + 1) {
        let st = s.chars().skip(begin).take(t.len()).collect::<Vec<char>>();
        let mut cur_cost = 0;
        for i in 0..t.len() {
            if t[i] != st[i] {
                cur_cost += 1;
            }
        }
        ans = cmp::min(ans, cur_cost);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2100
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        int n = int.Parse(input.ReadLine());
        int[] aa = ToIntArray(input.ReadLine(), n);
        int[] bb = ToIntArray(input.ReadLine(), n);
        int[] cc = ToIntArray(input.ReadLine(), n-1);

        int prev = -100;
        int count = 0;
        foreach(var a in aa) {
            count += bb[a-1];
            if (prev + 1 == a) {
                count += cc[a - 2];
            }
            prev = a;
        }

        return count;
    }

    static int[] ToIntArray(string strs, int n) {
        int[] ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    ll n; cin >> n;
    vector<ll> d(n);
    rep(i, n) cin >> d[i];
    sort(ALL(d));
    ll ans = 0;
    ans = d[n / 2] - d[n / 2 - 1];
    cout << ans << endl;
}


Measured memory_bytes: 1024
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include<iomanip>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ‘ ‘
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 1000;

int main(){
    
    int h,w,a,b;
    
    cin >> h>>w>>a>>b;
    
    
    
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i<=b&&j<=a)printf("0");
            else if(j>=a&&i<=b)printf("1");
            else if(i>=b&&j<=a)printf("1");
            else printf("0");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n+1];
    int b[n+1];
    int c[n+1];
    for(int i=1;i<=n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    int f[n][3];
    f[1][0]=a[1];
    f[1][1]=b[1];
    f[1][2]=c[1];
    for(int i=2;i<=n;i++)
    {
        f[i][0]=max(f[i-1][1],f[i-1][2])+a[i];
        f[i][1]=max(f[i-1][0],f[i-1][2])+b[i];
        f[i][2]=max(f[i-1][1],f[i-1][0])+c[i];
    }
    cout << max(f[n][0],max(f[n][1],f[n][2]));
    return 0;
}


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

const int MAX=100005;

int state[MAX],N;
vector<int> T[MAX],now(MAX);
stack<int> S;

void DFS(){
    int ans=0,count=0,z=0;
    while(count!=N){
        for(int j=z;j<N;j++){
            if(state[j]==0){
                S.push(j);
                state[j]=1;
                z=j;
                break;
            }
        }
    while(S.size()){
        int a=S.top();
        bool flag=true;
        for(int i=now[a];i<T[a].size();i++){
            if(state[T[a][i]]==0){
                S.push(T[a][i]);
                state[T[a][i]]=1;
                now[a]=i;
                flag=false;
                break;
            }
        }
            if(flag){
                state[a]=2;
                count++;
                S.pop();
            }
            
        }
        ans++;
    }
    cout<<ans<<endl;
}

int main(){
    
    int u,k,b,M;
    cin>>N>>M;
    
    for(int i=0;i<N;i++){
        state[i]=0;
        now[i]=0;
    }
    
    for(int i=0;i<M;i++){
        cin>>u>>k>>b;
        u--;
        k--;
        T[u].push_back(k);
        T[k].push_back(u);
        }
    for(int i=0;i<M;i++){
        sort(T[i].begin(),T[i].end());
    }
    DFS();
}


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

#define lugan "FROG1"
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define endl '\n'
#define _io ios_base::sync_with_stdio(0);   cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5+7;
const ll oo = 1e18+7;

inline void initf()
{
    freopen(lugan".inp", "r", stdin);
    freopen(lugan".out", "w", stdout);
}

int n, k;
int a[N];
ll dp[N];

int main()
{
    _io
    cin >> n >> k;
    for (int i=1; i<=n; i++)
        cin >> a[i];
    a[0] = a[1];
    for (int i=1; i<=n; i++)    dp[i] = oo;
    for (int i=1; i<=n; i++)
        for (int j=i-1; j>=max(0, i-k); j--)
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    cout << dp[n];
    return 0;
}



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

int main()
{
    int n, a, alice = 0, bob = 0;
    std::vector<int> vec;
    std::cin >> n;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a;
        vec.push_back(a);
    }
    std::sort(vec.begin(), vec.end(), [](int l, int r) { return l > r; });
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0) { alice += vec[i]; }
        else
        {
            bob += vec[i];
        }
    }
    std::cout << alice - bob << std::endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int X,  Y;
    cin >> X >> Y;
    if(Y-2*X >= 0 and (Y-2*X) % 2 == 0 and 4 * X - Y >= 0 and (4*X - Y) % 2 == 0) puts("Yes");
    else puts("No");
}


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

int main(){
    int N, W; cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i=0;i<N;i++){
        cin >> w[i] >> v[i];
    }
    vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j >= w[i]){
                dp[i+1][j]=max(dp[i][j-w[i]]+v[i], dp[i][j]);
            }
            else dp[i+1][j]=dp[i][j];
        }
    }
    cout << dp[N][W] << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

vector<bool> seen, finished; // 行きがけ, 帰りがけ
int pos = -1;
stack<int> hist;

void dfs(const vector<vector<int>> &G, int v) {
    seen[v] = true;
    hist.push(v);
    for (auto nv : G[v]) {
        if (finished[nv]) continue;
        
        if (seen[nv] && !finished[nv]) {
            pos = nv;
            return;
        }
        
        dfs(G, nv);
        
        if (pos != -1) return;
    }
    hist.pop();
    finished[v] = true;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    
    seen.assign(n, false);
    finished.assign(n, false);
    for (int i = 0; i < n; ++i) {
        pos = -1;
        dfs(G, i);
        if (pos != -1) break;
    }

    vector<int> cycle;
    while (!hist.empty()) {
        int t = hist.top();
        cycle.push_back(t);
        hist.pop();
        if (t == pos) break;
    }

    if (cycle.empty()) cout << -1 << endl;
    else {
        reverse(all(cycle));
        // サイクルのサイズを減らす
        while(true) {
            int from = -1, to = -1;
            vector<int> ord(n, -1);
            for (int i = 0; i < cycle.size(); ++i) {
                ord[cycle[i]] = i;
            }
            for (int i = 0; i < cycle.size(); ++i) {
                for (auto nv : G[cycle[i]]) {
                    if (nv != cycle[(i+1)%cycle.size()] && ord[nv] != -1) {
                        from = i, to = ord[nv];
                    }
                }
            }
            if (from == -1) break;

            vector<int> ncycle;
            ncycle.push_back(cycle[from]);
            int id = to;
            while (id != from) {
                ncycle.push_back(cycle[id]);
                id = (id+1) % cycle.size();
            }
            cycle = ncycle;
        }
        cout << cycle.size() << endl;
        for (auto v : cycle) {
            cout << v+1 << endl;
        }
    }
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  vector<int>dp(n,0);
  for(int i=1;i<n;i++)
  {
    dp[i]=INT_MAX;
    
    for(int j=max((long long) 0,i-k);j<i;j++)
    {
      dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
    }
  }
  cout<<dp[n-1]<<"\n";
}


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

int main() {
    int N, M;
    cin >> N >> M;
    char A[N][N], B[M][M];
    for(int i = 0;i < N;i++)
        for(int t = 0;t < N;t++)
            cin >> A[i][t];
    for(int i = 0;i < M;i++)
        for(int t = 0;t < M;t++)
            cin >> B[i][t];

    for(int i = 0;i <= N - M;i++){
        for(int t = 0;t <= N - M;t++) {
            bool inc = true;
            for(int x = 0;x < M;x++) {
                for(int y = 0;y < M;y++) {
                    if(A[x+i][y+t] != B[x][y]) {
                        x = 100;
                        y = 100;
                        inc = false;
                    }
                }
            }
            if(inc) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
# encoding:utf-8
def main():
	n, y = list(map(int, input().split()))
	bills = [0, 0, y // 1000]
	cnt = y // 1000

	print(sub(bills, n))

def sub(bills, n):
	while True:
		#print(bills)
		if n - sum(bills) == 0:
			return " ".join([str(x) for x in bills])
		if n - sum(bills) <= -1:
			if n - sum(bills) <= -4 and bills[2] >= 5:
				bills[1] += 1
				bills[2] -= 5
			elif bills[1] >= 2:
				bills[0] += 1
				bills[1] -= 2
			else:
				break
		else:
			break

	return "-1 -1 -1"



if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define Scan(a) scanf("%I64d", &a);
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

ll n, m, x;

ll solve(ll n)
{
    if (n == -1) return 0;
    return n/x+1;
}

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n >> m >> x;
    cout << solve(m) - solve(n-1);
    return 0;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll,ll> vll;
typedef pair<ll,ll> pll;

ld DP[310][310][310];
int n;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin >> n;
	vi freq(3);
	M00(i, n) {
		int x;
		cin >> x;
		freq[x-1]++;
	}
	M00(i, 310) M00(j, 310) M00(k, 310) DP[i][j][k] = 0;

	

	M00(k, 301) {
	M00(j, 301) {
	M00(i, 301) {
		if(i + j + k > n) continue;
		if(i == 0 && j == 0 && k == 0) continue;
		int same = n - i - j - k;
		ld prob = ((ld) same) / ((ld) n);
		if(i > 0)
			DP[i][j][k] += DP[i-1][j][k] * ((ld) i);
		if(j > 0)
			DP[i][j][k] += DP[i+1][j-1][k] * ((ld) j);
		if(k > 0)
			DP[i][j][k] += DP[i][j+1][k-1] * ((ld) k);
		DP[i][j][k] /= n;
		DP[i][j][k]++;
		DP[i][j][k] /= (1-prob);
	}
	}
	}
	cout << fixed << setprecision(11);
	cout << DP[freq[0]][freq[1]][freq[2]] << endl;

}


Measured memory_bytes: 465792
import sys
a,v  = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
kyori = abs(a - b)
tumari = v - w
if tumari <= 0:
    print('NO')

elif kyori / tumari <= t:
    print('YES')
else:
    print('NO')

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
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;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

double length(Pii a,Pii b){
    int ret = (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
    return sqrt((double)ret);
}

void solve(long long n, std::vector<long long> x, std::vector<long long> y){
    cout << fixed << setprecision(10);
    VPii v(n);
    REP(i,0,n) v[i]=mp(x[i],y[i]);

    // REP(i,1,n){
    //     cout<<length(v[i],v[i-1])<<endl;
    // }
    sort(ALL(v));
    // REP(i,0,n) cout<<v[i].first<<" "<<v[i].second<<endl;
    double ans=0;
    do{
        for(int i=1; i<n-1; i++){
            ans += length(v[i-1],v[i]);
//            cout<<ans<<endl;
        }
        ans += length(v[0],v[n-1]);
        // cout<<ans<<endl;
    }while(next_permutation(v.begin(),v.end()));
    REP(i,1,n+1) ans/=(double)i;
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long A, B, C;
	cin >> A >> B >> C;
	if(A == B && B == C){
		if(A%2 == 0) cout << -1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	long long ans = 0;
	while(A%2 == 0 && B%2 == 0 && C%2 == 0){
		long long a = B/2 + C/2;
		long long b = C/2 + A/2;
		long long c = A/2 + B/2;
		A = a;
		B = b;
		C = c;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	if((a * b) % 2 == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int h,w;
ll mp[10][10]; 

int main(){
    cin>>h>>w;
    ll ans=0;

    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin>>mp[i][j];
        }
    }

    for(int  i=0; i<10; i++){
        for(int j=0; j<10; j++){
            for(int k=0; k<10; k++){
                mp[j][k] = min(mp[j][k],mp[j][i]+mp[i][k]);
            }
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int v; cin>>v;
            if(abs(v) != 1)ans += mp[v][1];
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

int main() {
	const int MAX_N = 100000;
	int N, A[MAX_N];
	vector<int> B;
	int c;
	int res;

	scanf("%d", &N);
	for (int i = 0;i < N;i++) {
		scanf("%d", &A[i]);
	}

	c = 1;
	B.push_back(0);
	for (int i = 1;i < N;i++) {
		if (A[i - 1] != A[i]) {
			c++;
		}
		else{
			B.push_back(c);
			c = 1;
		}
	}
	B.push_back(c);
	B.push_back(0);
	res = 0;
	for (int i = 0;i + 2 < B.size();i++) {
		if (B[i] + B[i + 1] + B[i + 2] > res) {
			res = B[i] + B[i + 1] + B[i + 2];
		}
	}

	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 1660
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int list[] = new int[n];
		for(int i=0; i<n; i++){
			list[i] = sc.nextInt();
		}
		
		int numlist1[] = new int[100000];
		int numlist2[] = new int[100000];
		for(int i=0; i<100000; i++){
			numlist1[i] = 0;
			numlist2[i] = 0;
		}
		
		for(int i=0; i<n; i+=2){
			numlist1[list[i]-1] += 1;
			numlist2[list[i+1]-1] += 1;
		}
		
		int max11=0, max12=0, max21=0, max22=0;
		int val1=0, val2=0;
		for(int i=0; i<100000; i++){
			if(numlist1[i] >= max11){
				max12 = max11;
				max11 = numlist1[i];
				val1 = i;
			}
			else if(numlist1[i] >= max12){
				max12 = numlist1[i];
			}
			if(numlist2[i] >= max21){
				max22 = max21;
				max21 = numlist2[i];
				val2 = i;
			}
			else if(numlist2[i] >= max22){
				max22 = numlist2[i];
			}
		}
		
		if(val1 != val2){
			ans = n - max11 - max21;
		}
		else{
			ans = n - Math.max(max12+max21, max11+max22);
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 51040
def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    d = {'r': R, 's': S, 'p': P}
    T = input()
    scores = []
    for t in T:
        if t == 'r':
            scores.append('p')
        elif t == 's':
            scores.append('r')
        else:
            scores.append('s')
    for i in range(N-K):
        if scores[i] == scores[i+K]:
            scores[i+K] = 0
    print(sum([d[v] for v in scores if v in ['p', 'r', 's']]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 83984
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    vector<int> a(n),b(n);
    map<int,int> acnt,bcnt;
    rep(i,n){
        cin >> a[i];
        acnt[a[i]]++;
    }
    rep(i,n){
        cin >> b[i];
        bcnt[b[i]]++;
    }
    for(auto p : acnt){
        if(bcnt[p.first] + p.second > n){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    reverse(all(b));
    int non=-1 , nonidx=-1 , nonlastidx=n-1;
    rep(i,n)if(a[i]==b[i])non=b[i];

    if(non==-1)goto skip;

    rep(i,n){
        if(nonidx==-1&&non==b[i]){
            nonidx=i;
        }else if(nonidx!=-1&&b[i]!=non){
            nonlastidx=i-1;
            break;
        }
    }
{
    int idx=0;
    rep2(i,nonidx , nonlastidx+2){
        if(a[i]!=b[i])continue;
        if(nonidx==idx)idx=nonlastidx+2;
        swap(b[idx] , b[i]);
        idx++;
    }

    int j=n-1;
    rep(i,n){
        if(a[i]==b[i]){
            swap(b[i],b[j]);j--;
        }
    }
}
    skip:;
    rep(i,n)cout << b[i] << " \n"[i+1==n];
}

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

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

  string a,b,c;
  cin >> a >> b >> c;

  int ret = 0;
  for(int i = 0;i < n;i++){
    set<int> st;
    st.insert(a[i]-'a');
    st.insert(b[i]-'a');
    st.insert(c[i]-'a');
    ret += st.size() - 1;
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long int
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define LN outchar('\n')
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}

// DP for weights
// ith value ke liye minimum weight kya hai



int main ( ){
	int n;
	int w;
	inpos(n); inpos(w);
	int val[n]; int Wt[n];
	ll sum = 0;
	for (int i = 0; i<n;i++) {
		inpos(Wt[i]);
		inpos(val[i]);
		sum += val[i];
	}
	vector <ll> dp(sum+1, INT_MAX); // 
	dp[0] = 0;

	for (int i = 0; i<n;i++) { // iterate kar rahe ha items me
		
		for (int j = sum ; j-val[i] >=0 ; j--) {
			 dp[j] = min (dp[j ] , dp[j-val[i]] + Wt[i]) ;
		} 

	}
	// outpos(dp[w]);LN;
	// Reverse chal 
	for (int i = sum; i>=0;i--) {
		// outpos(dp[i]);
		if (dp[i] <=w) { // iske corrsepondin
			outpos(i);break;
		}
	}


}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

namespace math { namespace prime {

constexpr int Max = 1e7+1;    // !!!INPUT MAX NUMBER!!!

int prime[Max];
bool is_prime[Max];

int sieve(int n) {
  int prime_count = 0;
  rep(i, n+1) is_prime[i] = 1;
  is_prime[0] = is_prime[1] = 0;
  REP(i, 2, n+1) {
    if(!is_prime[i]) { continue; }
    prime[prime_count++] = i;
    for(long long j=(long long)i*i; j<=n; j+=i) {
      is_prime[j] = 0;
    }
  }
  return prime_count;
}

#define USE_PRIME_SIEVE \
  using namespace math::prime;
}}

USE_PRIME_SIEVE

int main() {
  constexpr int sieve_max = 1234567;
  sieve(sieve_max);
  int N; cin >> N;
  REP(i, 11, sieve_max) {
    if (is_prime[i] && (i - 1) % 5 == 0) {
      if (i != 11) cout << " ";
      cout << i;
      if (--N == 0) {
        break;
      }
    }
  }
  cout << "\n";
}


Measured memory_bytes: 3456
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                while(sc.hasNext()){
                        String s = sc.nextLine();
                        String s_ = s;
                        do{ 
                                String tmp = ""; 
                                for(int i = 0; i < s.length(); i++){
                                        char c = s.charAt(i);
                                        if(c != '.' && c != ' '){
                                                c++;
                                                if(c > 'z'){
                                                        c -= 26; 
                                                }     
                                        }   
                                        tmp += c;
                                }   
                                s = tmp;
                        }while(!s.equals(s_) && s.indexOf("the") == -1 && s.indexOf("this") == -1 && s.indexOf("that") == -1); 
                        System.out.println(s);
                }   
        }   
}

Measured memory_bytes: 12000
using System;

namespace abc117A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            double T = double.Parse(str[0]);
            double X = double.Parse(str[1]);
            double A = T / X;
            Console.WriteLine(A);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    string s;
    cin >> s;

    int head, tail;
    head = stoi(s.substr(0, 2));
    tail = stoi(s.substr(2, 2));

    bool yymm = true;
    bool mmyy = true;
    if (tail >= 13 || tail <= 0) {
        yymm = false;
    }
    if (head >= 13 || head <= 0) {
        mmyy = false;
    }

    if (yymm && !mmyy) {
        P("YYMM");
    }
    else if (!yymm && mmyy) {
        P("MMYY");
    }
    else if (yymm && mmyy) {
        P("AMBIGUOUS");
    }
    else {
        P("NA");
    }

    return 0;
}


Measured memory_bytes: 256
l,r=map(int,input().split())
x=l//2019
y=r//2019
if y-x>=1:
    print(0)
else:
    s=2019
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            s=min(s,i*j%2019)
    print(s)

Measured memory_bytes: 3060
#include <stdio.h>
#include <assert.h>
int n,i,j,x,a[10][10],list[200][3],size;
void push(int x,int y,int s){list[size][0]=i;list[size][1]=j;list[size][2]=s;size++;}

int check(int x,int y,int s){
	int d;
	if(s<3 && (x<1 || x>9 || y<1 || y>9)) return 0;
	if(s==3 && (x<2 || x>8 || y<2 || y>8)) return 0;
	d=a[x][y];
	if(a[x-1][y]<d)d=a[x-1][y];
	if(a[x+1][y]<d)d=a[x+1][y];
	if(a[x][y-1]<d)d=a[x][y-1];
	if(a[x][y+1]<d)d=a[x][y+1];
	if(s==1 || d==0)return d;
	if(a[x-1][y-1]<d)d=a[x-1][y-1];
	if(a[x+1][y+1]<d)d=a[x+1][y+1];
	if(a[x+1][y-1]<d)d=a[x+1][y-1];
	if(a[x-1][y+1]<d)d=a[x-1][y+1];
	if(s==2 || d==0)return d;
	if(a[x-2][y]<d)d=a[x-2][y];
	if(a[x+2][y]<d)d=a[x+2][y];
	if(a[x][y-2]<d)d=a[x][y-2];
	if(a[x][y+2]<d)d=a[x][y+2];
	return d;
}

void draw(int x,int y,int s,int d){
	if(size==3 && (x<2 || x>8 || y<2 || y>8)) return;
	a[x][y]+=d;
	a[x-1][y]+=d;
	a[x+1][y]+=d;
	a[x][y-1]+=d;
	a[x][y+1]+=d;
	if(s==1)return;
	a[x-1][y-1]+=d;
	a[x+1][y+1]+=d;
	a[x+1][y-1]+=d;
	a[x-1][y+1]+=d;
	if(s==2)return;
	a[x-2][y]+=d;
	a[x+2][y]+=d;
	a[x][y-2]+=d;
	a[x][y+2]+=d;
}

int search(int nn,int from){
	int i,x,y,s,t;
	for(i=from;i>=0;i--){
		x=list[i][0];y=list[i][1];s=list[i][2];
		if(x<8){if(s<3 && a[x+2][y]>0)return 0;}
		t=check(x,y,s);
		if(t>0){
			draw(x,y,s,-t);
			for(;t>0;t--){
				//if(s==1 && a[x+1][y+1]>0 && check(x-1,y+1,3)==0){draw(x,y,s,+1);return 0;}
				if(nn-t>0){
					if(search(nn-t,i-1)>0){goto answer;}
				}else{
					int p,q;
					for(p=0;p<10;p++)for(q=0;q<10;q++){{if(a[p][q]!=0)goto miss;}}
					goto answer;
					miss:;
				}
				draw(x,y,s,+1);
			}
		}
	}
	return 0;

	answer:
	for(;t>0;t--)printf("%d %d %d\n",y,x,s);
	return 1;
}

int main(void){
	scanf("%d",&n);size=0;
	for(i=0;i<10;i++){for(j=0;j<10;j++){scanf("%d",&a[i][j]);}}
	for(i=1;i<9;i++){
		for(j=1;j<9;j++){
			x=check(i,j,1); if(x==0)continue; push(i,j,1);
			x=check(i,j,2); if(x==0)continue; push(i,j,2);
			x=check(i,j,3); if(x==0)continue; push(i,j,3);
		}
	}
	/*
	 if(a[i][j]>5){
	 fprintf(stderr,"%3d\n",n);
	 for(i=0;i<10;i++){for(j=0;j<10;j++){fprintf(stderr,"%3d",a[i][j]);}fprintf(stderr,"\n");}fprintf(stderr,"\n");
	 assert(0);
	 }*/
	//for(i=0;i<size;i++)printf("%d %d %d\n",list[i][0],list[i][1],list[i][2]);
	search(n,size-1);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long a[n];
	for(int i=0;i<n;i++)
	{
		long long x,y,m;
		cin>>x>>y;
		long long t=sqrt(x*y-1);
		if(t*t>x*y-1) t--;
		a[i]=t*2;
		if(t*(t+1)>=(x*y))
		a[i]--;
		if(t>=x)
		a[i]--;
		if(t>=y)
		a[i]--;
	}
	for(int i=0;i<n;i++)
	cout<<a[i]<<endl;
	return 0;
} 

Measured memory_bytes: 256
import sys
from fractions import gcd
from collections import Counter
from itertools import combinations
from math import sqrt
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def calc(a, b):
    return sqrt(sum([(i -j)*(i-j) for i, j in zip(a,b)]))

def main():
    n, d = LI()
    xs = []
    ds = []
    ans = 0
    for i in range(n):
        xs.append(LI())
    for a, b in combinations(range(n), 2):
        ds.append(calc(xs[a], xs[b]))
    for i in ds:
        if i == i // 1:
            ans += 1
    print(ans)







if __name__ == "__main__":
    main()

Measured memory_bytes: 5584
N = int(input())
S = list(input())

count = []
for i in range(N):
    count.append([0,0])

cb = 0
for i in range(N):
    count[i][0] = cb
    if S[i] == "#":
        cb += 1
cw = 0
for i in range(N):
    count[N-i-1][1] = cw
    if S[N-i-1] == ".":
        cw += 1

ans = 10**10
for i in range(N):
    ans = min(ans,sum(count[i]))
print(ans)

Measured memory_bytes: 31420
from itertools import combinations
from collections import deque
n,k = map(int,input().split())
i_canerase = [n-2] * n
import sys
q = deque(combinations([i for i in range(n)],2))
use_edges = []
canmake = 0
while q:
    if canmake == k:
        use_edges += list(q)
        print(len(use_edges))
        for i in range(len(use_edges)):
            a,b = use_edges[i]
            print(a+1,b+1)
        sys.exit()

    a,b = q.popleft()
    if i_canerase[a]>0 and i_canerase[b]>0:
        i_canerase[a] -= 1
        i_canerase[b] -= 1
        canmake += 1
    else:
        use_edges.append([a,b])

print(-1)


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a);
    for (int i = 0; i < a; i++) cin >> p[i];
    vector<int> q(b);
    for (int i = 0; i < b; i++) cin >> q[i];
    vector<int> r(c);
    for (int i = 0; i < c; i++) cin >> r[i];
    
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    
    vector<int> z;
    for (int i = 0; i < x; i++) z.push_back(p[a - 1 - i]);
    for (int i = 0; i < y; i++) z.push_back(q[b - 1 - i]);
    
    sort(z.begin(), z.end());
    for (int i = 0; i < x + y; i++) {
        if (!r.empty() && r.back() > z[i]) {
            z[i] = r.back();
            r.pop_back();
        }
    }
    long s = 0;
    for (int x : z) {
        s += x;
    }
    cout << s << "\n";

    return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, A, B;
int h[100010];


bool judge(int t){
	int cnt = 0;
	rep(i, 0, N)
		if(h[i] > B*t) cnt += CEIL((h[i]-B*t)/(double)(A-B));
	if(cnt <= t) return true;
	return false;
}


int binarySearch(){
	int l = 0, r = INF;
	while(r-l > 1){
		int m = l+(r-l)/2;
		if(!judge(m)) l = m;
		else r = m;
	}
	return r;
}


signed main(){
	cin >> N >> A >> B;
	rep(i, 0, N) cin >> h[i];

	cout << binarySearch() << endl;

	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = 2019
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	S := sc.nextStr()
	N := len(S)
	set := make(map[int]int)
	set[0]++
	num := make([]int, N)
	m := 1
	for i := N - 1; i >= 0; i-- {
		d := int(S[i] - '0')
		d = m * d % MOD
		if i < N-1 {
			d += num[i+1]
			d %= MOD
		}
		num[i] = d
		set[d]++
		m = m * 10 % MOD
	}
	ans := 0
	for _, v := range set {
		if v > 1 {
			ans += v * (v - 1) / 2
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 4260
a, b, c, d, e, f = gets.split.map(&:to_i)

x = Array.new(10000)
y = Array.new(10000)

x[0] = y[0] = 1

(0..f).each do |i|
  
  x[i+100*a] = x[i+100*b] = 1 if x[i]
  y[i+c] = y[i+d] = 1 if y[i]
end

w = 100 * a
s = 0

100.step(f,100) do |i|
  if x[i]
    0.upto([i/100*e, f-i].min) do |j|
      if y[j] && s * i < j * w
        w = i
        s = j
      end
    end
  end
end

puts "#{w+s} #{s}"



Measured memory_bytes: 1916
wd=["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"]
md=[0,31,29,31,30,31,30,31,31,30,31,30,31]

while 1:
    m,d = map(int, raw_input().split())
    if m==0: break
    s = sum([md[i] for i in range(m)]) + d + 2
    s = wd[s % 7]+"day"
    print s

Measured memory_bytes: 4216
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

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

    int n;
    cin >> n;

    vi vec(100001);
    vi num(n);
    rep(i, n){ 
        scanf("%d", &num[i]);
        //cin >> num[i];
        vec[num[i]]++;
    }

    sort(all(num));

    int ans;
    int maxans = 0;
    REP(i, num[0], num[n - 1] + 1){
        ans = vec[i - 1] + vec[i] + vec[i + 1];
        //REP(j, i - 1, i + 2){ ans += vec[j]; }
        //maxans = max(ans, maxans);
        if(maxans < ans){ maxans = ans; }
    }
    cout << maxans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int n, a, b, c, x;

int slot(vector<int> y) {
	int fr = 0;
	int i = 0;
	if (x == y[0]) i = 1;
	for (; i < n; ++i) {
		do {
			x = (a * x + b) % c;
			fr++;
			if (fr > 10000) return -1;
		} while (x != y[i]);
	}
	return fr;
}

int main() {
	while (cin >> n >> a >> b >> c >> x && (n || a || b || c || x)) {
		vector<int> y(n);
		for (int i = 0; i < n; ++i)cin >> y[i];
		cout << slot(y) << endl;
	}

	return 0;
}


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

using namespace std;

char str[11];
int p,a=0,b=0,c=0,sum=0,m=0;
vector <int> Vecs,Veca;

int main()
{
    cin >> str;
    p = strlen(str);

    for (int i=0; i<p; i++)
    {
        Vecs.push_back(str[i]-48);
    }

    for (int j=0;j<p-2;j++)
    {
        a = 0;
        b = 0;
        c = 0;
        sum = 0;
        a += Vecs[j];
        b += (a*10)+Vecs[j+1];
        c += (b*10)+Vecs[j+2];

        sum = abs(753-c);
        Veca.push_back(sum);
    }
    sort(Veca.begin(),Veca.end());
    cout << Veca[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323
void solve()
{
       ll n, m,a,b,c,d,e;
       cin>>n;
       ll ar[5];
       rep(i,0,5) cin>>ar[i];
      ll cnt= ceil((double) n / min(ar[0],min(ar[1],min(ar[2],min(ar[3],ar[4])))))+4;
       cout<<cnt;

}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    str S;cin>>S;

    for(int i=0;i<S.size();i++){
      if(S[i]=='1') cout<<9;
      else cout<<1;
    }

    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		List<Long> li=new ArrayList<Long>();
		long arr[]=new long[(int)n];
		long sum1=0;
		for(int i=0;i<n;i++)
		{
			arr[i]=sc.nextLong();
			sum1=sum1^arr[i];
		}
		long sum=0;
		for(int i=0;i<n;i++)
		{
		    long x=sum1^arr[i];
			li.add(x);
			sum=0;
		}
		for(int i=0;i<li.size();i++)
		{
			System.out.print(li.get(i)+" ");
		}
	}
}

Measured memory_bytes: 68848