akhauriyash/Code-Regression huggingface dataset:
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define MP(x,y) make_pair(x,y)
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
ll dp[1000010][2];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:/Users/LENOVO/Desktop/in.txt","r",stdin);
#endif
	string s;cin>>s;
	dp[0][0]=s[0]-'0';
	dp[0][1]=11+'0'-s[0];
	for(int i=1;i<s.size();i++){
		dp[i][0]=min(dp[i-1][0],dp[i-1][1])+s[i]-'0';
		dp[i][1]=min(dp[i-1][0]+11+'0'-s[i],dp[i-1][1]+9+'0'-s[i]);
	}
	cout<<min(dp[(int)s.size()-1][0],dp[(int)s.size()-1][1])<<endl;
	return 0;
}



Measured memory_bytes: 16924
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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

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

fn main() {
    input!{
        n: usize,
        p: [u64; n],
    }
    println!("{}", p.iter().sum::<u64>() - p.iter().max().unwrap() / 2);
}


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

int main() {
  int h, w;
  cin >> h >> w;
  while (!(h==0 && w==0)) {
    for (int i = 0; i < h; i++){
      for (int j = 0;  j < w ; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
}


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

int main() {
  int n, a, b, c;
  cin>>a>>b>>c>>n;
  int d=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==n){
          d++;
        }
      }
    }
  }
  cout<<d<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int num;
    double h,m,bmi;
    while(scanf("%d,%lf,%lf",&num,&m,&h) != EOF){
        bmi = m / (h * h);
        if(bmi >= 25) printf("%d\n",num);
    }
	return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k,cnt=0,i;
    cin >> a >> b >> c >> k;
    for(i=0;i<k;i++){
        if(a>=b){
            b=b*2;
            cnt++;
        }
    }
    for(i=cnt;i<k;i++){
        if(b>=c){
            c=c*2;
        }
    }
    if((a<b)&&(b<c)){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3600
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}
ll dx[2]={1,0};
ll dy[2]={0,1};

int main(){
    IOS;
    make(string,s);
    ll n=s.length();
    for(ll len=n-1;len>=0;len--){
        if(len%2!=0) continue;
        if(s.substr(0,len/2)==s.substr(len/2,len/2)){
            cout<<len<<endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}
vector<string> w{"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    string s;
    cin>>s;
    cout<<7-(find(all(w),s)-w.begin())<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int a,b;
  cin>>a>>b;
  if(a*b%2==0)cout<<"Even"<<endl;
  else cout<<"Odd"<<endl;

}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ANewYear {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int m;
	    in >> m;
	    out << 48 - m << endl;
	}
};


int main() {
	ANewYear solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
    int n, counter = 0, max = 0;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vec[i];
    }

    for (int i = 0; i < n-1; i++)
    {
        if(vec[i]>=vec[i+1]){
            counter++;
        }else{
            counter =0;
        }
        if (counter > max)
        {
            max = counter;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
now = -1
res = -1
for x in s:
    if now != x:
        res += 1
        now = x
print(res)

Measured memory_bytes: 77116
fun main(args: Array<String>) {
    val (N, K, Q) = readLine()!!.split(" ").map(String::toLong)
    val counts = LongArray(N.toInt())
    for (i in 0 until Q) {
        counts[readLine()!!.toInt() - 1]++
    }
    for (c in counts.map { v -> K - Q + v }) {
        println(if(c > 0) "Yes" else "No")
    }
}


Measured memory_bytes: 48408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define llong long long
#define ldouble long double
#define uint unsigned int
#define ullong unsigned long long
#define udouble unsigned double
#define uldouble unsigned long double
#define modinc(x) {if(x>=P) x-=P;}
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define piiii pair<pair<int,int>,pair<int,int> >
#define pli pair<llong,int>
#define pll pair<llong,llong>
#define Memset(a,x) {memset(a,x,sizeof(a));}
using namespace std;

const int N = 2e5;
char str[N+3];
llong ans;
int n;

int main()
{
	scanf("%s",str+1);
	n = strlen(str+1);
	int cnt = 0; ans = 0ll;
	for(int i=1; i<=n; i++) if(str[i]=='W') {ans += (llong)i; cnt++;}
	printf("%lld\n",ans-(llong)cnt*((llong)cnt+1ll)/2ll);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <utility>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef string str;
typedef vector<ll> vl;
typedef vector<str> vs;
typedef list<ll> listl;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))
#define all(x) (x).begin(), (x).end()
#define mp make_pair

#define _rep(i, m)		for(ll i = 0, i_max = m; i < i_max; i++)
#define _erep(i, m)		for(ll i = 0, i_max = m; i <= i_max; i++)
#define _brep(i, b, m)	for(ll i = b, i_max = m; i < i_max; i++)
#define _ebrep(i, b, m)	for(ll i = b, i_max = m; i <= i_max; i++)
#define _rrep(i, m)		for(ll i = m; i >= 0; i--)
#define _rerep(i, b, e)	for(ll i = b; i >= e; i--)

#define rep(m)			_rep(i, m)
#define erep(m)			_erep(i, m)
#define brep(b, m)		_brep(i, b, m)
#define ebrep(b, m)		_ebrep(i, b, m)
#define rrep(m)			_rrep(i, m)
#define rerep(b, e)		_rerep(i, b, e)

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

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(vs& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

void rout(bool b, str True, str False)
{
	if (b) cout << True.c_str();
	else cout << False.c_str();
}

ll count(ll Num)
{
	ll r = 0;
	rep(6)
	{
		if (Num & 1 << i)r++;
	}
	return r;
}

int main()
{
	ll N;
	in(N);

	vl A(N);
	in(A);

	sort(all(A));

	ll Num = 0;

	brep(1, N)
	{
		Num += A[N - i / 2 - 1];
	}

	out(Num);

	return 0;
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n,m,a;
  while(cin>>n>>m>>a,n){
    a--;
    vector<pair<int,pair<int,int>>> k;
    REP(i,m){
      int h,p,q;
      cin>>h>>p>>q;
      p--;q--;
      k.PB(MP(h,MP(p,q)));
    }
    sort(ALL(k));
    vector<int> am(n+1);
    LOOP(i,1,n+1)am[i]=i;
    for(int i=0;i<k.size();i++){
      int x=k[i].SC.FR,y=k[i].SC.SC;
      swap(am[x],am[y]);
    }
    cout<<am[a]+1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3176
N = int(input())
red_counts = {}
for i in range(N):
    r = input()
    if r in red_counts:
        red_counts[r] += 1
    else:
        red_counts[r] = 1
M = int(input())
blue_counts = {}
for i in range(M):
    b = input()
    if b in blue_counts:
        blue_counts[b] += 1
    else:
        blue_counts[b] = 1
        
ans = 0
for k in red_counts.keys():
    if k in blue_counts:
        ans = max(ans, red_counts[k] - blue_counts[k])
    else:
        ans = max(ans, red_counts[k])
print(ans)

Measured memory_bytes: 3064
A, B, M = map(int, input().split())
*a, = map(int, input().split())
*b, = map(int, input().split())
xyc = [list(map(int, input().split())) for _ in range(M)]
ans = min(a) + min(b)
for x, y, c in xyc:
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)

Measured memory_bytes: 38444
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	string a,b;
	cin >> a >> b;
	if(a.size() < b.size()){
		cout << "LESS" << endl;
	}
	else if(a.size() > b.size()){
		cout << "GREATER" << endl;
	}
	else{
		if(a < b)cout << "LESS" << endl;
		else if(a == b)cout << "EQUAL" << endl;
		else cout << "GREATER" << endl;
	}
}


Measured memory_bytes: 3620
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;
 


signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);

  
  int n;
  int a, b, c;
  cin >> n >> a >> b >> c;
  string s[n];

  for (int i = 0; i < n; i++)
    cin >> s[i];

  bool could = true;
  vector<string> ans;
  for (int i = 0; i < n; i++){
    if (s[i] == "AB"){
      if (a > b)
	a--, b++, ans.pb("B");
      else if (a < b)
	a++, b--, ans.pb("A");
      else if (c == 0 and i < n - 1 and s[i + 1] == "AC")
	b--, a++, ans.pb("A");
      else
	b++, a--, ans.pb("B");
	
    }
    else if (s[i] == "AC"){
      if (a < c)
	a++, c--, ans.pb("A");
      else if (a > c)
	a--, c++, ans.pb("C");
      else if (b == 0 and i < n - 1 and s[i + 1] == "AB")
	c--, a++, ans.pb("A");
      else
	c++, a--, ans.pb("C");
    }else{
      if (b < c)
	b++, c--, ans.pb("B");
      else if (b > c)
	b--, c++, ans.pb("C");
      else if (a == 0 and i < n - 1 and s[i + 1] == "AC")
	b--, c++, ans.pb("C");
      else
	b++, c--, ans.pb("B");
    }
    if (a < 0 or b < 0 or c < 0){
      could = false;
      break;
    }
  }
  if (could){
    cout << "Yes" << endl;
    for (string h: ans)
      cout << h << endl;
  }
  else
    cout << "No" << endl;
}


Measured memory_bytes: 10568
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_164_c
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int n = ReadInt();
            HashSet<string> dic = new HashSet<string>();
            for(int i=0;i<n;i++)
            {
                string s = ReadString();
                dic.Add(s);
            }
            Write(dic.Count.ToString());
        }


        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#if !TEST
    }
}
#endif

Measured memory_bytes: 47080
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;



int main(){

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << 10*a[2] + a[1] + a[0] << endl;

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
    os << "[";
    for (auto x : V) os << x << ", ";
    return os << "]";
}
//--------------------------------------------------//

int main() {
    use_cio();
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1, dy = y2 - y1;
    int x3 = x2 - dy, y3 = y2 + dx;
    cout << x3 << " " << y3 << " " << x3 + x1 - x2 << " " << y3 + y1 - y2;
}


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

int main(){
    long long ans = 0;
    int n;
    cin >> n;

    long long a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long b[n+1] = {};
    for (int i = n-1; i >= 0; i--)
    {
        b[i] = b[i+1] + a[i];
        b[i] = b[i] % 1000000007;
    }

    for (int i = 0; i < n; i++)
    {
        ans += b[i+1] * a[i];
        ans = ans % 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6744
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
using namespace std;
int gcd(int a , int b){ return b ? gcd(b,a%b) : a;}
signed main(){
  int n,l,ans;
  cin>>n>>l;
  ans=n*(l-1)+((n*(n+1))/2);
  if(l>=0)ans-=l;
  else if(n<(1-l))ans-=(l+n-1);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def calc_stop_rec(high):
    return_list = []
    for i in range(len(high) - 1):
        if high[i] - high[i+1] < 0:
            return_list.append(i)
    return(return_list)
def print_max(rec, num):
    max_value = 0
    for i in range(len(rec)):
        if i == 0:
            if max_value < rec[i]:
                max_value = rec[i]
        if i == len(rec) - 1:
            if max_value < (num - 1) - rec[i] - 1:
                max_value = (num - 1) - rec[i] - 1
        elif max_value < rec[i] - rec[i-1] - 1:
            max_value = rec[i] - rec[i-1] - 1
    print(max_value)
num = int(input())
high = list(map(int, input().split()))
stop_rec = calc_stop_rec(high)
if len(stop_rec) == 0:
    print(len(high) - 1)
else:
    print_max(stop_rec, num)


Measured memory_bytes: 14480
# include<stdlib.h>
# include<stdio.h>

int main()
{
	int N = 0;
	int i;
	int result = 0;
	scanf("%d", &N);
	for (i = 1; i < 10; i++) {
		if (N % i == 0) {
			if (N / i < 10) {
				result = 1;
				break;
			}
		}
	}
	if (result) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;

namespace AtCoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var ac = 0;
            var tle = 0;
            var wa = 0;
            var re = 0;
            var counter = int.Parse(Read());

            for (int i = 0; i < counter; i++)
            {
                switch (Read())
                {
                    case "AC":
                        ac++; break;
                    case "TLE":
                        tle++; break;
                    case "WA":
                        wa++; break;
                    case "RE":
                        re++; break;
                    default:
                        break;
                }
            }

            Console.Write("AC x ");
            Console.WriteLine(ac);
            Console.Write("WA x ");
            Console.WriteLine(wa);
            Console.Write("TLE x ");
            Console.WriteLine(tle);
            Console.Write("RE x ");
            Console.WriteLine(re);

        }


        private static string Read() => Console.ReadLine();
        private static List<string> SplitRead(char delimiter = ' ')
        {
            var splitWord = new List<string>();
            var start = 0;
            var str = Console.ReadLine();

            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == delimiter)
                {
                    splitWord.Add(str[start..i]);
                    start = i + 1;
                }
            }
            return splitWord;
        }
    }
}


Measured memory_bytes: 20692
#include<stdio.h>
int G[101][101];
int d[101];
int n;
int Que[1000];
int head=0, tail=0;
void enqueue(int q){
  Que[head]=q;
  head++;
}  
int dequeue(){
  tail++;
  return Que[tail-1];
} 
int size(){
  return head-tail;
}

void bfs(int i){
  int j;
  for(j=0;j<n;j++){
    if(G[i][j]==1 && d[j]==-1){
      d[j]=d[i]+1;
      enqueue(j);
    }
  }
}  
int main(){ 
  int i,j,v,k,u;
  scanf("%d",&n);
  for(i=0;i<101;i++) d[i]=-1;
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    } 
  }
  d[0]=0;
  bfs(0);
  while(size()!=0) bfs(dequeue());
   
  for(i=0;i<n;i++) printf("%d %d\n",i+1,d[i]);
   
  return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define maxn 2010
#define lim 5000010
#define mod 1000000007
using namespace std;
int fac[lim+10],inv[lim+10],dp[maxn][maxn],n,k;
int qpow(int a,int b){
	int ans=1,tmp=a;
	for(;b;b>>=1,tmp=1ll*tmp*tmp%mod)
		if(b&1)ans=1ll*ans*tmp%mod;
	return ans;
}
int C(int x,int y){
	return 1ll*fac[y]*inv[x]%mod*inv[y-x]%mod;
}
int cal(int pos,int x){
	return C(x-1,x+pos-1);
}
int main(){
	scanf("%d%d",&n,&k),inv[0]=fac[0]=1;
	if(k==1)return puts("1"),0;
	for(int i=1;i<lim;++i)fac[i]=1ll*fac[i-1]*i%mod;
	inv[lim-1]=qpow(fac[lim-1],mod-2);
	for(int i=lim-2;i>=1;--i)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	dp[0][0]=1;
	for(int i=0;i<=n;++i)
		for(int j=i;j<=n;++j){
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			dp[i][j+1]=(dp[i][j+1]+1ll*dp[i][j]*cal((j)*(k-1)+i,k-1))%mod;
		}
	printf("%d",1ll*dp[n][n]*fac[n]%mod);
}

Measured memory_bytes: 55168
import           Control.Monad
import           Data.Array.IO

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [n, m, k] <- readInts
  a_ary <- newArray ((0, 0), (n, n)) 0 :: IO (IOUArray (Int, Int) Int)
  b_ary <- newArray ((0, 0), (n, n)) 0 :: IO (IOUArray (Int, Int) Int)
  lrs <- replicateM m readInts
  pqs <- replicateM k readInts

  forM_ lrs $ \[l, r] ->
    writeArray a_ary (l, r) =<< (+1) <$> readArray a_ary (l, r)

  forM_ [1..n] $ \i ->
    forM_ [1..n] $ \j ->
      writeArray b_ary (i, j) =<< (\x y z w -> x + y - z + w)
        <$> readArray b_ary (i-1, j)
        <*> readArray b_ary (i, j-1)
        <*> readArray b_ary (i-1, j-1)
        <*> readArray a_ary (i, j)

  forM_ pqs $ \[p, q] ->
    print =<< (\x y z w -> x - y - z + w)
      <$> readArray b_ary (q, q)
      <*> readArray b_ary (p-1, q)
      <*> readArray b_ary (q, p-1)
      <*> readArray b_ary (p-1, p-1)

Measured memory_bytes: 149756
#include<stdio.h>

#define MAX 250

void print(int);

int H[MAX]; 

int main(){
  int i,h;
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&H[i]);
  }
  print(h);
  return 0;
}

void print(int h){
  int i;
  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,H[i]);
    if(i/2!=0){
      printf("parent key = %d, ",H[i/2]);
    }
    if(i*2<=h){
      printf("left key = %d, ",H[i*2]);
    }
    if(i*2+1<=h){
      printf("right key = %d, ",H[i*2+1]);
    }
    printf("\n");
  }
}
  

  



Measured memory_bytes: 2108
N = [0] + list(map(int, input()))
K = int(input())
n = len(N)

DP = [
      [[0] * (K+2) for _ in range(2)] for _ in range(n)
]

# 0桁目(0)で最大値を取っていてk=0の要素は1個。
DP[0][0][0] = 1

for i in range(1, n):
  for k in range(K+1):
    if N[i] != 0:
      DP[i][0][k+1] += DP[i-1][0][k]
      DP[i][1][k] += DP[i-1][0][k]
      DP[i][1][k+1] += DP[i-1][0][k] * (N[i] - 1)
    else:
      DP[i][0][k] += DP[i-1][0][k]
    DP[i][1][k] += DP[i-1][1][k]
    DP[i][1][k+1] += DP[i-1][1][k] * 9
print(DP[n-1][1][K] + DP[n-1][0][K])

Measured memory_bytes: 3064
n = gets.to_i
arr = gets.split(" ").map{|i|i.to_i}
ans = 0
n.times{|i|
  k = 1
  while arr[i] % ( 2 ** k ) == 0 do
    k = k + 1
  end
  ans = ans + k - 1
}
puts ans

Measured memory_bytes: 2300
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  const A: number[] = [];
  const B: number[] = [];
  for (let i = 0; i < N; i++) {
    A[i] = Number(input[i + 1][0]);
    B[i] = Number(input[i + 1][1]);
  }

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

  if (N % 2 === 0) {
    const minMedian = A[N / 2 - 1] + A[N / 2];
    const maxMedian = B[N / 2 - 1] + B[N / 2];

    return (maxMedian - minMedian + 1).toString();
  } else {
    const minMedian = A[(N + 1) / 2 - 1];
    const maxMedian = B[(N + 1) / 2 - 1];

    return (maxMedian - minMedian + 1).toString();
  }
};

console.log(main(read()));


Measured memory_bytes: 125196
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
string s;
vi all;
vector<char> num;
string itos(int a)
{
	ostringstream s;
	s<<a;
	return s.str();
}
void conv()
{
	all.clear();
	num.clear();
	string tmp;
	int t=0;
	for(int i=0;i<s.size();i++)
	{
		if(s.size()==1)
		{
			num.pb(s[0]);
			all.pb(1);
			break;
		}
		if(i==0)
		{
			t++;
			continue;
		}
		if(i==s.size()-1)
		{
			if(s[i-1]==s[i])
			{
				++t;
				num.pb(s[i-1]);
				all.pb(t);
			}
			else
			{
				num.pb(s[i-1]);
				all.pb(t);
				num.pb(s[i]);
				all.pb(1);
			}
			break;
		}
		if(s[i-1]==s[i])
		{
			t++;
		}
		else
		{
			num.pb(s[i-1]);
			all.pb(t);
			t=1;
		}
	}
	for(int i=0;i<all.size();i++)
	{
		tmp+=itos(all[i]);
		tmp+=num[i];
	}
	s.clear();
	s=tmp;
	return ;
}
int main()
{
	int n;
	while(1)
	{
		s.clear();
		cin >> n;
		if(n==0)break;
		cin >> s;
		for(int i=0;i<n;i++)
		{
			conv();
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1464
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <memory.h>
#include <stdlib.h>


int main(void)
{	
	int n,a;
	scanf("%d %d",&n,&a);
	
	printf("%d\n",n*n-a);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int m = sc.nextInt();
    
    double[] item = new double[n];
    double sum = 0;
    for (int i =0; i < n; i++) {
      item[i] = sc.nextDouble();
      sum += item[i];
    }
    
    double point = sum / (4 * m);
    
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (item[i] >= point) {
        count++;
      }
    }
      
    if (count >= m) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 38116
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];
    vector<int> v;
    for(int i = 1; i <= n; i++) v.push_back(i);
    int i = 1, a = 0, b = 0;
    while(true){
        bool is_p = true, is_q = true;
        for(int i = 0; i < n; i++){
            if(v[i] != p[i] || is_p != true) is_p = false;
            if(v[i] != q[i] || is_q != true) is_q = false;
        }
        if(is_p == true) a = i;
        if(is_q == true) b = i;
        if(a * b != 0) break;
        i++;
        next_permutation(v.begin(), v.end());
    }
    cout << abs(a -b);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {

	// erasedream yes
	// dreameraser yes
	// eraserdreameraser
	// dreamerer no
	// dream dreamer erase eraser
	var s string
	fmt.Scan(&s)

	s = strings.Replace(s, "eraser", "",-1)
	s = strings.Replace(s, "erase", "",-1)
	s = strings.Replace(s, "dreamer", "",-1)
	s = strings.Replace(s, "dream", "",-1)

	if len(s) ==0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1664
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};
use std::cmp::Ordering;

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
struct Rev(usize);

impl Ord for Rev {
    fn cmp(&self, other: &Rev) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl PartialOrd for Rev {
    fn partial_cmp(&self, other: &Rev) -> Option<Ordering> {
        Some(other.0.cmp(&self.0))
    }
}


fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut aa: [i64; n],
    }

    if aa[0] != 0 {
        return puts!("{}\n", -1);
    }

    let mut ans = 0;
    for i in 1..n {
        if aa[i] > aa[i-1]+1 {
            return puts!("{}\n", -1);
        }

        if aa[i] == aa[i-1] + 1 {
            ans += 1;
        } else {
            ans += aa[i];
        }
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) (c).begin(),(c).end()
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())
#define pb(c) push_back(c)
using vi=vector<int>;  using vs=vector<string>; using vc=vector<char>;
using vvi=vector<vector<int>>; using vb=vector<bool>;
using vvs=vector<vector<string>>;
using vvc=vector<vector<char>>;
using gi=greater<int>; 

int main() {
	int h,w; cin>>h>>w;
	vs table(h); rep(i,h) cin>>table.at(i);

	vb row(h, false),col(w, false);
    rep(i,h){
        rep(j,w){
            if(table.at(i).at(j)=='#'){
                row.at(i)=true;
                col.at(j)=true;
            }
        }
    }
    rep(i,h){
        if(row.at(i)){
            rep(j,w){
                if(col.at(j)) cout<<table.at(i).at(j);
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 256
#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 fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  rep(i, N) {
    ll a;
    cin >> a;

    ll aa = a * 2;
    ll bb = abs(a - K) * 2;
    ans += min(aa, bb);
  }
  ANS;

  return 0;
}

Measured memory_bytes: 3656
n = gets.chomp.to_i
towns = (0...n).map { gets.chomp.split(' ').map(&:to_i) }

sum = 0
p_cnt = towns.permutation.to_a.count
towns.permutation do |permutation|
  permutation.each_cons(2) do |t1, t2|
    sum += Math.sqrt((t1[0] - t2[0]) ** 2 + (t1[1] - t2[1]) ** 2 )
  end
end

puts sum / p_cnt

Measured memory_bytes: 9468
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll n;
	string a;
	cin>>n;
	cin>>a;
	for(ll i=0;i<a.size();i++){
	    ll d=0;
	    d=int(a[i]);
	    d=d+n;
	   // cout<<d;
	    if(d>90){
	        ll c=0;
	        c=d-90;
	        c=64+c;
	        char charcter = char(c);
	        cout<<charcter;
	    }
	    else{ 
	    char charcter = char(d);
	    cout<<charcter;}
	}
	
	
	return 0;
}

Measured memory_bytes: 256
import itertools
import random


class Dice(object):

    def __init__(self, *args):
        self.faces = [None]
        self.faces.extend(args)
        self.top = self.faces[1]
        self.up = self.faces[5]
        self.down = self.faces[2]
        self.left = self.faces[4]
        self.right = self.faces[3]
        self.back = self.faces[6]

    def roll(self, direction):
        if direction == "N":
            self.top, self.up, self.down, self.back = self.down, self.top, self.back, self.up
        elif direction == "S":
            self.top, self.up, self.down, self.back = self.up, self.back, self.top, self.down
        elif direction == "W":
            self.top, self.left, self.right, self.back = self.right, self.top, self.back, self.left
        elif direction == "E":
            self.top, self.left, self.right, self.back = self.left, self.back, self.top, self.right
        else:
            raise ValueError("{} is not valid direction.".format(direction))

    def __eq__(self, other):
        return (
           self.top, self.up, self.left, self.down, self.right, self.back
        ) == (
            other.top, other.up, other.left, other.down, other.right, other.back
        )


def is_equal_pair(d1, d2):
    i = 0
    while i < 100:
        if d1 == d2:
            return True
        d2.roll(random.choice(["N", "S", "W", "E"]))
        i += 1
    return False


n = int(input())
dices = []
for i in range(n):
    f = [int(i) for i in input().split()]
    dice = Dice(*f)
    dices.append(dice)

ans = "Yes"
for d1, d2 in itertools.combinations(dices, 2):
    if is_equal_pair(d1, d2):
        ans = "No"
        break

print(ans)



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

int main(){ 
    Int M, N;
    cin >> N >> M;

    vector<Int> x(M), y(M);

    if (N % 2 == 1) {
        rep(i,M) {
            x[i] = M - i;
            y[i] = M + 1 + i;
        }
    }

    else {
        Int a = N / 4;
        if (M < a) {
            rep(i,M) {
                x[i] = a - i;
                y[i] = a + 1 + i;
            }
        }
        else {
            rep(i,a) {
                x[i] = a - i;
                y[i] = a + 1 + i;
            }
        }
        if (a < M) {
            if (N % 4 == 2) {
                rep(i,M-a) {
                    x[a + i] = a * 3 - i;
                    y[a + i] = a * 3 + 2 + i;
                }

            }
            else {
                rep(i,M-a) {
                    x[a + i] = a * 3 - 1 - i;
                    y[a + i] = a * 3 + 1 + i;
                }
            }
        }

    }

    rep(i,M) {
        cout << x[i] << " " << y[i] << endl;
    }
}

Measured memory_bytes: 4448
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long double ld;
const ld pi=3.1415926535897932384626, eps=1e-9;
int main(){
	cout << setprecision(9);
	while(true){
		ld w,h,a,b,ab,a_c,b_c;
		cin >> w >> h >> a >> b >> ab;
		if(w<eps) break;
		a_c=a;b_c=b;
		if(a>b) swap(a,b);
		ld ra=sqrt(a/pi);
		ld rb=sqrt(b/pi);
		ld ub=pi,lb=0;
		int cnt=0;
		ld mid,phi;
		while(cnt<80){
			cnt++;
			mid=(ub+lb)/2;
			phi=asin( ra*sin(mid)/rb );
			if(ra*ra*mid-ra*ra*cos(mid)*sin(mid)+rb*rb*phi-rb*rb*cos(phi)*sin(phi)>ab) ub=mid;
			else lb=mid;
		}
		ld dis=ra*cos(mid)+rb*cos(phi);
		if(2*rb>h || 2*rb>w){
			cout << "impossible" << endl;
			continue;
		}
		if(h-ra-rb>=dis){
			if(a_c<b_c) cout << rb << " " << rb+dis << " " << ra << " " << rb << " " << rb << " " << rb << endl;
			else 		cout << rb << " " << rb << " " << rb << " " << rb << " " << rb+dis << " " << ra << endl;
			continue;
		}
		ld theta=asin( (h-ra-rb)/dis );			//(0<=()<=1   0<=theta<=pi/2)
		if(ra+rb+dis*cos(theta)>w){
			cout << "impossible" << endl;
			continue;
		}
		if(a_c<b_c) cout << rb+dis*cos(theta) << " " << h-ra << " " << ra << " " << rb << " " << rb << " " << rb << endl;
		else 		cout << rb << " " << rb << " " << rb << " " << rb+dis*cos(theta) << " " << h-ra << " " << ra << endl;
	}
	return 0;
}

Measured memory_bytes: 1308
/******************************
＜解法＞
最初に、簡単のため D=1 の場合を考えると、
入力されたN個の点を、それぞれ任意の場所に移動できることがわかる
（ただし異なる点を同じ座標に置いてはいけない）
なので、答（正方形の一辺の長さの最小値）は
sqrt(N)の小数点以下を切りあげた値-1 となる。

一般のDに対しては、
入力された点を、x,y それぞれ modD することにより、D*D個のグループに分類する。
それぞれのグループについて上記と同じ考察をすれば、
小さい正方形や、長方形で2辺の長さの差が1というものに変形することによって
全体の収まる正方形領域を小さくする、という問題になる。

各グループの点の個数を数えて、その最大値を

****************************/


#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[105];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    map<string,int> mp;
    int i;
    vector<ll> s(n+1);
    for(i=0; i<n; i++) {
        scanf("%s", str);
        mp[string(str)]=i;
        int t;
        scanf("%d", &t);
        s[i+1]=s[i]+t;
    }
    scanf("%s", str);
    int k=mp[string(str)];
    printf("%lld\n", s[n]-s[k+1]);

    return 0;
}



Measured memory_bytes: 256