akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

void _main()
{
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];
    vector<ll> sum(N + 1);
    sum[0] = 0;
    vector<ll> alt;
    alt.push_back(-(1LL << 60));
    alt.push_back(0);
    rep(i, 0, N)
    {
        sum[i + 1] = sum[i] + a[i] - K;
        alt.push_back(sum[i + 1]);
    }
    sort(alt.begin(), alt.end());

    BinaryIndexedTree<ll> bit(N + 1);

    ll ans = 0;
    int added = 0;
    rrep(i, N - 1, 0)
    {
        const int x = lower_bound(alt.begin(), alt.end(), sum[i + 1]) - alt.begin();
        bit.add(x, 1);
        ++added;
        const int y = lower_bound(alt.begin(), alt.end(), sum[i]) - alt.begin();
        ans += added - bit.sum(y - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5872
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

int N;
umii A;
vector<int> p;

int main() {
    scanf("%d", &N);
    for (int i = 0, x; i < N; i++) {
        scanf("%d", &x);
        A[x] += 1;
        if (A[x] % 2 == 0) {
            p.pb(x);
        }
    }
    sort(p.begin(), p.end());

    if (p.size() <= 1) {
        printf("0\n");
        return 0;
    }

    printf("%lld\n", 1ll * p[p.size() - 1] * p[p.size() - 2]);
}


Measured memory_bytes: 4388
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()

def bubble(cards):
    for i in range(len(cards)):
        for j in range(len(cards)-1, i, -1):
            if cards[j][1]<cards[j-1][1]:
                cards[j],cards[j-1]=cards[j-1],cards[j]

def selection(cards):
    for i in range(len(cards)):
        mini=i
        for j in range(i,len(cards)):
            if cards[j][1]<cards[mini][1]:
                mini=j
        cards[i],cards[mini]=cards[mini],cards[i]

def stable_test(orders,cards):
    for order in orders:
        n=-1
        for c in order:
            p=n
            n=cards.index(c)
            if p>n:
                return False
    return True

sys.stdin.readline()
data1=sys.stdin.readline().split()
data2=data1[:]
orders=[[c for c in data1 if c.endswith(str(i))] for i in range(1,10)]
orders=[o for o in orders if len(c)>1]

bubble(data1)
print(*data1)
print('Stable' if stable_test(orders, data1) else 'Not stable')

selection(data2)
print(*data2)
print('Stable' if stable_test(orders, data2) else 'Not stable')

Measured memory_bytes: 4640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

int main(){
    string s, t;
    cin >> s >> t;
    int n1 = s.length();
    int n2 = t.length();
    map<char, int> s_cnt, t_cnt;
    vector<vector<int>> id(26);
    for(int i = 0; i < n1; ++i){
        int t = s[i] - 'a';
        id[t].push_back(i);
        ++s_cnt[s[i]];
    }
    for(int i = 0; i < n2; ++i){
        ++t_cnt[t[i]];
    }
    for(auto it = t_cnt.begin(); it != t_cnt.end(); ++it){
        if(s_cnt.find(it->first) == s_cnt.end()){
            cout << -1 << endl;
            return 0;
        }
    }
    
    ll res = 0;
    
    int now = -1;
    for(int i = 0; i < n2; ++i){
        int temp = t[i] - 'a';
        if(upper_bound(id[temp].begin(), id[temp].end(), now) == id[temp].end()){
            res += n1;
            now = id[temp][0];
        }
        else{
            now = *upper_bound(id[temp].begin(), id[temp].end(), now);
        }
    }
    
    res += now + 1;
    cout << res << endl;
}

Measured memory_bytes: 1216
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
const int maxn = 105;
char Map[maxn][maxn];
int n,m,dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};
void dfs(int x,int y,char s){
    Map[x][y]='x';
    for(int i=0;i<4;i++){
        int nx=dx[i]+x;
        int ny=dy[i]+y;
        if(0<=nx&&nx<n&&0<=ny&&ny<m&&Map[nx][ny]==s){
            dfs(nx,ny,s);
        }
    }
}
int main()
{
    //freopen("date.txt", "r", stdin);
    while(cin>>n>>m&&(n+m)){
        int res=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                cin>>Map[i][j];
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(Map[i][j]!='x'){
                    res++;
                    dfs(i,j,Map[i][j]);
                }
            }
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define mod 1000000007
#define PI acos(-1)
int main()
{
	IOS
	ll n;
	cin>>n;
	ll x=n%10;
	if(x==3)
	cout<<"bon";
	else if(x==0 || x==1 ||x==6||x==8)
	cout<<"pon";
	else
	cout<<"hon";
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int x;
		cin >> x;
		if (x >= 30) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string S;
  cin >> S;
  
  int hug = 0;
  
  int ssize = S.size();
  
  for (int i = 0; i < (ssize / 2); i++)
  {
    if(S[i] != S[ssize-1-i])
    {
      hug++;
    }
  }
  
  cout << hug << endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int d,k;
    cin >> d >> k;
    if(k==100){
        k+=1;
        rep(i,d){
            k*=100;
        }
    }
    else{
        rep(i,d){
            k*=100;
        }
    }
    cout << k;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define YES 1
#define NO 0

int main(void)
{
  int i;
  int num;
  int student[31] = {0};
  
  for(i = 0 ; i < 28 ; i++)
    {
      scanf("%d",&num);
      student[num] = YES;
    }
  
  for(i = 1 ; i < 31 ; i++)
    {
      if(student[i] == NO) printf("%d\n",i);
    } 
  
  return 0;
}

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

int main(){

  int W,H,N,i;
  cin>>W>>H>>N;
  int xl=0, xr=W, yd=0, yu=H;
  
  for(i=0; i<N; i++){
    int x,y,a;
    cin>>x>>y>>a;
    switch(a){
      case 1:
        xl=max(xl,x);
        break;
      case 2:
        xr=min(xr,x);
        break;
      case 3:
        yd=max(yd,y);
        break;
      case 4:
        yu=min(yu,y);
        break;
      default:
        break;
    }
  }
  if(xr-xl<=0 || yu-yd<=0){
    cout<<0<<endl;
    return 0;
  }
  cout<<(xr-xl)*(yu-yd)<<endl;
  return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>

#define rep( i, m, n ) for(int( i ) = ( m ); ( i ) < ( n ); ( i )++)

int main( void ){
	int n, k;
	if (!scanf( "%d%d", &n, &k ))
		return -1;
	int sum = (k-1)/(n-1);
	if ((k-1)%(n-1) != 0)
		sum++;
	printf("%d\n", sum);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll n, m, s;
  cin >> n >> m >> s;
  vector<tuple<ll, ll, ll, ll>> E;
  rep(_, m){
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    E.emplace_back(u, v, -a, b);
  }
  rep(v, n){
    ll c, d;
    cin >> c >> d;
    E.emplace_back(v, v, c, d);
  }

  ll S = 5050;
  auto dp = make_v(n, S, INF);
  dp[0][min(s, S - 1)] = 0;

  rep(_, 2 * n + 2) foreach(tup, E) rep(s, S){
    ll u, v, ds, dt;
    tie(u, v, ds, dt) = tup;
    ll ns = s + ds;
    if (0 <= ns && ns < S){
      chmin(dp[v][ns], dp[u][s] + dt);
      chmin(dp[u][ns], dp[v][s] + dt);
    }
  }
  
  rep(i, 1, n){
    ll res = INF;
    rep(j, S){
      chmin(res, dp[i][j]);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
using namespace std;


int main(){
  long X, y, c;
  c = 0;
  y = 100;
  cin >> X;
  while (y < X){
    y += long(y * 0.01);
    c += 1;
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 3620
N = int(input())
A = [int(a) for a in input().split()]

num_f2 = [0] * N
for i in range(N):
    a = A[i]
    while True:
        if a % 2 == 0:
            num_f2[i] += 1
            a //= 2
        else:
            break

print(sum(num_f2))

Measured memory_bytes: 4148
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>
using namespace std;
#define mod (long)(998244353)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
//#define long long long
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N, H, W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())
ls, lt = len(s), len(t)
ans = lt
for i in range(ls - lt + 1):
    cnt = 0
    for j in range(lt):
        if s[i + j] == t[j]:
            cnt += 1
    ans = min(ans, lt - cnt)
print(ans)

Measured memory_bytes: 9056
#include <iostream>
#include <vector>
#include <cmath>

long long solve(std::vector<long long> &a) {
    long long res = 0;
    long long nowsum = 0;
    for (int i = 0; i < a.size(); ++i) {
        if (i % 2 == 0) {
            if (nowsum + a[i] <= 0) {
                res += llabs(nowsum + a[i] - 1);
                nowsum = 1;
            } else { // nowsum + a[i] > 0)
                nowsum += a[i];
            }
        } else { // i % 2 != 0
            if (nowsum + a[i] >= 0) {
                res += llabs(nowsum + a[i] - (-1));
                nowsum = -1;
            } else { // nowsum + a[i] < 0
                nowsum += a[i];
            }
        }
/*
        std::cout << "i: " << i 
                  << ", a[i]: " << a[i]
                  << ", res: " << res
                  << ", nowsum: " << nowsum 
                  << std::endl;
*/
    }
    return res;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<long long> a;
    while (n--) {
        long long a_i;
        std::cin >> a_i;
        a.push_back(a_i);
    }

    long long res = solve(a);
    for (auto &i : a) {
        i *= -1;
    }
    
    res = std::min(res, solve(a));
    std::cout << res << std::endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;
const int mo = 1e9 + 7;

int n, k;
long long a[maxn], b[maxn], f[maxn];

void dfs(int u, int p, vector<vector<int> > &g) {
	int w = g[u].size();
	if (p != -1)
		--w;

	if (w == 0) {
		f[u] = 1;
		return;
	}

	if ((p == -1 && w > k-1) || (p != -1 && w > k-2)) {
		f[u] = 0;
		return;
	}

	long long cur = 1;
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i];
		if (v != p) {
			dfs(v, u, g);
			cur = cur * f[v] % mo;
		}
	}

	if (p != -1)
		f[u] = cur * a[w] % mo;
	else
		f[u] = cur * b[w] % mo;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> k;
	vector<vector<int> > g(n);

	for (int i = 0; i < n-1; ++i)
	{
		int u, v;
		cin >> u >> v;
		--u;
		--v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	a[0] = b[0] = 1;
	for (int i = 1; i <= k-2; ++i) {
		a[i] = a[i-1] * (k-2-i+1) % mo;
		b[i] = b[i-1] * (k-1-i+1) % mo;
	}

	b[k-1] = b[k-2];

	dfs(0, -1, g);

	cout << f[0] * k % mo << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

struct DSU {
    vi e; void init(int n) { e = vi(n,-1); }
    int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
    bool sameSet(int a, int b) { return get(a) == get(b); }
    int size(int x) { return -e[get(x)]; }
    bool unite(int x, int y) { // union by size
        x = get(x), y = get(y); if (x == y) return 0;
        if (e[x] > e[y]) swap(x,y);
        e[x] += e[y]; e[y] = x; return 1;
    }
};

int N; DSU DS;
vector<tuple<int,int,int>> adj;

ll Kruskal() {
    sort(all(adj)); DS.init(N); ll res = 0;
    trav(x,adj) {
        int u,v,w; tie(w,u,v) = x;
        if (DS.unite(u,v)) {
            res += w;
        }
    }
    return res;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> N;

    vector<tuple<int,int,int>> v;
    F0R(i,N) {
        int x,y; cin >> x >> y;
        v.pb(tie(x,y,i));
    }

    sort(all(v));

    F0R(i,N-1) {
        int x1,y1,ii,x2,y2,jj;
        tie(x1,y1,ii) = v[i];
        tie(x2,y2,jj) = v[i+1];

        int cost = min(abs(x1-x2),abs(y1-y2));
        adj.pb(tie(cost,ii,jj));
    }

    F0R(i,N) {
        int x1,y1,ii;
        tie(x1,y1,ii) = v[i];
        v[i] = tie(y1,x1,ii);
    }

    sort(all(v));

    F0R(i,N-1) {
        int x1,y1,ii,x2,y2,jj;
        tie(x1,y1,ii) = v[i];
        tie(x2,y2,jj) = v[i+1];

        int cost = min(abs(x1-x2),abs(y1-y2));
        adj.pb(tie(cost,ii,jj));
    }

    cout << Kruskal() << "\n";

}


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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  //$B<j$KF~$l$?Ju@P$N2ACM$N9g7W$r(B X $B!"(B
  //$B;YJ'$C$?%3%9%H$N9g7W$r(B Y $B$H$7$^$9!#(B
  //X $B!](B Y $B$N:GBgCM$r5a$a$F$/$@$5$$!#(B
  int v[n],c,ans=0;
  rep(i,n)cin>>v[i];
  rep(i,n){
    cin>>c;
    if(v[i]-c>0)ans+=v[i]-c;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 10000000000000
using namespace std;
using ll = long long;
int main() {
	ll n, k;
	cin >> n >> k;
	ll dp[100010];
	vector<ll> h(n);
	for (ll i = 0; i < n; i++) {
		cin >> h[i];
	}
	dp[0] = 0;
	ll zero = 0;
	for (ll i = 1; i < n; i++) {
		ll temp = INF;
		for (ll j = max(i-k,zero); j < i; j++) {
			if (abs(h[j] - h[i]) + dp[j] < temp) {
				temp = abs(h[j] - h[i]) + dp[j];
			}
		}
		dp[i] = temp;
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n,m = LI()
    s = [[] for i in range(n)]
    ans = 0
    for i in range(1,m+1):
        lst = LI()
        for j in lst[1:]:
            s[j-1].append(i)
    p = [0] + LI()
    # print(n,m,s,p)
    bits = itertools.product([0,1],repeat=n)
    for bit in bits:
        lst = [0 for _ in range(m+1)]
        for i in range(n):
            if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
        if lst == p:
            ans+= 1
    print(ans)
main()

Measured memory_bytes: 75412
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <iostream>

#define fo(i, x, y) for (int i = (x); i <= (y); ++i)
#define fd(i, x, y) for (int i = (x); i >= (y); --i)
using namespace std;

typedef long long ll;

const int maxn = 2e5 + 5;

int n;
char s[maxn];

int getint() {
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	ll ans = 0, b = 0;
	fo (i, 1, n) {
		b += s[i] == 'B';
		ans += b * (s[i] == 'W');
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

namespace mine
{
	const int MAX_N=310000;
	typedef long long ll;
	int mymin(int x,int y) {return x<y?x:y;}
	int myabs(int x) {return x>0?x:-x;}

	int a[MAX_N],b[MAX_N];
	bool check(int l,int r)
	{
		int left=0,right=0;
		for(int i=l;i<=r;i++)
		{
			if(a[i]<l or a[i]>r) return 0;
			if(a[i]<i)//left
			{
				if(left>a[i]) return 0;
				left=a[i];
			}
			else if(a[i]>i)
			{
				if(right>a[i]) return 0;
				right=a[i];
			}
		}
		return 1;
	}
	#define GG {puts("No");return;}
	void main()
	{
		int n;scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			if((a[i]-i)%2) GG//奇偶性
			b[i]=(a[i]==i);
			if(i>=3 and !b[i-2] and !b[i-1] and !b[i]) GG//连续三个动点
		}

		for(int l=1;l<=n;l++) if(b[l]==0)//动点
		{
			int now=1;//交替
			int r=l;while(r+1<=n and b[r+1]==now) now^=1,r++;
			if(!check(l,r)) GG
			l=r;
		}
		puts("Yes");
	}
};

int main()
{
	mine::main();
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;
static const double PI = 3.14159265358979323846;

int main(void){

  int n, m;
  std::cin >> n >> m;

  std::vector<std::set<int> > adj_mat(n+1);
  for(int i=0; i<m; i++){
    int a, b;
    std::cin >> a >> b;
    adj_mat[a].insert(b);
    adj_mat[b].insert(a);
  }

  std::vector<int>  dist(n+1);
  std::vector<bool> checked(n+1, false);
  
  std::priority_queue<std::array<int, 3>, std::vector<std::array<int, 3> >, std::greater<std::array<int, 3> > > pq;
  pq.push({0,1,-1});
  while(!pq.empty()){
    auto now = pq.top();
    //std::cout << now[0] << " " << now[1] << " " << now[2] << std::endl;
    pq.pop();
    if(checked[now[1]]) continue;
    checked[now[1]] = true;
    dist[now[1]] = now[2];

    for(const auto& elem: adj_mat[now[1]]){
      if(checked[elem]) continue;
      pq.push({now[0]+1, elem,now[1]});
    }
    
  }

  std::cout << "Yes" << std::endl;
  for(int i=2; i<=n; i++){
    std::cout << dist[i] << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 28568
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
ls1 = []
ls2 = []
ls3 = []
for i in range(N):
    if P[i]<=A:
        ls1.append(P[i])
    elif (A+1)<=P[i]<=B:
        ls2.append(P[i])
    else:
        ls3.append(P[i])
print(min(len(ls1),len(ls2),len(ls3)))

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int x[3];
  int tmp;
  for(int i=0;i<3;i++)scanf("%d",&x[i]);
  for(int i=0;i<2;i++){
    for(int j=i+1;j<3;j++){
      if(x[i]>x[j]){
        tmp=x[i];
        x[i]=x[j];
        x[j]=tmp;
      }
    }
  }
  printf("%d\n",x[0]+x[1]);
  return 0;
}
    

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc047/tasks/abc047_b
"use strict";
function Main(input) {
  const [basePoint, ...points] = input.trim().split("\n");
  const [W, H, N] = basePoint.trim().split(" ").map(Number);
  const field = Array(W)
    .fill()
    .map(() => Array(H).fill(1));

  for (let i = 0; i < N; i++) {
    const [x, y, a] = points[i].trim().split(" ").map(Number);
    if (a === 1) {
      for (let j = 0; j < x; j++) {
        for (let k = 0; k < H; k++) {
          field[j][k] = 0;
        }
      }
    } else if (a === 2) {
      for (let j = x; j < W; j++) {
        for (let k = 0; k < H; k++) {
          field[j][k] = 0;
        }
      }
    } else if (a === 3) {
      for (let j = 0; j < W; j++) {
        for (let k = 0; k < y; k++) {
          field[j][k] = 0;
        }
      }
    } else if (a === 4) {
      for (let j = 0; j < W; j++) {
        for (let k = y; k < H; k++) {
          field[j][k] = 0;
        }
      }
    }
  }

  const area = field.flat().reduce((acc, cur) => acc + cur, 0);
  console.log(area);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 33572
'use strict'

const main = (INPUT) => {
  const s = INPUT.split('\n')[0]
  let ans = ''
  for (let i = 0; i < s.length; i += 2) {
    ans += s[i]
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int n;
int a;
int c[limit];

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>n;
  rep(i, n) {
    cin>>a;
    c[a]++;
    c[a+1]++;
    c[a+2]++;
  }
  
  int m=0;
  
  rep(i, limit)m = c[i]>m?c[i]:m;
  
  cout<<m<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    int N, ans = 1;
    cin >> N;
    while(ans <= N){
        ans *= 2;
    }
    ans /= 2;
    if(ans == 0) ans = 1;
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a*n,b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    rep(i, 1, n) {
        if (s[i] != s[i - 1]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int N;
int A[210];

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

  int res = 0;

  while(true) {
    bool exist_odd = false;
    for (int i = 0; i < N; ++i) {
      if (A[i] % 2 != 0) exist_odd = true;
    }

    if (exist_odd) break;

    for (int i = 0; i < N; ++i) {
      A[i] /= 2;
    }
    ++res;
  }

  cout << res << endl;

  return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 2e5 + 5;

ll pw(ll x, ll y) {
    x %= mod;
    ll res = 1;
    while (y > 0) {
	if (y%2 == 1) {
	    res *= x;
	    res %= mod;
	}
	x = x * x;
	x %= mod;
	y = y / 2;

    }
    return res;

}


ll inv(ll x) {
    assert(x != 0);
    return pw(x, mod-2);

}

ll fac[maxn], ifac[maxn];

int n;
vector<int> g[maxn];
ll siz[maxn];
ll dp[maxn];
ll ans[maxn];


void dfs(int at, int p) {
    siz[at]=1;
    for (int to: g[at]) {
	if (to == p) continue;
	dfs(to, at);
	siz[at]+=siz[to];
    }
}

void dfs2(int at, int p) {
    dp[at]=fac[siz[at]-1];
    for (int to: g[at]) {
	if (to == p) continue;
	dfs2(to, at);
	dp[at]*=dp[to];
	dp[at]%=mod;
	dp[at]*=ifac[siz[to]];
	dp[at]%=mod;
    }
}

void dfs3(int at, int p) {
    ans[at]=dp[at];
    for (int to: g[at]) {
	if (to == p) continue;
	//undo `to` in me
	dp[at]*=fac[siz[to]];
	dp[at]%=mod;
	dp[at]*=inv(dp[to]);
	dp[at]%=mod;
	dp[at]*=ifac[siz[at]-1];
	dp[at]%=mod;
	siz[at]-=siz[to];
	dp[at]*=fac[siz[at]-1];
	dp[at]%=mod;
	
	//add me to `to`
	dp[to]*=dp[at];
	dp[to]%=mod;
	dp[to]*=ifac[siz[at]];
	dp[to]%=mod;
	dp[to]*=ifac[siz[to]-1];
	dp[to]%=mod;
	siz[to]+=siz[at];
	dp[to]*=fac[siz[to]-1];
	dp[to]%=mod;
	
	
	dfs3(to, at);

	//undo `to`
	dp[to]*=ifac[siz[to]-1];
	dp[to]%=mod;
	siz[to]-=siz[at];
	dp[to]*=fac[siz[to]-1];
	dp[to]%=mod;
	dp[to]*=fac[siz[at]];
	dp[to]%=mod;
	dp[to]*=inv(dp[at]);
	dp[to]%=mod;

	dp[at]*=ifac[siz[at]-1];
	dp[at]%=mod;
	siz[at]+=siz[to];
	dp[at]*=fac[siz[at]-1];
	dp[at]%=mod;
	dp[at]*=dp[to];
	dp[at]%=mod;
	dp[at]*=ifac[siz[to]];
	dp[at]%=mod;
    }
}

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

    fac[0]=ifac[0]=1;
    for (int i=1; i<maxn; i++) {
	fac[i]=1LL*i*fac[i-1]%mod;
	ifac[i]=inv(fac[i]);
    }
    assert(fac[4]==24);
    
    cin>>n;
    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }

    dfs(1,0);
    dfs2(1,0);
    dfs3(1,0);

    for (int i=1; i<=n; i++) {
	ans[i]%=mod;
	ans[i]+=mod;
	ans[i]%=mod;
	cout<<ans[i]<<"\n";
    }
  

    return 0;
}


Measured memory_bytes: 21748
a = gets.to_i
b = gets.split.map(&:to_i)

l = Array.new(a, 0)
r = Array.new(a, 0)

(a - 1).times do |i|
  l[i + 1] = l[i].gcd(b[i])
end

(a - 1).downto(1) do |i|
  r[i - 1] = r[i].gcd(b[i])
end

ans = 1
a.times {|i| ans = [ans, l[i].gcd(r[i])].sort[1]}
p ans

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  string s;
  cin >> s;

  int w = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'o') w++;
  }

  if (w + (15 - s.length()) >= 8) {
    py(true);
  } else {
    pn(true);
  }
}

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

using namespace std;

const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,-1,0,1 };
const int LIT = 1e9 + 7;
int n, m;

void solve() {
    int x, t;
    cin >> n >> x >> t;
    if (n % x == 0) cout << t * (n / x);
    else cout << t * ((n / x) + 1);

}

int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main() {
  int n, cnt, ans;
  cin >> n;
  cnt = 0;
  vector<char> vec(n), vecvec(n);
  for(int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  vecvec = vec;
  sort(vec.begin(), vec.end());
    
  for(int i = 0; i < n; i++){
    if(vec.at(i)!=vecvec.at(i)) cnt++;
  }
  
  ans = cnt/2;
  cout << ans;
  

    
}



Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<algorithm>

void turn(std::vector<int> &cards, int &ba){
	for(int i=0;i<cards.size();i++){
		if(cards[i] > ba){
			ba = cards[i];
			cards.erase(cards.begin() + i);
			return;
		}
	}
	ba = 0;
}

int main(){
	int n;

	while(std::cin >> n, n){
		std::vector<int> a, _v, b;

		for(int i=0;i<n;i++){
			int j;
			std::cin >> j;
			a.push_back(j);
			_v.push_back(2*i+1);
			_v.push_back(2*i+2);
		}
	
		std::sort(a.begin(), a.end());
		std::set_difference(_v.begin(), _v.end(), a.begin(), a.end(), std::inserter(b, b.begin()));

		int ba = 0;
		while(true){
			turn(a, ba);
			if(a.empty())break;
			turn(b, ba);
			if(b.empty())break;
		}
	
		std::cout << b.size() << "\n" << a.size() << "\n";
	}
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"

using namespace std;

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

	int a, b;
	cin >> a >> b;
	if (a == 0 || b == 0 || (a < 0 && b > 0))
		cout << "Zero" << endl;
	else if (b > -1)
		if(a > -1)
			cout << "Positive" << endl;
		else if (!(a % 2))
			cout << "Positive" << endl;
		else
			cout << "Negative" << endl;
	else
		if ((b - a) & 1)
			cout << "Positive" << endl;
		else
			cout << "Negative" << endl;

	return 0;

}

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

string s, t;
constexpr int mod = 1'000'000'007;
int dp[1005][1005];

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

  cin >> s >> t;
  rep(i, s.size()+1) dp[i][0] = 1;
  rep(i, s.size()) rep(j, t.size()) {
    dp[i+1][j+1] = dp[i][j+1];
    if (s[i] == t[j]) dp[i+1][j+1] += dp[i][j];
    dp[i+1][j+1] %= mod;
  }
  cout << dp[s.size()][t.size()] << "\n";
}


Measured memory_bytes: 7188
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int i=0,maxx=0;
    while(i<n){
        int j=i+1,cnt=0;
        while(j<n && arr[j]<=arr[j-1]){
            j++;
            cnt++;
        }
        i=j;
        maxx=max(maxx,cnt);
    }
    cout<<maxx;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
#include <map>
#include <math.h>

using ll = long long;
using namespace std;
int digit_disc(ll num){
    ll count=0;
    while(num!=0){
        num/=10;
        count++;
    }
    return count;
}

int main(){
   ll n, a, b;
   cin >> n;
   ll min_count=INF;
   for(ll i=1ll; i<=(sqrt(n)+1); i++){
       a = n/i;
       if(n%i==0){
           ll a_i = max(digit_disc(a), digit_disc(i));
           if(a_i<min_count) min_count = a_i;
       }
   }
   cout << min_count << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int n, i, j, k;
	string s;
	cin >> n >> s;
	ll r = 0, g = 0, b = 0;
	for (i = 0; i < n; i++) {
		if (s[i] == 'R') r++;
		if (s[i] == 'G') g++;
		if (s[i] == 'B') b++;
	}

	ll total = r * g * b;
	ll sub = 0;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			if (s[i] == s[j]) continue;
			int k = j + (j - i); // -> (2 * j) - i
			if (k >= n || s[k] == s[i] || s[k] == s[j]) continue;
			sub++;
		}
	}
	cout << (total - sub) << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

 

int main(void) {

  string s;
  cin >> s;
  if (s[1] == 'B') cout << "ARC\n";
  else cout << "ABC\n";
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int H, W;
	cin >> H >> W;
	int h,  w;
	cin >> h >> w;
	cout << (H*W) - (H*w + W*h - h*w) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int> m;
int n,i,j,x,y,a,b,maxn;
string maxs,s;
inline bool isnumber(char c){
    if(c>='0'&&c<='9') return 1;
    else return 0;
}
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(!isnumber(c)){
        c=getchar();
    }
    while(isnumber(c)) x=x*10+c-48,c=getchar();
    return x;
}
int main(){
    n=read();
    string h[n];
    for(i=1;i<=n;i++){
        cin >> s;
        h[i-1]=s;
        m[s]++;
        if(m[s]>maxn) maxn=m[s],maxs=s;      
    }
    sort(h,h+n);
   for(int i=0;i<n;i++)
   {
   		if(m[h[i]]==maxn)
   		{
   			cout<<h[i]<<endl;
			   m[h[i]]=-1;	
		}
   }
    return 0;
}

Measured memory_bytes: 26752
#include <stdio.h>
#include <stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMi(Node a){
  while(a->left!=NIL)
   a=a->left;
  return a;
}
Node treeMa(Node a){
  while(a->right!=NIL)
    a=a->right;
  return a;
}
Node treeS(Node w, int r){
  while(w!=NIL&&r!=w->key){
    if(r<w->key)w=w->left;
    else w=w->right;
  }
  return w;
}
Node treeM(Node a){
  Node b;
  if(a->right!=NIL)
    return treeMi(a->right);
  b=a->parent;
  while(b!=NIL&&a==b->right){
    a=b;
    b=b->parent;
  }
  return b;
}
void treeN(Node c){
  Node a;
  Node b;
  if(c->left==NIL||c->right==NIL)b=c;
  else
    b=treeM(c);
  if(b->left!=NIL){
    a=b->left;
  }
  else{
    a=b->right;
  }
  if(a!=NIL){
    a->parent=b->parent;
  }
  if(b->parent==NIL){
    root=a;
  }
  else{
    if(b==b->parent->left){
      b->parent->left=a;
    }
    else{
      b->parent->right=a;
    }
  }
  if(b!=c){
    c->key=b->key;
  }
  free(b);
}
void insert(int k){
  Node a = root;
  Node b = NIL;
  Node c;
  c = malloc(sizeof(struct node));
  c->key = k;
  c->left = NIL;
  c->right = NIL;
  while(a!=NIL){
    b=a;
    if(c->key < a->key){
      a=a->left;
    }
    else{
      a=a->right;
    }
  }
  c->parent=b;
  if(b==NIL){
    root=c;
  }
  else{
    if(c->key < b->key){
      b->left=c;
    }
    else{
      b->right=c;
    }
  }
}
void inorder(Node n){
  if(n==NIL)
    return;
  inorder(n->left);
  printf(" %d",n->key);
  inorder(n->right);
}
void outorder(Node n){
  if(n==NIL)
    return;
  printf(" %d",n->key);
  outorder(n->left);
  outorder(n->right);
}
int main(){
  int i,n,a;
  char c[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",c);
    if(c[0]=='f'){
      scanf("%d",&a);
      Node r = treeS(root,a);
      if(r!=NIL)
	printf("yes\n");
      else printf("no\n");
    }
    else if(c[0] ==  'i'){
      scanf("%d",&a);
      insert(a);
    }
    else if(c[0] ==  'p'){
      inorder(root);
      printf("\n");
      outorder(root);
      printf("\n");
    }
    else if(c[0]=='d'){
      scanf("%d",&a);
      treeN(treeS(root,a));
    }
  }
  return 0;
}



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

int main(){
  int N, Y;
  cin >> N >> Y;

  int x = -1, y = -1, z = -1;
  for(int ix = 0 ; ix <= N; ix++){
    for(int iy = 0; iy <= N - ix; iy++){
      int sum = ix * 10000 + iy * 5000 + (N- ix-iy) * 1000;
      if(sum == Y){
        x = ix;
        y = iy;
        z = N- ix-iy;
      }
    }
  }

  cout << x << " " << y << " " << z << endl;

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC124
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            if (ab[0] <= ab[1]) { ans += ab[1]; ab[1]--; }
            else { ans += ab[0]; ab[0]--; }
            if (ab[0] <= ab[1]) { ans += ab[1]; ab[1]--; }
            else { ans += ab[0]; ab[0]--; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	string s[N];int t[N];
	rep(i,0,N){
		cin>>s[i]>>t[i];
	}
	string X;cin>>X;
	int sum=0;bool flag=false;
	rep(i,0,N){
		if(flag) sum+=t[i];
		if(s[i]==X) flag=true;
	}
	cout<<sum<<endl;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n;
    cin>>n;
    if(n>=30) cout<<"Yes" el;
    else cout<<"No" el;
}

main()
{
//    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

int main() {
  int N ,K;
  cin >> N >> K;
  vector<int> d(K);
  vector<bool> S(N);
  for(int i = 0; i < N; i++) {
    S.at(i) = false;
  }
  for(int i = 0; i < K; i++) {
    cin >> d.at(i);
    vector<int> A(d.at(i));
    for(int j = 0; j < d.at(i); j++) {
      cin >> A.at(j);
      S.at(A.at(j)-1) = true;
    }
  }
  int cnt = 0;
  for(int i = 0; i < N; i++) {
    if(S.at(i)==false) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3632