akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
unordered_map<int,vector<int>> friends,block;
void dfs(int i,unordered_map<int,int> &blocked,vector<int> &visited,vector<int> &component)
{
    visited[i]=1;
    component.push_back(i);
    for(auto it:block[i])
    {
        blocked[it]++;
    }
    for(auto it:friends[i])
    {
        if(!visited[it])
        dfs(it,blocked,visited,component);
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,m,k;
  cin>>n>>m>>k;
  for(int i=0;i<m;i++)
  {
      int x,y;
      cin>>x>>y;
      friends[x].push_back(y);
      friends[y].push_back(x);
  }
  for(int i=0;i<k;i++)
  {
      int x,y;
      cin>>x>>y;
      block[x].push_back(y);
      block[y].push_back(x);
  }
  vector<int> visited(n+1,0);
  vector<int> ans(n+1);
  for(int i=1;i<=n;i++)
  {
      if(visited[i])
      continue;
      unordered_map<int,int> blocked;
      vector<int> component;
      dfs(i,blocked,visited,component);
      for(auto it:component)
      {
        ans[it]=(component.size()-friends[it].size()-blocked[it]-1);
      }
  }
  for(int i=1;i<=n;i++)
  cout<<ans[i]<<" ";
  return 0;
}

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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);

vector <int> a;

void input(int &n){
	cin >> n;
	for(int i = 0;i < n;i++){
		int t;
		cin >> t;
		a.pb(t);
	}
}

main() {
	did_you_calis_enough
	int n;
	cin >> n;
	return cout << bool(!n) , 0;
}

//Coded by LoliThief


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;
typedef pair<int, char> ICpair;

vector<int> A;
int nextNonZero[300000];

int N, x;

int main() {
	ios_base::sync_with_stdio(false);
	A.clear();
	cin >> N;
	A.clear();
	FOR (i, N) {
		cin >> x;
		A.pb(x);
	}

	LL ret = 0LL;
	int last = N;
	for (int i = N - 1; i > -1; i--) {
		nextNonZero[i] = last;
		if (A[i] != 0)
			last = i;
	}
	
	FOR (i, N) {
		LL sum = 0LL, XOR = 0LL;
		int j = i, k, cnt = 0;
		while (j < N && cnt < 100) {
			sum += A[j];
			XOR ^= A[j];
			if (sum == XOR)
				ret += nextNonZero[j] - j;
			cnt++;
			j = nextNonZero[j];
		}
	}
	
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1908
//
// [解法]
// この問題は、AとBの両方を隣接頂点として持つ頂点だけに限定して考えてもよいことがわかる
// （なぜなら、クヌースがそのような頂点に到達してしまった場合、次にAまたはBに進めといわれても進めなくなってしまうから、
//   最初からクヌースはそこに行けないとしてしまってもよい）
// なので、「隣接頂点にAまたはBを持たない頂点」を消す、という処理を繰り返せばよい。
// 具体的には、最初にn点全てをチェックして消すべき頂点をリストアップした後、
// 消すべき頂点を消す→その隣りを次回に削除すべき候補かチェックすべきリスト(queue)にためておく
// ということを繰り返せばよい。（計算量も頂点の数＋エッジの数程度ですむ）
// そして、その作業が終了したあと、頂点が1個以上残っていれば「Yes」としてよい
// （なぜなら、クヌースはそのうちどこか(AまたはB)の頂点からスタートして、AまたはBに移動することを永遠に続けることができるから）
// 頂点が残っていなかったら「No」になる
//
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#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
#define MOD 1000000007
using namespace std;

char str[200005];

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);
    scanf("%s", str);

    vector<vector<long> > z(n);

    long i,j;
    for(i=0; i<m; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        z[a-1].push_back(b-1);
        z[b-1].push_back(a-1);
    }

    queue<long> que;
    for(i=0; i<n; i++) {
        long a=0, b=0;
        for(j=0; j<z[i].size(); j++) {
            if(str[z[i][j]]=='A') a++;
            else                  b++;
        }
        if(a==0||b==0) {
            que.push(i);
        }
    }

    vector<long> flag(n, 0);
    while( !que.empty() ) {
        long i = que.front();
        que.pop();

        if(flag[i]) continue;

        long a=0, b=0;
        for(j=0; j<z[i].size(); j++) {
            if(!flag[z[i][j]]) {
                if(str[z[i][j]]=='A') a++;
                else                  b++;
            }
        }
        if(a==0||b==0) {
            flag[i]=1;
            for(j=0; j<z[i].size(); j++) {
                if(!flag[z[i][j]]) {
                    que.push( z[i][j] );
                }
            }
        }
    }

    for(i=0; i<n; i++) {
        if(flag[i]==0) {
            printf("Yes\n"); return 0;
        }
    }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 14080
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()
mod = 10**9+7

ans = 1
x,y,z = -1,-1,-1
for i in range(N):
    a = A[i]
    k = [x,y,z].count(a-1)
    if k == 3:
        ans *= 3
        ans %= mod
        z += 1
    elif k == 2:
        ans *= 2
        ans %= mod
        if x == a-1:
            x = a
        elif y == a-1:
            y = a
        else:
            z = a
    elif k == 1:
        if x == a-1:
            x = a
        elif y == a-1:
            y = a
        else:
            z = a
    else:
        print(0)
        exit()

print(ans)


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


void solve(long long A, long long B, long long C){
	cout<<min(B/A,C)<<endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [int(input())for _ in range(n)]
if A[0] != 0:
    print(-1)
    exit()

ans = A[-1]
for a, prev_a in reversed(tuple(zip(A, A[1:]))):
    if a == prev_a-1:
        continue
    if a < prev_a-1:
        print(-1)
        break
    ans += a
else:
    print(ans)


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

vector<long long> divide(string S)
{
    vector<long long> t;
    char tempS = S[0];
    long long temp = 0;
    for(int i = 0;i<S.size();i++)
    {
        if(S[i] == tempS)
        {
            temp++;
        }
        else
        {
            t.push_back(temp);
            temp = 1;
            tempS = S[i];
        }
    }
    t.push_back(temp);
    
    return t;
}

long long turn(long long x)
{
    return x/2;
}

int main()
{
    string S;
    cin >> S;
    long long K;
    cin >> K;
    
    //先頭と最後が同じ
    
    vector<long long> val = divide(S);
    int len = (int)S.size();
    int N = (int)val.size();
    long long ans = 0;
    if(S[0] == S[len-1])
    {
        //文字一つだけ
        if(N == 1)
        {
            ans = turn(val[0] * K);
        }
        else
        {
            //先頭 1
            ans += turn(val[0]);
            //ワードの中身 *K
            for(int i = 1;i<N-1;i++)
            {
                ans += turn(val[i]) * K;
            }
            //接続部分 *(K-1)
            ans += turn(val[0] + val[N-1]) * (K-1);
            //ラスト 1
            ans += turn(val[N-1]);

        }
    }
    //それ以外
    else
    {
       //ワードの中身 *K
        for(int i = 0;i<N;i++)
        {
            ans += turn(val[i]) * K;
        }
    }
    
    cout << ans << endl;
    //cout << K << endl;
    
   
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int main() {
    int L;
    while (cin >> L) {
        int N = 0;
        int pow = 1;
        while (pow <= L) pow *= 2, ++N;
        int M = (N-1)*2 + __builtin_popcount(L) - 1;
        
        cout << N << " " << M << endl;
        for (int i = 0; i < N-1; ++i) {
            cout << i+1 << " " << i+2 << " " << 0 << endl;
            cout << i+1 << " " << i+2 << " " << (1<<i) << endl;
        }
        int cur = 1<<(N-1);
        for (int i = N-2; i >= 0; --i) {
            if (L & (1<<i)) {
                cout << i+1 << " " << N << " " << cur << endl;
                cur += (1<<(i));
            }
        }
        
    }
}































Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n = 0, i = 1, j = 1, k = 1, cnt = 0;

    cin >> n;

    for (i = 1; i < n; i++) {
        for (j = 1; j < n; j++) {
            k++;
            cnt += 1;
            if (i * j + k > n) {
                break;
            }
        }
        k = 1;
    }
    cout << cnt;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main() {
    ll N; cin >> N;
    vll a(N);
    rep(i, N) cin >> a[i];

    vll cnt(100, 0);
    rep(bit, 61) {
        rep(i, N) if(a[i]>>bit&1) cnt[bit]++;
    }

    mint ans = 0;
    rep(bit, 61) {
        ans += modpow((mint)2, bit) * cnt[bit] * (N - cnt[bit]) ;
    }
    cout << ans << endl;
}


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

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-8

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

int n,m,k,X,Y;
char a[1005][1005];
int d[1005][1005];
int dx[]={0,0,1,0,-1},dy[]={0,1,0,-1,0};
vector<pii> v;
queue<pii> q;

void dfs(int x,int y)
{
	memset(d,-1,sizeof(d));
	d[x][y]=0;
	q.push(MP(x,y));
	while(!q.empty())
	{
		int tx=q.front().first;
		int ty=q.front().second;
		q.pop();
		for(int i=1;i<=4;i++)
		{
			int nx=tx+dx[i],ny=ty+dy[i];
			if(d[nx][ny]!=-1||nx<1||ny<1||nx>n||ny>m||a[nx][ny]!='.') continue;
			d[nx][ny]=d[tx][ty]+1;
			q.push(MP(nx,ny));
		}
	}
}

int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='S')
			{
				a[i][j]='.';
				X=i,Y=j;
			}
		}
	}
	dfs(X,Y);
	int mi=INF;
	for(X=1;X<=n;X++)
	{
		for(Y=1;Y<=m;Y++)
		{
//			cout<<d[X][Y]<<" ";
			if(d[X][Y]>k||d[X][Y]==-1) continue;
			mi=min(mi,n-X);
			mi=min(mi,m-Y);
			mi=min(mi,Y-1);
			mi=min(mi,X-1);
		}
//		cout<<endl;
	}
	cout<<1+(mi+k-1)/k;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
typedef long long LL;
const LL p = 1e9 + 7;

LL pow(LL a, LL b, LL p) {
    LL ans = 1;
    a %= p;
    while (b) {
        if (b & 1) {
            ans = (ans % p) * (a % p) % p;
        }
        b /= 2;
        a = (a % p) * (a % p) % p;
    }
    ans %= p;
    return ans;
}

LL inv(LL x, LL p) {
    return pow(x, p - 2, p);
}

LL C(LL n, LL m, LL p) {
    if (m > n) {
        return 0;
    }
    LL up = 1, down = 1;
    for (int i = n - m + 1; i <= n; i++) {
        up = up * i % p;
    }
    for (int i = 1; i <= m; i++) {
        down = down * i % p;
    }
    return up * inv(down, p) % p;
}

LL Lucas(LL n, LL m, LL p) {
    if (m == 0) {
        return 1;
    }
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}

int main() {
    LL n, a, b, ans = 0;
    cin >> n >> a >> b;
    LL cnt = pow(2, n, p);
    //ans = (cnt - 1 - C(n, a, p) - C(n, b, p) + (p << 1)) % p;
    ans = (cnt - 1 - Lucas(n, a, p) - Lucas(n, b, p) + (p << 1)) % p;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  	char a;
  	cin >> a;
  	if(isupper(a)) cout << 'A' << endl;
  	else cout << 'a' << endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int ans = 0;
    for(int i = 0; i < n; i++) {
      if(i < (n - 1)) {
        if(s.charAt(i) != s.charAt(i + 1)) ans++;
      } else {
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 24404
#include<stdio.h>
#include <stdlib.h>
void qsort(
  void *base, size_t num, size_t size,
  int (*compare)(const void *a, const void *b)
);
int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void){
  long int n;
  long int ans=0;
  scanf("%d",&n);
  int a[n],b[n],c[n];
  
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  for(int i=0;i<n;i++){
    scanf("%d",&c[i]);
  }
  qsort(a, sizeof(a) / sizeof(int), sizeof(int), asc);
  qsort(c, sizeof(c) / sizeof(int), sizeof(int), asc);
  
  for(int i=0;i<n;i++){
    int l=0;
    int r=n;
    while(r!=l){
      if(b[i] > a[(r+l)/2]){
        l=(r+l)/2+1;
      }
      else{
        r=(r+l)/2;
      }
    }
    int L=0;
    int R=n; 
    while(R!=L){    
      if(b[i] < c[(R+L)/2]){
        R=(R+L)/2;
      }
      else{
        L=(R+L)/2+1;
      }
    }
    ans += l*(n-L);
  }
  printf("%ld",ans);
  return 0;
}


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

int main() {
    int n;

    while(1) {
        cin >> n;
        if(n == 0) break;

        vector<string> w(n);

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

        for(int i = 0; i < n; i++) {
            vector<int> tanku{ 5, 7, 5 ,7, 7 };
            int k = 0;
            for(int j = 0; i+j < n; j++) {
                tanku[k] -= w[i+j].size();
                if(tanku[k] == 0) k++;
                else if(tanku[k] < 0) break;
            }
            if(tanku[0] == 0 && tanku[1] == 0 
            && tanku[2] == 0 && tanku[3] == 0 
            && tanku[4] == 0) {
                cout << i+1 << endl;
                break;
            }
            else continue;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
def main():
    import sys
    input = sys.stdin.readline
    from collections import Counter
    class BIT:
        def __init__(self,n):
            self.size = n
            self.tree = [Counter([]) for _ in range(n+1)]
    
        def change(self,i,x,y):
            while i <= self.size:
                if x in self.tree[i]:
                    self.tree[i][x] -= 1
                if y not in self.tree[i]:
                    self.tree[i][y] = 0
                self.tree[i][y] += 1
                i += i&-i
    
        def sum(self,i):
            res = Counter([])
            while i > 0:
                res += self.tree[i]
                i -= i&-i
            return res

    N = int(input())
    st = BIT(N)
    S = list(input())
    Q = int(input())
    for i in range(N):
        st.change(i+1," ",S[i])

    for _ in range(Q):
        q,a,b = input().split()
        if q == "1":
            st.change(int(a),S[int(a)-1],b)
            S[int(a)-1] = b
        else:
            res = st.sum(int(b)) - st.sum(int(a)-1)
            ans = 0
            for v in res.values():
                if v > 0:
                    ans += 1
            print(ans)
main()


Measured memory_bytes: 334644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

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

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[a[i]] == i) {
            ans++;
        }
    }

    cout << ans / 2 << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

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

    ll N, A, B;
    cin >> N >> A >> B;
    vector<int> X(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        if (i > 0)
            X[i - 1] = X[i] - X[i - 1];
    }

    ll ans = 0;
    for (int i = 0; i < N - 1; ++i)
        ans += min(X[i] * A, B);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long
#define int long long 
# define INF 2e5 + 5
#define ar array
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}

int32_t main()
{
    
    c_p_c();
   int n;
   cin>>n;
   vector<int>a(n+1);
   for(int i=1;i<=n;i++){
    cin>>a[i];
   }
   int cnt=0;
   for(int i=1;i<=n;i++){
    if(i&1 && a[i]&1)cnt++;
   }
   cout<<cnt<<"\n";




    return 0;


             
    
}


Measured memory_bytes: 3604
N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for Z in range(X+1, Y+1):
    result = True
    for xi in x:
        if xi >= Z:
            result = False
            break

    for yi in y:
        if yi < Z:
            result = False
            break
    if result:
        print('No War')
        break
else:
    print('War')


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int INF = 1e9;

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

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

int main()
{
    int h,w;
    cin >> h >> w;

    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    
    //孤立してる黒マスがあるか探す
    int dx[] = {0,1,0,-1};
    int dy[] = {1,0,-1,0};
    int ans = true;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(s[i][j] == '#')
            {
                bool alone = true;
                for (int k = 0; k < 4; k++)
                {
                    int sx = dx[k] + j;
                    int sy = dy[k] + i;
                    
                    if(0 <= sx && sx < w && 0 <= sy && sy < h)
                    {
                        if(s[sy][sx] == '#')alone = false;
                    }
                }
                if(alone)ans = false;
            }
        }
    }
    
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

int a,b,r,x;

scanf("%d %d",&a,&b);

if(a<b){

x=a;
a=b;
b=x;

}

r=a%b;

while(r!=0){

a=b;
b=r;
r=a%b;

}

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

return 0;

}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
int n, ans, a[200010];
map<int, int> am;
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		am[a[i]]++;
	}
	sort(a, a+n);
	reverse(a, a+n);
	for (int i = 0; i < n; i++)
	{
		if (!am[a[i]]) continue;
		am[a[i]]--;
		for (int b = 0; b <= 30; b++)
		{
			int p = (1 << b);
			if (p < a[i]) continue;
			if (am[p-a[i]])
			{
				am[p-a[i]]--;
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 29824
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


ll Luca(ll n){
    ll L[87];
    L[0] = 2;
    L[1] = 1;
    for(int i=2;i<=n;i++) L[i] = L[i-1] + L[i-2];
    return L[n];
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    cout << Luca(n);
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
def solve(string):
    n, *abc = map(int, string.split())
    a, b, c = map(sorted, [abc[i*n:(i+1)*n] for i in range(3)])
    ai = ci = ans = 0
    for _b in b:
        while ai < n and a[ai] < _b:
            ai += 1
        while ci < n and c[ci] <= _b:
            ci += 1
        ans += ai * (n - ci)
    return str(ans)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(3)])))


Measured memory_bytes: 43136
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (isok).erase(unique(ALL((isok))),(isok).end())
# define LOWER(s)    transform(ALL((maze)),(maze).begin(),TL<char>)
# define UPPER(s)    transform(ALL((maze)),(maze).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

LL a, b, c, x, y;

int main() {
	cin >> a >> b >> c >> x >> y;
	if (x == y) {
		cout << min(a*x + b*y, c*x*2) << endl;
		return 0;
	}
	if (x > y) {
		cout << min({ y*c*2 + a*(x - y),x*c*2 ,a*x+b*y}) << endl;
	}
	else {
		cout << min({ x*c*2 + b*(y - x),y*c*2,a*x+b*y }) << endl;
	}
}

Measured memory_bytes: 256
import math
n=int(input())
mod=10**9+7
ans=1

def primenumber_table(N):  # N以下の素数テーブル エラトステネスの篩
  table=[i for i in range(2,N+1)]
  l=[]
  while len(table)!=0:
    num=table[0]
    l.append(num)
    i=0
    while i<len(table):
      if table[i]%num==0:
        table.pop(i)
      else:
        i+=1
  return l
    
table=primenumber_table(1000)
v=math.factorial(n)
init_v=v
while v!=1:
  for num in table:
    cnt=0
    while v%num==0:
      cnt+=1
      v//=num
    if cnt!=0:
      ans*=(cnt+1)
      ans%=mod
  if v==init_v:
    ans*=2
    ans%=mod
print(ans)

Measured memory_bytes: 39024
#include<bits/stdc++.h>
using namespace std;
 
#define INF (1<<27)
typedef pair<int,int> P;
 
int N,E,T;
vector<P> G[500];
 
struct Node{
  int c,g;
  vector<int> S;
  
  void init(int c,int g){
    this->c = c; if( c > 0 ) S = vector<int>(c,INF);
    this->g = g;
  }
  bool check(){
    for(int i=0;i<c;i++)
      if( S[i] >= INF) return false;
    return true;
  }
  bool update(int id,int x){
    if( S[id] > x ){
      S[id] = x; return true;
    } return false;
  }
  int value() const{
    if( S.empty() ) return 1;
    vector<int> s = S;
    sort(s.begin(),s.end());
    int ret = 0;
    for(int i=c-1,cnt=0;i>=0;i--,cnt++){
      ret = max ( cnt + s[i], ret );
    }
    return ret;
  }
   
  bool operator<(const Node& b)const{
    return value() > b.value();
  }
 
};
 
Node H[2000];
 
int main(){
 
  priority_queue<Node> q;
 
  cin >> N >> E >> T;
  for(int i=0;i<N;i++){
    int w;
    cin >> w;
    if( w == 1 ){
      Node n;
      n.init(0,i+1);
      H[i+E] = n;
      q.push( n );
    }
  }
  for(int i=0;i<E;i++){
    int g,c;
    cin >> g >> c;
    H[i].init(c,g);
    for(int j=0;j<c;j++){
      int s;
      cin >> s;
      G[s].push_back( P(i,j) );
    }
  }
 
  while( !q.empty() ){
    Node st = q.top(); q.pop();
    int val = st.value();
    int id = st.g;
    for(int i=0;i<(int)G[id].size();i++){
      P to = G[id][i];
      if( H[to.first].update(to.second,val) ){
    if( H[to.first].check() ){
      q.push( H[to.first] );
    }
      }
    }
  }
 
  int res = INF;
  for(int i=0;i<N+E;i++){
    //  cout << H[i].g << " "<< H[i].value() << endl;
    if( H[i].g == T ) res = min( res, H[i].value() );
  }
  if( res >= INF ) cout << -1 << endl;
  else cout << res << endl;
}

Measured memory_bytes: 1476
// AOJ 0099: Surf Smelt Fishing Contest II
// 2017.10.28 bal4u@uu

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

#define QSIZE 110000
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int id, key, c; } QUE;
QUE que[QSIZE+3]; int qsize;

void max_heapify(int i)
{
	int l, r, max;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize &&
		(que[l].key > que[i].key || (que[l].key == que[i].key && que[l].id < que[i].id)))
		max = l;
	else max = i;
	if (r < qsize && (que[r].key > que[max].key ||
			(que[r].key == que[max].key && que[r].id < que[max].id)))
		max = r;
	if (max != i) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		max_heapify(max);
	}
}

void deq(void)
{
//	if (qsize == 0) return;
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(void)
{
	int i, max;
	i = qsize++;
	while (i > 0 && (que[max = PARENT(i)].key < que[i].key
		|| (que[max].key == que[i].key && que[max].id > que[i].id))) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		i = max;
	}
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define MAX 1000000
typedef struct { int f, c; } T;
T tbl[MAX + 5];

int main()
{
	int n, q, a, v;

	n = in(), q = in();
	qsize = 0;
	while (q--) {
		a = in(), v = in();
		tbl[a].f += v, tbl[a].c++;
		que[qsize].id = a, que[qsize].key = tbl[a].f, que[qsize].c = tbl[a].c;
		enq();

		while (1) {
			a = que[0].id;
			if (tbl[a].c == que[0].c) {
				printf("%d %d\n", que[0].id, que[0].key);
				break;
			}
			deq();
		}
	}
	return 0;
}



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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	std::string s;

	std::cin >> s;

	u32 i=0;
	u32 j=s.size()-1;

	u32 ans = 0;

	while(i<j)
	{
		if(s[i]!=s[j])
		{
			ans++;
		}
		++i;
		--j;
	}

	std::cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 256
//In the name of Allah
//Ya Ali!
#include <bits/stdc++.h>

using namespace std;
typedef long long ll ;

const ll maxn = 1000 * 101 ;
const ll INF = 1e18 ;

#define f first
#define s second

ll n , now = 0 , o0 = 'a' , k , ans = 0;
vector<pair<ll,ll> > v ;

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

string s1 ;
cin >> s1 ;
cin >> k ;
n = s1.size() ;

now = 1 ;

for(int i = 1 ; i < n ; i ++){
    if(s1[i] == s1[i-1])now ++ ;
    else{
        ll x = s1[i-1] ;
        x -= o0 ;
        v.push_back({x , now}) ;
        now = 1 ;
    }
}

ll x = s1[n-1] ;
x -= o0 ;

v.push_back({x , now}) ;

//for(int i = 0 ; i < v.size() ; i ++)cout << v[i].f << " " << v[i].s << endl ;

if(v.size() == 1){
    ans = (n*k)/2 ;
    return cout << ans , 0 ;
}

ll n1 = v.size() ;

if(v[0].f != v[n1-1].f){
    for(int i = 0 ; i < n1 ; i ++){
        ll xx = (v[i].s)/2 ;
        ans += (xx*k) ;
    }
   return cout << ans , 0 ;
}

for(int i = 1 ; i < n1-1 ; i ++){
        ll xx = (v[i].s)/2 ;
        ans += (xx*k) ;
}

ll x1 = v[0].s , x2 = v[n1-1].s ;

ll xx1 = (x1+x2)/2 ;

ans += xx1*(k-1) ;

ans += (x1/2) ;
ans += (x2/2) ;

cout << ans ;

 return 0;
}
/*
                  _     _   __
            /_\  (_    (_)  __)
           /   \  _) . (_) (__
*/


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
pair<long long, long long>p[114514];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + n);
	cout << p[n - 1].first + p[n - 1].second << endl;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
signed main(){
  string s;cin>>s;
  int ans=0;
  rep(i,4){
    if(s[i]=='+')ans++;
    else ans--;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
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; }

//繰り返し2乗法
ll mpower(ll x, ll y, ll m){//繰り返し2乗法
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){//偶数
    return mpower(x,y/2,m)*mpower(x,y/2,m)%m;
  }else{//奇数
    return mpower(x,y-1,m)*x%m;
  }
}

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S; cin >> S; ll N = S.length();
  
  //main
  ll mod = 2019;
  vll dp(N+1,0); 
  map<ll,ll> mp; mp[0] = 1;
  ll ans = 0;
  
  for(int i=N-1; i>=0; i--){
    dp[i] = (dp[i+1]+(S[i]-'0')*mpower(10,N-1-i,mod))%mod;
    ans += mp[dp[i]];
    mp[dp[i]]++;
  }
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

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

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int x,a,b; cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b)) cout<<"A"<<endl;
  else cout<<"B"<<endl;
}













Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
using namespace std;
typedef pair<int,int> XY;
struct P{
  int x,y,d;
  set<XY> s;
  P(){}
  P(int x,int y,int d,set<XY> s):x(x),y(y),d(d),s(s){}
};
 
string st[52];
int n,m;
 
int main(){
  cin >> n >> m;
  int i,j,k;
  for(j=0;j<m+2;j++){
    st[0]+="#";
    st[n+1]+="#";
  }
  P p,b;
  for(i=1;i<=n;i++){
    cin >> st[i];
    for(j=0;j<m;j++){
      if(st[i][j]=='^'){
	p.x=j+1;p.y=i;p.d=0;st[i][j]='.';
      }
      if(st[i][j]=='>'){
	p.x=j+1;p.y=i;p.d=1;st[i][j]='.';
      }
      if(st[i][j]=='v'){
	p.x=j+1;p.y=i;p.d=2;st[i][j]='.';
      }
      if(st[i][j]=='<'){
	p.x=j+1;p.y=i;p.d=3;st[i][j]='.';
      }
    }
    st[i]="#"+st[i]+"#";
  }
 
  //for(i=0;i<=n+1;i++) cout << st[i] << endl;
 
  int ax[]={0,1,0,-1};
  int ay[]={-1,0,1,0};
  
  int rx[]={1,0,-1,0};
  int ry[]={0,1,0,-1};
 
  bool f=false;
  int o;
  int inf = 1 << 20;
  bool used[55][55][4];
  memset(used,false,sizeof(used));
  queue<P> q;
  p.s.clear();
  q.push(p);
  while(!q.empty()){
    p=q.front();q.pop();    
    //cout << p.y <<":"<< p.x <<"/"<< p.d << ":"<<p.s.size()<<endl;
    //cout << used[p.y][p.x][p.d]<<":"<<p.s.size()<<endl;
    if(used[p.y][p.x][p.d]) continue;
    used[p.y][p.x][p.d]=true;

    p.s.insert(XY(p.x,p.y));
  
    if(st[p.y][p.x]=='G') {
      f=true;
      o=p.s.size();
      break;
    }
    
    if(st[p.y+ry[p.d]][p.x+rx[p.d]]!='#') q.push(P(p.x+rx[p.d],p.y+ry[p.d],(p.d+1)%4,p.s));
    else if(st[p.y+ay[p.d]][p.x+ax[p.d]]!='#') q.push(P(p.x+ax[p.d],p.y+ay[p.d],p.d,p.s));
    else q.push(P(p.x,p.y,(p.d+3)%4,p.s));
  }
  if(f){
    cout << o << endl;
  }
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 1496
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        for (int i=0;i<h;i++) {
            String s = sc.next();
            System.out.println(s);
            System.out.println(s);
        }
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int x[100010],w[100010];
int ans[100010]; 
int n,L,r,t;
long long fldl;
int main()
{
	scanf("%d%d%d",&n,&L,&t);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d%d",&x[i],&w[i]);
		if(w[i] == 2)w[i] = -1;
	}
    for(int i = 1;i <= n;i++)
    {
        int len = x[i] + w[i] * t;
        if (len > 0) (fldl += len / L) %= n;
        else if (len < 0) (fldl += (len + 1) / L - 1) %= n;
        ans[i] = (len % L + L) % L;
    }
    sort(ans + 1 ,ans + n + 1);
    fldl = (fldl + n) % n;
    for(int i = fldl + 1;i <= n;i++)printf("%d\n",ans[i]);
    for(int i = 1;i <= fldl;i++) printf("%d\n",ans[i]);
    return 0;
}

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

int main(void)
{
    std::string str;
    std::cin >> str;

    for(int i = str.size() - 1; i >= 0; --i)
    {
        std::cout << str[i];
    }

    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 3020
#include <stdio.h>
int main(void)
{
    int x[3000] ,y[3000] ,i ,c ,z;
    
    for(i=0;i<3000;i++){
    	scanf("%d %d",&x[i],&y[i]);
    	if(x[i]==0 && y[i]==0){
    		break;
    	}
    }
    c = i;
    
    for(i=0;i<c;i++){
    	if(y[i]>x[i]){
    		z = y[i];
    		y[i] = x[i];
    		x[i] = z;
    	}
    	printf("%d %d\n",y[i] ,x[i]);
    	
    }
    
    return 0;
}

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

using namespace std;

#ifdef KACTL
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
#endif
#define all(x) begin(x), end(x)

using ll = int64_t;
using ld = long double;
using pii = pair<int32_t, int32_t>;
using vi = vector<int32_t>;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, m, x;
    cin >> n >> m >> x;

    vi c(n);
    vector<vi> a(n, vi(m));
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }

    constexpr int INF = 1e9;
    int ans = INF;
    for (int mask = 1; mask < (1 << n); ++mask) {
        int cost = 0;
        vi b(m, 0);
        for (int i = 0; i < n; ++i) {
            if (mask & (1 << i)) {
                cost += c[i];
                for (int j = 0; j < m; ++j) {
                    b[j] += a[i][j];
                }
            }
        }

        if (*min_element(all(b)) >= x) {
            ans = min(ans, cost);
        }
    }

    cout << (ans == INF ? -1 : ans) << '\n';

    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>

int main(){
  int n,h,m,i;
  double ls,ss,angle;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d:%d",&h,&m);
    ls=m*6;
    ss=h*30+(double)m/2.0;
    //printf("%f:%f;",ls,ss);
    angle=ls-ss;
    if (angle < 0) angle *= -1;
    if (angle > 180) angle = 360 - angle;

    if (angle<30) printf("alert\n");
    else if (90 <= angle && angle <=180) printf("safe\n");
    else printf("warning\n");
  }
  return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if ((a[0] == a[1] and a[1] != a[2]) or (a[0] != a[1] and a[1] == a[2])) {
        dump("Yes");
    }
    else {
        dump("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    vector<int> a(9);
    rep(i,9) cin >> a[i];
    vector<vector<int>> p = {{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
    vector<bool> bingo(9,false);
    int n;
    cin >> n;
    rep(i,n) {
        int b;
        cin >> b;
        rep(j,9) {
            if(a[j] == b) bingo[j] = true;
        }
    }
    rep(j, p.size()) {
        if(bingo[p[j][0]] == bingo[p[j][1]]&& bingo[p[j][1]] == bingo[p[j][2]] &&
        bingo[p[j][2]]  == true) {
            cout << "Yes" << endl;            
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
a = [[] for _ in range(3)]
for i in range(3):
	a[i] = list(map(int,input().split()))
c = [[0,0,0] for _ in range(3)]

N = int(input())
b = [0]*N
for i in range(N):
	b[i] = int(input())

for i in range(N):
	b_temp = b[i]
	for k in range(3):
		for j in range(3):
			if a[k][j] == b_temp:
				c[k][j] = 1
	for k in range(3):
		if c[k][0]*c[k][1]*c[k][2] == 1:
			print("Yes")
			exit()
		if c[0][k]*c[1][k]*c[2][k] == 1:
			print("Yes")
			exit()
	if c[0][0]*c[1][1]*c[2][2] == 1:
		print("Yes")
		exit()
	if c[2][0]*c[1][1]*c[0][2] == 1:
		print("Yes")
		exit()
print("No")


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

int main() {
   std ::string s;
   cin>>s;
   if(s=="A"){
      cout<<"T"<<endl;
      return 0;
   }else if(s=="T"){
      cout<<"A"<<endl;
      return 0;
   }else if(s=="C"){
      cout<<"G"<<endl;
      return 0;
   }else if(s=="G"){
      cout<<"C"<<endl;
      return 0;
   }


}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath> 
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;   
int main()  
{ 
    int a,s,d,f;
    cin>>a>>s>>d>>f;
    cout<<min(a,s)+min(d,f);


//    system("pause");
    return 0;
}

Measured memory_bytes: 256