akhauriyash/Code-Regression huggingface dataset:
//g++ main.cpp -I /usr/local/include/ac-library
#include<cmath>
#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using namespace atcoder;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll n,k;
    cin >> n>>k;
    ll ABIG=LLONG_MAX/(n*k+10);
    mcf_graph<ll,ll> mcf(n*2+2);
    int s=0;
    int t=n*2+1;
    rep(i,n){
        rep(j,n){
            int a;
            cin >> a;
            mcf.add_edge(i+1,n+1+j,1,ABIG-a);
        }
    }
    rep(i,n){
        mcf.add_edge(s,i+1,k,0);
        mcf.add_edge(n+1+i,t,k,0);
    }
    mcf.add_edge(s,t,LLONG_MAX,ABIG);
    pair<ll,ll> ans=mcf.flow(s,t,n*k);
    cout<<n*k*ABIG-ans.second<<endl;
    vector<mcf_graph<ll,ll>::edge> eg=mcf.edges();
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool f=false;
            for(int k=0;k<eg.size();k++){
               //cout<<eg[k].from<<","<<eg[k].to<<","<<eg[k].flow<<endl;
                if(eg[k].from==i+1&&eg[k].to==j+n+1&&eg[k].flow==1){
                    f=true;
                }
            }
            if(f) cout<<"X";
            else cout<<".";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<long long> A(N);
    map<long long, int> m;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i) {
            A[i] += A[i-1];
        }
        m[A[i]]++;
    }
    m[0]++;
    long long ans = 0;
    for (auto x: m) {
        long long k = x.second;
        ans += k*(k-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
s=input()
t=s.translate(str.maketrans('','','x'))
n=len(t)
if t!=t[::-1]:
  print(-1)
else:
  A=[0]*(n+1)
  cur,ct=0,0
  for i in range(len(s)):
    if s[i]=="x":
      ct+=1
    else:
      A[cur]=ct
      cur+=1
      ct=0
    A[n]=ct
  B=A[::-1]
  ans=0
  for i in range((n+1)//2):
    ans+=abs(A[i]-B[i])
  print(ans)

Measured memory_bytes: 4848
s = str(input())


s1 = s.replace("A","1")
s2 = s1.replace("G","1")
s3 = s2.replace("T","1")
s4 = s3.replace("C","1")

if s4.count("1111111111") >= 1:
 print(10)
elif s4.count("111111111") >= 1:
 print(9)
elif s4.count("11111111") >= 1:
 print(8)
elif s4.count("1111111") >= 1:
 print(7)
elif s4.count("111111") >= 1:
 print(6)
elif s4.count("11111") >= 1:
 print(5)
elif s4.count("1111") >= 1:
 print(4)
elif s4.count("111") >= 1:
 print(3)
elif s4.count("11") >= 1:
 print(2)
elif s4.count("1") >= 1:
 print(1)
else:
 print(0)


Measured memory_bytes: 3064
while True:
    H,W=map(int, input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i==0 or j==0 or i==H-1 or j==W-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        long ab[][]=new long[n][2];
        for(int i=0;i<n;i++){
            for(int j=0;j<2;j++){
                ab[i][j]=fsc.nextLong();
            }
        }
        fsc.close();
        Arrays.sort(ab, (u,v)->u[1]>v[1]?1:u[1]<v[1]?-1:0);
        for(int i=0;i<n;i++){
            ab[i][0]+=i>0?ab[i-1][0]:0;
            if(ab[i][0]>ab[i][1]){
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Measured memory_bytes: 39364
#include <iostream>
#include <unordered_map>

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

	std::unordered_map<int, int> count;

	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		++count[a];
	}

	int ans = 0;
	for (auto&& p : count) {
		if (p.second >= p.first)
			ans += p.second - p.first;
		else
			ans += p.second;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 4260
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.next();
        String ans = "WA";
        out: if(str.charAt(0) == 'A' && Character.isLowerCase(str.charAt(1)) && Character.isLowerCase(str.charAt(str.length()-1))){
            for(int i = 2; i < str.length()-1; i++){
                char c = str.charAt(i);
                if(Character.isUpperCase(c)){
                    if(c == 'C'){
                        if(ans == "AC"){
                            ans = "WA";
                            break out;
                        }
                        else
                            ans = "AC";
                    }
                    else
                        break out;
                }
                
            }
        }
        System.out.println(ans);
        
    }
    
}


Measured memory_bytes: 22996
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int N = 123456;

vector<PI> edges[N];


ll dist[N];


void dfs(int v, int p, ll tot) {
  dist[v] = tot;
  REP(i, 0, edges[v].size()) {
    PI wd = edges[v][i];
    int w = wd.first;
    if (w == p) continue;
    int d = wd.second;
    dfs(w, v, tot + d);
  }
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  REP(i, 0, n - 1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    edges[a].push_back(PI(b, c));
    edges[b].push_back(PI(a, c));
  }
  int q, k;
  cin >> q >> k;
  k--;
  dfs(k, -1, 0);
  REP(i, 0, q) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << dist[x] + dist[y] << endl;
  }
}


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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int cnt = 0;
    int[] h = new int[N + 1];
    while (++cnt <= N) {
      h[cnt] = sc.nextInt();
    }
    int[] min = new int[N + 1];
    Arrays.fill(min, Integer.MAX_VALUE / 2);
    min[1] = 0;
    for (int i = 2; i < min.length; i++) {
      for (int k = 1; i - k >= 1 && k <= K; k++) {
        min[i] = Math.min(min[i], min[i - k] + Math.abs(h[i] - h[i - k]));
      }
    }
    System.out.println(min[N]);
  }
}

Measured memory_bytes: 52428
#include<bits/stdc++.h>
using namespace std;
int n, m, i, j, k;
char s[105];
int main(){
    scanf("%d", &n);
    scanf("%s", s);
    m=strlen(s);
    if(m>n){
    	for(i=0; i<=n-1; i++){
    		printf("%c", s[i]);
		}
		printf("...");
	}
	else{
		printf("%s", s);
	}
	return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    vl s(n),t(m);
    rep(i,n)cin >> s[i];
    rep(i,m)cin >> t[i];
    vvl dp(n+1,vl(m+1,1));
    rep(i,n+1){
        if(i==n)continue;
        rep(j,m+1){
            if(j==m)continue;
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j];
                dp[i+1][j+1]%=MOD;
            }
            else{
                dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j];
                dp[i+1][j+1]%=MOD;
            }
        }
    }
    /*rep(i,n+1){
        rep(j,m+1){
            cout << dp[i][j] <<" ";
        }
        cout <<endl;
    }*/
    if(dp[n][m]<0)dp[n][m]+=MOD;
    cout << dp[n][m]%MOD <<endl;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,a,b,t;
	cin>>k>>a>>b;
	for(t=a;t<=b;t++){
		if(t%k==0){
		printf("OK");
		break;
	}
	}
	if(t>b)
	printf("NG");
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    
    int ans;
  	ans = a.at(n - 1) - a.at(0);

    
    cout << ans << endl;
    
    

}

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

using namespace std;

#define int long long
//#define cerr if(false)cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define N 100005
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
int mod=998244353;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define mp make_pair

int32_t main() {
    faster;

    int k;
    cin>>k;

    int ans=0;

    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int h=1;h<=k;h++){
                ans+=gcd(i,gcd(h,j));
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3664
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [0]
for i in range(1, n):
    dp += [min([dp[-j] + abs(h[i] - h[i - j]) for j in range(1, min(i, k) + 1)])]
print(dp[-1])

Measured memory_bytes: 20424
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define ALL(a) a.begin, a.end()

using namespace std;

int main(void) {

	int N;

	cin >> N;

	vector <double> V(N);

	REP(i, N) cin >> V[i];

	sort(V.begin(), V.end());

	double half;

	REP(i, N-1) {

		half = (V[i] + V[i + 1]) / 2;
		V[i + 1] = half;
		sort(V.begin() + i + 1, V.end());

	}

	cout << V.back() << '\n';

	return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn=1e5+5,mod=1e4+7;
const double pi=acos(-1);

int main()
{
    string s;
    while(cin>>s)
    {
        if(s[2]==s[3]&&s[4]==s[5])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=1e2+5;
int n,m,a[N],odd;
signed main(){
	//freopen("a","r",stdin);
	n=read(),m=read();int k=0;
	rep(i,1,m){a[i]=read(),odd+=(a[i]&1);if((a[i]&1)&&!(a[1]&1))swap(a[1],a[i]);else if(a[i]&1)k=i;}if(k)swap(a[m],a[k]);
	if(n==1&&m==1)cout<<1<<'\n'<<1<<'\n'<<1;
	else if(m==1)cout<<n<<'\n'<<2<<'\n'<<1<<' '<<n-1;
	else if(odd>=3)cout<<"Impossible";
	else if(odd<=2){rep(i,1,m)cout<<a[i]<<' ';a[1]--;a[m]++;if(!a[1]){cout<<'\n'<<m-1<<'\n';rep(i,2,m)cout<<a[i]<<' ';}else{cout<<'\n'<<m<<'\n';rep(i,1,m)cout<<a[i]<<' ';}}
	return signed();
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  string s, ml, ms;
  int maxl = 0, maxm = 0;  
  
  map<string, int> m;

  while(cin >> s) {
    if(s.size() > maxl) {
      ml = s;
      maxl = s.size();
    }

    bool b = true;
    map<string, int>::iterator it = m.begin();
    while(it != m.end()) {
      if(it->first == s) {
	it->second++;
	b = false;
	break;
      }
      it++;
    }
    if(b) m.insert(map<string, int>::value_type(s, 1));
    if(m[s] > maxm) {
      maxm = m[s];
      ms = s;
    }
  }
  cout << ms << ' ' << ml << endl;
}

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

typedef long long ll;
const ll mod=1e9+7;
const int N=200000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int a[N];
set<int>v;
int main()
{
    Run();
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.size()>n)
    {
    for(int i=0;i<n;i++)
    {
        cout<<s[i];
    }
    cout<<"...";
    }

    else
        cout<<s;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(container) container.begin(), container.end()
#define debug(var) std::cout << #var << " : " << var;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;


int main(){


	int N; std::cin >> N;
	std::vector<int> X(N);
	rep(i, N)std::cin >> X[i];
	std::vector<int> sorted = X;
	std::sort(sorted.rbegin(), sorted.rend());

	rep(i, N){
		auto itr = std::lower_bound(all(sorted), X[i]);
		int index = std::distance(sorted.begin(), itr) - 1;
		if(index < N / 2){
			std::cout << sorted[N / 2 - 1] << std::endl;
		}else{
			std::cout << sorted[N / 2] << std::endl;
		}
	}


	return 0;
}


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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    vector<int> A(N);
    vector<int> B(N);
    vector<pair<int,int>> P(N);

    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        P[i] = make_pair(B[i], -A[i]);
    }
    sort(P.begin(), P.end());
    reverse(P.begin(), P.end());

    string ans = "Yes";
    int t = P[0].first + P[0].second;
    for (int i = 1; i < N; i++) {
        t = min(P[i].first + P[i].second, t + P[i].second);
        // cout << P[i].first << " " << P[i].second << " " << t << "\n";
        if (t < 0) {
            ans = "No";
            break;
        }
    }
    if (t < 0) {
        ans = "No";
    }
    
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int h,a,b;cin>>h>>a>>b;
	int cnt=0;
	for(int i=a;i<=b;i++){
		if(h%i==0)cnt++;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 3112
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int a, b, c, k, ans = 0;
  cin >> a >> b >> c >> k;
 // int ans = 0;
  if(k > 0) {
    ans += (min(k, a));
    k -= a; 
  }
  if(k > 0) {
    k -= b;
  }
  if(k > 0) {
    ans -= (min(k, c));
  }
  cout << ans << '\n';
}

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

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


Measured memory_bytes: 3652
n,m[256*256],c[4][256*256];
i,j,l,L,p;
main(){
	for(;~scanf("%d\n",&n);){
		int z[]={1,n+2,n+1,n};
		L=0;
		for(p=256,i=(n+1)*n;i--;p++){
			m[p]=getchar();
			for(j=4;j--;){
				l=c[j][p]=m[p]==49?c[j][p-z[j]]+1:0;
				if(l>L)
					L=l;
			}
		}
		n&&printf("%d\n",L);
	}
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  vector<int> a(3);
  cin >> a;
  sort(rrng(a));
  int r = a[0] * 10 + a[1] + a[2];
  cout << r;
}
#endif


Measured memory_bytes: 3656
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

int main(int argc, char *argv[])
{
  ll N, P;
  cin >> N >> P;
  if (N == 1) {
    cout << P << endl;
    return 0;
  }
  
  ll res = 1;
  for (ll i = 2; i * i <= P; i++ ) {
    int count = 0;
    while (P % i == 0) {
      P /= i;
      count++;
    }

    while (count >= N) {
      res *= i;
      count -= N;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main(void){
	int h, w;
	while(1){
		cin >>h >>w;
		if(h==0 && w==0){
			break;
		}
		for(int i=0; i<h; i++){
			if(i%2==0){
				for(int j=0; j<w; j++){
					if(j%2==0){
						cout <<"#";
					}else{
						cout <<".";
					}			
				}
			}else{
				for(int j=0; j<w; j++){
					if(j%2==0){
						cout <<".";
					}else{
						cout <<"#";
					}			
				}
			}
			cout <<endl;
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N,M; cin >> N >> M;
  int ans=0;
  vv<int> L(M);
  rep(i,M){
    int k; cin >> k;
    rep(j,k){
      int s; cin >> s;
      s--;
      L[i].push_back(s);
    }
  }
  v<int> p(M);
  rep(i,M){
    cin >> p[i];
  }

  for (int bit = 0; bit < (1 << N); ++bit) {
    int cnt=0;
    rep(j,M){
      int tmp=0;
      fore(k,L[j]){
        if (bit & (1 << k)){
          tmp++;
        }
      }
      if(tmp%2==p[j]) cnt++;
    }
    if(cnt==M) ans++;
  }
  cout << ans << endl;
  return 0;
}


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


using namespace std;

void a()
{
	string s;
	cin >> s;
	int cnt[26];
	memset(cnt, 0, 26*sizeof(int));
	for (int i = 0; i < 4; i++) {
		cnt[s[i] - 'A']++;
	}
	bool res = true;
	for (int i = 0; i < 26; i++) {
		if (cnt[i] != 0 && cnt[i] != 2) {
			res = false;
		}
	}
	cout << (res ? "Yes" : "No") << endl;
}

int main()
{
	a();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)
//円周率: M_PI

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

    vector<string> N;
    map<string,int> shouhin;

    rep(i,n){
        string in; cin >> in;
        if(i != 0){
            if(shouhin.count(in)){
                continue;
            }
        }
        shouhin[in] = 1;
    }
    cout << shouhin.size() << endl;

}





Measured memory_bytes: 19152
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;

int main()
{
  int A,B,C,X; cin >> A >> B >> C >> X;
  
  int count = 0;
  for(int i = 0; i <= A; i++){
  	for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
      	if( X == i * 500 + j * 100 + k * 50 ) count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <string>
#include <cstdlib>
#include <utility>

using namespace std;


int main() {
    typedef unordered_set<string> set_t;
    set_t A;
    int n;
    cin >> n;
    string order, word;
    
    for(int i = 0; i< n; i++)
    {
        cin >> order >> word;
        if(order=="insert")
        {
            A.insert(word);
        }
        else if(order=="find")
        {
            if(A.count(word) > 0)
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
        
    }
    
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int a,b;
int main() {
    cin >> a >> b;
    int c = 3*a+b;
    int ans = c/2;
    cout << ans << endl;

}

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


int main(){
    string s;
    cin >> s;
    int n = s.size();
	int MOD = 1000000007;

    long long dp[100010][4] = {};
    for(int i = n; i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == n){
                dp[i][j] = (j == 3 ? 1 : 0);
            }else{
                dp[i][j] = dp[i+1][j] * (s[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(){
    int a[3], val;
    cin >> a[0] >> a[1] >> a[2];
    
    for ( int i = 0; i < 3; i++ ){
        for( int j = i+1; j < 3 ; j++){
            if(a[i] > a [j] ){
                val = a[i];
                a[i] = a[j];
                a[j] = val;
            } 
        }
    }
  
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int sum = 0;
    rep(i, n) {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
double const pi=acos(double(-1));
const int maxn = 4e5+100;
using namespace std;
typedef long long ll;
struct node{ 
    ll to;
    ll next;
}edge[maxn+5];
ll n,m,ans;
ll head[maxn+5];
void addedge(ll u,ll v)
{
    edge[ans].to=v;
    edge[ans].next=head[u];
    head[u]=ans++;
}
void init()
{
    memset(head,-1,sizeof(head));
    ans=0;
}
ll cnt=0;
ll num[maxn+5];
int vis[maxn+5];
void bfs(int u)
{
    queue<int>q;
    vis[u]=1;
    q.push(u);
    while(!q.empty()){
        int k=q.front();
        q.pop();
        //printf("%d ",k);
        for(int i=head[k];~i;i=edge[i].next){
             int to=edge[i].to;
             if(vis[to]==-1){
                q.push(to);
                vis[to]=k;
				cnt++; 
             }
        }
    }
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    init();
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll u,v;
        cin>>u>>v;
        addedge(u,v);
        addedge(v,u);
    }
    memset(vis,-1,sizeof(vis));
    bfs(1);
    //printf("\n");
    if(cnt!=n-1){
    	cout<<"No";
    	return 0;
	}
	else cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
    cout<<vis[i]<<endl;
    cout<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int A, B;
    cin >> A >> B;
    printf("%lld\n", max({A+A-1, A+B, B+B-1}));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
    int N, index;
    double T, A, H[1000];
    double MIN = 1000000.0;

    cin >> N >> T >> A;

    for(int i = 0; i < N; i++)
    {
        cin >> H[i];
        double absv = fabs(T - H[i] * 0.006 - A);
        if(absv < MIN)
        {
            MIN = absv;
            index = i;
        }
    }
    cout << index + 1;
    return 0;
}

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

using namespace std;

int main(){
  string S;
  cin >> S;
  int s_size = (int)(S.length());
  int max_length = 0;
  for(int i=0;i<s_size;++i){
    for(int j=i;j<s_size;++j){
      string subS = S.substr(i,j-i+1);
      for(int k=0;k<(int)(subS.length());++k){
        if(subS[k]!='A'&&subS[k]!='C'&&
           subS[k]!='T'&&subS[k]!='G'){
          break;
        }else{
          if(max_length < k+1){
            max_length = k+1;
          }
        }
      }
    }
  }
  cout << max_length << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x,y,z,i;
int main()
{
	cin>>x>>y>>z;
	for(i=0;i<=10086;i++)
		if (i*x%y==z)
			{
    			cout<<"YES";
    			return 0;
			}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 101
#define INF 100000
#define FLAG 1
#define DEFLAG 0

int main(){
  int i,j,n,min,a[MAX][MAX],k,x[MAX],minNode,sum=0,g[MAX];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a[i][j]);
    }
  }

  //calc
  k = 1;
  x[0] = 0;
  g[0] = FLAG;
  for(i=1;i<n;i++){
    g[i] = DEFLAG;
  }
  
  while(1){
    min = INF;
    
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
	if(min > a[x[i]][j] && a[x[i]][j]!= -1 && g[j] != FLAG){
	  min = a[x[i]][j];
	  minNode = j;
	}
      }
    }

    if(k!=n){
      x[k] = minNode;
      g[minNode] = FLAG;
      k++;
      sum += min;
    }else{ break; }
    
  }

  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
const int MAX_N=1e5,MOD=1e9+7;
const ll INF=(1e18)+4;

int N;
ll A[2];
ll S[MAX_N];

ll memo[MAX_N];
int nex[MAX_N][2];
ll diff[MAX_N];

int st_size;
ll dat[MAX_N*4];

void init(){
	st_size=1;
	while(st_size<N-1) st_size<<=1;
	REP(i,st_size){
		dat[i+st_size-1]=INF;
	}
	REP(i,N-1){
		dat[i+st_size-1]=diff[i];
	}
	for(int i=st_size-2;i>=0;i--){
		dat[i]=min(dat[i*2+1],dat[i*2+2]);
	}
}

ll query(int s,int t,int k,int a,int b){
	if (s<=a && b<=t){
		return dat[k];
	}else if (t<=a || b<=s){
		return INF;
	}else{
		int m=(a+b)/2;
		return min(query(s,t,k*2+1,a,m),query(s,t,k*2+2,m,b));
	}
}

int dfs(int n){
	if (n==N){
		return 1;
	}
	if (memo[n]!=-1){
		return memo[n];
	}
	int res=0;
	REP(g,2){
		int ne=nex[n][g];
		if (ne!=-1){
			res+=dfs(ne);
			res%=MOD;
		}
	}
	return memo[n]=res;
}

int main(){
	scanf("%d",&N);
	REP(i,2) scanf("%lld",&A[i]);
	REP(i,N){
		scanf("%lld",&S[i]);
	}
	REP(i,N-1){
		diff[i]=S[i+1]-S[i];
	}
	init();
	for(int n=N-1;n>=0;n--){
		REP(g,2){
			int lb=lower_bound(S,S+N,S[n]+A[g])-S;
			if (n+1<lb-1){
				int mdiff=query(n+1,lb-1,0,0,st_size);
				if (mdiff<A[(g+1)%2]){
					nex[n][g]=-1;
					continue;
				}
			}
			if (lb==N){
				nex[n][g]=N;
				continue;
			}
			int s=S[lb];
			if (n+1==lb){
				nex[n][g]=n+1;
				continue;
			}
			if (S[lb-1]+A[(g+1)%2]<=s){
				nex[n][g]=lb;
			}else{
				nex[n][g]=nex[lb-1][(g+1)%2];
			}
		}
	}
	memset(memo,-1,sizeof(memo));
	printf("%d\n",dfs(0));
	return 0;
}


Measured memory_bytes: 8576
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0

for i in range(2**N):
    cnt = 0
    for j in range(M):
        count=0
        for k in ks[j][1:]:
            if (i >> k-1)&1:
                count += 1
        if count%2==p[j]:
            cnt+=1
    if cnt==M:
        ans+=1
print(ans)

Measured memory_bytes: 40944
main()
{
    long long int N, a[5]={0}, b, c, d, i, ans=0, min=1000000000000001;
    scanf("%lld", &N);
    for(i=0;i<5;i++)
    {
        scanf("%lld", &a[i]);
        min = min>a[i]?a[i]:min;
    }
    b = N / min;
    c = N % min;
    d = b + (c>0);
    d = d>1?d-1:0;
    ans = 5 + d;
    printf("%lld", ans);
}


Measured memory_bytes: 128
open Str

let list_of_string = Str.split (Str.regexp " ")

let pair_of_list list = match list with
    first :: second :: [] -> (first, second)
  | _ -> (0, 0)

let comparison (a, b) = if a < b then "a < b"
  else if a > b then "a > b"
  else "a == b";;

read_line()
|> list_of_string
|> List.map int_of_string
|> pair_of_list
|> comparison
|> print_endline



Measured memory_bytes: 2036
# -*- coding: utf-8 -*-
import sys
import os

def problem148D(N, alist):
  index = 0
  count = 0
  number = 1
  while index < N:
    if alist[index] == number:
      number += 1
    else:
      count += 1
    index += 1
  if count == N:
    count = -1
  print(count)

if __name__ == "__main__":
  N = int(input())
  alist= list(map(int, input().split()))
  problem148D(N, alist)

Measured memory_bytes: 26140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>

const double PI=acos(-1.0);
const double eps=1e-6;
const ll mod= 998244353;
const int inf=0x3f3f3f3f;
const int maxn=2e5+10;
const int maxm=100+10;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


ll dp[maxn];
int vis[maxn];
int n,k;
int main()
{
    cin>>n>>k;
    vector<pii>e;
    for(int i = 1; i<=k; i++)
    {
        int l,r;
        cin>>l>>r;
        e.push_back(make_pair(l,r));
    }
    sort(e.begin(),e.end());
    dp[1] = 1;
    for(int i = 2; i<=n; i++)
    {
        for(int j = 0; j<e.size(); j++)
        {
            int l = e[j].fi;
            int r = e[j].se;
            if(i-l < 0)
            {
                break;
            }
            else if(i-r >= 1)
                dp[i] = (dp[i] + dp[i-l] - dp[i-r-1] + mod)%mod;
            else
                dp[i] = (dp[i] + dp[i-l])%mod;
        }
        dp[i] = (dp[i] + dp[i-1])%mod;
    }
    cout<<(dp[n]-dp[n-1]+mod)%mod<<endl;
}


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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll POW(ll a, ll b){
	if(b==1) return a;
	if(b%2==0) return POW(a*a%INF, b/2);
	return a*POW(a, b-1)%INF;
}

int main(){
	int n, m;
	cin >> n >> m;
	int dp[101010] = { };
	dp[0] = 1;
	dp[1] = 1;
	REP(i, m){
		int x;
		cin >> x;
		dp[x] = -1;
	}
	FOR(i, 2, n+1){
		if(dp[i] != -1 && dp[i-1] != -1)  (dp[i] += dp[i-1]) %= INF;
		if(dp[i] != -1 && dp[i-2] != -1)  (dp[i] += dp[i-2]) %= INF;
	}
	cout << dp[n] << endl;
	return 0;
} 


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

const ll mod = 1e9+7;
//const ll mod = 998244353;

const int MAX = 510000;
const int MOD = 1000000007;

long long 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;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
	int n, k;
	cin >> n >> k;
	n -= k; // nが赤の数

	COMinit();
	ll ans = 0;
	for(int i = 1; i <= k; i++){
		ll ans = 0;
		ans = COM(n+1,i);
		// b1 + b2 + ... + bi = k;
		ans *= COM(k-1,i-1);
		ans %= mod;
		cout << ans << endl;
	} 
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int N; cin>>N;
  
  int h[N+1]; 
  for(int i=1;i<=N;++i){ cin >> h[i]; }

  int dp[N+1];
  FILL(dp,N+1,1e9+10);
  dp[1] = 0;

  for(int i=1;i+1<=N;++i){
    int temp = dp[i]+abs(h[i+1]-h[i]);
    chmin(dp[i+1],temp);
    if(i+2<=N) chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  }
  cout << dp[N] << "\n";
}

Measured memory_bytes: 4324
#include<stdio.h>
//小さい順にソート
int c[200002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,k,i,min=1000000000;
  scanf("%d%d",&n,&k);
  int h[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&h[i]);
  merge(0,n-1,h);
  for(i=0;i<=n-k;i++)
    if(h[i+k-1]-h[i]<min)
      min=h[i+k-1]-h[i];
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFLL = 1LL<<60;

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

  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  deque<ll> p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];

  sort(ALL(p), greater<ll>());
  sort(ALL(q), greater<ll>());
  sort(ALL(r));
  p.resize(x);
  q.resize(y);

  while (!r.empty()) {
    if (p.back() <= q.back() && p.back() < r.back()) {
      p.pop_back();
      p.push_front(r.back());
      r.pop_back();
    } else if (p.back() > q.back() && q.back() < r.back()) {
      q.pop_back();
      q.push_front(r.back());
      r.pop_back();
    } else {
      break;
    }
  }

  ll ans = SUM(p) + SUM(q);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        if (S.equals("A")) {
            System.out.println("T");
        } else if (S.equals("T")) {
            System.out.println("A");
        } else if (S.equals("C")) {
            System.out.println("G");
        } else if (S.equals("G")) {
            System.out.println("C");
        }

    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int n;
int a[200],b[200];
int main(){
	n=read();
	for (int i=1;i<=n;i++)a[i]=read(); 
	int sum=0;
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			for (int k=j+1;k<=n;k++){
				if (a[i]==a[j] or a[j]==a[k] or a[i]==a[k])continue;
				b[0]=a[i],b[1]=a[j],b[2]=a[k];
				sort(b,b+3);
				if (b[1]+b[0]>b[2])
				sum++;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n){
    int a;
    cin >> a;
    while (a % 2 == 0){
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}



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

using namespace std;

int main(){
    uint64_t N,K;
    cin >> N >> K;


    uint64_t sumNum=0;
    uint64_t tempNum;

    tempNum = ((N-K+2)*( K*(N+1) +(N+1)*(N+1)))/2;
    sumNum = tempNum;

    sumNum += N - K +2;

    tempNum = ((N+1)*(N+2)*(2* N+3)/6) -( (K-1)*K*(2*K-1)/6);
    sumNum -= tempNum ;

    sumNum = sumNum % (1000000000 + 7);

    cout<< sumNum <<std::endl;
}



Measured memory_bytes: 3628