akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) istr >> v[i]; return istr; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()

class DisjointSet {
private:
	vector<unsigned> par;
	vector<unsigned> rank;
	vector<unsigned> sz;	// 要素の個数
	size_t set_sz;			// 集合の個数

public:

	DisjointSet() : set_sz(0) { }

	DisjointSet(size_t n) :
		par(n), rank(n, 0), sz(n, 1), set_sz(n) {
		for (size_t i = 0; i < n; i++) par[i] = i;
	}

	size_t set_size() { return set_sz; }
	size_t size(size_t v) { return sz[find(v)]; }

	void makeset() {
		par.push_back(par.size());
		rank.push_back(0);
		sz.push_back(1);
		set_sz++;
	}
	void makeset(size_t n) {
		for (size_t i = 0; i < n; i++) makeset();
	}

	size_t find(size_t x) {
		if (par[x] == x)
			return x;
		else
			return par[x] = find(par[x]);
	}

	void unite(size_t x, size_t y) {
		x = find(x);
		y = find(y);
		if (x == y) return;

		if (rank[x] < rank[y])
			par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
		sz[x] += sz[y];
		sz[y] = sz[x];
		set_sz--;
	}

	bool same(size_t x, size_t y) {
		return find(x) == find(y);
	}
};

int main()
{
	//clock_t start, end;
	//start = clock();

	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<ll> a(N);
	cin >> a;

	DisjointSet ds(N);

	REP(i, M) {
		int x, y;
		cin >> x >> y;

		ds.unite(x, y);
	}

	typedef priority_queue<ll, vector<ll>, greater<ll>> PQ;

	map<int, PQ> mp;
	REP(i, N) mp[ds.find(i)].push(a[i]);

	auto comp = [](PQ& a, PQ& b) {
		if (a.size() == 0 || b.size() == 0) return a.size() < b.size();
		if (a.size() == 1 || b.size() == 1) {
			if (a.size() == 1 && b.size() == 1) return a.top() > b.top();
			else return a.size() < b.size();
		}
		else {
			ll a1, a2, b1, b2;
			a1 = a.top(); a.pop();
			a2 = a.top();
			b1 = b.top(); b.pop();
			b2 = b.top();
			a.push(a1); b.push(b1);
			return a2 > b2;
		}
	};

	priority_queue<PQ, vector<PQ>, decltype(comp)> pq(comp);

	for (const auto& e : mp) pq.push(e.second);

	ll ans = 0;
	while (pq.size() != 1) {
		PQ v1 = pq.top(); pq.pop();
		PQ v2 = pq.top(); pq.pop();
		if (v1.empty() || v2.empty()) {
			cout << "Impossible" << endl;
			return 0;
		}

		ans += v1.top() + v2.top(); v1.pop(); v2.pop();

		if (v1.size() >= v2.size()) {
			while (!v2.empty()) {
				v1.push(v2.top()); v2.pop();
			}
			pq.push(v1);
		}
		else {
			while (!v1.empty()) {
				v2.push(v1.top()); v1.pop();
			}
			pq.push(v2);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 21236
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

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

typedef long long ll;
const int MOD=1e9+7;
int xy[2][2]={2,2,1,3};
char str1[55],str2[55];
int main ()
{
    int i,n;
    ll ans;
    bool type;
    scanf ("%d",&n);
    scanf ("%s%s",str1,str2);
    if (str1[0]==str2[0]) {
        type=0;
        ans=3;
        i=1;
    }
    else {
        type=1;
        ans=6;
        i=2;
    }
    while (i<n) {
        if (str1[i]==str2[i]) {
            ans=(ans*xy[type][0])%MOD;
            i+=1;
            type=0;
        }
        else {
            ans=(ans*xy[type][1])%MOD;
            i+=2;
            type=1;
        }
    }
    printf ("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){

  ll A, B;
  cin >> A;
  cin >> B;

  // make sure A < B because A != B
  if (A > B) {
    ll temp = A;
    A = B;
    B = temp;
  }

  if ( ((A + B) % 2) == 1 )
    cout << "IMPOSSIBLE" << endl;
  else
    cout << ((ll)(A + B) / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
const int N = (int) 100 + 10;
const int V = (int) 1e3 + 10;
const ll oo = 1e18;
 
int n, w;
pair<int, int> items[N];
ll memo[N][N * V];
 
ll dp(int at, int value) {
    if(value < 0) return oo;
    if(at == n) return value == 0 ? 0 : oo;
    ll &ans = memo[at][value];
    if(ans != -1) return ans;
    ll choose = items[at].first + dp(at + 1, value - items[at].second);
    ll skip = dp(at + 1, value);
    return ans = min(choose, skip);
}
 
void solve() {
    cin >> n >> w;
    for(int i = 0; i < n; ++i) {
        cin >> items[i].first >> items[i].second;
    }
    memset(memo, -1, sizeof(memo));
    ll ans = -oo;
    for(ll value = 0; value < N * V; ++value) {
        if(dp(0, value) <= w) {
            ans = max(ans, value);
        }
    }
    cout << ans << endl;
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

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

int main()
{
    std::string s,t;
    std::cin>>s>>t;
    std::unordered_map<char,char> um1,um2;
    bool flag = true;
    for(int i=0;i<(int)s.size();i++){
        um1[s[i]] = t[i];
        um2[t[i]] = s[i];

    }
    for(int i=0;i<(int)s.size();i++){
        if(um1[s[i]] != t[i])flag = false;
        if(um2[t[i]] != s[i])flag = false;
    }
    std::cout<<(flag ? "Yes" : "No")<<std::endl;

}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
 
#define N (int)1e3+5
#define f1 first
#define s2 second
#define INF 9999999
#define pb push_back
#define ll long long
#define mod (int)1e9+7
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

string str;

int main(){
	//fri("in.txt");
//	fro("out.txt")
	cin>>str;
	if(str=="SUN"){
		cout<<7<<endl;
	}
	if(str=="SAT"){
		cout<<1<<endl;
	}
	if(str=="MON"){
		cout<<6<<endl;
	}
	if(str=="TUE"){
		cout<<5<<endl;
	}
	if(str=="WED"){
		cout<<4<<endl;
	}
	if(str=="THU"){
		cout<<3<<endl;
	}
	if(str=="FRI"){
		cout<<2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[True]*(n+1)
for i in range(m):
    a[int(input())]=False

mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
for now in range(n):
    for next in range(now+1,min(n,now+2)+1):
        if a[next]:
            dp[next]+=dp[now]
            dp[next]=dp[next]%mod

print(dp[n])


Measured memory_bytes: 7700
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int ans[1001];

int main(){
  int n;
  for(int i=1; i<1001; i++){
    int tmp = 1;
    int s=1, e=2;
    while(s < e){
      if(tmp == i){
        ans[i]++;
        tmp += e++;
      }else if(tmp < i) tmp += e++;
      else tmp -= s++;
    }
  }
  while(n = getInt()) print(ans[n] - 1);
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<long long int> que;
    for(int i = 0; i < N; i++){
        long long int A;
        cin >> A;
        que.push(A);
    }
    for(int i = 0; i < M; i++){
        long long int num = que.top();
        que.pop();
        que.push(num / 2);
    }
    long long int ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
/*input
15 1 3 15 13
...#.#...#.#...
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

string s;

bool go(int l,int r){
	char c=s[l];
	s[l]='.';
	while(l!=r){
		if(s[l+1]!='.'){
			if(s[l+2]!='.') return 0;
			else l+=2;
		}
		else l++;
	}
	s[r]='c';
	return 1;
}

int main(){
	IOS;
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	cin>>s;
	REP(i,10) s.push_back('#');
	a--;b--;c--;d--;
	s[a]='A';
	s[b]='B';

	if(c<d){
		if(go(b,d)&&go(a,c)){
			cout<<"Yes\n";
		}
		else cout<<"No\n";
	}
	else{
		s[b]='.';
		while(s[b-1]=='#'||s[b+1]=='#'){
			if(s[b+1]=='#'){
				if(s[b+2]=='#'){
					cout<<"No\n";
					return 0;
				}
				b+=2;
			}
			else b++;
		}
		if(b>d){
			cout<<"No\n";
			return 0;
		}
		s[b]='B';
		if(go(a,c)&&go(b,d)){
			cout<<"Yes\n";
		}
		else cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 200004;
const int MOD =998244353
 ;
const int INV2 = (MOD+1)/2;
int k,x,y;


     signed main(){
          int n;
          cin>>n;
         int s[n];
         for(int i=0;i<n;i++)cin>>s[i];
         bool k[10001]={};
         k[0]=true;
         for(int i=0;i<n;i++){
              for(int j=10000;j>=s[i];j--){
                   k[j]|=k[j-s[i]];
              }
         }
         for(int i=10000;i>=0;i--)if(i%10&&k[i]){
              cout<<i<<endl;
              return 0;
         }
         cout<<0<<endl;
         return 0;

        





}


        


Measured memory_bytes: 256
#!/usr/bin/env python3


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * n

    def sum(self, i):
        s = 0
        i -= 1
        while i >= 0:
            s += self.tree[i]
            i = (i & (i + 1)) - 1
        return s

    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i |= i + 1


def solve(n, a):

    ans = 0

    s = []
    r = 0
    for i in range(n):
        r += a[i]
        s.append((r, i))
        if 0 <= r:
            ans += 1

    s.sort()

    bit = Bit(n)
    for tpl in s:
        _, i = tpl
        ans += bit.sum(i)
        bit.add(i, 1)

    return ans


def main():
    n, k = input().split()
    n = int(n)
    k = int(k)
    a = []
    for _ in range(n):
        ai = input()
        ai = int(ai) - k
        a.append(ai)

    print(solve(n, a))


if __name__ == '__main__':
    main()



Measured memory_bytes: 40956
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll K, N = 50;
    cin >> K;
    cout << N << endl;
    ll base = K / N;
    REP(i, N) {
        if (i < K % N) cout << N + base - i << " ";
        else           cout << N + base - i - 1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("First");}else{puts("Second");}
const int MX = 200005;

int dp[MX];

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  vi a(n);
  cin>>a;
  rrep(i,m) {
    for (int j : a) {
      if (i-j >= 0) dp[i] |= !dp[i-j];
    }
  }
  if (dp[m]) yn;
  return 0;
}






















Measured memory_bytes: 640
n = int(input())
l = list(map(int,input().split()))
l2 = [2*l[i] for i in range(n)]
su = 0
for i in l2:
  su -= i
  su *= -1
#print(su)

l_answer = []
a = int(su//2)
s = 0
cou = 1
for i in l2:
  s -= i
  s *= -1
  l_answer.append(s+a*(-1)**cou)
  cou += 1
print(*([l_answer[-1]]+l_answer[:-1]))

Measured memory_bytes: 18376
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;




int main() {
	ll h, w;
	cin >> h>> w;
	vector<vector<ll>> li_w(h, vector<ll>(w,0));
	vector<vector<ll>> li_h(h, vector<ll>(w,0));
	vector<vector<char>> v(h, vector<char>(w));
	rep(i, h)
		rep(j, w)
		cin >> v[i][j];
	ll k = 0;
	vector<vector<ll>> l(0,vector<ll>(0));
	rep(i,h)
		rep(j, w) {
		if (v[i][j] == '.') {
			l.push_back({ i,j });
			k += 1;
		}
		if (v[i][j] == '#' || j == w - 1) {
			for (auto a : l) {
				//cout<< k << "a0:" << a[0] << " a1:" << a[1] << endl;
				li_w[a[0]][a[1]] = k;
			}
			k = 0;
			l.resize(0);
		}
	}
	rep(j, w)
		rep(i, h) {
		if (v[i][j] == '.') {
			l.push_back({ i,j });
			k += 1;
		}
		if (v[i][j] == '#' || i == h - 1) {
			for (auto a : l) {
				li_h[a[0]][a[1]] = k;
			}
			k = 0;
			l.resize(0);
		}
	}
	ll ans = 0;
	rep(i,h)
		rep(j, w) {
		ans = max(ans, li_w[i][j] + li_h[i][j]-1);
	}
	cout << ans << endl;
}

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

int main(){
    string n;
    int a,b=0;
    cin >> n;
    a = stoi(n);
    for(int i=0;i<n.size();i++){
        b += n[i] - '0';
    }
    if(a%b==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

void insert(int key);
void inorder(Node );
void preorder(Node );
Node search(Node u,int k);
void delete(Node z);
void trans(Node,Node);
Node min(Node x);

int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    if(com[0] == 'f'){
      scanf("%d",&x);
      Node t = search(root,x);
      if ( t != NULL ) printf("yes\n");
      else printf("no\n");
    }
    if ( com[0] == 'd' ){
      scanf("%d", &x);
      delete(search(root, x));
    }
  }

  return 0;
}

void insert(int key)
{
  Node x,y,z;
  y = NULL;
  x = root;

  z = malloc(sizeof(struct node));
  z->key = key;
  z->right = NULL;
  z->left = NULL;

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

void inorder(Node u)
{

  if(u != NULL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u)
{
  if(u != NULL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

Node search(Node u,int k)
{
  if(u == NULL || k == u->key) return u;
  if(k < u->key) return search(u->left,k);
  else return search(u->right,k);
}

void delete(Node z)
{
  Node x;
  Node y;
  if(z->left == NULL) trans(z,z->right);
  else if(z->right == NULL) trans(z,z->left);
  else{
    y = min(z->right);
    if(y->parent != z){
      trans(y,y->right);
      y->right = z->right;
      y->right->parent = y;
    }
    trans(z,y);
    y->left = z->left;
    y->left->parent = y;
  }
}

void trans(Node u,Node v)
{
  if(u->parent == NULL) root = v;
  else if(u == u->parent->left) u->parent->left = v;
  else u->parent->right = v;
  if(v != NULL) v->parent = u->parent;
}

Node min(Node x)
{
  while(x->left != NULL){
    x = x->left;
  }
  return x;
}




Measured memory_bytes: 20488
#include <stdio.h>
int main(void)
{
	int m, n, i, d[51], total=0;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &d[i]);
	}
	
	for(i = 0; i < n; i++){
		
		//d[50]の初期化
		d[50] = 0;
		
		for(m = 1; m <= n - i - 1; m++){
			d[50] = d[50] + d[i] * d[i + m];
		}
		total = total + d[50];
	}
	
	printf("%d", total);
	
	return 0;
}

Measured memory_bytes: 128
import random
import copy
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0
#greedyに最大とりまーす
#D=365
types=[(i%26)+1 for i in range(D)]
#print(l)
sc = [0] * D
last=[0]*26
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    # print(score,last)
    sc[i] = max(ans+10**6,0)
all = sum(sc)
for _ in range(4000):
    types2 = []
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,D+1))
    #print(l)
    #print(ind,types[ind]-1)
    l.pop(ind-1)
    ind2=random.choice(l)
    spans=ind//26
    types2=copy.deepcopy(types)
    buf=types[ind]
    types[ind]=types[ind2-1]
    types[ind2-1]=buf
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                # print(score,last)
        sc2[i] = max(ans+10**6,0)
    all2 = sum(sc2)
    if all2<=all:
        types=types2
    else:
        sc=sc2
        all=all2
        sc2=[]
        #print(114514)
    #print(all)
    #input()
for i in range(D):
    print(types[i])



Measured memory_bytes: 81992
import numpy as np

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n, k = map(int,input().split())
a = list(map(int,input().split()))

asum = sum(a)
adiv = make_divisors(asum)
adiv.reverse()

a = np.array(a)
ans = 1
flg = False
for i in adiv:
    a_ = np.sort(a % i)
    # print(i, a_)
    msum = a_.sum()
    msum_ = 0
    for j in range(-1, -n-1, -1):
        msum -= a_[j]
        msum_ += i - a_[j]
        if msum_ > k:
            break
        if msum < msum_:
            break
        if msum == msum_ :
            ans = i
            flg = True
            break
    if flg:
        break

print(ans)

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

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

  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    int a = min(A[i], B[i]);
    ans += a, A[i] -= a, B[i] -= a;
    int b = min(A[i + 1], B[i]);
    ans += b, A[i + 1] -= b, B[i] -= b;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

signed main(){

    int A, B;
    cin >> A >> B;
    vector<int> a(3);
    a[0] = A + B;
    a[1] = A - B;
    a[2] = A * B;
    sort(a.begin(), a.end());
    cout << a[2];

    return 0;
}

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

int main(){
    int N, count;
    cin >> N;
    count = 0;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < i; j++){
            for(int k = 0; k < j; k++){
                if((abs(vec.at(i) - vec.at(j)) < vec.at(k) && vec.at(k) < vec.at(i) + vec.at(j)) && vec.at(i) != vec.at(j) && vec.at(j) != vec.at(k)&& vec.at(k) != vec.at(i))
                count++;
        }
      
     }
       
	}
  cout << count << endl;
}

Measured memory_bytes: 3528
#include <map>
#include <cstdio>
#include <algorithm>

int T,top;
long long n,a,b,c,d;
struct point{
	long long v;
	unsigned long long c2,c3,c5;
}se[1000001];
long long Abs(long long x){
	return (x>0)?x:-x;
}
std::map<long long,unsigned long long>map;
long long g[1000001];
unsigned long long f(long long n){
//	printf("%lld\n",n);
	if(n==1)return d;
	if(n==2)return std::min(d<<1,d+a);
	if(n==3)return std::min(std::min(d*3,d+b),d+a+d);
//	if(n==4)return std::min(d*4,std::min(std::min(d+d+a,d+a+a),std::min()));
	if(map.count(n))return map[n];
	unsigned long long ans=-1;
	for(long long i=n-4;i<=n+4;i++){
		if(i<=0)continue;
		if(i%2==0&&(i>>1)<n)ans=std::min(ans,f(i>>1)+1ull*a+1ull*d*Abs(n-i));
		if(i%3==0&&(i/3)<n)ans=std::min(ans,f(i/3)+1ull*b+1ull*d*Abs(n-i));
		if(i%5==0&&(i/5)<n)ans=std::min(ans,f(i/5)+1ull*c+1ull*d*Abs(n-i));
	}
	if((ans/d)>n)ans=n*d;//	printf("%lld %llu\n",n,ans);
	return map[n]=ans;
}
int main(){
	scanf("%d",&T);
//	for(long long i=0,j=1;j<=1e18;i++,j*=2)
//		for(long long i1=0,j1=1;j*j1<=1e18;i1++,j1*=3)
//			for(long long i2=0,j2=1;j*j1*j2<=1e18;i2++,j2*=5)
//				se[++top]=(point){j*j1*j2,i,i1,i2};
	for(int fd=1;fd<=T;fd++){
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
//		g[1]=1;
//		for(int i=1;i<=30;i++)g[i]=1e18;
		map.clear();
//		unsigned long long ans=-1;
		printf("%llu\n",f(n));
	}
	
} 

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

int main(){
  string S;
  cin >> S;
  
  if(S == "Sunny") cout << "Cloudy" << endl;
  if(S == "Cloudy") cout << "Rainy" << endl;
  if(S == "Rainy") cout << "Sunny" << endl;
  
  return 0;
}

Measured memory_bytes: 256
(defun the-number-of-even-pairs ()
  (let ((n (read))
        (m (read))
        (ans 0))
    (if (/= 0 n)
        (setf ans (/ (* n (1- n)) 2)))
    (if (/= 0 m)
        (setf ans (+ ans (/ (* m (1- m)) 2))))
    ans))

(format t "~d~%" (the-number-of-even-pairs))


Measured memory_bytes: 11240
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;

  cin >> n;

  string ans;

  int s = 1;

  for(int i=0;n;i++){
    if(!!(n%2)) {
      ans = "1" + ans;
      n -= s;
    } else {
      ans = "0" + ans;
    }

    s *= -1;
    n /= 2;
  }

  if(!ans.size()) ans = "0";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n = int(input())
#a = [int(i) for i in read().split()]

n,m = [int(i) for i in readline().split()]
h = [int(i) for i in readline().split()]

res = [1]*n
for _ in range(m):
    a,b = [int(i)-1 for i in readline().split()]
    if h[a] >= h[b]:
        res[b] = 0
    if h[a] <= h[b]:
        res[a] = 0
    
    
print(res.count(1))


Measured memory_bytes: 20256
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = ReadLine().Split(' ').Select(value => decimal.Parse(value)).ToArray();
			WriteLine((long)(line[0] * line[1]));
		}
	}
}


Measured memory_bytes: 19244
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

//https://beta.atcoder.jp/contests/abc045/tasks/abc045_b 

int main() {

    string sa; cin >> sa;
    string sb; cin >> sb;
    string sc; cin >> sc;

    deque<char> vca(sa.begin(), sa.end());
    deque<char> vcb(sb.begin(), sb.end());
    deque<char> vcc(sc.begin(), sc.end());

    char current = vca.front();
    vca.pop_front();

    while(true) {
        if (current == 'a') {
            if (vca.empty()) {
                cout << "A" << "\n";
                return 0;
            }
            current = vca.front();
            vca.pop_front();
        }
        if (current == 'b') {
            if (vcb.empty()) {
                cout << "B" << "\n";
                return 0;
            }
            current = vcb.front();
            vcb.pop_front();
        }
        if (current == 'c') {
            if (vcc.empty()) {
                cout << "C" << "\n";
                return 0;
            }
            current = vcc.front();
            vcc.pop_front();
        }
    }

    return 0;
}


Measured memory_bytes: 256
s = str(input())
sl = list(s)
ans = 0
del sl[-1]
for i in range(1,len(sl)):
  if(len(sl)%2==0):
    if(sl[:len(sl)//2]==sl[len(sl)//2:]):
      ans = len(sl)
      break
  del sl[-1] 
print(ans)
  



Measured memory_bytes: 8920
N = int(input())
A = [[int(a) for a in input().split()] for _ in range(N)]
X = [0] * (1<<N)
for s in range(1, 1<<N):
    t = s & (s-1)
    ma = sum([sum([A[i][j] for j in range(i) if 1 << j & s]) for i in range(N) if 1 << i & s])
    while t:
        ma = max(ma, X[t] + X[s^t])
        t = (t-1) & s
    X[s] = ma
    ss = s & (s-1)
print(X[-1])

Measured memory_bytes: 47072
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<0 && 0<b)printf("Zero");
    else if(a==0 || b==0) printf("Zero");
    else if(a>0)printf("Positive");
    else if((b-a)%2==0) printf("Negative");
    else printf("Positive");
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
using namespace std;

int dp[1001][1001];
int main(){
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()<s2.size()) swap(s1,s2);
    rep(i,s1.size())rep(j,s2.size()) dp[i][j]=1000100010;
    FOR(i,0,s1.size()+1) dp[i][0]=i;
    FOR(i,0,s2.size()+1) dp[0][i]=i;
    FOR(i,1,s1.size()+1){
        FOR(j,1,s2.size()+1){
            if(s1[i-1]==s2[j-1]) dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j]+1,dp[i][j-1]+1));
            else dp[i][j]=min(dp[i-1][j-1]+1,min(dp[i-1][j]+1,dp[i][j-1]+1));
        }
    }
    cout<<dp[s1.size()][s2.size()]<<endl;
    return 0;
}

Measured memory_bytes: 7060
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES
#define X first
#define Y second
#define INF 1987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
char s[1001];
int main() {
	scanf("%s", s);
	int chk[4] = { 0 };
	int n = strlen(s);
	fup(i, 0, n - 1, 1)
	{
		if (s[i] == 'E')chk[0] = 1;
		if (s[i] == 'W')chk[1] = 1;
		if (s[i] == 'N')chk[2] = 1;
		if (s[i] == 'S')chk[3] = 1;
	}
	if (chk[0] + chk[1] == 1 || chk[2] + chk[3] == 1)puts("No");
	else puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define pb(v) push_back(v)
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using P = pair<int ,int>;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;

int gcd_(int a, int b){
	if (a%b == 0) return(b);
	else return(gcd_(b, a%b));
}

int gcd(int a, int b, int c) {
    return gcd_(gcd_(a, b), c);
}

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

    int k; cin >> k;
    ll ans = 0;
    FOR(i, 1, k+1) FOR(j, 1, k+1) FOR(l, 1, k+1) {
        ans += gcd(i, j, l);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	var cnt int
	fmt.Scan(&n, &x)

	m := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&m[i])
		x -= m[i]
		cnt++
	}
	sort.Ints(m)

	fmt.Println((x / m[0]) + cnt)
}

Measured memory_bytes: 512
/*
g++ -std=c++11 -o2 -Wall Educational_DP_E.cpp -o .\out\Educational_DP_E.out
.\out\Educational_DP_E.out
*/

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

typedef long long ll;

constexpr ll INF = 1e15;

ll dp[105][100005];

int w[105];
int v[105];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, W;
  cin >> n >> W;
  for (int i = 0; i < n; ++i) {
    cin >> w[i] >> v[i];
  }
  for (int i = 0; i < 105; ++i) {
    for (int j = 0; j < 100005; ++j) {
      dp[i][j] = INF;
    }
  }
  for (int i = 0; i < 105; ++i) {
    dp[i][0] = 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 100005; ++j) {
      if (j >= v[i]) {
        dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
      } else {
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  int ans = 0;
  for (int j = 0; j < 100005; ++j) {
    if (dp[n][j] <= W) {
      ans = j;
    }
  }
  cout << ans << "\n";
}


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

string inp;
char buff[6];

int main(){
    std::cin >> inp;
    inp.copy(buff, 6);
    
    if(buff[2]==buff[3]&&buff[4]==buff[5]){
        std::cout << "Yes";
    }else{
        std::cout << "No";
    }
}

Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod7=1000000007LL;
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add(LL _x, LL _y, LL _mod=mod7){
  _x+=_y;
  return _x>=_mod ? _x-_mod : _x;
}
inline LL sub(LL _x, LL _y, LL _mod=mod7){
  _x-=_y;
  return _x<0 ? _x+_mod : _x;
}
inline LL mul(LL _x, LL _y ,LL _mod=mod7){
  _x*=_y;
  return _x>=_mod ? _x%_mod : _x;
}
LL mypow(LL _a, LL _x, LL _mod){
  if(_x == 0) return 1LL;
  LL _ret = mypow(mul(_a, _a, _mod), _x>>1, _mod);
  if(_x & 1) _ret=mul(_ret, _a, _mod);
  return _ret;
}
LL mymul(LL _a, LL _x, LL _mod){
  if(_x == 0) return 0LL;
  LL _ret = mymul(add(_a, _a, _mod), _x>>1, _mod);
  if(_x & 1) _ret=add(_ret, _a, _mod);
  return _ret;
}
void sleep(double sec = 1021){
  clock_t s = clock();
  while(clock() - s < CLOCKS_PER_SEC * sec);
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
const int N=202020;
void build(){

}
int n, p[N], a[N];
void init(){
  n=getint();
  for(int i=1; i<=n; i++)
    p[i]=getint();
}
void solve(){
  int mx=1;
  for(int i=1; i<=n; i++){
    a[p[i]]=a[p[i]-1]+1;
    mx=max(mx,a[p[i]]);
  }
  printf("%d\n", n-mx);
}
int main(){
  build();
  //__ = getint();
  while(__ --){
    init();
    solve();
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxi 300005
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
#define gc getchar
#define REP(i,j,n)               for( i=j;i<n;i++)
#define PER(i,j,n)               for( i=n-1;i>=j;i--)
ll mpow(ll a, ll n,ll mod){
	ll ret=1;ll b=a;
	while(n) {
		if(n&1)
			ret=(ret*b)%mod;
		b=(b*b)%mod;
		n>>=1;
	}
	return (ll)ret;
}
ll gcd(ll a, ll b)
{
    if (a == 0 || b == 0)
       return 0;
    if (a == b)
        return a;
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
inline void read(int &x){
	x=0;
	register char c=gc();
	for(;c<'0' || c>'9';c=gc());
	for(;c>='0' && c<='9';c=gc())
		x=(x<<3)+(x<<1)+(c-'0');
}
inline void write(int x){
	register char buffor[35];
	register int i=0;
	do{
		buffor[i++]=(x%10)+'0';
		x/=10;
	} while(x);
	i--;
	while(i>=0) putchar(buffor[i--]);
	putchar('\n');
}
inline int in() { int x; read(x); return x; }
void solve();
int dbg=1;
using namespace std;
int main(){
	int t=1;
	//read(t);
	for(int i=0;i<t;i++){
		//printf("Case #%d:\n",i);
		solve();
	}
	return 0;
}
void solve() {
	ll n,i,j,k,m,a[100005]={0},dp[100005],mod=1000000007;
	cin>>n>>m;
	REP(i,0,m){
		cin>>j;
		a[j]=1;
	}
	dp[0]=1;
	if(a[1]!=1)
		dp[1]=1;
	else
		dp[1]=0;
	REP(i,2,n+1)
		if(!a[i])
			dp[i]=(dp[i-1]+dp[i-2])%mod;
		else
			dp[i]=0;
	cout<<dp[n]<<endl;
}



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

int main(){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long ans = max(max(a*c,a*d),max(b*c,b*d));
    cout << ans << endl;
}

Measured memory_bytes: 3640
def main():
    _, _, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    xyc = [tuple(map(int, input().split())) for _ in range(M)]

    ans = min(a[x - 1] + b[y - 1] - c for x, y, c in xyc)
    ans = min(ans, min(a) + min(b))

    print(ans)


main()



Measured memory_bytes: 29032
#include<stdio.h>

int DP[50];

int Fid(int n){
  if(n == 0 || n == 1)
    return DP[n]=1;
  if(DP[n] != -1)
    return DP[n];

  return DP[n]=Fid(n-1)+Fid(n-2);
}

int main(){
  int n, i;

  for(i=0; i<50; i++)
    DP[i]=-1;

  scanf("%d", &n);
  printf("%d\n", Fid(n));

return 0;
}



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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#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())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

using namespace std;

template <class T> int find_index(T x, const std::vector<T> &v) {
    auto it = std::find(v.begin(), v.end(), x);
    if (it != v.end()) { return (int)std::distance(v.begin(), it); }
    return -1;
}
template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }

template <class T> void print(T x) {
    std::cout << x << std::endl;
}
// 4近傍（右, 下, 左, 上）
const vector<int> dy = { 0, -1, 0, 1 };
const vector<int> dx = { 1, 0, -1, 0 };

int count(LL y1, LL y2, LL x1, LL x2, vector<long long> &x, vector<long long> &y) {
    if (y1 > y2) {
        swap(y1, y2);
    }
    if (x1 > x2) {
        swap(x1, x2);
    }
    int num = 0;
    FOR(i, 0, y.size()) {
        num += (y1 <= y[i] and y[i] <= y2) and (x1 <= x[i] and x[i] <= x2);
    }
    return num;
}

void solve(long long N, long long K, vector<long long> &x, vector<long long> &y){
    LL ans = LONG_LONG_MAX;

    FOR(y1, 0, y.size()) {
        FOR(y2, y1 + 1, y.size()) {
            FOR(x1, 0, x.size()) {
                FOR(x2, x1 + 1, x.size()) {
                    int num = count(y[y1], y[y2], x[x1], x[x2], x, y);
                    if (num >= K) {
                        ans = min<LL>(ans, abs(y[y1] - y[y2]) * abs(x[x1] - x[x2]));
                    }
                }
            }
        }
    }

    print(ans);
}

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

    long long K;
    long long N;
    scanf("%lld",&N);
    vector<long long> y(N-1+1);
    vector<long long> x(N-1+1);
    scanf("%lld",&K);
    for(int i = 0 ; i <= N-1 ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, K, x, y);
    return 0;
}

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

int main() {
    int X, Y;
    cin >> X >> Y;
    for(int c = 0; c <= X; ++c) {
        int t = X - c;
        if(c * 2 + t * 4 == Y) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int a[25],b[25],c[25];
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<n;i++){
        cin>>c[i];
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=b[a[i]];
        if(a[i+1]==a[i]+1){
            ans+=c[a[i]];
        }
    }
    cout<<ans;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    FOR(i, n) cin >> a[i];
    // 10 : 3 = 3 3 3 1
    // 9 : 3 = 3 3 3    2

    int l = 1, r = 1e9;
    int sol = 1e9;
    while(l<=r){
        ll m = (l+r)/2;
        ll need = 0;
        FOR(i, n){
            need += (a[i]+m-1) / m - 1;
        }
        if (need <= k){
            sol = m;
            r = m-1;
        }
        else{
            l = m+1;
        }
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 3968
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
from fractions import gcd
n = int(input())
# n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7


def lcm(x, y):
    return (x * y) // gcd(x, y)

l = 1
for i in range(n):
    l = lcm(l,a[i])

ans = 0
for i in range(n):
    ans += l // a[i]

ans %= mod
print(ans)

Measured memory_bytes: 6200
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, K;
  ci(N, K);
  int x, c = 0;
  rep(i, N){
    ci(x);
    c += min(abs(x), abs(K - x));
  }
  co(c * 2);
}

Measured memory_bytes: 256
// AOJ 2681 arentheses
// 2018.3.19 bal4u

#include <stdio.h>
#include <stdlib.h>

// 高速数値入出力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()  // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int N;
// 各文字列の最も深いレベル（先頭からみた場合）、高いレベル（末尾から見た場合）、左右括弧の数の差
int deep[105], high[105], phase[105]; //　解釈は上の行
int sz;   // 処理すべき文字列の数
char buf[105];  // 入力受付用

int main()
{
	int i, k, c, h, d, s, total;
	int left, right;   // 先頭、末尾からみた場合のphaseの合計
	char *p, *q;

	N = in(); sz = left = right = total = 0;
	while (N--) {
		p = buf; while ((c = gc()) > ' ') *p++ = c;

		// 文字列の先頭からみた場合の様子。右括弧の相対的な多さの最大値がd
		d = 200, s = 0;
		q = buf - 1; while (++q < p) {
			if (*q == '(') total++, s++;
			else if (--s < d) d = s;
		}
		deep[sz] = d, phase[sz] = s;

		// 後ろからみた場合の様子。左括弧の相対的な多さの最大値がh
		h = -200, s = 0;
		while (--p >= buf) {
			if (*p == ')') total--, s--;
			else if (++s > h) h = s;
		}
		high[sz] = h;

		if (d >= 0) left += s;   // 右括弧の数がどの位置で切っても左側（先頭から）の左括弧より少ない。例 (())(
		else if (h <= 0) right += s; // 左括弧の数がどの位置で切っても右側（末尾から）の右括弧より少ない。例 ())()
		else sz++;  // それ以外
	}
	if (total != 0) goto No;   // 左右括弧の数にずれがあり
	if (sz == 0) goto Yes;     // 未処理文字列がない

	k = s = 0;
	for (i = 0; i < sz; i++) {
		if (deep[i] + left >= 0 && phase[i] >= 0) left += phase[i], k++;
		else if (high[i] + right <= 0 && phase[i] <= 0) right += phase[i], k++;
		else s = deep[i];
	}
	if (k == sz || (k == sz - 1 && left + s >= 0)) {
Yes:	puts("Yes");
	}
	else {
No:		puts("No");
	}
	return 0;
}


Measured memory_bytes: 2112