akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, A, B;
    cin >> N >> A >> B;
    if(min(A, B) == 1 && max(A, B) == 2) {
        cout << "Borys" << endl;
    } else if(min(A, B) == N - 1 && max(A, B) == N) {
        cout << "Borys" << endl;
    } else {
        ll temp = abs(A - B);
        if(temp % 2) cout << "Borys" << endl;
        else cout << "Alice" << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;

int parent[N]; ll node[N], res[N];
pair<int, int> a[N];

int findSet(int a) {
  return parent[a] == a ? a : parent[a] = findSet(parent[a]);
}

void unionSet(int a, int b) {
  a = findSet(a);
  b = findSet(b);
  if (a != b) {
    node[a] += node[b];
    parent[b] = a;
  }
}

bool sameSet(int a, int b) {
  return findSet(a) == findSet(b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i].first >> a[i].second;
  }
  for (int i = 1; i <= n; i++) {
    parent[i] = i;
    node[i] = 1;
  }
  ll lol = n;
  ll ans = (lol * (lol - 1)) / 2;
  for (int i = m - 1; i >= 0; i--) {
    res[i] = ans;
    int u = a[i].first, v = a[i].second;
    if (!sameSet(u, v)) {
      ll x = node[findSet(u)], y = node[findSet(v)];
      unionSet(u, v);
      ans -= (x * y);
    }
  }
  for (int i = 0; i < m; i++) {
    cout << res[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
 
const ll mod = 1e9+7;
 
int main(){
    ll n;
    cin >> n;
    ll a = 1;
    ll b = 1;
    ll c = 1;
    rep(i, n){
        a *= 10;
        a %= mod;
        b *= 9;
        b %= mod;
        c *= 8;
        c %= mod;
    }
    ll ans = a-b-b+c;
    ans %= mod;
    ans = (ans + mod) % mod; 
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#define x first.first
#define y first.second
#define r second.first
#define color second.second

using namespace std;

typedef pair<double,double> P;
typedef pair<P,P> C;

bool check(C a,C b){
  return a.r+b.r>sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
 
int count(int bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits =(((bits >> 4) + bits) & 0x0f0f0f0f);
  bits += bits >> 8;
  return (bits + (bits >> 16)) & 0xff;
}
 
bool dp[(1<<25)];
 
int main(void){
 
	int n;
	while(cin >> n,n){
		C c[25];
		for(int i=0;i<n;i++){
			cin >> c[i].x >> c[i].y >> c[i].r >> c[i].color;
			//scanf("%lf %lf %lf %lf",&c[i].x,&c[i].y,&c[i].r,&c[i].color);
		}
		
		fill(dp,dp+(1<<n),false);
		dp[(1<<n)-1]=true;
		int ans=0;
		
		for(int S=(1<<n)-1;S>=0;S--){
			if(!dp[S])continue;
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					
					int nx=S;
					nx&=~(1<<i);
					nx&=~(1<<j);
					if(dp[nx])continue;
					
					if(!(S>>i&1) || !(S>>j&1))continue;
					if(c[i].color!=c[j].color)continue;
					
					for(int k=0;k<n;k++){
						if(!(S>>k&1))continue;
						if((k<i && check(c[i],c[k]))||(k<j && check(c[j],c[k])))goto end;
					}
					
					dp[nx]|=dp[S];
					end:;
				}
			}
			if(dp[S])ans=max(ans,n-count(S));
		}
		cout << ans << endl;
	}
   
  return 0;
}

Measured memory_bytes: 19652
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100002];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    for (int i = 1; i < s.size(); ++i)
    {
        if (s[i] == 'C' && s[i - 1] == 'A')
            a[i] = 1;
    }
    for (int i = 1; i < s.size(); ++i)
        a[i] += a[i - 1];
    for (int i = 0; i < q; ++i)
    {
        int l, r;
        cin >> l >> r; l--; r--;
        int sum = a[r];
        if (l)
        {
            sum -= a[l - 1];
            if (s[l] == 'C' && s[l - 1] == 'A')
                sum--;
        }
        cout << sum << '\n';
    }
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll a, b, t;
  cin >> a >> b >> t;

  ll ans = 0;
  for (ll i = 1; i <= t; ++i) {
    if (i % a == 0) ans += b;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
($N,$M,@A)=glob`dd`;$_+=$_<($a=shift@A)&&$M,$s+=$k=$_-$a,$@[$a]++,$@[$_-1]-=$k,$@[$_]+=$k-1for@B=@A[1..$#A];@@=map$c+=$_,$c=0,@@for a,b;$%+=$-=$@[$_]+$@[$_+$M]-$%for 1..$M;print$s-$%

Measured memory_bytes: 57424
import scala.io.StdIn.{readInt, readLine};
import scala.annotation.tailrec;
object Main {
    def main(args: Array[String]): Unit = {
        val size = readInt;
        val m = new Array[Array[Int]](size);
        (0 until size).foreach {  i => m(i) = readLine.trim.split(" ").map( a => if (a.toInt == -1) Int.MaxValue else a.toInt)}
        val g = new Graph(size, m);
        val (parent, distance) = g.prim;
        println(distance.sum)
    }
}
case class Graph(size: Int, matrix: Array[Array[Int]]) {
    val INFINITY = Int.MaxValue
    def prim(): (Array[Int], Array[Int]) = {
        // WHITE : 未訪問, GRAY: MST候補ノード, BLACK: MST追加済みノード
        val WHITE = 0; val GRAY = 1; val BLACK = 2;
        val color = new Array[Int](size); // 訪問状態リスト(WHITE, GRAY, BLACK)
        val distance = new Array[Int](size).map( e => INFINITY); //  重みリスト
        val parents = new Array[Int](size); //  親ノードリスト
        @tailrec
        def _prim(curr: Int): Unit = {
            // MSTに属する頂点の集合から最も近いノードの index を取得する
            val idx = (0 until size).foldLeft(-1) { (minidx, i) =>
                if (color(i) != BLACK) {
                    // curr の子ノードをMST候補ノードに追加
                    if (matrix(curr)(i) != -1) {
                        color(i) = GRAY;
                    }
                    if (color(i) == GRAY) {
                        // すでに登録されている重みよりも curr からの重みのほうが小さい場合は
                        // 親ノードと重みを更新する
                        if (matrix(curr)(i) < distance(i)) {
                            distance(i) = matrix(curr)(i);
                            parents(i) = curr;
                        }
                        if (minidx == -1 || distance(i) < distance(minidx)) i else minidx;
                    } else { // color(i) == WHITE
                        // 現時点のMSTに隣接していないノードは評価しない
                        minidx;
                    }
                } else { // color(i) == BLACK 
                    // すでにMSTに追加されているノードは評価しない
                    minidx;
                }
            }
            if (idx != -1){
                // MSTから最も距離の近いノードを追加
                color(idx) = BLACK;
                _prim(idx);
            }
        }
        distance(0) = 0;
        parents(0) = -1;
        color(0) = BLACK;
        _prim(0);
        (parents, distance);
    }
}


Measured memory_bytes: 48760
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int A;
    string S;
    cin >> A >> S;


    auto solve = [&]() {
        if (A >= 3200)return S;
        return string("red");
    };

    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef pair<int, int> p;

int n, m, x;

int main(int argc, char *argv[]) {
    scanf("%d %d %d", &n, &m, &x);
    int a = 0, b = 0;
    for (int i = 0; i < m; ++i) {
        int tmp;
        scanf("%d", &tmp);
        if (tmp < x) {
            ++a;
        } else {
            ++b;
        }
    }
    printf("%d\n", min(a, b));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] h = new int[n];
        for(int i=0; i<n; i++) {
            h[i] = in.nextInt();
        }
        int[] dp = new int[n];
        dp[n-1] = 0;
        dp[n-2] = 0;
        dp[n-2] = Math.abs(h[n-1]-h[n-2]);
        for(int i=n-3; i>=0; i--) {
            dp[i] = Math.min(Math.abs(h[i+1]-h[i])+dp[i+1], Math.abs(h[i+2]-h[i])+dp[i+2]);
        }
        System.out.println(dp[0]);
    }
}


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

int main() {
  vector<int>  N(4);
  int i, j = 0;
  for (i = 0; i < 4; i++) {
	  cin >> N.at(i);
  }
  
  sort(N.begin(), N.end()); // vector
  if(N.at(0) == 1&&N.at(1) == 4&&N.at(2) == 7&&N.at(3) == 9) cout << "YES" << endl;
  else cout << "NO" <<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  scanf("%d", &a);
  if(a == 25)  printf("Christmas\n");
  else if(a == 24) printf("Christmas Eve\n");
  else if(a == 23) printf("Christmas Eve Eve\n");
  else if(a == 22) printf("Christmas Eve Eve Eve\n");
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
R,G,B,N=[int(x) for x in stdin.readline().rstrip().split()]
ans=0
for r in range(0,N//R+1):
    for g in range(0,(N-(R*r))//G+1):
        if (N - R*r - G*g) % B == 0:
            ans+=1
print(ans)

Measured memory_bytes: 3060
import heapq
N = int(input())
town = []
for i in range(N):
    x, y = map(int, input().split())
    town.append((x, y, i))

uf = [i for i in range(N)]      #uf[i]==iであれば根

def root(x):
    if x == uf[x]:
        return x
    else:
        r = root(uf[x])
        uf[x] = r
        return r

def isSame(x,y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if x==y:
        return
    uf[x] = y
    return

road = []
town.sort() #x座標でソート O(NlogN + N)
for i in range(N-1):
    x1, _, ind1 = town[i]
    x2, _, ind2 = town[i+1]
    cost = abs(x2 - x1)
    heapq.heappush(road, (cost, ind1, ind2))
town.sort(key = lambda x:x[1]) #y座標でソート O(NlogN + N)
for i in range(N-1):
    _, x1, ind1 = town[i]
    _, x2, ind2 = town[i+1]
    cost = abs(x2 - x1)
    heapq.heappush(road, (cost, ind1, ind2))

ans = 0
while road: #O(2N)
    cost, i, j = heapq.heappop(road)
    if isSame(i,j):
        continue
    unite(i, j)
    ans += cost

print(ans)


Measured memory_bytes: 47048
#include <bits/stdc++.h>
using namespace std;
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i,a) repi(i,0,a)
#define all(u) begin(u),end(u)
#define pb push_back
const int inf = 1e9;
const double eps = 1e-9;
struct point{
    double x, y, z;
    point():x(0),y(0),z(0){}
    point(double x, double y, double z):x(x),y(y),z(z){}
    point operator+(const point &p) const{ return point(x+p.x, y+p.y, z+p.z);}
    point operator-(const point &p) const{ return point(x-p.x, y-p.y, z-p.z);}
    point operator*(const double &d) const{ return point(x*d, y*d, z*d);}
    point operator/(const double &d) const{ return point(x/d, y/d, z/d);}
};
struct sphere{
    point p; double r;
    sphere(point p, double r):p(p),r(r){}
};
struct line{
    point a, b;
    line(point a, point b):a(a),b(b){}
};
int N, M, R;
point obj;
vector<sphere> bal;
vector<point> src;
vector<int> rmv[16];
double br[16];

inline double norm(const point &a){ return a.x*a.x+a.y*a.y+a.z*a.z;}
inline double abs(const point &a){ return sqrt(norm(a));}
inline double dot(const point &a, const point &b){ return a.x*b.x+a.y*b.y+a.z*b.z;}
point proj(const line &l, const point &p){
    double t = dot(p-l.a, l.a-l.b) / norm(l.a-l.b);
    return l.a+(l.a-l.b)*t;
}
bool intersect(const line &l, const sphere &s){
    point a = l.a-s.p, b = l.b-s.p, c = proj(l,s.p)-s.p;
    if(abs(a) < s.r-eps and abs(b) < s.r-eps and abs(c) < s.r-eps)
	{
		return 0; // contain
	}
    if(abs(c) > s.r+eps) return 0; // far
    if(abs(a) < s.r-eps or abs(b) < s.r-eps) return 1; // intersect
    if(abs(a-c)+abs(b-c)<abs(a-b)+eps) return 1; // intersect
    return 0;
}

double solve(){
    rep(i,M) rmv[i].clear();
    rep(i,M)rep(j,N)
        if(intersect(line(src[i],obj), bal[j]))
		{
			rmv[i].pb(j);
		}
    double ans = 0.;
    rep(S,1<<M){
        bool rm[2048] = {};
        int cnt = 0; double sum = 0.;
        rep(i,M)if((S>>i)&1){
            rep(j,rmv[i].size()) if(!rm[rmv[i][j]]){
                rm[rmv[i][j]] = 1;
                cnt++;
            }
            sum += br[i]/norm(src[i]-obj);
        }
        if(cnt <= R) ans = max(ans, sum);
    }
    return ans;
}

bool input(){
    cin >> N >> M >> R;
    if(!N and !M and !R) return 0;
    int x, y, z, r;
    bal.clear(); src.clear();
    rep(i,N){
        cin >> x >> y >> z >> r;
        bal.pb(sphere(point(x,y,z),r));
    }
    rep(i,M){
        cin >> x >> y >> z >> r;
        src.pb(point(x,y,z));
        br[i] = r;
    }
    cin >> x >> y >> z;
    obj = point(x,y,z);
    return 1;
}
int main(){
    while(input()) printf("%.8f\n", solve());
    return 0;
}

Measured memory_bytes: 1376
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-05-18 20:41:30
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e3 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , xs , ys , xt , yt , mark[MAXN] , x[MAXN] , y[MAXN] , r[MAXN];
double dist[MAXN] , D[MAXN][MAXN];
vector<pair<pll , ll>> C;
vector<pair<ll , double>> adj[MAXN];

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

    cin >> xs >> ys >> xt >> yt >> n;
    C.push_back({{xs , ys} , 0});
    C.push_back({{xt , yt} , 0});
    for(int i = 0 ; i < n ; i++)    cin >> x[i] >> y[i] >> r[i] , C.push_back({{x[i] , y[i]} , r[i]});
    for(int i = 0 ; i < n + 2 ; i++){
        for(int j = i + 1 ; j < n + 2 ; j++){
            ll ax = C[i].X.X , ay = C[i].X.Y , ar = C[i].Y;
            ll bx = C[j].X.X , by = C[j].X.Y , br = C[j].Y;
            double d = sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by)) - ar - br;
            d = max(d , double(0));
            D[i][j] = D[j][i] = d;
        }
    }
    
    fill(dist , dist + MAXN , INF) ; dist[0] = 0;
    for(int i = 0 ; i < n + 2 ; i++){
        int v = MAXN - 1;
        for(int j = 0 ; j < n + 2 ; j++)    if(!mark[j] && dist[j] < dist[v])   v = j;
        mark[v] = 1;
        for(int j = 0 ; j < n + 2 ; j++){
            if(dist[j] > dist[v] + D[v][j]){
                dist[j] = dist[v] + D[v][j];
            }
        }
    }
    printf("%.10f" , dist[1]);

    return 0;
}
/*

*/


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N, K; cin >> N >> K;
  int res{};
  for (int i = 0; i < N; ++i) {
    int x; cin >> x;
    auto r0 = std::abs(x - 0);
    auto r1 = std::abs(x - K);
    res += std::min(r0, r1) * 2;
  }

  auto ans = res;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a[n];
    int cnt[100001];
    fill(cnt,cnt+100001,0);
    rep(i,0,n){
        cin>>a[i];
        if(a[i]>0)cnt[a[i]-1]++;
        cnt[a[i]]++;
        cnt[a[i]+1]++;
    }
    int ans=0;
    rep(i,0,100001)Max(ans,cnt[i]);
    cout<<ans<<endl;
    
}





Measured memory_bytes: 1024
map{*I=-$_;<>=~$",vec($I,$`-1,8)=$'+49for 1..<>;$Z.='{0,2}'}1..<>;
printf sort{$b-$a}map{
	$t=$_;
	map{$i=0;$i--,/2/&&($t|=$$i)for$t=~/./g}1..5;
	$_=$t;
	!/3/*y/2//
}glob$Z

Measured memory_bytes: 5168
n=int(input())+1
table0=[0]*10001
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      r=x*x+y*y+z*z+x*y+y*z+x*z
      if r<n:
        table0[r]+=1
for i in range(1,n):
  print(table0[i])

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

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

    map<int, int> mp;
    for (int i = 1; i <= n; ++i) {
        mp[i] = 0;
    }
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        mp[a]++, mp[b]++;
    }
    
    for (auto i : mp) {
        cout << i.second << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

vector<lld> fact,inv;


lld f(lld a,lld b, lld p)  // a^b mod pを求める
{
	if (b == 0)
	{
		return 1;
	}else if (b % 2 == 0)
	{
		lld d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else
	{
		return a * f(a,b-1,p) % mod;
	}
}

void init(lld n)
{
	fact.resize(n+1,1);
	inv.resize(n+1,1);

	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
	{
		fact[i] = fact[i-1] * i % mod;
	}
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
	{
		inv[i] = f(fact[i],mod-2,mod) % mod;
	}
}

lld comb(lld n,lld k)  //n_C_k
{
	if (n < k)
	{
		return 0;
	}
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}


int main()
{
	string s;
	cin >> s;
	lld n = s.size();
	init(n+1);

	lld al[26] = {0};
	for(int i = 0; i < n; i++)
	{
		al[s[i]-'a']++;
	}

	lld d = 0;
	for(int i = 0; i < 26; i++)
	{
		d += al[i]*(al[i]-1)/2;
	}

	cout << n*(n-1)/2 - d + 1 << endl;

	return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define ll long long
#define l long
#define all(x) x.begin(),x.end()
#define pb push_back
#define len(x) x.len
int main()
{


int n;
cin>>n;
if(n%1000==0) cout<<0;
else
{
    int y=n/1000;
    ++y;
    cout<<y*1000-n;
}


return 0;}

Measured memory_bytes: 3632
//Keep working hard :)
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

const int N = 50+5;
bool visited[N];
int low[N],tin[N];
int n,m;
vector<int> G[N];
set<pair<int,int>> s;
int timer;

void is_bridge(int a, int b){
    s.insert({a,b});
}
void dfs(int node, int p = -1)
{
    visited[node] = true;
    int v = node;
    tin[v] = low[v] = timer++;
    for(auto to : G[node])
    {
        if(to == p)continue;
        if(visited[to])
        {
            low[node] = min(low[node],tin[to]);
        }
        else
        {
            dfs(to,node);
            low[node] = min(low[node],low[to]);
            if(low[to] > tin[v])is_bridge(v,to);
        }
    }
}

void find_bridge()
{
    memset(tin,-1,sizeof(tin));
    memset(low,-1,sizeof(low));
    memset(visited,false,sizeof(visited));
    timer = 0;
    for(int i = 1; i <= n; i++)
    {
        if(!visited[i])
        {
            dfs(i);
        }
    }
}
void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}

int main()
{
	IOS;
    //fileIO();
    cin >> n >> m;
    for(int i = 1; i <= m ; i++)
    {
        int u,v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    find_bridge();
    cout << s.size();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,s=0,i;
  cin>>n;
  for(i=1;i<=1e7;i++){
  s=(s*10+7)%n;
  if(s==0) {cout<<i;exit(0);}
  }
 cout<<-1;
return 0;  
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	int k = 0;
	while(k < n-1 && a[k] == a[k+1]) k++;
	bool state = (a[k] < a[k+1]);
	int ans = 1;
	FOR(i, k+1, n-1){
		if(state && a[i] > a[i+1]){
			ans++;
			if(i != n-2){
				while(i < n-2 && a[i+1] == a[i+2]) i++;
				state = (a[i+1] < a[i+2]);
			} 
		}
		if(!state && a[i] < a[i+1]){
			ans++;
			if(i != n-2){
				while(i < n-2 && a[i+1] == a[i+2]) i++;
				state = (a[i+1] < a[i+2]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

// Trying out constant mod
const int mod = 1e9 + 7; 
int n, m, k, a, b, c, d;
vector< long long > factorial( 2e5 + 5, 1 ), dp( 3e3 + 3, 0 );
vector< pair< int, int > > arr;
 
void precompute( void )
{
	for( int i = 2; i <= 2e5 + 4; ++i )
	{
		factorial[ i ] = ( factorial[ i - 1 ] * i ) % mod;
	}
}
 
long long inv( long long a, long long p )
{
	long long res = 1;
	while( p > 0 )
	{
		if( p & 1 )
		{
			res *= a;
			res %= mod;
		}
		a *= a;
		a %= mod;
		p >>= 1;
	}
	return res;
}
 
long long nCr( int n, int r )
{	
	long long res = factorial[ n ];
	res = ( res * inv( factorial[ r ], mod - 2 ) ) % mod;
	res = ( res * inv( factorial[ n - r ], mod - 2 ) ) % mod;
	return res;
}
 
int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	precompute();
	cin >> n >> m >> k;
	for( int i = 1; i <= k; ++i )
	{
		cin >> a >> b;
		arr.emplace_back( a, b );		
	}
	sort( arr.begin(), arr.end() );
	arr.emplace_back( n, m );
	for( int i = 0; i <= k; ++i )
	{
		c = arr[ i ].first;
		d = arr[ i ].second;
		dp[ i ] = nCr( c + d - 2, c - 1 );
		for( int j = 0; j <= i - 1; ++j )
		{
			a = arr[ j ].first;
			b = arr[ j ].second;
			if( a <= c && b <= d )
			{
				dp[ i ] -= dp[ j ] * nCr( c - a + d - b, c - a );
				dp[ i ] %= mod;
				dp[ i ] += mod;
				dp[ i ] %= mod;
			}
		}
	}
	cout << dp[ k ] << "\n";
	return 0;
}


Measured memory_bytes: 4616
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
using namespace std;

bool check(int n,int l,int r){
    for(int i=l;i<=r;i++){
        if(i%n==0) return true;
    }
    return false;
}

int main() {
    fast
	int t=1;
// 	cin>>t;
	while(t--){
	    int n;
	    cin>>n;
	    int l,r;
	    cin>>l>>r;
	    if(check(n,l,r)) cout<<"OK";
	    else cout<<"NG";
	}
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define MAX_N 100000

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

  vector<ll> a;
  
  ll c;
  REP(i, n){
    cin >> c;
    a.push_back(c);
  }

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

  ll ans = n;
  int flag = 0;
  FOR(i, 1, n){
    if(a[i] != a[i - 1]){
      flag = 0;
    }else if(flag == 0){
      flag = 1;
      ans -= 2;
    }else{
      flag = 0;
    }
  }

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

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int N;
long long h[100010];


long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;

    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N-1] << endl;
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<int> v(N, 0);
    for (int i = 1; i < N; i++) {
        v[i] += v[i - 1];
        if (s.substr(i - 1, 2) == "AC") {
            v[i]++;
        }
    }
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        cout << v[r] - v[l] << endl;
    }
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
#if !DEBUG
    using System.IO;
#endif

public class Program {
    public static void Main() {
        #region SetAutoFlushIsFalse
#if !DEBUG
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
#endif
        #endregion
        var n = ReadLib.ReadAsInt();
        var aArr = ReadLib.ReadAsIntArray();

        
        Console.WriteLine(aArr.Max() - aArr.Min());
        #region Flush
#if !DEBUG
        Console.Out.Flush();
        sw.Close();
#endif
        #endregion

    }
}

static class ReadLib {
    public static long ReadAsLong() {
        return long.Parse(Console.ReadLine());
    }

    public static int ReadAsInt() {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadAsIntArray() {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    public static long[] ReadAsLongArray() {
        return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static ulong[] ReadAsULongArray() {
        return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
    }

    public static string[] ReadAsStringArray() {
        return Console.ReadLine().Split(' ');
    }

    public static int[] ReadNTimesAsInt(int n) {
        return Enumerable.Range(1, n).Select(s => int.Parse(Console.ReadLine())).ToArray();
    }

    public static int[][] ReadNTimesAsIntArray(int n) {
        return Enumerable.Range(1, n).Select(s => ReadAsIntArray()).ToArray();
    }

}

Measured memory_bytes: 11476
#include <stdio.h>
#include <math.h>
int main(void){
	double x,h,t,area;
	while(scanf("%lf %lf",&x,&h),x+h){
		area=0;
		area+=(double)x*x;
		x/=2;
		t=sqrt(x*x+h*h);
		area+=x*t*4;
		printf("%f\n",area);
	}
	return 0;
}

Measured memory_bytes: 644
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    print(S.count('ABC'))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.next();
        long count = 0;
        int wIndex = 0;
        for (int i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == 'W') {
                count += i - wIndex;
                ++wIndex;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26052
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 2;

const int MAX_W = 80;
const int MAX_H = 80;
const int MAX_A = 80;
const int MAX_DIFF = (MAX_W + MAX_H) * MAX_A;

bool memo[MAX_H + 1][MAX_W + 1][MAX_DIFF + 1];

vector<vector<int>> grid;

int solve(const int H, const int W) {
    memo[0][0][0] = true;
    memo[0][1][0] = true;
    memo[1][0][0] = true;

    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            // from up
            for (int i = 0; i <= MAX_DIFF; i++) {
                if (memo[h - 1][w][i]) {
                    memo[h][w][abs(i + grid[h][w])] = true;
                    memo[h][w][abs(i - grid[h][w])] = true;
                }
            }

            // from left
            for (int i = 0; i <= MAX_DIFF; i++) {
                if (memo[h][w - 1][i]) {
                    memo[h][w][abs(i + grid[h][w])] = true;
                    memo[h][w][abs(i - grid[h][w])] = true;
                }
            }
        }
    }

    for (int i = 0; i <= MAX_DIFF; i++) {
        if (memo[H][W][i]) {
            return i;
        }
    }

    return INF;
}

int main(void) {
    int H, W;
    cin >> H >> W;

    grid.resize(H + 1, vector<int>(W + 1, 0));
    // for A
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> grid[i][j];
        }
    }
    // for B
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            int b;
            cin >> b;
            grid[i][j] = abs(grid[i][j] - b);
        }
    }

    // cout << "grid: " << endl;
    // for (int i = 0; i <= H; i++) {
    //     for (int j = 0; j <= W; j++) {
    //         cout << grid[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    cout << solve(H, W) << endl;

    return 0;
}


Measured memory_bytes: 80896
/*
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll factor(ll x) {
	ll ret = 1;
	ll tmp = 0;
	for (ll p = 2;;p++) {
		if (x == 1) {
			ret *= tmp + 1;
			break;
		}
		if (x % p == 0) {
			tmp += 1;
			x /= p;
			p--;
			continue;
		}
		ret *= tmp + 1;
		tmp = 0;
	}
	return ret;
}

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

	ll N;
	cin >> N;
	ll ans = 0;

	for (ll i = 1; i <= N; i++) {
		ll ret = factor(i);
		ll tmp = ret;
		ans += i * tmp;
	}

	cout << ans << endl;



EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}


*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

	string S;
	cin >> S;

	if (S == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}

EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 3176
console.log((args=>{
  const [_N,s,t] = args.trim().split`\n`, N = _N|0;
  S: for ( let i = 0; i < N; i++ ) {
    for ( let j = 0; i+j < N; j++ ) {
      if ( s[i+j] !== t[j] ) continue S;
    }
    return i + N;
  }
  return N+N;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  string s;
  cin >> s;
  int64_t wcnt = 0;
  int64_t wdist = 0; 
  rep(i,s.size()){
    if(s.at(i) == 'W'){
      wcnt++;
      wdist += i;
    }
  }
  cout << wdist - (wcnt - 1)*wcnt/2 << endl;
  
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s= sc.next();
		String buff= "";
		//double n = sc.nextInt()/1000.0;
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		//String s=sc.next();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		//int[] array = new int[m];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		//Arrays.sort(array);

		for(int i=0;i<s.length();i++) {
			if((i+1)%2==0) {
				if((char)s.charAt(i)=='R') {
					System.out.println("No");//R, U, D のいずれか。偶数文字目がすべて L, U, D の
					System.exit(0);
				}
			}else {
				if((char)s.charAt(i)=='L') {
					System.out.println("No");//R, U, D のいずれか。偶数文字目がすべて L, U, D の
					System.exit(0);
				}
			}
		}
		/*for(int i=0;i<m;i++) {
			if(array[i]>=k) {
				count++;
			}
		}*/

		/*if(count==0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}*/

		System.out.println("Yes");
	}
}




Measured memory_bytes: 23124
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = 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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


vll par(100005);
vll siz(100005);

void init(ll n){
    rep(i,n){
        par[i]=i;
        siz[i]=1ll;
    }
}

ll root(ll x){
    return (par[x]==x)?x:par[x]=root(par[x]);
}

void unite(ll x, ll y){
    x=root(x); y=root(y);
    if(x==y) {return;}
    if(x<y){
        siz[x]+=siz[y];
        par[y]=x;
    }else{
        siz[y]+=siz[x];
        par[x]=y;
    }
}

bool same(ll x, ll y){
    return root(x)==root(y);
}


int main() {
    vector<vll> gm(100005,vll(0));
    vector<vll> gk(100005,vll(0));
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n,m,k;
    cin>>n>>m>>k;

    init(n);

    //友人
    rep(i,m){
        ll a,b;cin>>a>>b;
        --a;--b;
        unite(a,b);
        gm[a].push_back(b);
        gm[b].push_back(a);
    }

    //ブロック
    rep(i,k){
        ll a, b;cin>>a>>b;
        --a;--b;
        gk[a].push_back(b);
        gk[b].push_back(a);
    }

    rep(i,n){
        ll ans= siz[root(i)] - gm[i].size() -1;
        for(auto u: gk[i]){
            if(same(i,u))ans--;
        }
        cout<<ans<<" ";
    }

    return 0;
}

Measured memory_bytes: 16860
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

//Referin to exp.
int main(){
	llong t[2],a[2],b[2];
	REP(i,2) cin>>t[i];
	REP(i,2) cin>>a[i];
	REP(i,2) cin>>b[i];
	
	llong p[2];
	if(a[0]<b[0]) swap(a,b);
	REP(i,2) p[i]=(a[i]-b[i])*t[i];
	
	if(p[0]+p[1]==0){
		cout<<"infinity"<<endl;
		return 0;
	}else if(p[0]+p[1]>0){
		cout<<0<<endl;
		return 0;
	}
	
	llong cnt=p[0]/abs(p[0]+p[1]);
	if(p[0]%abs(p[0]+p[1])) cnt=cnt*2+1;
	else cnt*=2;
	
	cout<<cnt<<endl;
}


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

const int r=1e9+7;
int main(){

ll n;
cin>>n;

ll arr[n+1];
ll arr1[n+1];
for(int i=0;i<n;i++){
    cin>>arr[i];

}
int a=0;
ll sum=0;
ll b=0;
for(int i=n-1;i>0;i--){
    b+=arr[i];
    sum+=((b%r)*(arr[i-1])%r)%r;
    sum%=r;
}
cout<<sum%r;
return 0;
}


Measured memory_bytes: 5160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		String ans;
		String str;
		str = bf.readLine();
		switch(str) {
		case "A":
			ans = "T";
			break;
		case "T":
			ans = "A";
			break;
		case "G":
			ans = "C";
			break;
		case "C":
			ans = "G";
			break;
		default:
			ans = "";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21072