akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())

def brute(N):
    ans = []
    for a in range(1, N + 1):
        for b in range(1, N + 1):
            a2 = str(a)
            b2 = str(b)
            if a2[0] == b2[-1] and a2[-1] == b2[0]:
                ans.append((a, b))

    return ans

def faster(N):
    arr = defaultdict(list)
    c = Counter()
    for n in range(1, N + 1):
        s = str(n)
        first = s[0]
        last = s[-1]
        arr[first + last].append(n)
        c[first + last] += 1

    ans = 0
    for key in c:
        key2 = key[-1] + key[0]
        ans += c[key] * c[key2]

    for n in range(11, 100, 11):
        s = str(n)
        ans -= len(arr[n]) * len(arr[n])

    return ans

print(faster(N))

# for n in range(1, 1000):
#     b = len(brute(n))
#     f = faster(n)
#     if b != f:
#         print("error!")
#         print(b, f)
#         sys.exit(0)


            


Measured memory_bytes: 14792
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

int main(){
   IOS
    
    int n, m; cin>>n>>m;

    int i = 1, d = (m>>1) * 2;
    for(; d >= 2; d-= 2){
        cout<<i<<" "<<i + d<<"\n";
        i++;
    }

    if(m & 1) d = m;
    else d = m-1;

    i = 2 + ((m>>1) * 2);
    for(; d >= 1; d-=2){
        cout<<i<<" "<<i+ d<<"\n";
        i++;
    }  

}




Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> a(n), b(n), c(n);
  for(auto& x: a) cin >> x;
  for(auto& x: b) cin >> x;
  for(auto& x: c) cin >> x;

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long ans = 0;
  for(const auto& x: b){
    long long a_num = lower_bound(a.begin(), a.end(), x) - a.begin();
    long long c_num = c.end() - upper_bound(c.begin(), c.end(), x);
    ans += a_num * c_num;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
import sys
while True:
    m, f, r = [int(i) for i in sys.stdin.readline().strip().split(' ')]

    if m == -1 and f == -1 and r == -1:
        break
    sum = m + f
    
    if m == -1 or f == -1:
        print("F")
    elif sum >= 80:
        print("A")
    elif sum >= 65:
        print("B")
    elif sum >= 50:
        print("C")
    elif sum >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

// frog-2.rs --- Frog 2
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
        hs: [i32; n],
    };

    let mut dp = vec![std::i32::MAX; n];
    dp[0] = 0;

    for i in 0..n {
        for j in i + 1..min(i + k + 1, n) {
            dp[j] = min(dp[i] + (hs[i] - hs[j]).abs(), dp[j]);
        }
    }

    let ans = dp[n - 1];
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,m;cin>>n>>m;
  vector<pair<int,int> > a(m);rep(i,m)cin>>a[i].fi>>a[i].se;
  vector<vector<int> > b(n+100,vector<int>(0));

  rep(i,m){
    b[a[i].fi].pb(a[i].se);
  }
  rep(i,b[1].size()){
    rep(j,b[b[1][i]].size()){
      if(b[b[1][i]][j] == n){
        print("POSSIBLE");
        return 0;
      }
    }
  }

  print("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 10112
#include<iostream>
int main() {
	int A, N, x,y;
	std::cin >> N >> A;
	x = N % 500;
	y = x / 1;

	if (x = 0) {
		std::cout << "Yes" << std::endl;
	}
	if (y<=A){
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	system("PAUSE");
}


Measured memory_bytes: 504
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

int n, i;

int ju(int in){
	if (in == 0)return 0;
	if (in % 10 == 3) {
		cout << " " << i;
		return 0;
	}
	ju(in / 10);
}

int main() {
	cin >> n;
	if (n > 2) cout << " " << "3";
	if (n > 5) cout << " " << "6";
	if (n > 8) cout << " " << "9";
	if (n < 10) { cout << endl; return 0; }
	for (i = 10; i <= n; i++){
		if (i % 3 == 0) cout << " " << i;
		else ju(i);
	}
	cout << endl;
}

Measured memory_bytes: 1164
from datetime import datetime as dt
X,Y,Z,K = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))
Bs = list(map(int,input().split(" ")))
Cs = list(map(int,input().split(" ")))

As.sort(reverse = True )
Bs.sort(reverse = True )

ABs = []
for a in As:
    for b in Bs:
        ABs.append(a + b)
ABs.sort(reverse = True)
upper = min(len(ABs),K)

ABs = ABs[:upper]
ans = []

for C in Cs:
    for AB in ABs:
        ans.append(AB+C)
ans.sort(reverse = True)
for i in range(K):
    print(ans[i])


Measured memory_bytes: 167928
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

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

  vll X(N);
  ll MAX = 0;
  rep(i, N) {
    cin >> X[i];
    MAX = max(MAX, X[i]);
  }

  ll MIN = INF;
  rep(i, MAX + 1) {
    ll sum = 0;
    rep(j, N) {
      sum += (X[j] - i) * (X[j] - i);
    }
    MIN = min(MIN, sum);
  }
  COUT(MIN);
  return 0;
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

void checker(vector<vector<int>>& card, int num){
    REP(i, 3)REP(j, 3){
        if (card[i][j] == num) card[i][j]=0;
    }
}

int main(){
    vector<vector<int>> card(3, vector<int>(3));
    REP(i, 3)REP(j, 3) cin >> card[i][j];
    int n;
    cin >> n;
    vector<int> b(n);
    REP(i, n) cin >> b[i];

    for (auto num:b){
        checker(card, num);
    }

    if (card[0][0]==0 && card[1][1]==0 && card[2][2]==0) {
        cout << "Yes" << endl;
        return 0;
    }
    if (card[0][2]==0 && card[1][1]==0 && card[2][0]==0) {
        cout << "Yes" << endl;
        return 0;
    }
    REP(i, 3){
        if (card[i][0]==0 && card[i][1]==0 && card[i][2]==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    REP(i, 3){
        if (card[0][i]==0 && card[1][i]==0 && card[2][i]==0){
            cout << "Yes" << endl;
            return 0;
        }
    }


    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import unittest
import string


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2, 'ABCXYZ'), 'CDEZAB')

    def test_2(self):
        self.assertEqual(think(0, 'ABCXYZ'), 'ABCXYZ')

    def test_3(self):
        self.assertEqual(think(13, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 'NOPQRSTUVWXYZABCDEFGHIJKLM')


def solve():
    n, s = read()
    result = think(n, s)
    write(result)


def read():
    n = read_int(1)[0]
    s = read_line()
    return n, s


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, s):
    result = ''
    d = string.ascii_uppercase
    for c in s:
        index = d.index(c)
        new_index = (index + n) % len(d)
        result += d[new_index]
    return result


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 6468
import java.util.Scanner;
 public class Main{
   public static void main(String[]args){
     Scanner s = new Scanner(System.in);
     int n = s.nextInt();
     int a = n/2;
     int b = (n/2)+1;
     double c = a;
     double d = b;
     
     if(n%2==0){
       System.out.println(c/n);
     }else if(n%2!=0){
       System.out.println(d/n);
     }
   }
 }

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

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

int main() {
    double L;
    cin >> L;
    double ans = (1.0/27.0)*pow(L, 3.0);
    printf("%lf",ans);
}

Measured memory_bytes: 4180
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef vector<vector<ll>> vvll;

typedef pair<int, int> Pair;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

//nが素数かをO(√n)で判断
bool is_prime(int n) {
    bool res = true;

    if (n == 1) return false;
    else if (n == 2) return true;

    else {
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                res = false;
                break;
            }
        }
    }

    return res;
}



int perm(int n, int r) {
    if (r == 1) return n;
    return n * perm(n - 1, r - 1);
}

int fact(int n) {
    if (n == 1) return 1;
    return fact(n - 1) * n;
}

int comb(int n, int r) {
    int a = min(n, r), b = max(n, r);
    return perm(a, b) / fact(a);
}



/*
ll pow_mod(ll a, ll n, ll mod) {
    ll res = 1;

    ll base = a;
    while (n) {
        if (n & 1) res = res * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return res;
}
*/

//aの逆元　（a^(-1)）を求める
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

/*
ll fact_mod(ll n, ll mod) {
    if (n == 1) return 1;
    return n * fact_mod(n - 1, mod) * mod;
}
*/

// 階乗 (mod とりバージョン)
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}

ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

// 組み合わせ nCr を求める (modあり)
ll comb_mod(ll n, ll r, ll mod) {
    if (r > n - r) r = n - r;
    if (r == 0) return 1;
    ll a = 1;
    for (int i = 0; i < r; i++) a = a * ((n - i) % mod) % mod;
    ll b = pow_mod(fact_mod(r, mod), mod - 2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    int n; cin >> n;
    bool flag = false;

    vector<Pair> D(n);
    rep(i, n) cin >> D[i].first >> D[i].second;

    for (int i = 0; i + 2 < n; i++) {
        if (D[i].first == D[i].second && D[i + 1].first == D[i + 1].second && D[i + 2].first == D[i + 2].second) flag = true;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int n, s;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int t; scanf("%d", &t);
		s += (t % 2);
	}
	puts(s % 2 ? "NO" : "YES");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D, T, S;
  cin >> D >> T >> S;
  double A = (double)D / T;
  if (A <= S) {
  	cout << "Yes" << endl;
  } 
  else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)

#define MAX_N 100
#define MAX_M 100

int n, m;
int a[MAX_M], b[MAX_M][MAX_N], s[MAX_N] = {};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin>>n>>m;
	rep(i, m)cin>>a[i];
	rep(i, m) {
		rep(j, n)cin>>b[i][j];
	}
	
	rep(i, m) {
		int X=0;
		rep(j, n) {
			if(b[i][j]==a[i])s[j]++;
			else X++;
		}
		s[a[i]-1]+=X;
	}
	
	rep(i, n)cout<<s[i]<<endl;
	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
int md = 100000;
#define addm(X, Y) ((X) = ((X) + (Y) % md) % md)

int n;
int a[100000 + 5];
int cnt, cnt2, cnt4;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        if (a[i] % 4 == 0) cnt4++;
        else if (a[i] % 2 == 0) cnt2++;
        else cnt++;
    }
    if (cnt2 == 0) {
        if (cnt4 + 1 >= cnt) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        if (cnt4 + 1 >= cnt + min(1,cnt2)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}


Measured memory_bytes: 640
def calc(h, w):
    w_1_1 = w // 3
    w_1_2 = w_1_1 + 1

    ans = inf
    for w_1 in w_1_1, w_1_2:
        s_1 = w_1 * h

        # 縦に割る
        w_2 = (w - w_1) // 2
        s_2 = w_2 * h

        w_3 = w - w_1 - w_2
        s_3 = w_3 * h

        ss = [s_1, s_2, s_3]
        # print(h, w, ss)
        ans = min(ans, max(ss) - min(ss))

        # 横に割る
        h_2 = h // 2
        s_2 = h_2 * (w - w_1)

        h_3 = h - h_2
        s_3 = h_3 * (w - w_1)

        ss = [s_1, s_2, s_3]
        # print(h, w, ss)
        ans = min(ans, max(ss) - min(ss))

    return ans


inf = float('inf')

h, w = map(int, input().split())

a = calc(h, w)
b = calc(w, h)
print(min(a, b))


Measured memory_bytes: 3064
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Circle2 = pair<Pld, ld>;
struct Pos{ld x, y, z;};
using Circle3 = pair<Pos, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecPld = vector<Pld>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<double>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

Circle2 min_ball(Pld p, VecPld &point){
	Pld k;
	ld move, maxi;

	auto dist = [](const Pld &a, const Pld &b) -> ld{
		ld dx = a.fs-b.fs;
		ld dy = a.sc-b.sc;
		return sqrt(dx*dx+dy*dy);
	};

	move = 0.5;
	while(move > EPS/100){
		maxi = 0.0;
		for(Pld i : point) if(chmax(maxi, dist(p, i))) k = i;
		p.fs += (k.fs-p.fs)*move;
		p.sc += (k.sc-p.sc)*move;
		move *= 0.999;
	}
	
	return {p, maxi};
}

Circle3 min_ball(Pos p, Vec1<Pos> &point){
	Pos k;
	ld move, maxi;

	auto dist = [](const Pos &a, const Pos &b) -> ld{
		ld dx = a.x-b.x;
		ld dy = a.y-b.y;
		ld dz = a.z-b.z;
		return sqrt(dx*dx+dy*dy+dz*dz);
	};

	move = 0.5;
	while(move > EPS/100){
		maxi = 0.0;
		for(Pos i : point) if(chmax(maxi, dist(p, i))) k = i;
		p.x += (k.x-p.x)*move;
		p.y += (k.y-p.y)*move;
		p.x += (k.z-p.z)*move;
		move *= 0.999;
	}

	return {p, maxi};
}

int main(void){
    ll n;
    cin >> n;
    VecPld p(n);
    rep(i, n) cin >> p[i].fs >> p[i].sc;

    Pld mid = {500.0, 500.0};
    Circle2 ans = min_ball(mid, p);
    setp(10);
    co(ans.sc);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N;
	double D;
	cin >> N >> D;
	vector<ll> X(N), Y(N);
	REP(i,N) cin >> X[i] >> Y[i];
	int ans = 0;
	REP(i,N) {
		double dis = sqrt(X[i] * X[i] + Y[i] * Y[i]);
		if (dis <= D) ++ans;
	}
	cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 6436
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int h, w, a, b;
LL table[200000];
/**********************************************/

LL change_div_mul_mod(LL divisor, LL mod_minus_2, LL mod){
    if(mod_minus_2 == 0) return 1;
    else if(mod_minus_2 % 2 == 0){
        LL d = change_div_mul_mod(divisor, mod_minus_2/2, mod);
        return (d * d) % mod;
    }else{
        return (divisor * change_div_mul_mod(divisor, mod_minus_2-1, mod)) % mod;
    }
}

LL nCr(LL n, LL r){
    return table[n] * change_div_mul_mod(table[r] ,MOD-2, MOD) % MOD * change_div_mul_mod(table[n-r], MOD-2, MOD) % MOD;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    table[0] = 1;
    for(int i = 1; i < 200000; i++) table[i] = table[i-1] * i % MOD;

    cin >> h >> w >> a >> b;
    LL ans = 0;
    for(int i = b; i < w; i++){
        ans += nCr((h-a-1) + i, i) * nCr((a-1) + (w-i-1), a-1);
        ans %= MOD;
    }
    cout << ans << endl;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int K, X;

	cin >> K >> X;

	if(500 * K >= X) cout << "Yes" << endl;
	else cout << "No" << "\n";

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define ld long double
#define mod 998244353ll
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)#define case_g "Case #"<<ti<<": "
#define Debug(x) cout << x << "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
vector<string> arr(6);
int main() {
    ll h, w, check;
    cin >> h >> w >> check;
    for(int i = 0; i < h; ++i) {
        cin >> arr[i];
    }
    ll ans = 0;
    for(int i = 0; i <= ((1 << h) - 1); ++i) {
        for(int j = 0; j <= ((1 << w) - 1); ++j) {
            ll sum = 0;
            for(int k = 0; k < h; ++k) {
                for(int l = 0; l < w; ++l) {
                    ll row = 1 << k;
                    ll col = 1 << l;
                    //cout << row << " " << "\n";
                    if(row & i && col & j && arr[k][l] == '#') {
                        ++sum;
                    }
                }
            }
            if(sum == check)
                ++ans;
            //cout << ans << "\n";
        }
    }
    cout << ans;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n * 2);
  for (int i = 0; i < n * 2; i++) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int l = 0, r = n;
  while (l < r) {
    int mid = (l + r) >> 1;
    bool ok = true;
    for (int i = 0; i < n * 2 - mid * 2; i++) {
      if (a[mid * 2 + i] + a[n * 2 - 1 - i] < m) {
        ok = false;
        break;
      }
    }
    if (ok) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < l * 2; i++) {
    ans = max(ans, (a[i] + a[l * 2 - 1 - i]) % m);
  }
  for (int i = 0; i < n * 2 - l * 2; i++) {
    ans = max(ans, (a[l * 2 + i] + a[n * 2 - 1 - i]) % m);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1152
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase
from collections import deque
from math import *

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def solve():
    n = int(input())
    count = 0
    lst = []
    for j in range(n):
        a, b = map(int, input().split())
        lst.append((a,b))
    for i in range(n-2):
        if lst[i][0] == lst[i][1]:
            if lst[i+1][0] == lst[i+1][1] and lst[i+2][0] == lst[i+2][1]:
                print('Yes')
                break
    else:
        print('No')
            
        
           
def main():
    #k = int(input())
    #tests = 1
    #tests = int(input().strip())
    #for test in range(tests):
        solve()
        
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 66676
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Measured memory_bytes: 26140
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

ll power_without_mod(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector<vector<ll>> graph;
vector<bool> visited;
vector<ll> dist;
map<ll,ll> mymap;
ll max_dist = 1;

void bfs(int u1){
    visited[u1] = 1;
    dist[u1] = 1;
    mymap[1] = u1;
    queue<ll> q;
    q.push({u1});
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(auto i=graph[u].begin();i!=graph[u].end();i++){
            if(!visited[*i]){
                dist[*i] = dist[u] + 1;
                visited[*i] = 1;
                max_dist = max(dist[*i],max_dist);
                mymap[dist[*i]] = *i;
                q.push({*i});
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
	
    ll t;
    // cin>>t;
    t = 1;
    for(ll z=0;z<t;z++){
        ll n;
        cin>>n; 
        ll sum = 0;
        for(ll i=1;i<=n;i++){
            if(i%3 != 0 && i%5 !=0)
                sum += i; 
        }
        cout<<sum;
    }
}

Measured memory_bytes: 3664
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
ll f(ll n){
	if(n == 1){
		return 1;
	}
	else{
		return 1 + 2 * f(n / 2);
	}
}
int main(){
	fast;
	ll h = 1;
	//cin >> h;
    while(h--){
 	ll h;
 	cin >> h;
 	cout << f(h) << endl;
}
}

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

using namespace std;


int main(){
    
    int m,f,r ;
    char ans[50] ;
    
    int count = 0;
    while(1){
        cin >> m >> f >> r ;
        if(m==-1 && f==-1 && r==-1){
            break ;
        }
        
    if(m==-1 || f==-1){
        ans[count] = 'F' ;
    }else if((m+f)>=80){
        ans[count] = 'A' ;
    }else if((m+f)<80 && (m+f)>=65){
        ans[count] = 'B' ;
    }else if((m+f)<65 && (m+f)>=50){
        ans[count] = 'C' ;
    }else if((m+f)<50 && (m+f)>=30){
        if(r>=50){
        ans[count] = 'C' ;
        }else{
        ans[count] = 'D' ;
        }
    }else{
        ans[count] = 'F' ;
    }
       count++ ; 
    }
    
    for(int i=0;i<count;i++){
        cout << ans[i] << "\n" ;
    }
}



Measured memory_bytes: 3028
#define $ scanf("%d",
a[100],l,r,p,n;main(c){for(;$&r)*r;printf("%d\n",c)){for(l=r;c=l;)$--l+a);for($&n);l<r&&!++c|a[p=l+r>>1]-n;)a[p]<n?r=p:(l=p+1);}}

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

#define MAX 1000002

int n;

#define MOD 1000000007


long long int dp[MAX];  //any number

vector<int> vv;
vector<vector<int> > V;

int anss = 0;
inline void dfs(int b){
	if (b == n){
		bool ok = false;
		for (int i = 0; i < vv.size(); i++){
			for (int j = i + 1; j <= i + vv[i]&&j<vv.size(); j++){
				if (vv[j] != vv[i + 1]){
					ok = true;
					break;
				}
			}
		}
		if (ok == false){
			anss++;
			V.push_back(vv);
		}
		
	}
	else{
		for (int i = 1; i <= n; i++){
			vv.push_back(i);
			dfs(b + 1);
			vv.pop_back();
		}

	}
}

int main(){

	cin >> n;
	//dfs(0);
	long long int sum = 0;
	long long int im = 0;
	long long int ans = 0;
	for (int i = 1; i <= n; i++){
		dp[i] += sum;
		dp[i] %= MOD;
		dp[i]++;
		//endless
		if (i < n){
			ans += ((dp[i] * (long long int)(n-1)) % MOD)*(long long int)(n - 1);
			ans %= MOD;
		}
		long long int can = n - i+1;
		can--;
		if (can == 1)can++;
		if (i < n){
			ans += dp[i] * (long long int)(n-can+1LL);
			ans %= MOD;
		}
		else{
			ans += dp[i]*n;
			ans %= MOD;
		}
		//end
		if(i-2>=0)im += dp[i - 2];
		sum += im;
		im %= MOD;
		sum %= MOD;
	}
	ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

int main(){
	int n,k,q;
	cin >> n >> k >>q;
	int arr[n] = {0};
	for(int i = 1; i <= n; i++){
		arr[i] = k - q;
	}
	for(int i = 1; i <= q; i++){
		int temp;
		cin >> temp;
		arr[temp]++;
	}
	for(int i = 1; i <= n; i++){
		if(arr[i]>0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1024
(N, M), *ABs = readlines.map{|l| l.split.map(&:to_i)}

G = (ABs + ABs.map(&:reverse)).group_by(&:first).map{|k, v| [k, v.map(&:last)]}.to_h
G.default = []
puts (G[1] & G[N]).empty? ? 'IMPOSSIBLE' : 'POSSIBLE'

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

int main(void)
{
  char a[1111],b[1111];
  int al, bl, i, j;
  scanf("%s%s",a,b);
  al = strlen(a);
  bl = strlen(b);
  for( i = 0; i < al; i++ ) {
    int ok = 1;
    for( j = 0; j < bl; j++ ) {
      if( a[i+j] != b[j] && b[j] != '_' ) ok = 0;
    }
    if( ok ) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 524
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

const m = 1000000007

func main() {
	n := scanInt()
	as := scanInts(n)

	sums := make([]int, n)
	var sum int
	for i, a := range as {
		sum += a
		sums[i] = sum % m
	}

	var ans int
	for i := 1; i < n; i++ {
		ans += as[i] * sums[i-1]
		ans = ans % m
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 7468
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
if N == 2:
  print(sum(A)/2)
  exit()
else:
  temp = (A[0]+A[1])/2
  for i in range(2, N):
    temp = 1/2*(A[i] + temp)
print(temp)

Measured memory_bytes: 9100
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;

ll k;
ll d[15][105];
ll ans;

void f(ll p, ll q)
{
    printf("%lld", q);
    if(p <= 0) return;
    if(q <= 0)
    {
        if(k <= d[q][p - 1]) f(p - 1, q);
        else if(k <= d[q + 1][p - 1] + d[q][p - 1]) k -= d[q][p - 1], f(p - 1, q + 1);
    }
    else
    {
        if(k <= d[q - 1][p - 1]) f(p - 1, q - 1);
        else if(k <= d[q][p - 1] + d[q - 1][p - 1]) k -= d[q - 1][p - 1], f(p - 1, q);
        else k -= d[q - 1][p - 1] + d[q][p - 1], f(p - 1, q + 1);
    }
}

int main()
{
    scanf("%lld", &k);
    if(k <= 9) {printf("%lld\n", k);return 0;}
    for(ll i = 0; i <= 9; i++)
    {
        d[i][0] = 1, k--;
    }
    k++;
    for(ll i = 1; i <= 100; i++)
    {
        for(ll j = 0; j <= 9; j++)
        {
            d[j][i] = d[j][i - 1] + d[j + 1][i - 1];
            if(j > 0) d[j][i] += d[j - 1][i - 1];
            if(j > 0) k -= d[j][i];
            if(k <= 0) {k += d[j][i];f(i, j);puts("");return 0;}
        }
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      a: usize,
      b: usize,
      c: usize
    }
    let m = max(a, max(b, c));
    let mut a = m - a;
    let mut b = m - b;
    let mut c = m - c;

    let mut ans = 0;
    ans += a/2;
    ans += b/2;
    ans += c/2;

    a = a%2;
    b = b%2;
    c = c%2;
    match a + b + c {
        1 => ans += 2,
        2 => ans += 1,
        3 => ans += 3,
        _ => ans += 0,
    }
    println!("{}", ans);
}


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

using namespace std;

int main()
{
    int a, b, c;    cin >> a >> b >> c;
    if (a == b && b == c)
        cout << "1" << endl;
    else if (a == b)
        cout << "2" << endl;
    else if (a == c)
        cout << "2" << endl;
    else if (b == c)
        cout << "2" << endl;
    else
        cout << "3" << endl;
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;

ll dp[100005][105][2];

int main(){
	string k;
	int d;
	cin>>k;
	cin>>d;
	int n = k.size();
	for(int rem=1;rem<d;rem++){
		dp[n][rem][0] = dp[n][rem][1] = 0; 
	}
	dp[n][0][0] = dp[n][0][1] = 1;
	for(int i=n-1;i>=0;i--){
		for(int rem=0;rem<d;rem++){
			dp[i][rem][0] = dp[i][rem][1] = 0;
			for(int j=0;j<=9;j++){
				dp[i][rem][1] = (dp[i][rem][1]+dp[i+1][(rem+j)%d][1])%MOD;
				if(j<k[i]-'0')
					dp[i][rem][0] = (dp[i][rem][0]+dp[i+1][(rem+j)%d][1])%MOD;
				else if(j==k[i]-'0')
					dp[i][rem][0] = (dp[i][rem][0]+dp[i+1][(rem+j)%d][0])%MOD;	
			}
		}
	}
	cout<<(dp[0][0][0]-1+MOD)%MOD<<"\n";
	return 0;
}

/*
dp[i][rem][0] = No. of ways to put the digits in such a way that their sum%D is D-rem such that digits put till now are matching with s.
dp[i][rem][1] = No. of ways to put the digits in such a way that their sum%D is D-rem
*/

Measured memory_bytes: 18688
#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
  long long N,Q;
  
 long long A[100010];
 long long B[100010];
 long long C[100010];
  
  cin>>N;
  
  
  for(long long i = 0;i < N;i++)
  {
    long long tmp;
    cin>>tmp;
    A[tmp]++;

  }
  
  cin>>Q;
  
  for(long long i = 0;i < Q;i++)
  {
    cin>>B[i];
    cin>>C[i];
  }
  
  long long res = 0;
  
  for(long long j = 1;j < 100010;j++)
    {
      if(A[j] > 0){
      res += A[j] * j; 
      }
    }
  
  
  for(long long i = 0;i < Q;i++)
  {
    
    res -= B[i]*A[B[i]];
    res -= C[i]*A[C[i]];
    
    A[C[i]] += A[B[i]];
    A[B[i]] = 0;
    
    res += B[i]*A[B[i]];
    res += C[i]*A[C[i]];
    
    cout<<res<<endl;
  }
  
  return 0;
 
}

Measured memory_bytes: 5916
N = int(raw_input())
X = map(float, raw_input().split())

P = 0.0
for item in X:
    P = P + item
P = P/N

P1 = int(P)
P2 = int(P)+1

ans1 = 0.0
for item in X:
    ans1 = ans1 + (P1-item)**2

ans2 = 0.0
for item in X:
    ans2 = ans2 + (P2-item)**2


print int(min(ans1, ans2))


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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        queue<ll>q;
        loop(i,1,9) q.push(i);
        loop(i,1,n-1)
        {
            ll x=q.front();
            q.pop();
            if(x%10) q.push((x*10)+(x%10)-1);
            q.push((x*10)+(x%10));
            if((x%10)!=9) q.push((x*10)+(x%10)+1);
        }
        cout<<q.front();

    }
    return 0;
}


Measured memory_bytes: 4764