akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MAXN 200000
#define MOD 1000000007

LL fact[MAXN + 3], dp[MAXN + 3], answer[MAXN + 3];
int N, sz[MAXN + 3];
vector<int> adj[MAXN + 3];

LL fastExponentiation(int base, int p) {
    if (p == 0)
        return 1;

    LL half = fastExponentiation(base, p/2);
    LL halfhalf = (half * half)%MOD;

    if (p%2 == 0)
        return halfhalf;
    else
        return (halfhalf * base)%MOD;
}

void DFS(int u, int prv) {
    sz[u] = 1;
    for (auto v: adj[u]) {
        if (v != prv) {
            DFS(v, u);
            sz[u] += sz[v];
        }
    }
}

void fillDp(int u, int prv) {
    dp[u] = fact[sz[u] - 1];
    for (auto v: adj[u]) {
        if (v != prv) {
            fillDp(v, u);

            dp[u] = (dp[u] * dp[v])%MOD;
            dp[u] = (dp[u] * fastExponentiation(fact[sz[v]], MOD - 2))%MOD;
        }
    }
}

void reroot(int u, int prv) {
    answer[u] = dp[u];
    for (int v: adj[u]) {
        if (v != prv) {
            LL tempDpU = dp[u];
            int tempSzU = sz[u];
            LL tempDpV = dp[v];
            int tempSzV = sz[v];

            //Adjust u
            sz[u] -= tempSzV;
            dp[u] = (dp[u] * fastExponentiation(fact[tempSzU - 1], MOD - 2))%MOD;
            dp[u] = (dp[u] * fact[sz[u] - 1])%MOD;
            dp[u] = (dp[u] * fastExponentiation(tempDpV, MOD - 2))%MOD;
            dp[u] = (dp[u] * fact[tempSzV])%MOD;

            //Adjust v
            sz[v] += sz[u];
            dp[v] = (dp[v] * fastExponentiation(fact[tempSzV - 1], MOD - 2))%MOD;
            dp[v] = (dp[v] * fact[sz[v] - 1])%MOD;
            dp[v] = (dp[v] * dp[u])%MOD;
            dp[v] = (dp[v] * fastExponentiation(fact[sz[u]], MOD - 2))%MOD;

            reroot(v, u);

            dp[u] = tempDpU;
            sz[u] = tempSzU;
            dp[v] = tempDpV;
            sz[v] = tempSzV;
        }
    }
}

int main() {
    fact[0] = 1;
    for (int i = 1; i <= MAXN; i++)
        fact[i] = (fact[i - 1] * i)%MOD;

    cin >> N;
    for (int i = 1; i < N; i++) {
        int u, v;
        cin >> u >> v;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    DFS(1, 1);
    fillDp(1, 1);

    reroot(1, 1);

    for (int i = 1; i <= N; i++)
        cout << answer[i] << endl;
}


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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n, W, w, v;
	cin >> n >> W;
	vector<ll> Dp(W + 1);
	for (int i = 0; i < n; ++i)
	{
		cin >> w >> v;
		for (int j = W - w; j >= 0; --j)
			Dp[j + w] = max(Dp[j + w], Dp[j] + v);
	}
	ll ans = 0;
	for (ll x : Dp)
		ans = max(ans, x);
	cout << ans;
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>n>>k;
        string s;
        cin>>s;
        vector<pair<ll,ll>> rng;
        rng.pb(mp(0,0));
        FOR(i,0,s.length())
        {
            if(s[i]=='1') 
            {
                j=i;
                while (s[j]=='1') 
                    j++;
                rng.pb(mp(i,j));
                i = j-1;
            }
        } 
        rng.pb(mp(s.length(),s.length()));
        // for(auto it:rng)
        //     cout<<it.f<<" "<<it.s<<endl;   
        ll ans=0;
        FOR(i,0,rng.size())
        {
            j = min(i+k,(ll)rng.size()-1);
            ll len = rng[j].s - rng[i].f;
            ans = max(ans,len);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4484
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG

int main()
{
  int numOfArray;
  cin >> numOfArray; cin.ignore();

  DPRINTF("NUM OF ARRAY %d\n", numOfArray);

  int max = -1;
  int array[numOfArray];
  for (int i = 0; i < numOfArray; i++)
  {
    cin >> array[i];
    if (array[i] > max)
      max = array[i];
  }

#if DEBUG
  for (int i = 0; i < numOfArray; i++)
    if (i == 0) DPRINTF("%d", array[i]);
    else        printf(" %d", array[i]);
  cout << endl;
#endif // DEBUG

  max++; // make array which ranges 0 to max for index
  int counter[max];
  DPRINTF("MAX NUM %d\n", max);

  // init
  for (int i = 0; i < max; i++)
    counter[i] = 0;

  // count
  for (int i = 0; i < numOfArray; i++)
    counter[array[i]]++;

  // to know how many number of less than i exist at i index
  for (int i = 1; i < max; i++)
    counter[i] += counter[i-1];

#if DEBUG
  for (int i = 0; i < max; i++)
    DPRINTF("counter[%d] %d\n", i, counter[i]);
#endif // DEBUG

  int sortedArray[numOfArray + 1]; // ignore index 0

  // walking through in descending order can achieve stable sort
  for (int i = numOfArray - 1; i > -1; i--)
  {
    sortedArray[counter[array[i]]] = array[i];
    counter[array[i]]--;
    DPRINTF("i %d  array %d  counter %d\n", i, array[i], counter[array[i]]);
  }

  for (int i = 1; i < numOfArray + 1; i++)
  {
    if (i == 1) printf("%d", sortedArray[i]);
    else        printf(" %d", sortedArray[i]);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 18780
Imports System
Imports System.Collections.Generic
class p
    shared sub main()
        dim s = Console.ReadLine()
        dim k = Integer.Parse(Console.ReadLine())
        dim hs as new HashSet(of String)
        dim l as new List(of String)
        for i as Integer = 0 To s.Length
            for j as Integer = 0 To k + 1
                if s.Length > (i + j) then
                    hs.Add(s.Substring(i, j))
                else
                    hs.Add(s.Substring(i, j - ((i + j) - s.Length)))
                end if
            next
        next
        for each i as String in hs
            l.Add(i)
        next
        ' dim l = hs.ToList()
        l.Sort()
        Console.WriteLine(l(k))
    end sub
end class

Measured memory_bytes: 26640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    Int n, a, b;
    cin >> n >> a >> b;
    Int q = n / (a + b);
    n -= q * (a + b);
    PUTS(q*a+ min(n, a));
}


Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
  if (a[i] == b[i]) & (b[i] == c[i]):
    continue
  if (a[i] == b[i]) | (b[i] == c[i]) | (c[i] == a[i]):
    ans += 1
    continue
  ans += 2
print(ans)


Measured memory_bytes: 9104
#include <stdio.h>
int F[44];
void Fibo(int N){
        int i;
        F[0]=1;
        F[1]=1;
        for(i=2; i<=N; i++) {
                F[i]=F[i-2]+F[i-1];
        }
        printf("%d\n",F[N]);
}
int main(){
        int n;
scanf("%d",&n);
Fibo(n);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 100001;


int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  string s;
  cin >> n >> s;
  int dp[n][n];
  int S[n][n];
  memset(dp, 0, sizeof(dp));
  for(int i = 0;i < n;i++)
    dp[0][i] = 0, S[0][i] = 1;
  dp[0][0] = 1;
  for(int i = 1;i < n;i++){
    for(int j = 0;j <= i;j++){
      if(s[i - 1] == '<')
        dp[i][j] = (j ? S[i - 1][j - 1] : 0);
      else
        dp[i][j] = (1LL * S[i - 1][n - 1] - (j ? S[i - 1][j - 1] : 0) + MOD) % MOD;
    }
    S[i][0] = dp[i][0];
    for(int j = 1;j < n;j++)
      S[i][j] = (S[i][j - 1] + dp[i][j]) % MOD;
  }
  ll res = 0;
  for(int i = 0;i < n;i++)
    res += dp[n - 1][i];
  res %= MOD;
  cout << res;
  return 0;
}



Measured memory_bytes: 70528
# bsdk idhar kya dekhne ko aaya hai, khud kr!!!
# import math
# from itertools import *
# import random
# import calendar
# import datetime
# import webbrowser

# f = open("input.txt", 'r')
# g = open("output.txt", 'w')
# n, m = map(int, f.readline().split())

#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    pass


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion


def main():
    arr = list(map(int, input().split()))
    arr.sort()
    if arr[0] == 5 and arr[1] == 5 and arr[-1] == 7:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()




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

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

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

#define SZ(v) (int)v.size()
#define endl "\n"
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const LL INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

const int sz = 1e7;
int NOD[ sz + 1 ];

void f() {
    for( int i = 1; i <= sz; i++ ) {
        for( int j = i; j <= sz; j += i ) {
            NOD[j]++;
        }
    }
}

void solve() {
    int n;
    cin >> n;
    LL ans = 0;
    for (int i = 1; i <= n; i++) ans += 1LL * NOD[i] * i;

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1;
    f();
    for (int tc = 1; tc <= t; tc++) solve();
    return 0;
}



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


int main(){       
  int N;  cin >> N;
  int num = 0;

  int max = 0;
  for(int i = 0; i < N; i++){
    int val;  cin >> val;
    if(max <= val){                   //見える...
      max = val;                          //後ろのホテルはmax(val)以上求
      num++;                               //条件に該当するホテル
    }
  }
  
  cout << num << endl;
  return 0;
  
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 1000000007
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 100003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
long long dep[303][303][303],n,m,l,r,x;
vector<pair<int,int>>gg[303];
long long dp(int r,int g,int b){
	int now=max(r,max(g,b))+1;
	if(now==n+2)return 1;
	long long&ret=dep[r][g][b];
	if(ret!=-1)return ret;
	ret=0;
	bool ya=true;
//	debug(r);
//	debug(g);
//	debug(b);
	for(auto i:gg[now-1]){
		int cnt=0;
		if(r>=i.f)cnt++;
		if(g>=i.f)cnt++;
		if(b>=i.f)cnt++;
		//debug(i.f);
		//debug(i.s);
		if(cnt!=i.s)ya=false;
	}
//	if(ya){
	//	debug(r);
	//	debug(g);
	//	debug(b);
//		cout<<"---\n";
//	}
	if(ya && now<n+1){
		ret=(ret+dp(r,g,now))%MOD;
		ret=(ret+dp(r,now,b))%MOD;
		ret=(ret+dp(now,g,b))%MOD;
	}
	else if(ya){
		ret=(ret+dp(r,g,now))%MOD;
	}
	return ret;
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>l>>r>>x;
		gg[r].pb({l,x});
	}
	reset(dep,-1);
	cout<<dp(0,0,0)<<endl;
}




Measured memory_bytes: 217600
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<vector<ll>> cnt(10, vector<ll>(10));
    for ( int i = 1; i <= n; ++i ) {
        int w = i;
        while(1) {
            if ( w < 10 ) break;
            w /= 10;
        }
        ++cnt[w][i%10];
    }
    ll ans = 0;
    for ( int i = 1; i < 10; ++i ) {
        for ( int j = 1; j < 10; ++j ) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2005;
ll dp[N*3][N],ans;
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),mod=read();
	dp[0][0]=1;
	For(i,0,3*n-1){
		For(j,0,n){
			dp[i][j]%=mod;
			dp[i+1][j]+=dp[i][j];
			dp[i+2][j+1]+=dp[i][j]*(i+1);
			dp[i+3][j+1]+=dp[i][j]*(i+1)*(i+2);
		}
	}
	For(i,0,n)ans+=dp[3*n][i]%mod;
	//For(i,0,n)cout<<dp[3*n][i]<<" ";
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 94464
#include <bits/stdc++.h>
using namespace std;
//解説AC
int main() {
  int s;
  cin>>s;
  map<int,int>mp;
  int x=s;
  while(mp.count(x)==0){
    mp[x]=1;
    if(x%2==0){
      x/=2;
    }else{
      x=x*3+1;
    }
  }
  cout<<(mp.size()+1)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(b, n * a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  	vector<int> a_1(3);
  	vector<int> a_2(3);
  	vector<int> a_3(3);
  	vector<int> ans_1{0,0,0};
  	vector<int> ans_2{0,0,0};
  	vector<int> ans_3{0,0,0};
    int n;
    rep(i, 3) {
        cin >> a_1[i];
//        cout << a_1[i]; cout << " ";
    }
//    cout << endl;
    rep(i, 3) {
        cin >> a_2[i];
//        cout << a_2[i]; cout << " ";
    }
//    cout << endl;
    rep(i, 3) {
        cin >> a_3[i];
//        cout << a_3[i]; cout << " ";
    }
//    cout << endl;
    cin >> n;
//    cout << n << endl;
  	vector<int> b(n);
    rep(i, n) {
        cin >> b[i];
//        cout << b[i] << endl;
    }
    rep(i, n){
        for (int x = 0; x < 3; x++) {
            if(b[i] == a_1[x]){
                ans_1[x] = 1;
            }            
        }
        for (int x = 0; x < 3; x++) {
            if(b[i] == a_2[x]){
                ans_2[x] = 1;
            }
        }
        for (int x = 0; x < 3; x++) {
            if(b[i] == a_3[x]){
                ans_3[x] = 1;
            }
        }
    }
/*
    rep(i, 3){
        cout << ans_1[i];
    }
    cout << endl;
    rep(i, 3){
        cout << ans_2[i];
    }
    cout << endl;
    rep(i, 3){
        cout << ans_3[i];
    }
    cout << endl;
*/
    if( (ans_1[0] == 1 && ans_1[1] == 1 && ans_1[2] == 1)
        || (ans_2[0] == 1 && ans_2[1] == 1 && ans_2[2] == 1)
        || (ans_3[0] == 1 && ans_3[1] == 1 && ans_3[2] == 1)
        || (ans_1[0] == 1 && ans_2[0] == 1 && ans_3[0] == 1)
        || (ans_1[1] == 1 && ans_2[1] == 1 && ans_3[1] == 1)
        || (ans_1[2] == 1 && ans_2[2] == 1 && ans_3[2] == 1)
        || (ans_1[0] == 1 && ans_2[1] == 1 && ans_3[2] == 1)
        || (ans_1[2] == 1 && ans_2[1] == 1 && ans_3[0] == 1)
        ){
            cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Set (Set)
import qualified Data.Set as S

main :: IO ()
main = do
  s <- getLine
  unless (s == "#") $ do
    print $ solve s
    main

solve :: String -> Int
solve = subtract 1 . length . groupBy f
  where
    lh = S.fromList "qwertasdfgzxcvb"
    f c1 c2 = S.member c1 lh == S.member c2 lh



Measured memory_bytes: 4100
#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <assert.h>
#include <stdlib.h>
using namespace std;

void smain();
int main() {
    ios_base::sync_with_stdio(0);
#ifdef TASK
    freopen(TASK".in","rt",stdin);
    const clock_t start = clock();
#endif
    smain();
#ifdef TASK
    cerr << "\nTotal Execution Time: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

#ifndef M_PI
#define M_PI 3.14159265358979311599796346854418516
#endif
#define forn(i,n) for (int i=0;i<n;i++)
#define rforn(i,n) for (int i=n-1;i>=0;i--)
#define LL long long
#define int long long
#define mp(a,b) make_pair(a,b)
#define INF 2305843009213693951LL
#define MOD 1000000007
#define EPS 1E-12
#define N 200
/* --------- END TEMPLATE CODE --------- */
int n;
int a[N], b[N];

vector<pair<int, int> > calc(int x) {
    vector<pair<int, int> > res;
    forn(i, n) b[i] = a[i];
    for (int i = x; i > 0; --i) {
        if (b[i - 1] <= b[i]) continue;
        if (b[i] >= 0) return vector<pair<int, int> >();
        int k = -b[i-1] / b[i] + 1;
        if (k > n) return vector<pair<int, int> >();
        b[i - 1] += k * b[i];
        while (b[i - 1] > b[i]) b[i - 1] += b[i], k += 1;
        forn(j, k) res.emplace_back(i + 1, i);
    }
    for (int i = x; i + 1 < n; ++i) {
        if (b[i] <= b[i + 1]) continue;
        if (b[i] <= 0) return vector<pair<int, int> >();
        int k = (-b[i+1] + b[i] - 1) / b[i] + 1;
        if (k > n) return vector<pair<int, int> >();
        forn(j, k) res.emplace_back(i + 1, i + 2);
        b[i + 1] += k * b[i];
    }
    return res;
}

vector<pair<int, int> > solve() {
    bool ok = 1;
    forn(i, n - 1) if (a[i] > a[i + 1]) ok = 0;
    if (ok) return vector<pair<int, int>> ();
    forn(i, n) {
        auto res = calc(i);
        if (res.empty()) continue;
        if ((int)res.size() > 2 * n) continue;
        return res;
    }
    assert(false);
}

void smain() {
    forn(_t, 0) {
        n = rand() % 50 + 2;
        forn(i, n) a[i] = rand() % 100 - 50;
        cout << n << endl;
        forn(i, n) cout << a[i] << ' '; cout << endl;
        auto res = solve();
        assert((int)res.size() <= 2 * n);
        forn(i, n) b[i] = a[i];
        for (auto it : res) b[it.second - 1] += b[it.first - 1];
        forn(i, n) cout << b[i] << ' '; cout << endl;
        forn(i, n - 1) assert(b[i] <= b[i + 1]);
    }
    for (; cin >> n;) {
        forn(i, n) cin >> a[i];
        auto res = solve();
        cout << res.size() << '\n';
        for (auto it : res) cout << it.first << ' ' << it.second << '\n';
    }
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors

n = int(input())
d = make_divisors(n)

ans = 100000000000000000
for div in d:
    r = n//div
    temp = max(len(str(div)),len(str(r)))
    if ans > temp:
        ans = temp

print(ans)


Measured memory_bytes: 39408
// JavaScript source code
"use strict";

let myFunc = (input) => {
    input = input.split("\n");
    let S = input[1].split(" ");
    let N = parseInt(input[0]);
    let P, W, G, Y;
    P = W = G = Y = 0;
    for(let i = 0; i < N; i++){
        if(S[i] === 'P') P = 1;
        if(S[i] === 'W') W = 1;
        if(S[i] === 'G') G = 1;
        if(S[i] === 'Y') Y = 1;
    }
    if(P + W + G + Y === 3) console.log("Three");
    if(P + W + G + Y === 4) console.log("Four");
};

myFunc(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30468
# -*- coding: utf-8 -*-

import math

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

def func(I,J,D):
    tmp = 0
    for x in range(D):
        tmp = tmp + (I[x]-J[x]) * (I[x]-J[x])
    return tmp

N,D=map(int, input().split())
X=[list(map(int, input().split())) for _ in range(N)]


ans = 0
tmp = 0
for i in range(N):
    for j in range(i+1,N):
        if float.is_integer(math.sqrt(func(X[i],X[j],D))):
            ans = ans+1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

struct Edge {int to, id;};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c= -1, int p=-1) {
    int k = 1;
    rep(i, g[v].size()) {
        int u = g[v][i].to, ei=g[v][i].id;
        if(u == p) continue;
        if(k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u, ans[ei], v);
    }
}

int main() {
    int n;
    cin >> n;
    g.resize(n);
    ans = vector<int>(n-1);
    for(int i=0;i<n-1;++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }
    dfs(0);
    int mx = 0;
    for (int i=0;i<n;++i) {
        mx = max(mx, int(g[i].size()));
    }
    cout << mx << endl;
    for(int i =0;i<n-1;++i) {
            cout << ans[i] << endl;
        }
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <string.h>
#define maxn 401
#define int long long
using namespace std;
typedef pair<int,int> pii;
int arr[maxn];
pii dp[maxn][maxn];
main() {
	ios::sync_with_stdio(false);
	//   sync_with_YinHsuan(true);
	cin.tie(0);
	int n;
	cin >> n;
	memset(dp,0x7f,sizeof(dp));
	for ( int i=1; i<=n; ++i )	cin >> arr[i];
	for ( int i=1; i<=n; ++i )	dp[i][i] = make_pair(arr[i],0);
	for ( int i=2; i<=n; ++i )
		for ( int j=1; j+i-1<=n; ++j ) {
			int l = j, r = j+i-1;
			pii cost = make_pair(0,-1);
			for ( int k=l; k<r; ++k )
				if ( cost.second == -1 || dp[l][k].second+dp[k+1][r].second+dp[l][k].first+dp[k+1][r].first < cost.second )
					cost = make_pair(dp[l][k].first+dp[k+1][r].first,dp[l][k].second+dp[k+1][r].second+dp[l][k].first+dp[k+1][r].first);
			dp[l][r] = cost;
		}
	cout << dp[1][n].second << '\n';
	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  if(op=='+') cout<< a+b <<endl;
  else cout<< a-b <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int int_sort( const void * a , const void * b ) {
  if( *( int  * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}

int main(void){
 
  int N;
  int X[100];
  int i,j;
  
  size_t data_cnt;
  
   scanf("%d\n",&N);
  
  for(i=0;i<N;i++){
  	
    scanf("%d ",&X[i]);
  
  }
  
  data_cnt =N;
  
  int hoko=2147483647;
  
  qsort((void*)X, data_cnt , sizeof(X[0]), int_sort );
  
  int sum=0;
 
  for(i=1;i<=100;i++){
	
    sum=0;
    
    for(j=0;j<N;j++){
    	sum=sum+(X[j]-i)*(X[j]-i);
      	//printf("%d %d\n",X[i],sum);
      
      	
    }
    
    if(hoko>sum){
          
    		hoko=sum;
    	
        }
    
  
    
    
    //printf("%d\n",hoko);
    
  }
  
  printf("%d\n",hoko);
  return 0;
  
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)
int main(){
    ll N, A, B;
    cin >> N >> A >> B;

    if (A % 2 == B % 2) {
        cout << (B-A)/2 << endl;
    } else {
        cout << min(A + (B - A - 1)/2, (N-B + 1) + (B - A - 1)/2) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int fib(int a){
    int b=0;
    if(a==1){
        return 1;
    }
  else if(a==2){
    return 2;
  }
    else{
        b=+(fib(a-1)+fib(a-2));
        return b;
    }
}
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans;
  ans=(b-a+1)-((b/c-(a-1)/c)+(b/d-(a-1)/d));
  ll r,x;
  x=c*d;
  if(c<d){
    int temp=c;
    c=d;
    d=temp;
  }
  r=c%d;
  while(r!=0){
    c=d;d=r;r=c%d;
  }
  x=x/d;
  ans+=(b/x-(a-1)/x);
  cout<<ans<<endl;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var x = input[0];
            var a = input[1];
            if (x < a)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine("10");
            }
        }
    }
}

Measured memory_bytes: 13396
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
from collections import deque
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

def BFS(G, N, s, g, ans):
	Q = deque()
	Q.append(s)
	dist = [INF] * N
	dist[s] = 0
	prev = [None] * N
	jud = "No"
	while Q:
		v = Q.popleft()
		for i in G.graph[v]:
			if dist[i] == INF:
				dist[i] = dist[v] + 1
				prev[i] = v
				Q.append(i)
				if i == g:
					jud = "Yes"
					break
		if jud == "Yes":
			break

	if ans > dist[g]:
		state = g
		path = [g]
		while True:
			state = prev[state]
			path.append(state)
			if state == s:
				break
		return dist[g], path[::-1]
	else:
		return INF, []

#処理内容
def main():
	N, M = getlist()
	G = Graph()
	edgefrom = []
	edgeto = []
	for i in range(M):
		a, b = getlist()
		a -= 1; b -= 1
		edgefrom.append(a)
		edgeto.append(b)
		G.add_edge(a, b)

	ans = 100000
	path = None
	for i in range(M):
		predis, prepath = BFS(G, N, edgeto[i], edgefrom[i], ans)
		if predis != INF:
			ans = predis
			path = prepath

	if ans == 100000:
		print(-1)
	else:
		print(ans + 1)
		for i in path:
			print(i + 1)

if __name__ == '__main__':
	main()

Measured memory_bytes: 53340
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int n  = ReadLineInt();
        int[] aList = ReadLineIntArray();
        int[] rtnList = new int[n];
        for (int i = 0;i < n; i++) {
            rtnList[i] = i + 1;
        }
        Array.Sort(aList, rtnList);
        for (int i = 0;i < n - 1; i++) {
            Console.Write(rtnList[i] + " ");
        }
        Console.WriteLine(rtnList[n - 1]);
    }
 
    static string[] ary = new string[] {"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", "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"};
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 30296
// atcoder/abc125/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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


  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;

    vector<int> x;
    {
      int prev = a.front();
      each (i, a) {
        x.push_back(__gcd(prev, i));
        prev = x.back();
      }
    }

    vector<int> y;
    {
      reverse(a.begin(), a.end());
      int prev = a.front();
      each (i, a) {
        y.push_back(__gcd(prev, i));
        prev = y.back();
      }
      reverse(begin(y), end(y));
    }

    // cout << endl;
    // cout << x << endl;
    // cout << y << endl;

    int mx = a.front();
    each (i, a) mx = __gcd(mx, i);
    setmax(mx, max(x[n - 2], y[1]));
    for (int i = 1; i + 1 < n; ++i) {
      setmax(mx, __gcd(x[i - 1], y[i + 1]));
    }
    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 1784
N = int(input())
A = list(map(int, input().split()))

A.sort()
for i in range(1, A[0]):
    print(0)

idx = 0
for shain in range(A[0], N+1):
    num = 0
    while True:
        if idx >= N - 1:
            print(num)
            num = 0
            break
        if shain != A[idx]:
            print(num)
            num = 0
            shain += 1
            break
        else:
            num += 1
            idx += 1



Measured memory_bytes: 92228
#include <iostream>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int a[n+1];   //左からi桁目をa[i]とする
    for (int i=1; i<n+1; i++) {
        a[i] = -1;
    }
    int s, c;
    for (int i=0; i<m; i++) {
        cin >> s >> c;
        if (s == 1 && c == 0 && n != 1) {
            cout << -1 << endl;
            return 0;
        } else if (a[s] == -1) {
            a[s] = c;
        } else if (a[s] != c) {
            cout << -1 << endl;
            return 0;
        }
    }
    int result = 0;
    for (int i=1; i<n+1; i++) {
        result *= 10;
        if (a[i] == -1) {
            if (i == 1 && n > 1) {
                a[i] = 1;
            } else {
                a[i] = 0;
            }
        }
        result += a[i];
    }
    cout << result << endl;
}

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

int main() {
    int N, A, B, dig5,dig4, dig3, dig2, dig1, ans = 0, sum = 0;
    string x;
    cin >> N >> A >> B;
    

    for (int i = 1; i <= N; ++i){
        dig5 = i / 10000;
        dig4 = (i - dig5 * 10000) / 1000;
        dig3 = (i - dig5 * 10000 - dig4 * 1000) / 100;
        dig2 = (i - dig5 * 10000 - dig4 * 1000 - dig3 * 100) / 10;
        dig1 = (i - dig5 * 10000 - dig4 * 1000 - dig3 * 100 - dig2 * 10 );
        sum = dig5 + dig4 + dig3 + dig2 + dig1;
        if (sum >= A && sum <= B){
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,q,mx,cnt;
int al[15];
struct strukt
{
	int a;
	int b;
	int c;
	int d;
}k[55];
void dfs(int s)
{
	if(s>n)
	{
		int cn=0;
		for(int i=1;i<=q;i++)
			if(al[k[i].b]-al[k[i].a]==k[i].c)
				cn+=k[i].d;
		mx=max(mx,cn);
	}
	else
		for(int i=(s==1?1:al[s-1]);i<=m;i++)
		{
			al[s]=i;
			dfs(s+1);
		}
}
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
		cin>>k[i].a>>k[i].b>>k[i].c>>k[i].d;
	dfs(1);
	cout<<mx;

	return 0;
}

Measured memory_bytes: 3648
from collections import Counter


def f(d, val):
    res = 0
    for elem, amount in d.items():
        if elem == val:
            continue
        res += amount
    return res


N = int(input())
V = list(map(int, input().split()))

e = Counter(V[0::2])
o = Counter(V[1::2])

e1 = e.most_common()[0]
o1 = o.most_common()[0]

ans = 0
if e1 != o1:
    ans += f(e, e1[0])
    ans += f(o, o1[0])
else:
    if e1[1] > o1[1]:
        if len(o) < 2:
            ans += o1[1]
        else:
            ans += f(o, o.most_common()[1][0])
        ans += f(e, e1[0])
    elif e1[1] < o1[1]:
        if len(e) < 2:
            ans += e1[1]
        else:
            ans += f(e, e.most_common()[1][0])
        ans += f(o, o1[0])
    else:
        if len(o) == len(e) == 1:
            ans += e1[1]
        elif len(o) == 1:
            ans += f(e, e.most_common()[1][0])
        elif len(e) == 1:
            ans += f(o, o.most_common()[1][0])
        else:
            e2 = e.most_common()[1]
            o2 = o.most_common()[1]

            if e2[1] > o2[1]:
                ans += f(e, e2[0])
                ans += f(o, o1[0])
            else:
                ans += f(e, e1[0])
                ans += f(o, o2[0])
print(ans)


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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,m; cin>>n>>m;
  vector<int> oks(n+1, 1);
  for (int i=0; i<m; i++) {
    int a; cin>>a;
    oks[a] = 0;
  }
  vector<ll> dp(n+1, 0);
  dp[0] = 1;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<=min(n, i+2); j++) {
      if (oks[j]) {
        dp[j] += dp[i];
        dp[j]%=mod;
      }
    }
  }
  cout << dp[n] << endl;
}

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


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }

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


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

#define INF 1e9

typedef vector <int> vi;

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

    int v[n];
    for (int i = 0; i < n; i++) cin >> v[i];

    vi dp(n, INF);
	dp[0] = 0;

    for (int i = 0; i < n; i++) {
        if (i+1 < n) dp[i+1] = min(dp[i+1], dp[i] + abs(v[i] - v[i+1]));
        if (i+2 < n) dp[i+2] = min(dp[i+2], dp[i] + abs(v[i] - v[i+2]));
    }

	// for (int i = 0; i < n; i++) cout << dp[i] << " ";
	// cout << endl;

    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h)
  cin >> s[i];

  int di[] = {-1, 0, 1, 0}, dj[] = {0, -1, 0, 1}, ans = 0;
  REP(si, h)
  REP(sj, w)
  {
    if (s[si][sj] == '#')
      continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF)
        return;
      dist[i][j] = x;
      q.push(P(i, j));
    };
    update(si, sj, 0);
    while (!q.empty())
    {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      REP(dir, 4)
      {
        int ni = i + di[dir], nj = j + dj[dir];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w)
          continue;
        if (s[ni][nj] == '#')
          continue;
        update(ni, nj, dist[i][j] + 1);
      }
    }
    REP(i, h)
    REP(j, w)
    {
      if (dist[i][j] == INF)
        continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;

  return 0;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;

  string ans="";
  string alphabet="abcdefghijklmnopqrstuvwxyz";  

  while(n > 0) {
    ll amari = n % 26;
    if (amari != 0) {
      ans.push_back(alphabet[(n - 1) % 26]);
    }
    else {
      ans.push_back(alphabet[(n - 1) % 26]);
      n--;
    }
    n /= 26;
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 3624