akhauriyash/Code-Regression huggingface dataset:
pub struct Scanner{
    line : Vec<String> ,
    idx : usize
}

#[allow(dead_code)]
impl  Scanner{
   fn new() -> Scanner{
       return Scanner{ line: vec![], idx : 0}
   }
   fn next<T: std::str::FromStr> (&mut self) -> T{
       if self.idx == self.line.len() {
           let mut buffer = String::new();
           std::io::stdin().read_line(&mut buffer).ok();

           let a : Vec<&str>  = buffer.trim().split(' ').collect();
           self.line = a.iter().map(|&s| String::from(s)).collect();
           self.idx = 0;
       }
       let ret : T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
       self.idx += 1;
       ret
   }
   fn next_string(&mut self) -> Vec<char> {
       let s : String = self.next();
       return s.chars().collect::<Vec<char>>();
   }
   fn next_vec<T: std::str::FromStr>  (&mut self, n: usize) -> Vec<T>{
       let mut v : Vec<T>= Vec::with_capacity(n);
       for _i in 0..n {
           v.push(self.next());
       }
       v
   }
}


fn main() {
    let mut scan = Scanner::new();
    let mut k:i32 = scan.next();

    let mut ans : i64 = 0;

    let mut p3 = 1;
    let mut n = 0;
    loop {
        for st in 1..10{
            for pp in 0..p3{
                let mut x = st;
                let mut p = pp;
                let mut ok = true;
                let mut num : i64 = st;
                let mut dif : Vec<i64> = Vec::with_capacity(n);
                for _ in 0..n{
                    dif.push(p %3 - 1);
                    p /= 3;
                }
                dif.reverse();

                for i in 0..n{
                    x += dif[i];
                    if x < 0 || x==10{
                        ok = false;
                        break;
                    }
                    num = num*10 + x;
                }
                if ok {
                    k -= 1;
                }
                if k==0{
                    ans = num;
                    break;
                }
            }
            if k==0 {
                break;
            }
        }
        if k==0 {
            break;
        }
        n += 1;
        p3 *= 3;
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>

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

using namespace std;

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

    REP(i, Y / 10000 + 1) REP(j, (Y - i * 10000) / 5000 + 1) {
        int k = (Y - i * 10000 - j * 5000) / 1000;
        if (i + j + k == N) {
            cout << i << " " << j << " " << k << endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;

    return 0;
}

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

int main()
{
    ll n, ans = 1e13;
    cin >> n;

    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ans = min(ans, i + n / i - 2);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using Int = unsigned long long;
typedef pair<int,int> P;
typedef priority_queue<int> Pr;
Int const MOD = 1000000007;
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);

    int q; cin>>q;
    for (int i = 0; i < q; i++){
        int dp[1001][1001]={};
        string s1,s2; cin>>s1>>s2;
        for (int j = 0; j < s1.size(); j++){
            for (int k = 0; k < s2.size(); k++){
                if(s1[j]==s2[k]){
                    chmax(dp[j+1][k+1],max(dp[j][k+1],max(dp[j+1][k],dp[j][k]+1)));
                }else chmax(dp[j+1][k+1],max(dp[j][k+1],dp[j+1][k]));
            }
        }
        cout<<dp[s1.size()][s2.size()]<<'\n';
    }
}


Measured memory_bytes: 7120
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

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

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h;
    cin >> a >> b >> h;
    cout << (double)(a+b)*h/2 << endl;
    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

bool dp[32][3010];

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    dp[0][0] = true;


    for (ll mode = 0; mode < 4; mode++) {
        for (ll w = 0; w <= F / 100; w++) {
            for (ll s = 0; s <= F; s++) {
                if (100 * w + s > F) continue;
                if (w * E < s) continue;
                if (mode == 0) {
                    if (w - A >= 0)
                        dp[w][s] |= dp[w - A][s];
                }
                else if (mode == 1) {
                    if (w - B >= 0)
                        dp[w][s] |= dp[w - B][s];
                }
                else if (mode == 2) {
                    if (s - C >= 0)
                        dp[w][s] |= dp[w][s - C];
                }
                else {
                    if (s - D >= 0)
                        dp[w][s] |= dp[w][s - D];
                }
            }
        }
    }

    ll w_ans, s_ans;
    double mx = -1.0;
    for (ll w = 0; w <= F / 100; w++) {
        for (ll s = 0; s <= F; s++) {
            if (dp[w][s] == true) {
                double c = (double)s * 100.0 / (w * 100 + s);
                if (c > mx) {
                    w_ans = w;
                    s_ans = s;
                    mx = c;
                }
            }
        }
    }

    cout << w_ans * 100 + s_ans << " " << s_ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int x = 0;
	string h = "", t= "";
	for(auto it:s)
	{
		x += it=='('?1:-1;
		if(x<0)
		{
			x++;
			h += '(';
		}
	}
	while(x--)
		t +=')';
	cout<<h<<s<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  int a, m=10,n = 5;
  int b[5];
  int ans = 0;
  rep(i,5){
    cin >> a;
    if(a%10==0){
      ans += a;
    }else{
      m = min(m,a%10);
      ans += (a-(a%10)+10);
    }
  }
  ans += (m-10);
  cout << ans << endl;
}


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

using namespace std;


int minimum_votes(const string& input, int& index) {
    if(input[index+1] != '[') {
        int num = 0;
        index++;
        while(input[index] != ']') {
            num = 10*num + input[index] - '0';
            index++;
        }
        return num / 2 + 1;
    }
    vector<int> nums;
    while(true) {
        index++;
        nums.push_back(minimum_votes(input, index));
        if(input[index+1] == ']') {
            index++;
            break;
        }
    }
    sort(nums.begin(), nums.end());
    return accumulate(nums.begin(), nums.begin() + nums.size() / 2 + 1, 0);
}

int main() {
    int T; cin >> T;
    for(int t = 0; t < T; t++) {
        string input; cin >> input;
        int index = 0;
        cout << minimum_votes(input, index) << endl;
    }
}
// 
// [Probrem] Hierarchical Democracy
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1188&lang=jp
// 


Measured memory_bytes: 3176
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "OK" << endl ; else cout << "NG" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll a,b,n ;
	cin >> a >> b >> n ;
	ll ans = 0 ;
	if(b-1<=n){
		cout << a*(b-1)/b-a*((b-1)/b) << endl ;
	}else{
		cout << a*n/b-a*(n/b) << endl ;
	}
}


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


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

    for (int i = 1; i < 10; ++i) {
        int x = i + i * 10 + i * 100;
        if(n <= x){
            cout << x;
            break;
        }
    }

    return 0;
}


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


def main():
    """Function."""
    s = str(input())
    s = list(s)

    amin = s.index("A")
    zmax = max([i for i, x in enumerate(s) if x == "Z"])
    print(zmax-amin+1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8856
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String coffee;
        Scanner scan = new Scanner(System.in);


        coffee = scan.nextLine();

        if(coffee.length() == 6 && method(coffee)) {
            if(coffee.charAt(2) == coffee.charAt(3) &&
               coffee.charAt(4) == coffee.charAt(5)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            System.out.println("No");
        }
    }

    public static boolean method(String s) {
        char[] alpha = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

        a:
        for(int i = 0; i < s.length(); i++) {
            for(int j = 0; j < alpha.length; j++) {
                if(s.charAt(i) == alpha[j]) {
                    continue a;
                }
            }
            return false;
        }

        return true;
    }
}

Measured memory_bytes: 21716
n = int(input())
a = [[0 for j in range(10)] for i in range(10)]

for i in range(1, n+1):
    if i >= 10**5:
        tmp1 = i//10**5
    elif i >= 10**4:
        tmp1 = i//10**4
    elif i >= 10**3:
        tmp1 = i//10**3
    elif i >= 10**2:
        tmp1 = i//10**2
    elif i >= 10:
        tmp1 = i//10
    else :
        tmp1 = i
    tmp2 = i % 10
    a[tmp1][tmp2] += 1

cnt = 0
for i in range(1, 10):
    for j in range(1, 10):
        cnt += a[i][j] * a[j][i]
print(cnt)



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

int main(){
    int W, H, n, w, h;
    cin >> W >> H >> n;

    
    while(n--){
        int x, y, a;
        cin >> x >> y >> a;
        
        if(a == 1) w = max(w, x);
        if(a == 2) W = min(W, x);
        if(a == 3) h = max(h, y);
        if(a == 4) H = min(H, y);
    }
    cout << (w < W && h < H ? (W - w) * (H - h) : 0) << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter
from itertools import product
from math import factorial

# prime numbers
primes = list(range(int(10**5) + 1))
primes[1] = 0
for i in range(2, int(len(primes) ** 0.5) + 1):
    if primes[i]:
        for j in range(2 * i, len(primes), i):
            primes[j] = 0

def main():
    N, M = LI()
    # 素因数分解
    factors = Counter()
    for i in range(int(M ** 0.5) + 1):
        if primes[i]:
            while M % i == 0:
                factors[i] += 1
                M //= i
        if M < i:
            break
    if M != 1:
        factors[M] += 1
    ans = 1
    for k in factors.values():
        a, b = 1, 1
        for i in range(1, k + 1):
            a *= N + k - i
            b *= i
        ans = (ans * (a // b)) % MOD

    return ans % MOD

print(main())

Measured memory_bytes: 7404
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+10 , M = 5e5+10, OO = 0x3f3f3f3f ,  MOD = 1e9+7;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
int n,h[N];
int dp[N];

int solve(int idx){

    if(idx > n)
        return OO;
    if(idx == n-1)
        return 0;

    int& ret = dp[idx];
    if(~ret)
        return ret;

    ret = min(solve(idx+1)+abs(h[idx]-h[idx+1]) , solve(idx+2)+abs(h[idx]-h[idx+2]));
    return ret;
}

/*
void build(int idx){

    if(idx == n)
        return ;

    int& ret = dp[idx];
    if(ret == solve(idx+1)+abs(h[idx]-h[idx+1])){
        cout << abs(h[idx]-h[idx+1]) << " ";
        build(idx+1);
        return;
    }
    if(ret == solve(idx+2)+abs(h[idx]-h[idx+2])){
        cout << abs(h[idx]-h[idx+2]) << " ";
        build(idx+2);
        return;
    }
   // ret = min(solve(idx+1)+abs(h[idx]-h[idx+1]) , solve(idx+2)+abs(h[idx]-h[idx+2]));
    return ;
}

*/

    
int main(){
    

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);

    
    scanf("%d",&n);
    loop(i, n) scanf("%d",h+i); 

    memset(dp ,-1 , sizeof dp);
    printf("%d\n",solve(0));
   // build(0);
    //puts("");


    


    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std; typedef long long int ll;
#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{os << "("; os << v.first << ", " << v.second << ")"; return os;}
/*******************************************************************************/
int a, b, c;
void solve()
{
  int n;
  cin>>n;
  int k=n%10;
  if(k==2 || k== 4 || k== 5 || k==7 || k== 9)
    cout<<"hon";
  else if(k==3)
    cout<<"bon";
  else
    cout<<"pon";
}
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
    int t=1;
  //cin >> t;
    while (t--) solve();
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll h, w;
    cin >> h >> w;
    vector<string> s;
    for (ll i = 0; i < h; i++)
    {
        string temp;
        cin >> temp;
        s.push_back(temp);
    }
    for (ll i = 0; i < h; i++)
    {
        for (ll k = 0; k < w; k++)
        {
            if (s[i][k] == '#')
            {
                if (i - 1 >= 0)
                {
                    if (s[i - 1][k] == '#')
                        continue;
                }
                if (i + 1 < h)
                {
                    if (s[i + 1][k] == '#')
                        continue;
                }
                if (k - 1 >= 0)
                {
                    if (s[i][k - 1] == '#')
                        continue;
                }
                if (k + 1 < w)
                {
                    if (s[i][k + 1] == '#')
                        continue;
                }
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[10],i;
  scanf("%d",&a[0]);
  while(a[0] !=0){
    for(i =0;i <9;i++){
    scanf("%d",&a[i+1]);
    a[0]=a[0]-a[i+1];
  }
  printf("%d\n",a[0]);
  scanf("%d",&a[0]);
  }
  return(0);
}

Measured memory_bytes: 600
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const A = lines[0].split(' ').map(Number)

    A.sort((a, b) => b - a)

    const diff = (A[0] - A[1]) + (A[0] - A[2])
    const ans = Math.ceil(diff / 2) + diff % 2

    console.log(ans)

})(input)


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

/* -------------------------------- Template -------------------------------- */

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(n);
  REP(i,n) a[i] = int('a' + 26 - s[i]) % 26;
  int k; cin >> k;
  REP(i,n) {
    if (a[i] <= k) { k -= a[i]; a[i] = 0; }
  }
  a.back() -= k;
  REP(i,n) {
    s[i] = (52 - a[i]) % 26 + 'a';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long n,a[202020],sum[202020],ans=1e18+10;
long long ch(int x,int y)
{
	return sum[y]-sum[x-1];
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i-1];
	}
	int a=1,c=3;
	for(int b=2;b<=n-2;b++)
	{
		while(a<b-1 && abs(ch(1,a)-ch(a+1,b))>abs(ch(1,a+1)-ch(a+2,b)))
		{
			a++;
		}
		while(c<n-1 && abs(ch(b+1,c)-ch(c+1,n))>abs(ch(b+1,c+1)-ch(c+2,n)))
		{
			c++;
		}
		long long cha[4];
		cha[0]=ch(1,a);
		cha[1]=ch(a+1,b);
		cha[2]=ch(b+1,c);
		cha[3]=ch(c+1,n);
		sort(cha,cha+4);
		ans=min(ans,cha[3]-cha[0]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3456
#!/usr/bin/env python3
import sys
from itertools import permutations

def solve(N: int, x: "List[int]", y: "List[int]"):
    def d(xy1_xy2):
        xy1, xy2 = xy1_xy2
        return ((xy1[0] - xy2[0]) ** 2 + (xy1[1] - xy2[1]) ** 2) ** 0.5

    acc = [sum(map(d, zip(perm, perm[1:]))) for perm in map(tuple, permutations(zip(x, y)))]
    return sum(acc) / len(acc)

# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(solve(N, x, y))

if __name__ == '__main__':
    main()


Measured memory_bytes: 4528
N = int(input())
H = list(map(int, input().split()))
count = 0
ans = 0
for i in range(N-1):
    if H[i] < H[i+1]:
        ans = max(ans, count)
        count = 0
    else:
        count += 1
ans = max(ans, count)
print(ans)


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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	a.push_back(-1);
	ll now_num = a[0];
	ll cnt = 0;
	ll ans = 0;
	rep(i,n+1) {
		if (a[i] == now_num) cnt++;
		else {
			if (cnt - now_num >= 0)
				ans += cnt - now_num;
			else
				ans += cnt;
			cnt = 1;
			now_num = a[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<numeric>
#include<vector>
#include<cmath>
#include<climits>
#include<cfloat>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<limits>

using namespace std;
typedef pair<int,bool> Pair;

int main(){

int N,a;
int count,breakBlock;

cin >> N;

count = 0;
breakBlock = 0;

for(int i = 1;i<=N;++i){

    cin >> a; 

    if((count+1) == a) count++;
    else breakBlock++;


}

    if(breakBlock == N) cout << "-1" << endl;
    else cout << breakBlock << endl;

return 0;

}


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

int main(){
  string s,t;
  cin>>s>>t;
  int cnt=0;
  rep(i,s.size()){
    if(s[i]==t[i])cnt++;
  }
  cout<<s.size()-cnt<<endl;
  return 0;
}

Measured memory_bytes: 3860
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
	double x, h;
	double l;
	double ans;

	while(cin >> x >> h, x || h){
		l = sqrt(pow(x/2, 2)+pow(h, 2));

		ans = x*l*2 + pow(x, 2);

		printf("%f\n", ans);

	}
}

Measured memory_bytes: 1228
<?php
/*
検証部
for ($i = 1; $i < 100000; $i++) {
$str = strval($i);
$array = str_split($str);
$sum = array_sum($array);
if ($sum > $max) {
printf("%d %d\n", $sum, $i);
$max = $sum;
}
}
 */

for ($i = 0; $i <= 16; $i++) {
	for ($j = 1; $j < 10; $j++) {
		$str = $j . str_repeat("9", $i);
		$num = $j + $i * 9;
		$array[$num] = intval($str);
	}
}

krsort($array);
// var_dump($array);

fscanf(STDIN, "%d", $N);

foreach ($array as $key => $val) {
	if ($N >= $val) {
		$answer = $key;
		break;
	}
}

echo $answer;


Measured memory_bytes: 4984
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import           Data.List
import           Data.Maybe
import           Data.Ord
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n =
  replicateM n (map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine)

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n =
  replicateM n (map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine)

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n (map BS.unpack . BS.words <$> BS.getLine)

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

checkPerformance action = do
  x <- getCurrentTime
  action
  y <- getCurrentTime
  return $ diffUTCTime y x

main :: IO ()
main = do
  [k, s] <- readInts
  print $ solve k s

solve :: Int -> Int -> Int
solve k s = length
  [ () | x <- [0 .. k], y <- [0 .. k], let z = s - x - y, z >= 0, z <= k ]


Measured memory_bytes: 764
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }

  int Lmax = 0, Rmin = N;
  for (int i = 0; i < M; i++) {
    if (L[i] > Lmax) Lmax = L[i];
    if (R[i] < Rmin) Rmin = R[i];
    if(Lmax > Rmin){
      cout << 0 << endl;
      return 0;
    }
  }

  if (N < Rmin - Lmax + 1) {
    cout << N << endl;
  } else if (N >= Rmin - Lmax + 1) {
    cout << (Rmin - Lmax + 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
N = gets.to_i
nums = gets.chomp.split.map(&:to_i)

nums.sort!.reverse!

alice = []
bob = []
nums.each_with_index do |n, i|
   (i+1).odd? ? alice.push(n) : bob.push(n)
end

puts alice.inject(:+) - bob.inject(:+)

Measured memory_bytes: 14292
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <limits>
using namespace std;

#define ll long long
#define Coordinate pair<ll,ll>

const ll inf = numeric_limits<ll>::max();
int N,K;
vector<ll> x,y;
vector<Coordinate> xy; 

ll area(ll x_l, ll x_r, ll y_d, ll y_t){
	ll width, height;
	width = x_r - x_l;
	height = y_t - y_d;
 
	return width*height;
}

bool threshold(ll x_l, ll x_r, ll y_d, ll y_t, vector<Coordinate> v, int k){
	int l=0;
	for(auto p:v){
		ll px = p.first; ll py = p.second;
		if(x_l <= px && px <= x_r && y_d <= py && py <= y_t) l++;
	}

	return k <= l;
}


void solve(){
	ll ans = inf;
	ll x_l,x_r,y_d,y_t;
	sort(y.begin(),y.end());
	sort(x.begin(),x.end());

	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			y_d = y[i]; y_t = y[j];
			for(int k=0;k<N-1;k++){
				for(int l=k+1;l<N;l++){
					x_l = x[k]; x_r = x[l];
					if(threshold(x_l,x_r,y_d,y_t,xy,K)){
						ans = min(ans, area(x_l,x_r,y_d,y_t));
					}
				}
			}
		}
	}

	cout << ans << endl;
}

int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++){
		int px,py;
		cin >> px >> py;
		x.push_back(px);
		y.push_back(py);
		xy.push_back({px,py});
	}

	
	solve();
	return 0;
}


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

int main(void)
{
    long long N;
    cin >> N;
    vector<string> S(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> S[i];
    }

    vector<long long> C(4);
    for (long long i = 0; i < 4; i++)
    {
        C[i] = 0;
    }

    for (long long i = 0; i < N; i++)
    {
        if (S[i] == "AC")
        {
            C[0]++;
        }
        else if (S[i] == "WA")
        {
            C[1]++;
        }
        else if (S[i] == "TLE")
        {
            C[2]++;
        }
        else
        {
            C[3]++;
        }
    }
    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;
}

Measured memory_bytes: 6380
import sys
sys.setrecursionlimit(100000)

def load_balls():
	LINE_NUM, TOTAL = 0, 0
	balls = []
	i = 0
	for line in sys.stdin:
		line = line.strip()
		LINE_NUM += 1
		if LINE_NUM == 1:
			TOTAL = int(line.strip())
			continue
		balls.append([int(i) for i in line.split(" ")])
		if LINE_NUM == TOTAL+1: break
	return balls

class VesselClass:

	def __init__(self):
		self.tmp = []
		self.left = [0]
		self.right = [0]

	def fill(self, balls:list):
		self.tmp = balls

	def DFS(self):
		if len(self.tmp) == 0: print("YES")
		elif self.left[-1] < self.tmp[0]:
			self.left.append(self.tmp[0])
			self.tmp.pop(0)
			self.DFS()
		elif self.right[-1] < self.tmp[0]:
			self.right.append(self.tmp[0])
			self.tmp.pop(0)
			self.DFS()
		else: print("NO")

balls_list = load_balls()
for balls in balls_list:
	Vessel = VesselClass()
	Vessel.fill(balls)
	Vessel.DFS()

Measured memory_bytes: 7588
#include<cstdio>
const int MAXN=55,MAXA=50*50*2+10,ZERO=50*50;

int N,A;
int x[MAXN];
long long dp[MAXN][MAXA];

int main()
{
	scanf("%d%d",&N,&A);
	for(int i=1;i<=N;i++)
		scanf("%d",x+i),x[i]-=A;
	
	dp[0][ZERO]=1;
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<MAXA;j++)
			dp[i][j]=dp[i-1][j];
		for(int j=0;j<MAXA;j++)
			if(j-x[i]>=0&&j-x[i]<MAXA)
				dp[i][j]+=dp[i-1][j-x[i]];
	}
	printf("%lld\n",dp[N][ZERO]-1);

	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;
typedef long long ll;

const int mxn = 100;
vector<int> coins;
int n;

void solve() {
	int n;
    cin >> n;
    vector<int>a(n), b(n), c(n-1);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        --a[i];
    }
    for(int i=0; i<n; ++i)
        cin >> b[i];
    for(int i=0; i<n-1; ++i)
        cin >> c[i];
    int ans = 0;
    for(int i=0; i<n; ++i){
        ans += b[a[i]];
        if(i > 0 && a[i] == a[i-1] + 1)
            ans += c[a[i-1]];
    }
    cout << ans;
}

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

	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3596
s = input()
a, b = -1, -1

if len(s) == 2 and s[0] == s[1]:
    a, b = 1, 2
elif len(s) > 1:
    for i in range(len(s)-2):
        if s[i] == s[i+1]:
            a, b = i+1, i+2
            break
        if s[i] == s[i+2]:
            a, b = i+1, i+3
            break
print(a, b)


Measured memory_bytes: 3188
/*
 * atcoder/abc110_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * 1文字の場合
 * a
 * b
 * 必ずYes
 * 2文字の場合
 * a a
 * b b
 * Yes
 * a c
 * d e
 * Yes
 * a b
 * b c
 * Yes (b <=> c, a <= b)
 * a b
 * b a
 * Yes (a <=> b)
 * a a
 * a b
 * No
 *
 * 仮説: T, Sのそれぞれに2回以上出現する文字集合のうち、相方の複数とマッチするものが存在するならx
 */

const int MAX = 200100;
string S, T;
int N;
char M[200];
char M2[200];

void solve() {
  loop(n,0,200) M[n] = ' ', M2[n] = ' ';
  cin >> S >> T;
  N = T.size();
  loop(n,0,N) {
    char t = T[n];
    if (M[t] == ' ') M[t] = S[n];
    else {
      if (M[t] != S[n]) {
        cout << "No" << endl;
        return;
      }
    }

    char s = S[n];
    if (M2[s] == ' ') M2[s] = T[n];
    else {
      if (M2[s] != T[n]) {
        cout << "No" << endl;
        return;
      }
    }
  }

  cout << "Yes" << endl;
}

int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


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

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for (int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to;
    int cap;
    int rev;
};

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const int MAXV = 10000;

vector<edge> G[MAXV];
int level[MAXV];
int iter[MAXV];

void add_edge(int from, int to, int cap)
{
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}
void bfs(int s)
{
    memset(level, -1, sizeof(level));
    queue<int> q;
    level[s] = 0;
    q.push(s);
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int i = 0; i < G[v].size(); i++)
        {
            edge &e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0)
            {
                level[e.to] = level[v] + 1;
                q.push(e.to);
            }
        }
    }
}
int dfs(int v, int t, int f)
{
    if (v == t)
        return f;
    for (int &i = iter[v]; i < G[v].size(); i++)
    {
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to])
        {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0)
            {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s, int t)
{
    int flow = 0;
    while (1)
    {
        bfs(s);
        if (level[t] < 0)
            return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, iINF)) > 0)
        {
            flow += f;
        }
    }
}

int main()
{
    int V, E;
    cin >> V >> E;
    rep(i, E)
    {
        int a, b, c;
        cin >> a >> b >> c;
        add_edge(a, b, c);
    }

    cout << max_flow(0, V - 1) << endl;

    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
int main()
{   int_fast64_t s;
cin>>s;
int c=1000;
while(s>=100){
  int a=s%1000;
  int b=abs(a-753);
  c=min(c,b);
  s/=10;
}
cout<<c<<endl;
}

Measured memory_bytes: 3576
#include <iostream>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i+=2) {
    int tmp = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) tmp++;
    }
    if (tmp == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define BR putchar('\n')
#define MS0(ar) memset(ar, 0, sizeof(ar))
#define MS1(ar) memset(ar, -1, sizeof(ar))
#define F first
#define S second
#define MP make_pair
#define MT make_tuple
#define IO(name) freopen(name".in", "r", stdin);freopen(name".out", "w", stdout)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef complex<double> CD;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VL;

void R(int &x) { scanf("%d", &x); }
void R(LL &x) { scanf("%lld", &x); }
void R(ULL &x) { scanf("%llu", &x); }
void R(double &x) { scanf("%lf", &x); }
void R(LD &x) { scanf("%Lf", &x); }

template <typename T> void R(T &t) { cin >> t; }
template <typename A, typename B> void R(pair<A, B> &x) {
  R(x.F);
  R(x.S);
}

template <typename T> void R(vector<T> &ar) {
  for (auto &it : ar)
    R(it);
}

template <typename T, typename... Args> void R(T &t, Args &... args) {
  R(t);
  R(args...);
}

void W(const char &c) { putchar(c); };
void W(const int &x) { printf("%d", x); }
void W(const LL &x) { printf("%lld", x); }
void W(const ULL &x) { printf("%llu", x); }
void W(const double &x) { printf("%lf", x); }
void W(const LD &x) { printf("%Lf", x); }

template <typename T> void W(const T &t) { cout << t; }
template <typename T> void W(const vector<T> &ar) {
  for (size_t i = 0; i < ar.size(); ++i) {
    W(ar[i]);
    putchar(" \n"[i + 1u == ar.size()]);
  }
}
template <typename T, typename... Args>
void W(const T &t, const Args &... args) {
  W(t);
  W(args...);
}
#define BR putchar('\n')

template <typename T> void Min(T &x, T v) { x = min(x, v); }
template <typename T> void Max(T &x, T v) { x = max(x, v); }
//}}}
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int maxn = 100010;

const LL mod = 1000000007;
int n, a[maxn] = {}, b[maxn] = {};
int c[maxn] = {};
int h[maxn] = {};
int main() {
  R(n);
  REPE(i, 1, n) R(a[i]);
  REPE(i, 1, n) R(b[i]);
  REPE(i, 1, n) if (a[i] != a[i - 1]) c[i] = a[i];
  for (int i = n; i >= 1; --i) if (b[i] != b[i + 1]) {
    if (c[i] && c[i] != b[i]) {
      puts("0");
      return 0;
    }
    c[i] = b[i];
  }
  int mx = 0;
  REPE(i, 1, n) {
    mx = max(mx, c[i]);
    if (mx != a[i]) {
      puts("0");
      return 0;
    }
  }
  mx = 0;
  for (int i = n; i >= 1; --i) {
    mx = max(mx, c[i]);
    if (mx != b[i]) {
      puts("0");
      return 0;
    }
  }
  REPE(i, 1, n) if (c[i] == 0) h[i] = INT_MAX;

  int cur = 0;
  REPE(i, 1, n) {
    if (c[i]) cur = c[i];
    else h[i] = min(h[i], cur);
  }
  cur = 0;
  for (int i = n; i >= 1; --i) {
    if (c[i]) cur = c[i];
    else h[i] = min(h[i], cur);
  }
  LL ans = 1;
  REPE(i, 1, n) if (c[i] == 0) ans = ans * h[i] % mod;
  printf("%lld\n", ans);


  return 0;
}



Measured memory_bytes: 1664
#include<stdio.h>
#include<queue>
std::priority_queue<std::pair<int,int>,std::vector<std::pair<int,int> >,std::greater<std::pair<int,int> > >Q;
int cntl[200002],cntr[200002],v[200002],tmp1[200002],tmp2[200002],tmp3[200002],r[200002],pool[200002],n,m;
long long ans;
long long calc(int n,int l[],int r[],int t[]){
	static std::queue<std::pair<int,int> >Q;
	while(!Q.empty())Q.pop();
	static int tmp1[200002],tmp2[200002];
	long long ans=0,cnt=0;int g=n/m;
	for(int i=1;i<=n;i++){
		Q.push(std::make_pair(t[i],l[i]));
		while(Q.size()>=m&&Q.front().first!=t[i])cnt+=Q.front().second,Q.pop();
		ans+=cnt*r[i];tmp1[i]=tmp2[i]=0;
	}for(int i=m;i<=n;i++)tmp2[i/m]+=r[i];
	for(int i=n-m+1;i>=1;i--)tmp1[g+1-(n+1-i)/m]+=l[i];
	for(int i=1;i<=g;i++)l[i]=tmp1[i],r[i]=tmp2[i];
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);r[0]=1;ans=n;
	for(int i=1;i<=n;i++){
		int hdhdAKIOI;scanf("%d",&hdhdAKIOI);Q.push(std::make_pair(hdhdAKIOI,i));
		r[i]=i+1;v[i]=i;cntl[i]=cntr[i]=1;
	}while(!Q.empty()){
		int V=Q.top().first,tp=0;
		while(!Q.empty()&Q.top().first==V){
			pool[++tp]=Q.top().second;Q.pop();
		}tmp1[1]=cntl[pool[1]];tmp2[1]=cntr[pool[1]];tmp3[1]=v[pool[1]];
		for(int i=2,j=1;i<=tp;i++){
			if(r[pool[i-1]]==pool[i]){
				j++;tmp1[j]=cntl[pool[i]];tmp2[j]=cntr[pool[i]];tmp3[j]=v[pool[i]];
			}else{
				if(j>=m){
					ans+=calc(j,tmp1,tmp2,tmp3);
					int s=pool[i-j],c=j/m;
					for(int p=s;p<s+c-1;p++)r[p]=p+1;r[s+c-1]=r[pool[i-1]];
					for(int p=s;p<s+c;p++)cntl[p]=tmp1[p-s+1],cntr[p]=tmp2[p-s+1],v[p]=s,Q.push(std::make_pair(V+1,p));
				}j=1;tmp1[1]=cntl[pool[i]];tmp2[1]=cntr[pool[i]];tmp3[1]=v[pool[i]];
			}if(i==tp&&j>=m){
				ans+=calc(j,tmp1,tmp2,tmp3);
				int s=pool[i-j+1],c=j/m;
				for(int p=s;p<s+c-1;p++)r[p]=p+1;r[s+c-1]=r[pool[i]];
				for(int p=s;p<s+c;p++)cntl[p]=tmp1[p-s+1],cntr[p]=tmp2[p-s+1],v[p]=s,Q.push(std::make_pair(V+1,p));
			}
		}
	}printf("%lld",ans);
}

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

using namespace std;
typedef long long ll;
const int N=110000;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a[N],i,j,dp[N],n;
	cin>>n;
	for(i=0;i<n;++i) cin>>a[i];
	dp[0]=0; dp[1]=abs(a[0]-a[1]);
	for(i=2;i<n;i++){
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def popcount(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    return x & 0x0000007f


def solve():
    n, k, s, t = nm()
    a = [x ^ s for x in nl() if x & s == s and x | t == t]
    n = len(a)
    t ^= s
    s = 0
    C = [[0]*(n+1) for i in range(n+1)]
    for i in range(n+1):
        for j in range(i+1):
            if j == 0:
                C[i][j] = 1
            elif i > 0:
                C[i][j] = C[i-1][j] + C[i-1][j-1]
    D = [0]*(n+1)
    for i in range(n+1):
        for j in range(1, min(k, n)+1):
            D[i] += C[i][j]
    for i in range(n, 0, -1):
        D[i] -= D[i-1]
    l = list()
    for i in range(20, -1, -1):
        if t & (1 << i):
            l.append(i)
    p = len(l)
    na = list()
    for x in a:
        v = 0
        for i in l:
            v = v << 1 | x >> i & 1
        na.append(v)
    pc = [popcount(i) for i in range(1 << p)]
    l = [0]*(1 << p)
    ans = 0
    for bit in range(1 << p):
        cur = 0
        for x in na:
            l[bit&x] += 1
            cur += D[l[bit&x]]
        for x in na:
            l[bit&x] -= 1
        if pc[bit] & 1:
            ans -= cur
        else:
            ans += cur
    print(ans)
    return

solve()


Measured memory_bytes: 87608
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;



void chmax(ll &a,ll b) {
	if (a < b)a = b;
}

bool prime(int n) {
	if (n == 1) {
		return false;
	}
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	ll N, K;
	cin >> N >> K;
	vector < pair<ll, ll > > x_y;
	rep(i, 0, N) {
		ll x, y;
		cin >> x >> y;
		x_y.push_back({x,y});
	}
	
	vector<ll>ans;
	rep(i, 0, N - 1) {
		rep(j, i + 1, N) {
			rep(k, 0, N - 1) {
				rep(l, k+1, N) {
					ll x_left, x_right, y_bottom, y_top;
					x_left = min(x_y[i].first,x_y[j].first);
					x_right = max(x_y[i].first, x_y[j].first);
					y_bottom = min(x_y[k].second, x_y[l].second);
					y_top = max(x_y[k].second, x_y[l].second);
					int cnt = 0;
					rep(s, 0, N) {
						if (x_left <= x_y[s].first && x_y[s].first <= x_right && y_bottom <= x_y[s].second && x_y[s].second <= y_top) {
							cnt++;
						}
					}
					if (cnt >= K) {
						ans.push_back((x_right - x_left)*(y_top - y_bottom));
					};

				}
			}
		}
	}

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

	cout << ans[0] << endl;
	return 0;
}

Measured memory_bytes: 18408
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n;
    cin>>n;
    vector<int> ans(2*int(1e4)+1,0);
    for(int i=1;i*i<ans.size();i++)
        for(int j=1;j*j<ans.size();j++)
            for(int k=1;k*k<ans.size();k++)
                if(i*i+j*j+k*k+(i+j+k)*(i+j+k)<ans.size()) ans[i*i+j*j+k*k+(i+j+k)*(i+j+k)]++;
    for(int i=1;i<=n;i++) cout<<ans[2*i]<<"\n";
}

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

    solve();
    return 0;
}

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

int main(){
	string s;
	cin>>s;
	if(s[0]!='A'){
		puts("WA");
		return 0;
	}
	int count=0;
	for(int i=2;i<s.length()-1;i++){
		if(s[i]=='C')count++;
	}
	if(count!=1){
		puts("WA");
		return 0;
	}
	int coun=0;
	rep(i,s.size()){
		bool is_small=false;
		rep(j,26){
			if(s[i]=='a'+j)is_small=true;
		}
		coun+=is_small;
    }
	if(coun<s.size()-2){
		puts("WA");
		return 0;
	}
	puts("AC");
	
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    
    int[] a = new int[5];
        
    for (int i = 0; i < 5; i++) {
    	a[i] = scan.nextInt();
    }
    
    int k = scan.nextInt();
    
    if (a[4] - a[0] > k) {
    	System.out.print(":(");
    } else {
    	System.out.print("Yay!");
    }
  }
}


Measured memory_bytes: 23764
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include<unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if(b-a == c-b) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++)cin >> d[i];
  sort(d.begin(),d.end());
  if(N%2==1)cout << 0;
  else cout << d[N/2] - d[N/2-1];
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f,maxn=1<<18|10;
int dp[maxn][60];
int a[20],b[20];
int n,S;
void solve(){
    scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%d",a+i);
    for(int i=0;i<n;++i)scanf("%d",b+i);
    memset(dp,0x3f,sizeof dp);
    S=1<<n;
    dp[0][0]=0;
    for(int s=0,cnt;s<S;++s){
        cnt=__builtin_popcount(s);
        for(int j=0,t,u,p=0;j<n;++j)if(~s&(1<<j)){
            u=(abs(cnt-j)&1)?b[j]:a[j];
            for(int k=0;k<=50;++k)
                if(u>=k)dp[s|1<<j][u]=min(dp[s|1<<j][u],dp[s][k]+p);
            ++p;
        }
    }
    int ans=inf;
    for(int j=0;j<=50;++j)
        ans=min(ans,dp[S-1][j]);
    if(ans==inf)puts("-1");
    else printf("%d\n",ans);
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 61696