akhauriyash/Code-Regression huggingface dataset:
from collections import deque
def main():
    N,M= map(int, input().split())
    ans = [-1]*(N+1)
    ans2 = [-1]*(N+1)
    ans[1] = 0

    L=[]
    [L.append([])for _ in range(N+1)]

    for i in range(M):
        A,B = map(int, input().split())
        L[A].append(B)
        L[B].append(A)
    
    q = deque()
    qq = deque()


    for i in range(len(L[1])):
        q.append(L[1][i])
        qq.append(1)

    while len(q) !=0:
        temp = q.popleft()
        tempq = qq.popleft()
        if ans[temp]==-1:
            ans[temp] = tempq + 1
            ans2[temp] = tempq

            for i in range(len(L[temp])):
                q.append(L[temp][i])
                qq.append(temp)

    for i in range(2,N+1):
        if ans[i]==-1:
            print('No')
            return

    print('Yes')

    for i in range(2,N+1):
        print(ans2[i])





if __name__ == '__main__':
    main()

Measured memory_bytes: 39816
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

const ll MOD=998244353;

int main(){
  ll N,M,K;
  cin >> N >> M >> K;

  ll n=max(N,M)+1;

  vector<ll> fac(n);
  vector<ll> inv(n);
  vector<ll> facinv(n);
  
  fac[0]=fac[1]=1;
  facinv[0]=facinv[1]=1;
  inv[1]=1;

  for(ll i=2;i<n;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    facinv[i]=facinv[i-1]*inv[i]%MOD;
  }
  
  ll ans=0;

  ll tmp=1;
  for(int i=0;i<N-K-1;i++){
    tmp*=(M-1); tmp%=MOD;
  }

  for(ll i=K;0<=i;i--){
    ll t=M;
    t*=tmp; t%=MOD;
    t*=fac[N-1]; t%=MOD;
    t*=facinv[i]; t%=MOD;
    t*=facinv[N-1-i]; t%=MOD;
    //cout << i << " " << t << endl;
    ans+=t;
    ans%=MOD;
    tmp*=M-1; tmp%=MOD;
  }

  cout << (ans+MOD)%MOD << endl;

  return 0;
}


Measured memory_bytes: 8016
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int a, b;
    cin >> a >> b;
    long long int result = 0;
    
    if(a%2){
        result ^= a;
        a++;
    }
    if(b%2==0){
        result ^= b;
        b--;
    }
    if((b-a)%4==1){
        result ^= 1;
    }else{
        
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MAX 2000002
#define MIN_VALUE -2000000001
using namespace std;
int T[MAX];
int heap=0;

void maxHeapify(int *A,int i){
    int largest,l=2*i,r=2*i+1;
    if(l<=heap&&A[l]>A[i])largest =l;
    else largest=i;
    if(r<=heap&&A[r]>A[largest])largest=r;
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A,largest);
    }
}
void buildMaxHeap(int *A){
    for(int i=heap/2;i>0;i--){
        // for(int j=1;j<=heap;j++)printf(" %d",T[j].k); 
        // printf("\n"); 
        maxHeapify(A,i);
    }
}

int heapExtractMax(int *A){
    if(heap<1)cout<<"Error"<<endl;
    int max=A[1];
    A[1]=A[heap];
    heap--;
    maxHeapify(A,1);
    return max;
}

void heapIncreaseKey(int *A,int i,int key){
    if(key<A[i])cout<<"Error"<<endl;
    A[i]=key;
    while(i>1&&A[i/2]<A[i]){
        swap(A[i],A[i/2]);
        i=i/2;
    }
}

void maxHeapInsert(int *A,int key){
    heap++;
    A[heap]=MIN_VALUE;
    heapIncreaseKey(A,heap,key);
}

int main(){
    int i,key;
    char c[20];
    // cin>>heap;
    for(i=1; i<=MAX; i++){
        scanf("%s",c);
        if(c[0]=='i'){
            cin>>key;
            maxHeapInsert(T,key);
        }else if(c[0]=='e'&&c[1]=='x'){
            cout<<heapExtractMax(T)<<endl;
        }else if(c[0]=='e'&&c[1]=='n')break;
    }
    // for(i=1;i<=heap;i++)cout<<" "<<T[i];; 
    // cout<<endl;
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int r[200020];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n)cin>>r[i];
	int res=-2000000001,minn=r[0];
	repl(i,1,n){
		maxch(res,r[i]-minn);
		minch(minn,r[i]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

struct UnionFind {
    private:
        vll par;
    public:
        map<ll, ll> mp;
        UnionFind(ll N) : par(N) {
            rep(i, N) par[i] = i;
        }

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

        void unite(ll x, ll y) {
            ll rx = root(x);
            ll ry = root(y);
            if (rx == ry) return;
            par[rx] = ry;
        }

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

        void calc_group_size() {
            rep(i, par.size()) {
                mp[root(i)]++;
            }
        }

        ll get_group_size(ll i) {
            return mp[root(i)];
        }
};

int main()
{
    ll n, m, k; cin >> n >> m >> k;
    UnionFind uf(n);
    vector<set<ll>> rel(n), block(n);
    rep(i, m) {
        ll a, b; cin >> a >> b; a--, b--;
        uf.unite(a, b);
        rel[a].insert(b);
        rel[b].insert(a);
    }
    rep(i, k) {
        ll c, d; cin >> c >> d; c--, d--;
        block[c].insert(d);
        block[d].insert(c);
    }
    uf.calc_group_size();
    // cout << "---------------- group and size" << endl;
    // for (auto elem : uf.mp) {
    //     cout << elem.first << " " << elem.second << endl;
    // }
    // cout << "------------------------" << endl;

    rep(i, n) {
        // i番目のユーザーについて        // cout << "group size: " << uf.get_group_size(i) << endl;
        // cout << "direct relation size: " << rel[i].size() << endl;

        ll num = uf.get_group_size(i) - rel[i].size() - 1ll;
        for (auto c : block[i]) {
            if (uf.same(i, c)) num--;
        }
        cout << num << " ";
    }
    cout << endl;


    return 0;
}

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

using namespace std;

using Graph = vector<vector<int>>;

int MinimumPath(const Graph &g) {
    const int n = g.size();
    int min_d = 1e8;

    vector<int> idx(n - 1);
    iota(idx.begin(), idx.end(), 1);

    do {
        int d = g[0][idx[0]];
        for (int i = 0; i < n - 2; ++i) d += g[idx[i]][idx[i + 1]];
        min_d = min(min_d, d);
    } while (next_permutation(idx.begin(), idx.end()));

    return min_d;
}

const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, -1, 0, 1};

int Distance(const auto &src, const auto &dst, const int h, const int w, const vector<string> &c) {
    vector<vector<int>> d(h, vector<int>(w, -1));
    queue<pair<int, int>> que;
    que.push(src);
    d[src.first][src.second] = 0;

    while (!que.empty()) {
        auto cur = que.front(); que.pop();

        for (int dir = 0; dir < 4; ++dir) {
            pair<int, int> nxt(cur.first + dr[dir], cur.second + dc[dir]);
            if (nxt.first < 0 || nxt.second < 0 || h <= nxt.first || w <= nxt.second
                || d[nxt.first][nxt.second] != -1 || c[nxt.first][nxt.second] == 'x')
                continue;
            d[nxt.first][nxt.second] = d[cur.first][cur.second] + 1;
            que.push(nxt);
        }
    }

    return d[dst.first][dst.second];
}

pair<bool, Graph> MakeGraph(const int w, const int h, const vector<string> &c) {
    vector<pair<int, int>> pos(1);
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
            if (c[i][j] == 'o') pos[0] = make_pair(i, j);
            else if (c[i][j] == '*') pos.emplace_back(make_pair(i, j));
        }

    const int n = pos.size();
    Graph d(n, vector<int>(n));
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            int d_ij = Distance(pos[i], pos[j], h, w, c);
            if (d_ij == -1) return make_pair(true, d);
            d[i][j] = d[j][i] = d_ij;
        }

    return make_pair(false, d);
}

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

    int w, h;

    while (cin >> w >> h, (w != 0 || h != 0)) {
        vector<string> c(h);
        for (auto &x : c) cin >> x;

        auto res = MakeGraph(w, h, c);
        if (res.first) cout << -1 << '\n';
        else cout << MinimumPath(res.second) << '\n';
    }

    return 0;
}



Measured memory_bytes: 3152
n, w = map(int, input().split())
item = [list(map(int, input().split())) for i in range(n)]

# dp[i][j]
dp = [[0 for j in range(w + 1)] for i in range(n + 1)]

# i: i 番目のアイテム
# sum_w: 総容量 sum_w の場合
for i in range(n):
    for sum_w in range(w + 1):
        if sum_w - item[i][1] >= 0:
            # i 番目のアイテムを選ぶ場合
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - item[i][1]] + item[i][0])
        # i 番目のアイテムを選ばない場合
        dp[i + 1][sum_w] = max((dp[i + 1][sum_w], dp[i][sum_w]))
print(dp[n][w])


Measured memory_bytes: 42472
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  int maxa = 0, mina = 1000;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    maxa = max(a, maxa);
    mina = min(a, mina);
  }
  cout << maxa - mina << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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


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

	ll A,B,C,K;

	cin>>A>>B>>C>>K;

	ll sum = 0;

	while(K!=0 && A!=0)
	{
		sum = sum + 1;
		A--;
		K--;
	}

	while(K!=0 && B!=0)
	{
		sum = sum + 0;
		B--;
		K--;
	}

	while(K!=0 && C!=0)
	{
		sum = sum - 1;
		C--;
		K--;
	}

	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 3636
from collections import deque

N, M = map(int, input().split())

graph = [[] for i in range(N)]
for i in range(M):
  u, v = map(int, input().split())
  graph[u-1].append(v-1)

s, t = map(int, input().split())
s -= 1
t -= 1


is_visited = [[False]*N for i in range(3)]
is_visited[0][s] = True

d = deque([s])
ans = 0
while d:
  ans += 1
  for step in [1, 2, 0]:
    diff = 0
    if d:
      len_d = len(d)
      for i in range(len_d):
        node = d.popleft()
        children = graph[node]
        for child in children:
          if step == 0:
            if child == t:
              d = []
              diff = 1
              break
          
          if not is_visited[step][child]:
            is_visited[step][child] = True
            diff += 1
            d.append(child)
          
        else:
          continue
        break
    
    else:
      ans = -1
      break
  
  if not diff:
    ans = -1
    break

print(ans)

Measured memory_bytes: 20688
import heapq, copy
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = -10 ** 10
for a in range(min(n, k) + 1):
    for b in range(min(n, k) - a + 1):
        have = []
        
        for i in range(a):
            have.append(v[i])
        for i in range(b):
            have.append(v[n-i-1])

        heapq.heapify(have)
        
        for c in range(k - a - b):
            if len(have) <= 0:
                break
            item = heapq.heappop(have)
            if item >= 0:
                have.append(item)
                break
        ans = max(ans, sum(have))

print(ans)


Measured memory_bytes: 75748
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

double a, b, x;

int main(){
    cin >> a >> b;
    cout << 1 + ceil((a-b) / (1-a));

}


//g++ -std=c++14 comp.cpp; ./a.exe


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

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    string s;
    cin >> s;
    if (s.back() == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s << endl;
}

Measured memory_bytes: 3648
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var param = lines[0].split(' ').map(Number);
  var result = (function(a,b,c) {
    var count = 0;
    for (var i = a; i < b + 1; i++){
        if (c % i === 0) count++;
    }
    return count;
  }(param[0],param[1],param[2]
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  vector< vector<int>> card(3, vector<int>(3,0));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> card[i][j];
    }
  }

  int64_t n;
  cin >> n;
  int number;
  for(int i=0;i<n;i++){
    cin >> number;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(number==card[i][j]){
          card[i][j] = 0;
        }
      }
    }
  }
  
  int row[3] = {0}; 
  int col[3] = {0}; 
  for(int i=0;i<3;i++){
  	for(int j=0;j<3;j++){
      row[i] += card[i][j];
      col[j] += card[i][j];
    }
  }
  for(int i=0;i<3;i++){
    if(row[i]==0||col[i]==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if( (0==card[0][0]+card[1][1]+card[2][2])
     || (0==card[0][2]+card[1][1]+card[0][2]) )
  { 
      cout << "Yes" << endl;
      return 0;
  }

  cout << "No" << endl;

  return 0;
}




Measured memory_bytes: 3700
fun main(args: Array<String>) {
    while (true){
        val (h, w) = readLine()?.split(" ")?.map { it.toInt() } ?: return
        if (h == 0 && w == 0) return
        for (i in h downTo 1){
            for (j in w downTo 1){
                if (j == 1) {
                    println("#")
                }else if (i == 1 || i == h || j == w){
                    print("#")
                }else {
                    print(".")
                }
            }
        }
        println("")
    }
}


Measured memory_bytes: 36696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
 int n,m;
 cin >> n >> m;
 vector<int> a(n),w(n);
 rep(i,m){
   int p;
   string m;
   cin >> p >> m;
   p--;
   if(a.at(p)) continue;
   if(m == "AC") a.at(p)++;
   else w.at(p)++;
 }
 int sums = 0,sump = 0;
rep(i,n){
   sums+=a.at(i);
   if(a.at(i))sump+=w.at(i);
 }
 cout << sums << " " << sump << endl;
}

Measured memory_bytes: 4036
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const double PI=3.14159265358979323846;

int main() {
    double a,b,x; cin >> a >> b >> x;
    double ans;
    if(x / a <= a * b / 2) ans = 90 - (atan(2 * x / (a * b * b)) * 180 / PI);
    else {
         ans = 90 - (atan(a*a*a/(2*(a*a*b-x))) * 180 / PI); 
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int i,N,M,X;
  scanf("%d%d%d",&N,&M,&X);
  int A[M+1];
  for(i=1;i<=M;i++){
    scanf("%d",&A[i]);
  }
  int k=0;
  for(i=1;i<M;i++){
    if(A[i]<X && X<A[i+1]){
      k=i;
    }
  }

  if(k<M-k){
    printf("%d",k);
  }else{
    printf("%d",M-k);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <vector>
    #include <cmath>
    #include <map>

    #define ll long long
    #define mod 1000000007
    using namespace std;

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

       ll a,b,c,x,y;
       cin>>a>>b>>c>>x>>y;
       ll temp1=a*x + b*y;
       ll temp2=max(x,y)*2*c;
       ll temp3,temp4;
       if(x<y) {
           temp3=x*2*c;
           y-=x;
           temp3+=min(y*b,y*2*c);
       } else {
           temp3=y*2*c;
           x-=y;
           temp3+=min(x*a,x*2*c);
       }
        ll ans=min(temp1,min(temp2,temp3));
       cout<<ans<<"\n";
        return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

const ll BTC_TO_YEN = 380000;

int main() {
    int n;
    double x, ans = 0.0;
    string u;
    cin >> n;
    for(int i=0;i<n;++i) {
        cin >> x >> u;
        if(u == "JPY") {
            ans += x;
        } else {
            ans += x * BTC_TO_YEN;
        }
    }
    cout << setprecision(6) << ans << "\n";
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
ll A,B;

int main()
{
	scanf("%d%lld%lld",&N,&A,&B);
	vector<ll> X(N),diff(N - 1);
	FOR(i,0,N){
		scanf("%lld",&X [i]);
	}
	FOR(i,0,N - 1){
		diff [i] = X [i + 1] - X [i];
	}
	sort(ALL(diff),greater<ll>());

	ll sum = accumulate(ALL(diff),0ll) * A,ans = sum;
	FOR(i,0,N - 1){
		sum += B - diff [i] * A;
		chmin(ans,sum);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
  int a, b, ans = 1;
  
  cin >> a >> b;
  if (b == 100) {
    b = 101;
  }
  
  for (int i = 1; i <= a; i++) {
    ans = ans * 100;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    int rem = (n-1)*(n-2)/2 - k;
    if (rem < 0) {
        cout << -1 << endl;
        return 0;
    }

    cout << (n-1)+rem << endl;

    for (int i = 2; i <= n; ++i) {
        cout << 1 << " " << i << "\n";
    }

    for (int i = 2; i <= n-1 && rem; ++i) {
        for (int j = i+1; j <= n && rem; ++j) {
            cout << i << " " << j << "\n";
            --rem;
        }
    }

    cout << flush;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap, pair
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt,ceil,M_PI, pow, sin
#include <sstream>	//stringstream,getline
#include <numeric>	//gcd, accumlate
#include <deque>	//deque
#include <random>	//randam_device

using namespace std;

int main() {

	string S;
	cin >> S;

	sort(S.begin(), S.end());
	S.erase(unique(S.begin(), S.end()), S.end());

	if (S.size() == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=100010;
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
int n,m;
int a[N];
bool spj()
{
	if(m!=n-1)return 0;
	for(int i=1;i<=n;i++)if(a[i]&1){if(a[i]==1)return 0;a[i]--;}
	int d=a[1];
	for(int i=2;i<=n;i++)d=gcd(d,a[i]);
	for(int i=1;i<=n;i++)a[i]/=d;
	return 1;
}
bool check()
{
	m=0;
	for(int i=1;i<=n;i++)m+=(a[i]&1)==0;
	if(m&1)return 1;
	if(!spj())return 0;
	return !check();
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	printf("%s\n",check()?"First":"Second");
	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<utility>
#include<algorithm>
int const nax = 2e5 + 5, mod = 998244353;

struct P{
    int x, d;
    P () {}
    P (int x, int d) : x(x), d(d) {}
    bool operator < (const P &a) const {
        return x < a.x;
    }
    void read () {
        scanf("%d %d", &x, &d);
    }
};

void add (int &a, int b) {
    if ((a += b) >= mod) a -= mod;
}

int dp[nax];
int n;
std::pair<int, int> st[nax];
int top;
P p[nax];

int main () {
    scanf("%d", &n);
    for (int i = 1 ; i <= n ; ++ i)
        p[i].read();
    std::sort(p + 1, p + 1 + n);
    dp[n + 1] = 1;
    st[top = 1] = std::make_pair(n + 1, (int)2e9 + 1);
    for (int i = n ; i >= 1 ; -- i) {
        while (top > 0 && st[top].second < p[i].x + p[i].d) -- top;
      	dp[i] = dp[i + 1];
      	add(dp[i], dp[st[top].first]);
        st[++ top] = std::make_pair(i, p[i].x);
    }
    printf("%d\n", dp[1]);
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int A; cin >> A;
  int n = 1;
  while(n*(n+1) / 2 < A) n++;
  string ans = "";
  rep(i, n) ans += ")";
  rep(i, n) ans += "(";
  swap(ans[n], ans[n - n*(n+1)/2 + A]);
  cout << ans << endl;

  return 0;
}

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


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

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, a[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int mean = 0;
	for (i = 1; i <= N; i++) mean += a[i];
	mean /= N;
	
	int k, cost[3] = {};
	for (k = 0; k < 3; k++) {
		for (i = 1; i <= N; i++) cost[k] += (a[i] - mean - k + 1) * (a[i] - mean - k + 1);
	}
	if (cost[0] <= cost[1] && cost[0] <= cost[2]) printf("%d\n", cost[0]);
	else if (cost[1] <= cost[0] && cost[1] <= cost[2]) printf("%d\n", cost[1]);
	else printf("%d\n", cost[2]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;

typedef long long int ll;

int main(){
    int N;
    cin >> N;
    vector<int> H(N+1);
    for(int i=1; i<N+1; i++){
        cin >> H[i];
        }
    int Count=0;
    for(int i=0; i<100; i++){
        int k=100 - i;
        for(int l=1; l<N+1; l++){
            if(k <= H[l] && k > H[l-1]){
                Count++;
                }
            }
        }
    cout << Count;

}

Measured memory_bytes: 256
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

char grid[100][100];
int h,w;
int dp[100][100];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    cin >> h >> w;
    rep(i,h)rep(j,w){
        cin >> grid[i][j];
        dp[i][j] = INT_MAX;
    }
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(!i && !j){
                dp[i][j] = (grid[i][j] == '#');
            }else{
                if(i){
                    if(grid[i][j] == '#'){
                        if(grid[i-1][j] == '#')chmin(dp[i][j],dp[i-1][j]);
                        else chmin(dp[i][j],dp[i-1][j] + 1);
                    }else{
                        chmin(dp[i][j],dp[i-1][j]);
                    }                    
                }

                if(j){
                    if(grid[i][j] == '#'){
                        if(grid[i][j-1] == '#')chmin(dp[i][j],dp[i][j-1]);
                        else chmin(dp[i][j],dp[i][j-1] + 1);
                    }else{
                        chmin(dp[i][j],dp[i][j-1]);
                    }                    
                }
            }
        }
    }
    cout << dp[h-1][w-1] << '\n';
    return 0;
}


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

using namespace std;

typedef long long ll;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define per(i,n,a) for(ll i=n-1;i>=a;i--)
#define nl "\n"
#define LLMAX 1e18
#define fastread cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

int main(){
  fastread;

  ll n,a,b,c;
  cin >> n;
  ll dp[n][3];

  cin >> a >> b >> c;
  dp[0][0]=a;
  dp[0][1]=b;
  dp[0][2]=c;

  rep(i,1,n){
     cin >> a >> b >> c;
     dp[i][0]=a+max(dp[i-1][1], dp[i-1][2]);
     dp[i][1]=b+max(dp[i-1][0], dp[i-1][2]);
     dp[i][2]=c+max(dp[i-1][0], dp[i-1][1]);
  }

  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << nl;
  return 0;
}


Measured memory_bytes: 2560
n = int(input()); arr = [list(map(int,input().split())) for _ in range(n-1)]
graph = [[] for _ in range(n)]
for a,b in arr:
    graph[a-1].append(b-1); graph[b-1].append(a-1)


mod = 10**9+7
fac = [1]*(n+1)
inv = [1]*(n+1)
ifac = [1]*(n+1)
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod
    inv[i] = (- (mod//i)*inv[(mod%i)]) % mod
    ifac[i] = ifac[i-1] * inv[i] % mod

parents = [-1]*n
children = [[] for _ in range(n)]
orders = []
stack = [0]
flags = [True] * n; flags[0] = False
while stack:
    tmp = stack.pop()
    orders.append(tmp)
    for node in graph[tmp]:
        if flags[node]:
            flags[node] = False
            children[tmp].append(node)
            stack.append(node)
            parents[node] = tmp

size = [1] * n
dp = [1] * n
for parent in orders[::-1]:
    for child in children[parent]:
        size[parent] += size[child]
        dp[parent] = dp[parent] * dp[child] * ifac[size[child]] % mod
    dp[parent] = dp[parent] * fac[size[parent]-1] % mod


size2 = [n-i+1 for i in size]
dp2 = [1] * n; dp2[0] = dp[0]
for parent in orders[1:]:
    child = parents[parent]
    dp2[parent] = dp2[parent] * size[parent] * dp2[child] * inv[size2[parent]-1] % mod
    
for i in range(n):
    print(dp2[i])

Measured memory_bytes: 151984
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){
	
	double d,t,s;
	cin >> d >> t >> s;
	double time=d/s;
	if(time>t){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3720
// C - To Infinity
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S;
	long long K;
	cin>>S>>K;
	int pos = S.find_first_not_of('1');
	cout<<S[pos==string::npos || K<pos+1? 0: pos] <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
long double L;
  cin >> L;
  long double ans = (L*L*L)/27.00;
  cout << fixed<< setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import string

N=int(input())
S=input()
#print(chr(65))
for i in range(len(S)):
    if ord(S[i])+N<=90:
        print(chr(ord(S[i])+N),end='')
    else:
        print(chr(ord(S[i])+N-26),end='')

Measured memory_bytes: 4984
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAX = 20000+5;
stack<int> pos;
stack<int> ss;
stack<int> leftmost;
std::vector<int> v;
char c[MAX];
int sums = 0;   //总面积
int cs = 0;     //当前面积
int main(int argc, char const *argv[])
{
    cin >> c;
    int len = strlen(c);
    for(int i = 0;i < len;i++){
        if(c[i] == '\\')    pos.push(i);
        if(c[i] == '/' && pos.size() > 0){
            int cpos = pos.top();
            pos.pop();
            cs = i-cpos;
            sums += cs;
            //保证当前积水坑的最左边的'\'的位置 > pos中'\'的位置(已经回退到的位置)
            while(ss.size() > 0 && leftmost.top() > cpos){
                cs += ss.top();
                leftmost.pop();
                ss.pop();
            }
            ss.push(cs);
            leftmost.push(cpos);
        }
    }
    cout << sums << endl;

    while(!ss.empty()){
        v.push_back(ss.top());
        ss.pop();
    }
    cout << v.size();
    reverse(v.begin(),v.end());
    for(std::vector<int>::iterator it = v.begin(); it != v.end();it++)
        cout <<" "<< *it;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3228
N = int(input())

exp_2_list = []
for i in range(100):
  exp_2 = 2 ** i
  if exp_2 > 100:
    break
  exp_2_list.append(exp_2)

answer = 1
for exp_2 in sorted(exp_2_list, reverse=True):
  if exp_2 <= N:
    answer = exp_2
    break

print(answer)

Measured memory_bytes: 9156
# coding: utf-8
# Your code here!
x=int(input())
ans=[]
if x==1:
    print(1)
else:
    for i in range(1,x+1):
        for j in range(2,x+1):
            if i**j<=x:
                ans.append(i**j)
            else:
                break
    ans.sort(reverse=True)
    print(ans[0])
#print(ans)

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

int main() {
 	string s,t; 
	cin >> s >> t; 
	int ans = 0;
  	int a;
  	a = s.size() ;
  for(int i=0; i<a; i++)
  {
    if(s[i] != t[i]){ans ++;}
    //	cout << a << endl;
  }
  
	cout << ans << endl;
}

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

int main(){
  int x;
  cin >> x;
  int count = 0;
  int i;
  for (i = 1; i < x; i++) {
    count += i;
    if (count >= x) break;
  }
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,W;
    cin >> n >> W;
    vector<vector<ll>>dp(n+1,vector<ll>(W+10,0));
    vector<ll>w(n),v(n);
    for(ll i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<=W;j++){
            if(j>=w[i]) dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 83156
n=int(input())
s=0
a=list(map(int,input().split(" ")))
b=list(map(int,input().split(" ")))
c=list(map(int,input().split(" ")))

for i in range(n):
  s+=b[a[i]-1]
  if i>0:
    if a[i-1]+1==a[i]:
      s+=c[a[i-1]-1]

print(s)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back
#define MAX 1500

using namespace std;

int memoH[MAX+1][MAX+1];
int memoW[MAX+1][MAX+1];
int countH[MAX*1000+1];
int countW[MAX*1000+1];

int main() {
  int n, m, res;
  while (cin >> n >> m, n | m) {
    res = 0;
    for (int i = 0; i <= MAX; i++) {
      for (int j = 0; j <= MAX; j++) {
        memoH[i][j] = memoW[i][j] = -1;
      }
    }
    for (int i = 0; i <= MAX*1000; i++) {
      countH[i] = countW[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      cin >> memoH[i][i];
    }
    for (int i = 0; i < m; i++) {
      cin >> memoW[i][i];
    }
    for (int j = 0; j < n; j++) {
      for (int i = 0; i < n-j; i++) {
        if (memoH[i+1+j][i+1+j] == -1) break;
        memoH[i][i+1+j] = memoH[i][i+j] + memoH[i+1+j][i+1+j];
      }
    }
    for (int j = 0; j < m; j++) {
      for (int i = 0; i < m-j; i++) {
        if (memoW[i+1+j][i+1+j] == -1) break;
        memoW[i][i+1+j] = memoW[i][i+j] + memoW[i+1+j][i+1+j];
      }
    }
    for (int i = 0; i < MAX; i++) {
      for (int j = i; j < MAX; j++) {
        if (memoH[i][j] != -1) countH[memoH[i][j]]++;
        if (memoW[i][j] != -1) countW[memoW[i][j]]++;
      }
    }
    for (int i = 0; i <= MAX*1000; i++) {
      res += countH[i]*countW[i];
    }
    cout << res << el;
  }
}

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

int N;
const int MAX_N = 100 + 10;
ll T[MAX_N];

ll gcd(ll a, ll b) {
    ll large = max(a, b);
    ll small = min(a, b);
    if (small == 0) return large;
    else return gcd(small, large % small);
}

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

    ll ans = T[0];
    for (int i = 1; i < N; i++) {
        ans = (ans / gcd(ans, T[i])) * T[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		int z = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		long []a = new long [x];
		long []b = new long [y];
		long []c = new long [z];
		
		for(int i = 0 ; i < x ;i++) {
			a[i] = Long.parseLong(sc.next());
		}
		for(int i = 0 ; i < y ;i++) {
			b[i] = Long.parseLong(sc.next());
		}
		for(int i = 0 ; i < z ;i++) {
			c[i] = Long.parseLong(sc.next());
		}
		
		
		long []sum1 = new long  [x * y];
		int id = 0;
		
		for(int i = 0 ;i < x ;i++) {
			for(int j = 0 ; j < y ;j++) {
				sum1[id] = a[i] + b[j];
				id++;
			}
		}
		
		Arrays.sort(sum1);
		
		int m = x * y -1;
		long []sum = new long [k * z];
		id = 0;
	
		for(int i = m ; i > Math.max(-1, m - k ) ;i--) {
			for(int j = 0 ; j < z ; j++) {
				sum[id] = sum1[i] + c[j];
				id++;
			}
		}
		
		Arrays.sort(sum);
		int l = k * z -1;
		
		for(int i = l ; i > l - k ; i--) {
			System.out.println(sum[i]);
		}
	}
}




Measured memory_bytes: 61120
N, M = map(int, input().split())
H = list(map(int, input().split()))
highest = [True for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] <= H[b]:
        highest[a] = False
    if H[b] <= H[a]:
        highest[b] = False

print(sum(highest))

Measured memory_bytes: 20100
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  char a[27] = {'!','A','B','C','D','E','F','G','H','I','J', 
                'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      string s;
      cin >> s;
      if(s == "snuke"){
        cout << a[j] << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

int func(int a){
    int sum = 0;
    while(a % 2 == 0){
        sum++;
        a /= 2;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += func(A.at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int N,K;
string S;

signed main(){
  cin>>N>>K;
  int a,d;
  vector<int> child(N,0);
  REP(j,0,K){
    cin>>d;
    REP(i,0,d){
      cin>>a;
      a--;
      child[a]++;
    }
  }
  int ans=0;
  REP(i,0,N){
    if(child[i]==0){
      ans++;
    }
  }
  print(ans);

}


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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right) {
    int i, j, k;
    llong cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for(i = 0; i < n1; i++) L[i] = A[left + i];
    for(i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i = j= 0;
    for(k = left; k < right; k++) {
        if(L[i] <= R[j]) {
            A[k] = L[i++];
        }else {
            A[k] = R[j++];
            cnt += n1 - i;   // = mid + j - k - 1
        }
    }
    return cnt;
}

llong mergeSort(int A[], int n, int left, int right) {
    int mid;
    llong v1, v2, v3;
    if(left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n ,mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }else return 0;
}

int main() {
    int A[MAX], n, i;
    
    cin >> n;
    for(i = 0; i < n; i++) {
        cin >> A[i];
    }
    
    llong ans = mergeSort(A, n, 0, n);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4660
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

void strToLower(string& str);
void getAlpha(string& str);

int main()
{
        string str, tmp;
        int total=0;

        cin >> str;
 
        strToLower(str);
//        getAlpha(str);
        while(cin>>tmp){
                if(tmp=="END_OF_TEXT"){break;}
                strToLower(tmp);
                //              getAlpha(tmp);
//                cout << tmp << endl;
                if(tmp==str){total++;}
        }
        cout << total << endl;
        return 0;
}

void strToLower(string& str)
{
        int size=str.length();
        for(int i=0; i<size; i++){
                str[i] = tolower(str[i]);
        }
}

Measured memory_bytes: 1192
import math
A,B=map(int,input().split())
a=math.ceil(A/0.08)
list=[]
count=0
while math.floor((a+count)*0.08)==A:
    list.append(a+count)
    count+=1
suuji=0

for b in list:
    if math.floor(b*0.1)==B:
        print(b)
        break
    else:
        suuji+=1
if suuji==len(list):
    print(-1)
else:
    pass


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var n int
	numbers := make([]int, 0)

	fmt.Scanln(&n)

	scanner.Scan()
	string := scanner.Text()
	words := strings.Split(string, " ")

	for i := 0; i < n; i++ {
		x, _ := strconv.Atoi(words[i])
		numbers = append(numbers, x)
	}

	for i := 0; i < len(numbers)/2; i++ {
		numbers[i], numbers[len(numbers)-1-i] = numbers[len(numbers)-1-i], numbers[i]
	}

	for i := 0; i < len(numbers); i++ {
		if i < len(numbers)-1 {
			fmt.Printf("%d ", numbers[i])
		} else {
			fmt.Println(numbers[i])
		}

	}

}



Measured memory_bytes: 1172
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		int b;scanf("%d",&b);b++;
		p[b]++;
	}
	int ret=0;
	for(int i=1;i<105000;i++)ret=max(ret,p[i-1]+p[i]+p[i+1]);
	printf("%d\n",ret);
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll N;
ll A[100005];

string solve()
{
    sort(A, A + N);
    ll n = 1;
    FOR(i, N, 1)
    {
        if (A[i] != A[i - 1])
            n++;
    }
    if (n > 3)
        return "No";
    if (n == 1)
    {
        //! Aが0のみ
        if (A[0] == 0 && A[N - 1] == 0)
            return "Yes";
        else
            return "No";
    }

    if (N % 3 != 0)
        return "No";

    ll x = 0;
    ll f = 1, l = 1;
    FOR(i, N, 1)
    {
        if (A[i] != A[i - 1])
        {
            x = A[i];
            break;
        }
        f++;
    }
    FOR(i, N, 1)
    {
        if (A[N - 1 - i] != A[N - i])
            break;
        l++;
    }

    if (n == 2)
    {
        if (A[0] == 0 && l == 2 * f)
            return "Yes";
        else
            return "No";
    }

    if ((A[0] ^ A[N - 1]) == x && (f == l) && (3LL * f == N))
        return "Yes";
    return "No";
}

int main()
{
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999
using namespace std;

const int hwmax=50;

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

          string s[hwmax];
          REP(i,h)  cin >> s[i];

          const int dx[8] = {1,0,-1,0,1,-1,-1,1};
          const int dy[8] = {0,1,0,-1,1,1,-1,-1};

          REP(i,h){
                    REP(j,w){
                              if (s[i][j]=='#')   continue;

                              int count=0;
                              REP(d,8){
                                        const int ni = i + dy[d];
                                        const int nj = j + dx[d];

                                        if (ni < 0 or h <= ni)        continue;
                                        if (nj < 0 or w <= nj)        continue;
                                        if (s[ni][nj] == '#')         count++;
                              }
                              s[i][j] = char(count + '0');
                    }
          }
          REP(i,h)  cout << s[i] << endl;
          return 0;
}


Measured memory_bytes: 256