akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 

int main() {
    string s;

    cin >> s;

    if(s[1] =='B'){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}


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

using namespace std;

const int N = 1234;
long long a[N] , ans , n;

int main()
{
	cin >> n;
	for(int i = 0 ; i < 2 * n ; i++)
		cin >> a[i];
	sort(a , a + (2 * n));
	for(int i = 0 ; i < n * 2 ; i++)
	{
		if((i + 1) % 2)
		{
			ans += a[i];
		}
	}
	cout << ans;
}

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

int main() {
	long long N; cin >> N;
	vector<long long> A(N-1);
	vector<long long> Ans(N);
	for (int i = 0; i < N; i++)
	{
		Ans[i] = 0;
	}
	for (long long i = 0; i < N-1; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N-1; i++)
	{
		Ans[A[i]-1]++;
	}
	for (int i = 0; i < N; i++)
	{
		cout << Ans[i] << endl;
	}
}

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

int main(){
  int n; cin>>n;
  vector<char> S(n);
  rep(i, 0, n) cin>>S[i];

  int ans = 0;
  rep(i, 0, n) {
    int tmp=0;
    vector<int> X(26), Y(26);
    rep(j, 0, i) X[(int)(S[j]-'a')]++;
    rep(j, i, n) Y[(int)(S[j] - 'a')]++;
    rep(j, 0, 26) if (X[j]>0 && Y[j]>0) tmp++;
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using pint = pair<int, int>;

bool cmp(pint a, pint b) { return a.second < b.second; }

int main()
{
  int N;
  scanf("%d", &N);
  vector<pint> V(N);
  for (int i = 0; i < N; i++) cin >> V[i].first >> V[i].second;

  sort(V.begin(), V.end(), cmp);
  long long endtime = 0;
  for (int i = 0; i < N; i++) {
    endtime += V[i].first;
    if (endtime > V[i].second) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL){
    y = x;
    if( z->key < x->key ){
      x = x->left;
    }else {
      x = x->right;
    }
  }

  z->parent = y;
  if( y == NIL ){
    root = z;
  } else {
    if ( z->key < y->key ){
      y->left = z;
    }else{
     y->right = z;
    }
  }
}

void inorder(Node *u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if ( u == NIL)return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for( i = 0; i < n; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    } else if( com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24684
from random import choice
from random import random
from time import time


class Optimizer:
    def __init__(self, C, S):
        self.C = C
        self.S = S
        X = []
        L = [-1] * 26
        for i in range(365):
            max_diff = -10**10
            best_j = 0
            for j in range(26):
                memo = L[j]
                L[j] = i
                diff = self.S[i][j] - \
                    sum([self.C[jj] * (i - L[jj]) for jj in range(26)])
                if diff > max_diff:
                    max_diff = diff
                    best_j = j
                L[j] = memo
            L[best_j] = i
            X.append(best_j)
        self.X = X

    def calc_score(self):
        score = 0
        L = [-1 for j in range(26)]
        A = [0 for j in range(26)]
        for i in range(365):
            score += self.S[i][self.X[i]]
            A[self.X[i]] += (i - L[self.X[i]]) * \
                (i - L[self.X[i]] - 1) // 2
            L[self.X[i]] = i
        for j in range(26):
            A[j] += (365 - L[j]) * (365 - L[j] - 1) // 2
            score -= self.C[j] * A[j]
        return score

    def optimize(self, temp, threp, interval, start_time=time(), lim=1.8):
        max_score = self.calc_score()
        while True:
            t = (time() - start_time) / 2
            if random() < threp:
                i = choice(range(365))
                j = choice(range(26))
                memo = self.X[i]
                self.X[i] = j
                new_score = self.calc_score()
                if new_score > max_score:
                    max_score = new_score
                elif random() < pow(2.7, (new_score - max_score) / pow(2000, 1 - t)):
                    max_score = new_score
                else:
                    self.X[i] = memo
            else:
                a = choice(range(interval))
                i0 = choice(range(365 - a))
                i1 = i0 + a
                self.X[i0], self.X[i1] = self.X[i1], self.X[i0]
                new_score = self.calc_score()
                if new_score > max_score:
                    max_score = new_score
                elif random() < pow(2.7, (new_score - max_score) / pow(2000, 1 - t)):
                    max_score = new_score
                else:
                    self.X[i0], self.X[i1] = self.X[i1], self.X[i0]
            if time() - start_time > lim:
                break
        return max(max_score + 10**6, 0)


if __name__ == "__main__":
    d = int(input())
    *C, = map(int, input().split())
    S = [list(map(int, input().split())) for i in range(d)]
    opt = Optimizer(C, S)
    opt.optimize(400, 0.2, 16)
    for x in opt.X:
        print(x + 1)
    # print(opt.calc_score())


Measured memory_bytes: 90096
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

int v[105];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z;
  for (i = 0; i < n; i++) cin >> v[i];
  int ans = 0;
  for (i = 0; i < n; i++)
    for (j = i+1; j < n; j++)
      for (z = j+1; z < n; z++)
        if (v[i] + v[j] > v[z] && v[i] + v[z] > v[j] && v[j] + v[z] > v[i] && v[i] != v[j] && v[j] != v[z] && v[z] != v[i]) {
          ans++;
        }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	char a;
	int ans = 700;
	rep(i, 3) {
		cin >> a;
		if (a == 'o')ans += 100;
	}
	cout << ans << endl;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

#define MAXN 200005

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator () (uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n;

template<int SZ>
struct SegmentTree {
    int st[2*SZ];

    SegmentTree() {
        memset(st, 0, sizeof(st));
    }

    int query(int l, int r) {
        int ret = 0;
        for (l+=n, r+=n; l<r; l>>=1, r>>=1) {
            if (l&1) ret = max(ret, st[l++]);
            if (r&1) ret = max(ret, st[--r]);
        }
        return ret;
    }

    void update(int p, int val) {
        for (st[p+=n]=val; p>1; p>>=1)
            st[p>>1] = max(st[p], st[p^1]);
    }
};

int a[MAXN], ret[MAXN];
vector<int> adj[MAXN];
multiset<int> mst[MAXN];
SegmentTree<MAXN> st;

void dfs(int u, int p) {
    int dp = st.query(0, a[u]) + 1;
    mst[a[u]].insert(dp);
    st.update(a[u], *mst[a[u]].rbegin());
    ret[u] = st.query(0, n);
    for (int v : adj[u])
        if (v != p)
            dfs(v, u);
    mst[a[u]].erase(mst[a[u]].find(dp));
    st.update(a[u], mst[a[u]].empty() ? 0 : *mst[a[u]].rbegin());
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

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

    sort(b.begin(), b.end());
    unordered_map<int, int, custom_hash> compression;
    for (int i=0; i<n; i++)
        compression[b[i]] = i;
    for (int i=0; i<n; i++)
        a[i] = compression[a[i]];

    dfs(0, -1);

    for (int i=0; i<n; i++)
        cout << ret[i] << "\n";

    return 0;
}


Measured memory_bytes: 53340
S = input()

A_left=[0]
C_left=[0]
Q_left=[0]

for (i,s) in enumerate(S):
    if s == "A":
        A_left.append(A_left[i]+1)
        C_left.append(C_left[i])
        Q_left.append(Q_left[i])
    elif s == "C":
        A_left.append(A_left[i])
        C_left.append(C_left[i]+1)
        Q_left.append(Q_left[i])
    elif s == "?":
        A_left.append(A_left[i])
        C_left.append(C_left[i])
        Q_left.append(Q_left[i]+1)
    else:
        A_left.append(A_left[i])
        C_left.append(C_left[i])
        Q_left.append(Q_left[i])

A_right = []
C_right = []
Q_right = []
for i in range(len(S)):
    A_right.append(A_left[-1] - A_left[i+1])
    C_right.append(C_left[-1] - C_left[i+1])
    Q_right.append(Q_left[-1] - Q_left[i+1])

ans = 0
for (i,s) in enumerate(S):
    if s == "B":
        ans = (ans + A_left[i] * C_right[i] * pow(3,Q_left[-1],10**9+7)) % (10**9+7)
        if Q_left[-1]>=1:
            ans = (ans + (Q_left[i] * C_right[i] + A_left[i] * Q_right[i]) * pow(3,(Q_left[-1]-1),10**9+7)) % (10**9+7)
        if Q_left[-1]>=2:
            ans = (ans + (Q_left[i] * Q_right[i]) * pow(3,(Q_left[-1]-2),10**9+7)) % (10**9+7)
    elif s == "?":
        if Q_left[-1]>=1:
            ans = (ans + A_left[i] * C_right[i] * pow(3,(Q_left[-1]-1),10**9+7)) % (10**9+7)
        if Q_left[-1]>=2:
            ans = (ans + (Q_left[i] * C_right[i] + A_left[i] * Q_right[i]) * pow(3,(Q_left[-1]-2),10**9+7)) % (10**9+7)
        if Q_left[-1]>=3:
            ans = (ans + (Q_left[i] * Q_right[i]) * pow(3,(Q_left[-1]-3),10**9+7)) % (10**9+7)

print(ans)


Measured memory_bytes: 20248
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const B& (*func)(A)){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}

ll n,m,a,b;
map<ll,ll> ma;
void input(){
    cin>>n>>m;
    rep(i,m){
        cin>>a>>b;
        ma[a-1]++;
        ma[b-1]++;
    }
}
void src(){
    rep(i,n){
        cout<<ma[i]<<"\n";
    }
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(X) for(c=0;c<X;c+=v[p++]);if(c-X)goto L;
main(){for(char n,v[99],s,p,c;n=atoi(gets(v));){for(s=0;s<n;v[++s]=strlen(gets(v+n)));s=0;L:p=++s;f(5)f(7)f(5)f(7)f(7)printf("%d\n",s);}}

Measured memory_bytes: 1128
import sys
def main():
    input = sys.stdin.readline
    H,W=map(int, input().split())
    A=[list(map(int, input().split())) for _ in range(H)]
    B=[list(map(int, input().split())) for _ in range(H)]

    mx=80*(H+W)
    C=[[abs(A[i][j]-B[i][j]) for j in range(W)] for i in range(H)]
    dp=[[0 for _ in range(W)] for __ in range(H)]
    dp[0][0]=1<<(mx+C[0][0])
    for i in range(H):
        for j in range(W):
            for ni,nj in ((i+1,j),(i,j+1)):
                if ni>=H or nj>=W: continue
                dp[ni][nj] |= dp[i][j] << C[ni][nj]
                dp[ni][nj] |= dp[i][j] >> C[ni][nj]

    for ans in range(mx+1):
        if dp[H-1][W-1] & (1<<(mx+ans) | 1<<(mx-ans)):
            print(ans)
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 59228
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000000000000000
using namespace std;

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

int main() {
	int a = 0, b = 0, h = 0;
	cin >> a >> b;      //a<b  w<e
	int w = 0, e = 0;

	for (int i = 1; i <= 998; i++) {    //西側の高さ
		w += i;
		e = w + (i + 1);
		if (e - w == b-a) {
			h =e- w; //両方の差
			cout << w - a << endl;
			break;
		}
	}
	
	
	return 0;
}

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

int main(){
    long long A, B;
    cin >> A >> B;
    long long i;
    long long answered = 0;
    if(A % 2 == 0){
        for(i = 25 * (A / 2); i <= 25 * (A/2) + 12; i++){
            if(i / 10 == B){
                cout << i << endl;
                answered = 1;
                break;
            }
        }
    }else{
        for(i = 25 * (A / 2) + 13; i <= 25 * (A / 2) + 24; i++){
            if(i / 10 == B){
                cout << i << endl;
                answered = 1;
                break;
            }
        }
    }
    if(answered == 0) cout << -1 << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
N = int(input())
A = list(map(int,input().split()))
S = sum(A)/2
Es = []
tmp = 0
for i in range(N):
    tmp += A[i]
    Es.append(abs(tmp-S))
cut_point = Es.index(min(Es))

ans1 = abs(sum(A[cut_point:])-sum(A[:cut_point]))
ans2 = abs(sum(A[cut_point+1:])-sum(A[:cut_point+1]))
ans = min(ans1,ans2)

print(ans)

Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N;
  cin >> A;
  
  if (N % 500 >= 0 && N % 500 <= A) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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


int main()
{
    std::string s;
    std::cin >> s;
    std::vector<char> cvec;
    for (char c = 'a'; c <= 'z'; ++c) { cvec.push_back(c); }

    for (const char &ch : s) { cvec.erase(std::remove(cvec.begin(), cvec.end(), ch), cvec.end()); }
    if (cvec.size() == 0) { std::cout << "None"; }
    else
    {
        std::cout << cvec[0];
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
const int AMAX = 100000; 
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
vector<LL>ans;
rep(i,3){
  int a;
cin>>a;  
  ans.pb(a);
}
  int k;
  cin >> k;
  SORT(ans);
  rep(i,k)ans[2]*=2;
cout << ans[0]+ans[1]+ans[2];
return 0;
}

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

n = int(input())
c = 0
for i in range(n):
    m = int(input())
    if m != 2 and m % 2 == 0:
        c += 1
        continue
    i = 3
    while i * i <= m:
        if m % i == 0:
            c += 1
            break
        i += 2
print(n-c)


Measured memory_bytes: 5616
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
var n = +input.shift();
var cards = input.shift().split(' ');

function bubbleSort(input) {
  var cards = [].concat(input);

  for (var i = 0; i < cards.length; i++) {
    for (var j = cards.length - 1; j > i; j--) {
      if ((+cards[j][1]) < (+cards[j - 1][1])) {
        var tmp = cards[j];
        cards[j] = cards[j - 1];
        cards[j - 1] = tmp;
      }
    }
  }

  return cards;
}

function selectionSort(input) {
  var cards = [].concat(input);

  for (var i = 0; i < cards.length; i++) {
    var minIndex = i;
    for (var j = i; j < cards.length; j++) {
      if ((+cards[j][1]) < (+cards[minIndex][1])) minIndex = j;
    }

    if (minIndex !== i) {
      var tmp = cards[i];
      cards[i] = cards[minIndex];
      cards[minIndex] = tmp;
    }
  }

  return cards;
}

function isStable(bubble, selection) {
  if (bubble === selection) {
    return 'Stable';
  } else {
    return 'Not stable';
  }
}

function stableSort(cards) {
  var bubble = bubbleSort(cards).join(' ');
  var selection = selectionSort(cards).join(' ');

  console.log(bubble);
  console.log('Stable');
  console.log(selection);
  console.log(isStable(bubble, selection));
}

stableSort(cards);

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

int main() {
    int N;
    cin >> N;
    int H[N] = {};
    for (int i = 0;i < N;i++){
        cin >> H[i];
    }
    int A[N] = {};
    A[N - 1] = 0;
    for (int i = N - 1;i > 0;i--){
        if (H[i - 1] >= H[i]) A[i - 1] = A[i] + 1;
        else A[i - 1] = 0;
    }
    int ans = 0;
    for (int i = 0;i < N;i++){
        if (A[i] > ans) ans = A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <ios>

using namespace std;

vector<int> match_KMP(const string & T, const string & P);
vector<int> preprocess_KMP(const string & P);
vector<int> preprocess2_KMP(const string & P, const vector<int> & pi);


int main()
{
    ios::sync_with_stdio(false);
    string T;
    string P;
    cin >> T;
    cin >> P;
    auto result = match_KMP(T, P);
    for (auto pos : result) cout << pos << '\n';
    return 0;
}

vector<int> match_KMP(const string & T, const string & P){
    int n = T.size();
    int m = P.size();
    auto pi = preprocess_KMP(P);
    vector<int> result;
    int q = 0;
    for (int i = 0; i != n; ++i){
        while (q > 0 and T[i] != P[q]){
            q = pi[q];
        }
        if (T[i] == P[q]) ++q;
        if (q == m){
            result.push_back(i - m + 1);
            q = pi[q];
        }
    }
    return result;
}

vector<int> preprocess_KMP(const string & P){
    int m = P.size();
    vector<int> pi(m + 1, 0);
    int k = 0;
    for (int q = 1; q != m; ++q){
        while (k > 0 and P[q] != P[k]){
            k = pi[k];
        }
        if (P[q] == P[k]) ++k;
        pi[q + 1] = k;
    }
    return preprocess2_KMP(P, pi);
}

vector<int> preprocess2_KMP(const string & P, const vector<int> & pi){
    int m = P.size();
    vector<int> pi2(m + 1, 0);
    for (int i = 1; i != m; ++i){
        if (pi[i] == 0){
            pi2[i] = 0;
        }else if (P[pi[i]] == P[i]){
            pi2[i] = pi2[pi[i]];
        }else{
            pi2[i] = pi[i];
        }
    }
    pi2[m] = pi[m];
    return pi2;
}

Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >>a;
  cout << (((a % 1000 == 0 )||( (a%1000) % 111 < 10 )||(a % 1110 < 10)||(a % 1111 < 10)) ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

food=[]

for i in range(n):
    food.append(list(map(int,input().split())))

for i in food:
    del i[0]
#print(food)

if n==1:
    print(len(food[0]))

else:

    ans=0
    for i in range(1,m+1):
        cnt=0
        for sfood in food:
            if i in sfood:
                cnt+=1

        if cnt==n:
            ans+=1
    print(ans)


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

int main(){
  int x,n,d,dd;
  cin >> x >> n;
  
  if(n == 0) cout << x << endl;
  else {
    vector<int> p(n);
    for(int i=0;i<n;i++){
      cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    
    for(int i=0;i<1000;i++){
      int cnt = 0;
      for(int k=0;k<n;k++){
        if(x+i == p.at(k)){
          cnt++;
          break;
        }
      }
      if(cnt == 0){
        d = x+i;
        break;
      }
    }
    
    for(int i=0;i<1000;i++){
      int cnt = 0;
      for(int k=0;k<n;k++){
        if(x-i == p.at(k)){
          cnt++;
          break;
        }
      }
      if(cnt == 0){
        dd = x-i;
        break;
      }
    }
    
    if(d-x < x-dd) cout << d << endl;
    else cout << dd << endl;
  }
  
  return 0;
}


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

int main(){
    int h, n, a[100000];
    cin >> h >> n;
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <math.h>

#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    int in;
    int min = 1000001;
    int max = -1000001;
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> in;
        if (in > max) {
            max = in;
        }
        if (in < min) {
            min = in;
        }

        sum += in;
    }

    cout << min << ' ' << max << ' ' << sum << endl;
}



Measured memory_bytes: 3128
l 0 = (1,1)
l n = (\(a,b)->(3+a*2,1+2*b)) (l (n-1))
main=map read.words<$>getLine>>=print.f
 where f [n,x] |x==0         = 0
               |(fst(l n))<x = (snd(l n))+1+(f [n,x-(fst(l n))-1])
               |(fst(l n))>x = f [n-1,x-1]
               |otherwise    = (snd(l n))

Measured memory_bytes: 1020
#include<iostream>
#include<map>
using namespace std;
#define START 0
#define END 1

int main()
{
  while(true){
    int n;
    scanf("%d", &n);
    if(n==0)break;
    multimap<int,pair<int,int> > M; 
    for(int i = 0; i < n; ++i){
      int m,a,b;
      scanf("%d%d%d", &m, &a, &b);
      M.insert(make_pair(a,make_pair(START,m)));
      M.insert(make_pair(b,make_pair(END,m)));
    }
    
    int total = 0;
    bool ng=false;
    for(map<int,pair<int,int> >::iterator itm = M.begin();
	itm != M.end();
	++itm)
      {
	int t=itm->first;
	while(t==itm->first){
	  if(itm->second.first==START){
	    total += itm->second.second;
	  }else{
	    total -= itm->second.second;
	  }
	  ++itm;
	  if(itm==M.end())break;
	}
	if( total > 150 ){
	  ng = true;
	}
	--itm;
      }

    if( ng ){
      puts("NG");
    }else{
      puts("OK");
    }
  }
  return 0;
}

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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef pair<int,int> pii;

int A,B;
int D[11][11];
int mem[110][110];
vector<pii> G[300];
int dis[300];

int main()
{
    scanf("%d%d",&A,&B);
    for(int i = 1; i <= A; i++)
    {
        for(int j = 1; j <= B; j++)
        {
            scanf("%d",&D[i][j]);
        }
    }

    for(int i = 0; i <= 100; i++)
    {
        for(int j = 0; j <= 100; j++)
        {
            int res = 0;
            for(int k = 1; k <= A; k++)
            {
                for(int l = 1; l <= B; l++)
                {
                    res = max(res,D[k][l] - i * k - j * l);
                }
            }
            if(res > 100)
            {
                printf("Impossible\n");
                return 0;
            }
            mem[i][j] = res;
        }
    }

    for(int i = 1; i <= A; i++)
    {
        for(int j = 1; j <= B; j++)
        {
            int MIN = 1001001001;
            for(int k = 0; k <= 100; k++)
            {
                for(int l = 0; l <= 100; l++)
                {
                    MIN = min(MIN,k * i + l * j + mem[k][l]);
                }
            }
            if(MIN != D[i][j])
            {
                printf("Impossible\n");
                return 0;
            }
        }
    }

    printf("Possible\n");

    printf("202 10401\n");
    for(int i = 0; i < 100; i++)
    {
        printf("%d %d X\n",i + 1,i + 2);
        printf("%d %d Y\n",i + 2 + 101,i + 1 + 101);
    }

    for(int i = 0; i < 101; i++)
    {
        for(int j = 0; j < 101; j++)
        {
            printf("%d %d %d\n",i + 1,j + 1 + 101,mem[i][j]);
        }
    }

    printf("1 102\n");

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n,k;
    cin >> n >> k;
    vi d(k);
    rep(i,k) cin >> d.at(i);
    // 10^5まで(99999)の場合がある
    ll res = INF;
    for(ll i=n; i<100000; i++){
        string s = to_string(i);
        bool contains = false;
        rep(j,s.size()){
            if(find(d.begin(), d.end(), s.at(j)-'0')!=d.end()){
                contains = true;
                break;
            }
        }
        if(!contains) res = i;
        if(res!=INF) break;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import heapq
A1,A2,A3=map(int,input().split())
a = [A1, A2, A3]
heapq.heapify(a)
min=a[0]
heapq.heappop(a)
M=a[0]
heapq.heappop(a)
max=a[0]
print(max-min)

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

int main()
{
	int n;
	cin>>n;
	int r=n%10;
	if(r==3)
		cout<<"bon"<<endl;
	else if(r==0 || r==1 || r==6 || r==8)
		cout<<"pon"<<endl;
	else
		cout<<"hon"<<endl;

	return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
const int N = 510;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
int _w;

int n, p[N*N], a[N][N], d[N][N], inq[N][N], ans;
queue<pii> q;

bool inside( int x, int y ) {
	return x >= 1 && x <= n && y >= 1 && y <= n;
}

void update( int sx, int sy ) {
	q.push( pii(sx, sy) );
	inq[sx][sy] = 1;
	while( !q.empty() ) {
		pii tmp = q.front(); q.pop();
		int x = tmp.first, y = tmp.second;
		inq[x][y] = 0;
		for( int dir = 0; dir < 4; ++dir ) {
			int nx = x + dx[dir];
			int ny = y + dy[dir];
			if( inside(nx, ny) && d[x][y] + a[nx][ny] < d[nx][ny] ) {
				d[nx][ny] = d[x][y] + a[nx][ny];
				if( !inq[nx][ny] ) {
					inq[nx][ny] = 1;
					q.push( pii(nx, ny) );
				}
			}
		}
	}
}

int calc_init( int x, int y ) {
	return min(min(abs(x-1), abs(x-n)), min(abs(y-1), abs(y-n))) + 1;
}

void init() {
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= n; ++j ) {
			a[i][j] = 1;
			d[i][j] = calc_init(i, j);
		}
	ans = 0;
	for( int i = 1; i <= n*n; ++i ) {
		int now = p[i];
		int x = (now-1)/n+1;
		int y = (now-1)%n+1;
		ans += d[x][y] - 1;
		--d[x][y];
		a[x][y] = 0;
		update(x, y);
	}
	cout << ans << endl;
}

void solve() {
	init();
}

int main() {
	cin >> n;
	for( int i = 1; i <= n*n; ++i )
		_w = scanf( "%d", p+i );
	solve();
	return 0;
}


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

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

    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (h[i] >= h[i + 1]) {
            cnt++;
        } else {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#define Max(a,b) a>b?a:b
#define n_max 110
#define w_max 114514

long dp[n_max][w_max];
void init_dp(void);

int main(void){
    int n,w;
    scanf("%d%d",&n,&w);
    int weight[n_max];
    long value[n_max];
    for(int i=0;i<n_max;i++)
    {
        weight[i]=value[i]=0;
    }
    init_dp();
    
    for(int i=0;i<n;i++)
    {
        scanf("%d%ld",&weight[i],&value[i]);
    }
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<w+1;j++)
        {
            if(j>=weight[i])
            {
                dp[i+1][j]=Max(dp[i][j-weight[i]]+value[i],dp[i][j]);
            }
            else
            {
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    
    long ans=0;
    for(int i=0;i<w+1;i++)
    {
        ans=Max(ans,dp[n][i]);
    }

    printf("%ld\n",ans);    
}

void init_dp(void){
    for(int i=0;i<n_max;i++)
    {
        for(int j=0;j<w_max;j++)
        {
            dp[i][j]=0;
        }
    }
}

Measured memory_bytes: 98560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

 // void dfs(ll node){
 // 	vis[node]=1;
 // 	res.pb(node);
 //    vector<ll> ans;


 // 	for(auto i:v[node]){
 // 		if(!vis[i]){
 // 			ans.pb(i);

 // 		}
 // 	}
 // 	sort(ans.begin(),ans.end());

 // 	for(auto i:ans){
 // 		if(!vis[i])
 // 			dfs(i);
 // 	}




 // }

void solve(){

ll n;
cin>>n;
if(n==1){
	cout<<0<<endl;

}
else if(n==2){
	cout<<2<<endl;

}
else{
	ll ans;
	ans=(binexp(10,n,mod)%mod-(2*binexp(9,n,mod))%mod+binexp(8,n,mod)%mod+mod)%mod;

	cout<<ans<<endl;






	

}




return;
}



int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    

    ll t;
    t=1;
    // cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=1000010;
const ll mod=1e9+7;

int n;

bool ch(ll x){
  if(x>n){return false;}
  string s=to_string(x);
  if(s.find('3')!=std::string::npos && s.find('5')!=std::string::npos && s.find('7')!=std::string::npos){
    return true;
  } else {
    return false;
  }
}
int main(){  
  cin >> n;
  priority_queue<ll> p;
  int sz=floor(log10(n));
  p.push(3);
  p.push(5);
  p.push(7);
  ll ans=0;
  rep(i,sz+1){
    priority_queue<ll> q;
    swap(p,q);
    while(!q.empty()){
      ll tmp=q.top(); q.pop();
      if(ch(tmp)){ans++;}
      p.push(tmp*10+3);
      p.push(tmp*10+5);
      p.push(tmp*10+7);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1048
#input
H, W = map(int, input().split())
a = ["" * W for _ in range(H)]
for i in range(H):
    a[i] = list(map(str, input().split()))

#output
mod = 10**9 + 7

dp = [[0]*W for _ in range(H)]
dp[0][0] = 1

for j in range(W):
    if a[0][0][j] == ".":
        dp[0][j] = 1
    else:
        break
for i in range(H):
    if a[i][0][0] == ".":
        dp[i][0] = 1
    else:
        break

for i in range(H-1):
    for j in range(W-1):
        if a[i+1][0][j+1] == "#":
            dp[i+1][j+1] = 0
        else:
            dp[i+1][j+1] = dp[i+1][j] % mod + dp[i][j+1] % mod

print(dp[H-1][W-1] % mod)

Measured memory_bytes: 43860
#include<stdio.h>
#include<iostream>
#include<algorithm> 
using namespace std;

int main() {

    int A, B;
    cin >> A >> B;
    int A1, B1, A2, B2;
    
    A1 = A * 12.5 -1;
    A2 = (A+ 1) * 12.5;
    B1 = B * 10;
    B2 = (B + 1) * 10-1;
    //printf("%d\n%d\n%d\n%d\n", A1, B1, A2, B2);
    if ((A1 < B2) && (B1 < A2)) {
        printf("%d\n", max((25 * A + 1) / 2, 10 * B));
    }else {
        printf("%d", -1);
    }
}

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

ll a[214514];

int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	ll now=1;
	for(int i=0;i<n;i++){
		if(a[i]==now)now++;
	}
	if(now==1)cout<<-1;
	else cout<<n+1-now;
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

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

struct P
{
	double x, y;
	P(double x, double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return x*x + y*y;
	}
	
	bool operator<(const P& v)const
	{
		return y != v.y ? y < v.y : x < v.x;
	}
	bool operator>(const P& v)const
	{
		return y != v.y ? y > v.y : x > v.x;
	}
};

int ccw(P a, P b, P c) 
{
	b = b - a; c = c - a;
	if (b.cross(c) > 0)   return +1;			// counter clockwise
	if (b.cross(c) < 0)   return -1;			// clockwise
	if (b.dot(c) < 0)     return +2;			// c--a--b on line
	if (b.length2() < c.length2()) return -2;   // a--b--c on line
	return 0;
}

vector<P> convex_hull(vector<P>& points)
{
	int n = points.size(), k = 0;
	sort(points.begin(), points.end());
	vector<P> ch(2 * n);
	for (int i = 0; i < n; ch[k++] = points[i++]) // lower-hull
	{
		while (k >= 2) 
		{
			int state = ccw(ch[k - 2], ch[k - 1], points[i]);
			if (state > 0 || state < -1)
			{
				break;
			}
			--k;
		}
	}
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = points[i--]) // upper-hull
	{
		while (k >= t)
		{
			int state = ccw(ch[k - 2], ch[k - 1], points[i]);
			if (state > 0 || state < -1)
			{
				break;
			}
			--k;
		}
	}
	ch.resize(k - 1);
	return ch;
}

vector<P> points;

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

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		double x, y;
		cin >> x >> y;
		points.push_back(P(x, y));
	}

	vector<P> output = convex_hull(points);

	printf("%d\n", output.size());
	for (auto& v : output)
	{
		printf("%d %d\n", (int)v.x, (int)v.y);
	}
	
	return 0;
}


Measured memory_bytes: 7556
#include<stdio.h>

int main(){
	
	int N,K,i;
	scanf("%d %d",&N,&K);
	long long int ans=K;
	
	for(i=1;i<N;i++){
		ans*=K-1;
	}
	
	printf("\n%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInput() (int, int, int) {
	sc.Split(bufio.ScanWords)

	N := 0
	if sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		N = n
	}
	A := 0
	if sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		A = a
	}
	B := 0
	if sc.Scan() {
		b, _ := strconv.Atoi(sc.Text())
		B = b
	}

	return N, A, B
}

func main() {
	N, A, B := getInput()

	n := 0
	for i := 1; i <= N; i++ {
		sum := 0
		t := i
		for t > 0 {
			sum += t % 10
			t /= 10
		}
		if A <= sum && sum <= B {
			n += i
		}
	}

	fmt.Println(n)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int H,W,h,w;
int main(){
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(H%h==0&&W%w==0) return puts("No"),0;
	int val=-((h*w-1)*1000)-1;
	puts("Yes");
	for(int i=1;i<=H;i++,puts(""))
		for(int j=1;j<=W;j++)
			if(i%h==0&&j%w==0) printf("%d ",val);
			else printf("1000 ");
	return 0;
} 

Measured memory_bytes: 1536
import fractions as fr
import itertools as it
import collections as col
import heapq as hq
import sys
sys.setrecursionlimit(10**9)

"""
N=int(input())
W=list(map(int, input().split()))
ans=10**100
for T in range(1,N):
        S1=sum(W[:T])
        S2=sum(W[T:])
        ans = min(ans, abs(S1-S2))
print(ans)
"""
"""
P,Q,R=map(int, input().split())
print(min([P+Q, P+R, Q+R]))
"""
MOD=1000000007
N,M=map(int, input().split())
A=set()
for i in range(M):
        A.add(int(input()))

dp=dict()
dp[0]=1
dp[1]=1
def f(i):
        if i in A: return 0
        if i in dp: return dp[i]
        m1=0 if (i-1) in A else f(i-1)
        m2=0 if (i-2) in A else f(i-2)
        dp[i]=(m1+m2) % MOD
        return dp[i]

print(f(N))

Measured memory_bytes: 100264
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

ll next_combination(ll sub) {
	int x = sub & -sub, y = sub + x;
	return (((sub & ~y) / x) >> 1) | y;
}






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

ll v[q+1][5];

rep(i, q){
	rep(j,4){
		cin>>v[i][j];
	}
}

ll ans=0;

for(int w=0;w<=m-1;w++){
	int r = n+w;  
	int s = n;
 
ll bit = (1 << s) - 1;  // bit = {0, 1, 2}
	for (; bit < ((ll)1 << r); bit = next_combination(bit)) {
		/* ここに処理を書く */
ll val=0;
ll cnt=0;
ll d[n];
d[0]=0;
ll e=0;

for(ll l=0;l<=r-1;l++){
if(bit&((ll)1<<l)){
	if(cnt){
		d[cnt]=l-cnt-e;
		cnt++;
	}
	if(cnt==0){cnt++;
	e=l;}
	
}

}

for(ll k=1;k<=q;k++){
	if(d[v[k][2]-1]-d[v[k][1]-1]==v[k][3]) val+=v[k][4];
}


ans=max(ans,val);


	}

}


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






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

using namespace std;

int main()
{
    long long int m,n;
    cin>>n>>m;
    long long int p[n+1],w[n+1];
    w[0] = p[0] = 0;
    for(int i = 1; i<=n; i++)
        cin>>w[i]>>p[i];
    long long int v[n+1][m+1];
    long long int ans = -999999;
    for(int i = 0; i<=n; i++)
    {
        for(int j = 0; j<=m; j++)
        {
            if(i == 0 || j == 0)
                v[i][j] = 0;
            else if(w[i]<=j)
                v[i][j] = max(v[i-1][j],((v[i-1][j-w[i]])+ p[i]));
            else
                v[i][j] = v[i-1][j];
            if(v[i][j]>ans)
                ans = v[i][j];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 79104
<?php

fscanf(STDIN, "%d", $n);

$list = explode(" ", trim(fgets(STDIN)));
$point = explode(" ", trim(fgets(STDIN)));
$bonus = explode(" ", trim(fgets(STDIN)));

$last = 99;
$ans = 0;
foreach($list as $number){
    if($last + 1 == $number){
        $ans += $bonus[$last - 1];
    }
    $last = $number;
}

echo array_sum($point) + $ans;

Measured memory_bytes: 4728
program abc060c
  use,intrinsic :: iso_fortran_env
  implicit none
  integer(int64) :: n, t
  integer(int64),dimension(:),allocatable :: a
  read *, n, t
  allocate(a(n))
  read *, a
  a = a(2:) - a(:n-1)
  print *, sum(merge(a, t, a < t)) + t
end program abc060c


Measured memory_bytes: 3968
n = int(input())
A = list(map(int, input().split()))

M = [0]*n

M[0] = sum(A[i] if i%2==0 else -A[i] for i in range(n))

for i in range(1, n):
	M[i] = 2*A[i-1] - M[i-1]
print(*M)

Measured memory_bytes: 64996
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int imos[501][501];

int main(){
  int N,M,Q,L,R;
  cin >> N >> M >> Q;
  vector<pair<int,int>> v,que;
  FOR(i,0,M){
    cin >> L >> R;
    imos[L][R]++;
  }
  FOR(i,0,Q){
    cin >> L >> R;
    que.push_back(make_pair(L,R));
  }
  FOR(i,0,501)FOR(j,1,501){
    imos[i][j] += imos[i][j-1];
  }
  for(auto q:que){
    int ans = 0;
    FOR(i,q.first,N+1){
      ans += imos[i][q.second];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 2804
#include <cstdio>
#include <algorithm>

using namespace std;

const int INF = 1000000000;

int main(){
  int n, a, b, c, d;

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

  int ans = min((n+a-1)/a * b, (n+c-1)/c * d);

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

  return 0;
}



Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

ll int euclidean_gcd(ll int a, ll int b) {
  if(a < b) return euclidean_gcd(b, a);
  ll int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
    ll int a,b;
    ll int ans;
    cin>>a;
    cin>>b;
    ans = a*b/euclidean_gcd(a,b);
    cout<<ans<<endl;
}




Measured memory_bytes: 256