akhauriyash/Code-Regression huggingface dataset:
H,W,K = map(int, input().split())
c_table = [input() for _ in range(H)]
SUM = 0
for i in range(H):
    for j in range(W):
        if c_table[i][j] == '#':
            SUM += 1
answer = 0

for i in range(2 ** (H)):
    tmp_h = [False] * H
    for j in range(H):
        if i >> j & 1:
            tmp_h[j] = True
    for k in range(2**W):
        tmp_w = [False] * W
        for l in range(W):
            if k>>l & 1:
                tmp_w[l] = True
        cnt = 0
        for ti in range(len(tmp_h)):
            if tmp_h[ti]:
                for tk in range(W):
                    if c_table[ti][tk] == '#':
                        cnt += 1
        for tj in range(len(tmp_w)):
            if tmp_w[tj]:
                for tk in range(H):
                    if tmp_h[tk]:
                        continue
                    if c_table[tk][tj] == '#':
                        cnt += 1

        if K == SUM - cnt:
            answer += 1
        

print(answer)

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

int main(){
    ll a,b,x;
    double ans;
    cin>>a>>b>>x;
    if(2*x>a*a*b){
        ans=180*atan((double)(2.0*(a*a*b-x)/(a*a*a)))/pi;
    }else{
        ans=90-180*atan((double)(2.0*x)/(a*b*b))/pi;
    }
    cout << std::fixed << std::setprecision(15) << ans << endl;
}

Measured memory_bytes: 4064
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int A, B, X, p = 0, t1, t2, t3, tx;
    scanf("%d %d %d", &A, &B, &X);
    tx = X;
    t1 = (X % 1000 == 0) ? (X/1000) * A : (X/1000+1) * A;
    t2 = (X % 500 == 0) ? (X/500) * B : (X/500+1) * B;
    t3 = X/1000 * A, tx %= 1000;
    t3 += (tx % 500 == 0) ? (tx/500) * B : (tx/500+1) * B;
    p = min(t1, min(t2, t3));
    printf("%d\n", p);
    return 0;
}




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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        string s = to_string(i);
        if (s.size()%2 != 0) {
            ans++;
        }
    }

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

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  CIN(string, S, T);
  CIN(int, A, B);
  CIN(string, U);
  (U == S ? A : B)--;
  COUT(A, B);
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;


vector<string> a {
    "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
};


int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
//    std::random_device rd;
//    std::mt19937 g(rd());
    auto start = clock();


    string s; cin >> s;
    for (int i = 0; i < a.size(); ++i) {
        if (s == a[i]) {
            cout << 7 - i << endl;
            return 0;
        }
    }



    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;
#define mp make_pair
#define pb push_back

vector<pair<double, double>> vs;

// ベクトルを受け取りその長さ(大きさ)を返す
double length(pair<double, double> p) {
	return sqrt(pow(p.first, 2) + pow(p.second, 2));
}

// 3点を受け取り、その3点が作る三角形の面積を返す
double area(pair<double, double> p1, pair<double, double> p2, pair<double, double> p3) {
	pair<double, double> p12 = mp(p1.first - p2.first, p1.second - p2.second);
	pair<double, double> p13 = mp(p1.first - p3.first, p1.second - p3.second);
	pair<double, double> p32 = mp(p3.first - p2.first, p3.second - p2.second);
	double a = length(p12);
	double b = length(p13);
	double c = length(p32);
	double z = (a + b + c) / 2;
	double S = sqrt(z * (z-a) * (z-b) * (z-c));
	return S;
}


int main(void) {
	double x, y;
	while(~scanf("%lf, %lf", &x, &y)) {
		pair<double, double> p = mp(x, y);
		vs.pb(p);
	}
	
	double sum = 0;
	for (int i = 1; i < vs.size() - 1; i++) {
		sum += area(vs[0], vs[i], vs[i+1]);
	}

	//for (auto v : vs) {
	//	cout << "(" <<  v.first << "," << v.second << ")" << endl;
	//}

	cout << sum << endl;

}



Measured memory_bytes: 3156
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <map>

int main(){
    long long n, m;
    std::cin >> n >> m;

    std::vector<long long> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }
    
    std::sort(a.begin(), a.end());

    std::multimap<long long, long long> mp;
    for(long long i = 0; i < m; ++i){
        long long b, c;
        std::cin >> b >> c;
        mp.insert(std::make_pair(c, b));
    }

    long long i = 0;
    auto ritr = mp.rbegin();
    std::vector<long long> vec;
    while(mp.rend() != ritr && i < n){
        long long val = ritr->first, num = ritr++->second;
        std::vector<long long> buf(num, val);
        vec.insert(vec.end(), buf.begin(), buf.end());
        i += num;
    }

    long long min = std::min(n, i);
    for(long long j = 0; j < min; ++j){
        if(a.at(j) < vec.at(j)){
            a.at(j) = vec.at(j);
        }else{
            break;
        }
    }

    std::cout << std::accumulate(a.begin(), a.end(), 0ll) << std::endl;

    return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;

    bool ym = false, my = false;
    int a = n / 100, b = n % 100;
    if (1 <= a && a <= 12)
        my = true;
    if (1 <= b && b <= 12)
        ym = true;

    if (my && ym)
        cout << "AMBIGUOUS\n";
    else if (my)
        cout << "MMYY\n";
    else if (ym)
        cout << "YYMM\n";
    else
        cout << "NA\n";


    return 0;
}


Measured memory_bytes: 256
/*--------------------------------
    Anshul Gangwar
  Chandigarh University
--------------------------------*/
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

#define For(i,n)        for(int i = 0;i < n;i++)
#define fr(i,a,b)       for(int i = a;i <= b;i++)
#define Rfor(i,n)       for(int i = n-1;i >= 0;i--)
#define endl            '\n'
#define pb              push_back
#define mp              make_pair


int main()
{
  #ifdef ANSHUL
  freopen("input.txt", "r", stdin);
  #endif
  ll r,d,x;
  cin>>r>>d>>x;
  ll ans = x;
  For(i,10)
  {
    ans = (r * ans) - d;
    cout<<ans<<endl;
  }
  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(ll i = a; i < b; i++)
#define DB( x ) cout << #x << " = " << x << endl;
#define sz(s) ((int)((s).size()))
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<int, pii> tri;
typedef vector <vector <ll>> matrix;
typedef pair<string, string> pss;

const ll mod = (ll)1e9 + 7;
const int MAX = (int)1e2 + 100;

const int oo = 0x3f3f3f3f;

bool dp[100005];

int n, k, mn, a[MAX];

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

    cin >> n >> k;

    for(int i = 0;i < n;++i) {
        cin >> a[i];
        if(i == 0) mn = a[i];
        else mn = min(mn, a[i]);
    }

    for(int i = mn;i <= k;++i)
        for(int j = 0;j < n;++j)
            if(i - a[j] >= 0)
                dp[i] |= !dp[i - a[j]];

    if(dp[k]) cout << "First\n";
    else cout << "Second\n";
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,k;
ll a[200005],sum;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum += max(0LL,a[i]);
	}
	ll P = 0,Q = 0,MN = 1e18;
	for(int i=1;i<=k;i++){
		if(a[i] > 0) P += a[i];
		else Q -= a[i];
	}
	for(int i=1;i<=n-k+1;i++){
		MN = min(MN,min(P,Q));
		if(a[i]>0) P -= a[i];
		else Q += a[i];
		if(a[i+k]>0) P += a[i+k];
		else Q -= a[i+k];
	}
	cout << sum-MN << endl;
}

Measured memory_bytes: 1024
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

use std::collections::BinaryHeap;
use std::cmp::Ordering;

#[derive(Clone, Copy, Eq, PartialEq)]
struct E {
    num: u64,
    idx: usize,
}

impl Ord for E {
    fn cmp(&self, other: &Self) -> Ordering {
        self.num.cmp(&other.num)
    }
}

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

fn main() {
    let kt = reads();
    let xs = reads();

    let mut q = BinaryHeap::new();
    for (i, x) in xs.into_iter().enumerate() {
        let e = E { num: x, idx: i};
        q.push(e);
    }

    let mut res = 0;
    let mut prev = kt[1];
    while let Some(e) = q.pop() {
        if e.idx == prev {
            if let Some(next) = q.pop() {
                q.push(e);
                prev = next.idx;

                if next.num > 1 {
                    q.push( E {num: next.num - 1, idx: next.idx});
                }
            }
            else {
                res += e.num as u64;
            }
        }
        else {
            prev = e.idx;

            if e.num > 1 {
                q.push(E { num: e.num - 1, idx: e.idx});
            }
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    a=a%b;
    if(a==0){
        return b;
    }
    gcd(b,a);
}
ll lcd(ll a,ll b){
    return a*b/gcd(a,b);
}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=0;
    ans=(b-a+1)-(b/c+b/d-b/lcd(c,d))+((a-1)/c+(a-1)/d-(a-1)/lcd(c,d));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d\n" @@ fun d ->
  let n = d mod 10 in
  let ans =
    if n = 3 then "bon "
    else if n = 0 || n = 1 || n = 6 || n = 8 then "pon "
    else "hon " in
  Printf.printf "%s\n" ans

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

#define N 100005
ll a[3][N];
ll dp[3][N];
void solve(){
    ll n;cin>>n;
    rep(i,n)rep(j,3)cin>>a[j][i];

    rep(i,3)dp[i][0]=a[i][0];
    rep(i,1,n){
        rep(j,3){
            rep(k,3){
                if(j==k)continue;
                chmax(dp[j][i],dp[k][i-1]+a[j][i]);
            }
        }
    }
    ll ans=0;
    rep(i,3)chmax(ans,dp[i][n-1]);
    cout<<ans<<endl;
}

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


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
    for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(v[i]>=a[i]){
      ans+=v[i]-a[i];
    }
  }
  cout<<ans<<endl;
}

    


Measured memory_bytes: 256
#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
const long long MOD = 1000000007;
using namespace std;


ll a[16][16];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int i,j;
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            scanf("%lld", &a[i][j]);
        }
    }

    int mm=(1<<n);
    int z[17];
    vector<ll> dp(mm);
    int k;
    for(k=0; k<mm; k++) {
        int siz=0;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) z[siz++]=i;
        }

        dp[k]=0;
        for(i=0; i<siz; i++) {
            for(j=i+1; j<siz; j++) {
                dp[k] += a[z[i]][z[j]];
            }
        }
    }

    for(k=0; k<mm; k++) {
        int siz=0;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) z[siz++]=i;
        }
        ll max=0;
        int MM=(1<<siz);
        for(i=0; i<MM; i++) {
            int tmp0=0;
            for(j=0; j<siz; j++) {
                if(i & (1<<j)) tmp0 |= (1<<z[j]);
            }
            ll val = dp[tmp0]+dp[k^tmp0];
            max = MAX(max, val);
        }
        dp[k] = max;
    }
    printf("%lld\n", dp[mm-1]);

    return 0;
}


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

int main() {
    int c[3][3];
    
    rep(i, 3) {
        rep(ii, 3) {
            cin >> c[i][ii];
        }
    }
    
    for(int i = 1; i < 3; i++) {
        if (
            ((c[0][0] - c[i][0]) != (c[0][1] - c[i][1])) ||
            ((c[0][1] - c[i][1]) != (c[0][2] - c[i][2]))
        ) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    for(int i = 1; i < 3; i++) {
        if (
            ((c[0][0] - c[0][i]) != (c[1][0] - c[1][i])) ||
            ((c[1][0] - c[1][i]) != (c[2][0] - c[2][i]))
        ) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            string s = Console.ReadLine();
            Console.WriteLine("2018" + s.Substring(startIndex: 4));
        }


    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef struct{
    int from, to, cost;
}Edge;
const int INF = 0x3f3f3f3f;

int main(){
    int n, k, s;
    scanf("%d %d %d", &n, &k, &s);
    Edge e[k];
    int d[n];
    for(int i = 0 ; i < k; i++)
        scanf("%d %d %d", &e[i].from, &e[i].to, &e[i].cost);
    for(int i = 0; i < n; i++) d[i] = (i == s) ? 0 : INF;

    int cnt;
    for(cnt = 0 ; cnt < n; cnt++) {
        int update = 0;
        for (int i = 0; i < k; i++) {
            if (d[e[i].from] != INF && d[e[i].from] + e[i].cost < d[e[i].to]) {
                d[e[i].to] = d[e[i].from] + e[i].cost;
                update = 1;
            }
        }
        if (!update) break;
    }
    int flag = 0;
    if(cnt == n) flag = 1;
    if(flag){
        printf("NEGATIVE CYCLE\n");
    }else{
        for(int i = 0; i < n; i++){
            d[i] == INF ? printf("INF\n") : printf("%d\n", d[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 3236
N,M= map(int,input().split())
k_list = []
s_list = []
for _ in range(M):
    input_list = list(map(int,input().split()))
    k_list.append(input_list[0])
    s_list.append(input_list[1:])
p_list = list(map(int,input().split()))


on_num_dict = {} # それぞれの電球に対して、いくつのスイッチが押されていたらonになるかの辞書
for m in range(M):
    num_list = [i for i in range(k_list[m]+1) if i%2==p_list[m]]
    on_num_dict[m] = num_list

ans = 0
for i in range(2**N): # on off のパターン
    flag = 1
    bin_list = list(format(i, '0'+str(N)+'b'))
    for m in range(M): #電球ひとつひとつに対して
        on_switch = [int(bin_list[s-1]) for s in s_list[m]] # switch の on off
        on_switch_num = sum(on_switch)
        if on_switch_num in on_num_dict[m]:
            flag = 1
        else:
            flag = 0
            break
    if flag == 1:
        ans+=1
print(ans)

Measured memory_bytes: 3064
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]


def dfs(i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(A - a) + abs(B - b) + abs(C - c)
    res = dfs(i + 1, a, b, c)
    res = min([res, dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])
    res = min([res, dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])
    res = min([res, dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])
    return res


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

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

inline int two(int n) { return 1 << n; }
inline int test(int n, int pos) { return (bool) (n & two(pos)); }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }

const int DMAX = 1e5+10;

vector <int> vec;
vector <int> arb[DMAX];

struct nume{
    int node,val;
};

int V[DMAX];

priority_queue <nume> heap;

int n,ans;

inline bool operator<(nume x,nume y){
    return x.val<y.val;
}

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

    int t,i,j,k,ant,cate;

    cin>>k>>n;
    for(i=1;i<=n;i++){
        cin>>V[i];
        heap.push({i,V[i]});
    }
    ant=0;
    nume var,var2;
    cate=ans=1;
    while(!heap.empty()){
        var=heap.top();
        heap.pop();
        if(var.node != ant){
           ant=var.node;
           if(var.val > 1)
              heap.push({var.node,var.val-1});
           cate=1;
           continue;
        }
        if(heap.empty()){
           cate++;
           ans=max(cate,ans);
           if(var.val > 1)
              heap.push({var.node,var.val-1});
           continue;
        }
        var2=heap.top();
        heap.pop();
        ant=var.node;
        cate=1;
        if(var2.val > 1)
           heap.push({var2.node,var2.val-1});
        if(var.val > 1)
           heap.push({var.node,var.val-1});

    }
    cout<<ans-1<<'\n';
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int n = S.size();
    string A, B;
    int flag = 0;

    for(int i = 1; i <= n; i++) {
        A = S.substr(n-1);
        B = S.substr(0, n-1);
        S = A + B;
        if(S == T) {
            flag = 1;
        }
    }
    
    if(flag == 1) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#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(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M; cin >> N >> M;
    vl cnt(M, 0);
    rep(i, N){
        ll K; cin >> K;
        rep(j, K){
            ll a; cin >> a; a--;
            cnt[a]++;
        }
    }
    ll ans = 0;
    rep(i, M) if(cnt[i] == N) ans++;
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>



using namespace std;


int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	
	int solve = 0;
	int cnt = 0;
	char last = s[0];
	for (int i = 1; i < n; i++) {
		if (s[i] == last) {
			solve++;
		}
		else {
			cnt++;
		}

		last = s[i];

	}

	/*
	int cnt = 0;
	char st_char = s[0];
	bool isChanged = false;
	for (int j = 1; j < n-1; j++) {
		if (st_char != s[j]){
			isChanged = true;
		}
		else {
			if (isChanged == true) {
				cnt++;
			}

			isChanged = false;
		}
	}
	*/

	if (cnt /2< k) {
		solve += (2 *( cnt/2));
		if (s[0] != s[n - 1]) {
			solve++;
		}

	}
	else {
		solve += (2 * k);
	}
	cout << solve << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt(), M = sc.nextInt();
        int[][] route = new int[M][2];
        for(int i=0;i<M;i++){
            route[i][0] = sc.nextInt()-1;   //最後に1を足せ
            route[i][1] = sc.nextInt()-1;
        }
        int[] ans = new int[N];
        for(int i=0;i<N;i++){
            ans[i] = -1;
        }
        ans[0] = 0;
        List<Integer>[] destination = new List[N];
        for(int i=0;i<N;i++){
            destination[i] = new ArrayList<>();
        }
        for(int i=0;i<M;i++){
            destination[route[i][0]].add(route[i][1]);
            destination[route[i][1]].add(route[i][0]);
        }
        Queue<Integer> queue = new ArrayDeque<>();
        queue.add(0);
        while(!queue.isEmpty()){
            int iter = queue.poll();
            for(int i : destination[iter]){
                if(ans[i] == -1) {
                    ans[i] = iter;
                    queue.add(i);
                }
            }
        }

        boolean flag = false;
        for(int i=0;i<N;i++){
            if(ans[i] == -1){
                flag = true;
                break;
            }
        }
        if(flag){
            System.out.println("No");
        }else{
            for(int i=0;i<N;i++) {
                System.out.println(i == 0 ? "Yes" : ans[i]+1);
            }
        }
    }
}


Measured memory_bytes: 71592
#include <stdio.h>
int main()
{
	int A,B,C; 
	scanf("%d %d %d",&A,&B,&C);
	if(A==5&&B==5&&C==7)
	printf("YES");
	else if(A==5&&B==7&&C==5)
	printf("YES");
	else if(A==7&&B==5&&C==5)
	printf("YES");
	else
	printf("NO");
	return 0;
}

Measured memory_bytes: 128
n=int(input())
def multiset(a,b): #listのab
  x,y=list(set(a)&set(b)),[]
  for s in x:
    for t in range(min([a.count(s),b.count(s)])):
      y.append(s)
  return y
for s in range(n):
  a=list(input())
  if s==0:
    b=a
  b=multiset(a,b)
print("".join(sorted(b)))

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pic = pair<int, char>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main(){
    ll ans=0;
    ll n,k;
    cin>>n>>k;
    vector<int> v(n),vr(n);
    for (int i = 0; i < n; i++)
    {
        cin>>v[i];
        vr[i]=v[i];
    }
    reverse(all(vr));
    ll dpl[55][105], dpr[55][105];
    for (int i = 0; i < 55; i++)
    {
        for (int j = 0; j < 105; j++)
        {
            dpl[i][j]=LONG_MIN/3;
            dpr[i][j]=LONG_MIN/3;
        }
    }
    dpl[0][0]=0;
    dpr[0][0]=0;
    
    for (int i = 0; i < n; i++)
    {
        dpl[i+1][i+1]=dpl[i][i]+v[i];
        dpr[i+1][i+1]=dpr[i][i]+vr[i];
    }
    for (int i = 1; i <= n; i++)
    {
        vector<ll> pql,pqr;
        for (int j = 0; j < i; j++)
        {
            pql.push_back(v[j]);
            pqr.push_back(vr[j]);
        }
        sort(all(pql));
        sort(all(pqr));
        for (int j = 0; j < i; j++)
        {
            dpl[i][i+j+1]=max(dpl[i][i+j+1], dpl[i][i+j]-pql[j]);
            dpr[i][i+j+1]=max(dpr[i][i+j+1], dpr[i][i+j]-pqr[j]);
        }
    }
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            dpl[i][j+1]=max(dpl[i][j], dpl[i][j+1]);
            dpr[i][j+1]=max(dpr[i][j], dpr[i][j+1]);
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            dpl[i+1][j]=max(dpl[i][j], dpl[i+1][j]);
            dpr[i+1][j]=max(dpr[i][j], dpr[i+1][j]);
        }
    }
    
    for (ll nl = 0; nl <= n; nl++)
    {
        for (ll kl = 0; kl <= k; kl++)
        {
            ll nr=n-nl;
            ll kr=k-kl;
            ll tmp = dpl[nl][kl]+dpr[nr][kr];
            ans=max(ans,tmp);
        }
        
    }
    

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

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

string s;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s; int n = s.size();
	int res = 0; int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'g') {
			if (!cnt) cnt++;
			else res++, cnt--;
		}
		else {
			if (!cnt) res--, cnt++;
			else cnt--;
		}
	}
	cout << res;
}

Measured memory_bytes: 512
from collections import Counter
s = input()
C = Counter(s)
if len(C) % 2 != 0:
    print('No')
    exit()
else:
    if len(s) == 4:
        print('Yes')
    else:
        if 'N' in s and 'S' in s:
            print('Yes')
        elif 'E' in s and 'W' in s:
            print('Yes')
        else:
            print('No')

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}


int main()
{
    ll n;
    ll col[8] = {399,799,1199,1599,1999,2399,2799,3199};
    cin >> n;

    ll cnt=0;
    vll a(n),tmp(8,0);
    rep(i,n){
        cin >> a[i];
        rep(j,8){
            if(a[i] <= col[j]){
                tmp[j]++;
                break;
            }
        }
        if(a[i] >= 3200)cnt++;
    }

    ll minn = 0;
    rep(i,8){
        if(tmp[i] > 0)minn++;
    }

    if(minn == 0){
        cout << 1 << " " << cnt << endl;
        return 0;
    }

    cout << minn << " " << minn + cnt << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e6+5;
const int MOD=1e9+7;

int fact[N], invfact[N];

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

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

int get(int x1, int y1, int x2, int y2)
{
	int xdiff=x2-x1;
	int ydiff=y2-y1;
	return nCr(xdiff+ydiff, xdiff);
}

int32_t main()
{
	IOS;
	precompute();
	int n, m, p, q;
	cin>>n>>m>>p>>q;
	int ans=nCr(n-1+m-1, n-1);
	int curx=n-p+1, cury=q;
	while(curx<=n && cury>=1)
	{
		ans-=(get(1, 1, curx, cury) * get(curx, cury, n, m))%MOD;
		curx++;
		cury--;
		ans+=MOD;
		ans%=MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

vector<string>vec;
auto cell = [](int i, int j) {
	if (i < 0 || j < 0 || i >= 8 || j >= 8)return (char)0;
	return vec[i][j];
};
int dx[] = { 1,1,0,-1,-1,-1,0,1 };
int dy[] = { 0, 1,1,1,0,-1,-1,-1 };
const char hs[] = "ox";
int f(int i, int j, bool k)
{
	int cnt = 0;
	for (int dir = 0; dir < 8; ++dir)
	{
		int ii = i + dx[dir], jj = j + dy[dir];
		int num = 0, numm = 0;
		while (cell(ii, jj))
		{
			if (cell(ii, jj) == '.')
			{
				num = 0;
				break;
			}
			else if (cell(ii, jj) == hs[k])
			{
				numm = num;
				break;
			}
			else
			{
				++num;
			}
			ii += dx[dir];
			jj += dy[dir];
		}
		cnt += numm;
	}
	return cnt;
}
void g(int i, int j, bool k)
{
	for (int dir = 0; dir < 8; ++dir)
	{
		int ii = i + dx[dir], jj = j + dy[dir];
		int num = 0, numm = 0;
		while (cell(ii, jj))
		{
			if (cell(ii, jj) == '.')
			{
				num = 0;
				break;
			}
			else if (cell(ii, jj) == hs[k])
			{
				numm = num;
				break;
			}
			else
			{
				++num;
			}
			ii += dx[dir];
			jj += dy[dir];
		}
		if (numm)
		{
			ii = i + dx[dir], jj = j + dy[dir];
			while (cell(ii, jj) == hs[!k])
			{
				vec[ii][jj] = hs[k];
				ii += dx[dir];
				jj += dy[dir];
			}
		}
	}
}
int main(void)
{
	for (int i = 0; i < 8; ++i)
	{
		string s;
		cin >> s;
		vec.push_back(s);
	}
	for (;;)
	{
		bool p1 = true, p2 = true;
		//o
		{
			pair<int, pair<int, int>>cl = { 0,{0,0} };
			for (int i = 0; i < 8; ++i)for (int j = 0; j < 8; ++j)
			{
				if (vec[i][j] == '.')
				{
					int ret = f(i, j, false);
					if (ret)
					{
						cl = max(cl, { ret,{-i,-j} });
					}
				}
			}
			if (cl.first)
			{
				p1 = false;
				vec[-cl.second.first][-cl.second.second] = 'o';
				g(-cl.second.first, -cl.second.second, false);
			}
		}
		//x
		{
			pair<int, pair<int, int>>cl = { 0,{ 0,0 } };
			for (int i = 0; i < 8; ++i)for (int j = 0; j < 8; ++j)
			{
				if (vec[i][j] == '.')
				{
					int ret = f(i, j, true);
					if (ret)
					{
						cl = max(cl, { ret,{ i,j } });
					}
				}
			}
			if (cl.first)
			{
				p2 = false;
				vec[cl.second.first][cl.second.second] = 'x';
				g(cl.second.first, cl.second.second, true);
			}
		}
		if (p1 && p2)break;
	}
	for (int i = 0; i < 8; ++i)
	{
		cout << vec[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer quantity = sc.nextInt();
        Set<Integer> NumSet = new HashSet<Integer>();
        boolean flg = false;
        for (int i = 0; i < quantity; i++){
            if (!NumSet.add(sc.nextInt())) {
                flg = true;
                System.out.println("NO");
                break;
            }
        }
        if (!flg) {
            System.out.println("YES");
        }
    }
}

Measured memory_bytes: 102708
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
//const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = unsigned long long;
using P  = pair<int, int>;
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 ll INF = 1000000000000000000;
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    sort(ALL(A));
    if(*A.begin() == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    if(*A.rbegin() > INF)
    {
        cout << -1 << endl;
        return 0;
    }
    ll ans = 1;
    rep(i, N) {
        if(A[i] > INF/ans)
        {
            cout << -1 << endl;
            return 0;
        }
        ans *=A[i];
        if(ans > INF) 
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


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

int main(){
    int a[5];
    rep(i,5){cin>>a[i];}
    int min=10;
    int min_i=0;
    rep(i,5){
        if(min>a[i]%10 &&a[i]%10!=0){
            min=a[i]%10;
            min_i=i;
        }
    }
    int ans=0;
    rep(i,5){
        if(i==min_i){
            ans+=a[i];
        }else{
            ans+=((a[i]+9)/10)*10;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ln = readLine()!!.split(" ").map(String::toInt).sorted().toIntArray()

    var sum = 0
    for (ai in 0 until ln.size - 2) {
        val a = ln[ai]
        for (bi in ai + 1 until ln.size - 1) {
            val b = ln[bi]
            for (ci in bi + 1 until ln.size) {
                if (ln[ci] < a + b) {
                    sum++
                } else {
                    break
                }
            }
        }
    }
    println(sum)
}



Measured memory_bytes: 48396
#include <bits/stdc++.h>
using namespace std;
long long rev(string s,int n)
{
   	string revl,revh;
    revl.push_back(s[s.length()-1]);
  	revh.push_back(s[s.length()-1]);
  	int len=s.length();
  	int i=1;
  	while(i<len-1)
    {
      revl.push_back('0');
      revh.push_back('9');
      i++;
    }
  
  	revl.push_back(s[0]);
  	revh.push_back(s[0]);
  	//cout<<revl<<" "<<revh<<endl;
  	int rl,rh;
  	stringstream st(revl);
  	stringstream st1(revh);
  	st>>rl;
  	st1>>rh;
  	if(n<rl)return 0;
  	else if(n>=rl && n<=rh)
    {
      int ld=n%10;
      int l=n/10;
      long long  rtn=l-((revl[0]-'0')*pow(10,len-2));
      if(ld<(s[len-1]-'0'))rtn-=1;
      return rtn+1;
      
    }
  	else return (long long)pow(10,len-2);
}
int main()
{
  int n;
  cin>>n;
  long long ans=0;
  for(int i=n;i>=1;i--)
  {
    string s=to_string(i);
    int len=s.length();
    if(s[len-1]=='0')continue;
    if(len>=2)
    {
    	ans+=rev(s,n);
    	if(len>=2)ans+=2*((pow(10,len-2)-1)/9);
    	if(s[0]==s[len-1])ans+=2;
    }
    else ans++;
    //cout<<i<<' '<<ans<<endl;
  }
  cout<<ans<<endl;
  /*string s="25";
  cout<<rev(s,25)<<endl;*/
  return 0;
}

Measured memory_bytes: 4032
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, c = MAP()
if (b - a) == (c - b):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 26920
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	long long int X,Y;
	cin>>X>>Y;
	long long int ans=0;
	while(X<=Y){
		X*=2;
		ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                                                                                               
#include <map>                                                                                                                                    
using namespace std;                                                                                                                              
                                                                                                                                                  
int main() {                                                                                                                                      
    string str;                                                                                                                                   
    cin >> str;                                                                                                                                   
                                                                                                                                                  
    int max = 0, cnt = 0;                                                                                                                         
    for (auto sc : str) {                                                                                                                         
        if (sc == 'A' || sc == 'C' || sc == 'G' || sc == 'T') {                                                                                   
            cnt++;                                                                                                                                
        } else {                                                                                                                                  
            cnt = 0;                                                                                                                              
        }                                                                                                                                         
        max = max < cnt ? cnt : max;                                                                                                              
    }                                                                                                                                             
                                                                                                                                                  
    cout << max << endl;                                                                                                                          
}    

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

template<typename T>
vector<T> getPrime(T x)
{
  vector<T> div;

  for (int i = 2; i*i <= x; ++i) {
    if (x % i == 0) {
      div.emplace_back(i);
      while (x % i == 0) x /= i;
    }
  }

  if (x != 1) div.emplace_back(x);
  return div;
}

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

  ll n;
  cin >> n;

  auto div = getPrime(n);
  int m = div.size();
  ll ans = 0;

  for (int bit = 1; bit < (1<<m); ++bit) {
    int cnt = __builtin_popcount(bit);
    ll tmp = 1;

    for (int i = 0; i < m; ++i) if (bit & (1<<i)) tmp *= div[i];

    ll num = n / tmp;

    if (cnt & 1) ans += num;
    else ans -= num;
  }

  cout << n - ans << endl;

  return (0);
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> y(m), x(m);
    rep(i, m) cin >> y[i] >> x[i];

    map<int, int> my, mx;
    map<pii, int> myx;
    rep(i, m) {
        my[y[i]]++;
        mx[x[i]]++;
        myx[make_pair(y[i], x[i])]++;
    }

    int maxY = -1, maxX = -1;
    rep1(i, h) chmax(maxY, my[i]);
    rep1(i, w) chmax(maxX, mx[i]);

    vector<int> py, px;
    rep1(i, h) {
        if (my[i] == maxY) py.push_back(i);
    }
    rep1(i, w) {
        if (mx[i] == maxX) px.push_back(i);
    }

    int ans = maxX + maxY;
    for (int ty: py) {
        for (int tx: px) {
            if (!myx[make_pair(ty, tx)]) {
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans - 1 << endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9;



int main()
{
    LL n,a,b;
    cin>>n>>a>>b;
    LL c=a-b;
    vector<LL> h(n);
    REP(i,n)
        cin>>h[i];
    sort(ALL(h),greater<int>());
    
    LL mi=0,ma=INF,mid;
    auto f=[=](LL p){
        LL cnt=0;
        REP(i,n)
        {
            LL hp=h[i];
            hp-=p*b;
            if(hp<0)continue;
            cnt+=(hp+(c-1))/c;
        }
        return cnt<=p;
    };
    while(ma>mi+1)
    {
        mid=(ma+mi)/2;
        bool t=f(mid);
        //cout<<mid<<" "<<t<<endl;
        if(t)
        {
            ma=mid;
        }
        else
        {
            mi=mid;
        }
    }
    cout<<ma<<endl;
}


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

int main() {
  vector<char> s(3);
  rep(i,3) cin >> s[i];
  int a = 0;
  int b = 0;
  rep(i,3) {
    if (s[i] == 'A') a++;
    if (s[i] == 'B') b++;
  }
  string ans;
  if (a > 0 && b > 0) {
    ans = "Yes";
  } else {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256