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

int main(){
    int N;
    cin >> N;
    vector<string> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    vector<vector<int> > ans(N,vector<int>(26));
    rep(i,N){
        int len = vec[i].size();
        rep(j,len){
            ans[i][vec[i][j] - 'a']++;
        }
    }
    vector<int> ans_copy(26);
    rep(i,26){
        int minim = 51;
        rep(j,N){
            minim = min(ans[j][i], minim);
        }
        ans_copy[i] = minim;
    }
    string str_ans = "";
    rep(i,26){
        int len = ans_copy[i];
        rep(j,len){
            if (i == 0) str_ans += "a";
            if (i == 1) str_ans += "b";
            if (i == 2) str_ans += "c";
            if (i == 3) str_ans += "d";
            if (i == 4) str_ans += "e";
            if (i == 5) str_ans += "f";
            if (i == 6) str_ans += "g";
            if (i == 7) str_ans += "h";
            if (i == 8) str_ans += "i";
            if (i == 9) str_ans += "j";
            if (i == 10) str_ans += "k";
            if (i == 11) str_ans += "l";
            if (i == 12) str_ans += "m";
            if (i == 13) str_ans += "n";
            if (i == 14) str_ans += "o";
            if (i == 15) str_ans += "p";
            if (i == 16) str_ans += "q";
            if (i == 17) str_ans += "r";
            if (i == 18) str_ans += "s";
            if (i == 19) str_ans += "t";
            if (i == 20) str_ans += "u";
            if (i == 21) str_ans += "v";
            if (i == 22) str_ans += "w";
            if (i == 23) str_ans += "x";
            if (i == 24) str_ans += "y";
            if (i == 25) str_ans += "z";
        }
    }
    cout << str_ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int n=s.size();
    V<int> cs(26,0),ct(26,0);
    rep(i,n){
        cs[s[i]-'a']++;
        ct[t[i]-'a']++;
    }
    sort(all(cs));
    sort(all(ct));
    bool ok=1;
    rep(i,26){
        if(cs[i]!=ct[i]){
            ok=0;
        }
    }
    string ans="Yes";
    if(!ok) ans="No";
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 916
#include <stdio.h>

int main(void) {

int a,b;char s;
scanf("%d %c %d\n",&a,&s,&b);

while(s!='?'){

switch(s){
 case '+':
  printf("%d\n",a+b);
  break;
 case '/':
  printf("%d\n",a/b);
  break;
 case '*':
  printf("%d\n",a*b);
  break;
 case '-':
  printf("%d\n",a-b);
  break;
default:
break;
}

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

}


return 0;
}

Measured memory_bytes: 604
q = int(input())
A = []

for i in range(q):
    Q, *x = (int(x) for x in input().split())
    x = x[0] if x else None
    if Q == 0:
        A.append(x)
    elif Q == 1:
        print(A[x])
    else:
        del A[-1]




Measured memory_bytes: 13372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){


    int n,m,x;
    cin>>n>>m>>x;
    int mn=1000000000;
    int a[m];
    for(int i=0;i<m;i++)cin>>a[i];
    int i=0;
    int sum=0;
    while(i<x){
        bool ok=false;
        for(int j=0;j<m-1;j++){
            if(a[j]==i){
                i=a[j+1];
                sum++;
                ok=true;
                break;
            }
        }
        if(!ok){
            i++;
        }

    }
    mn=min(mn,sum);
    i=n;sum=0;
    while(i>x){
        bool ok=false;
        for(int j=m;j>0;j--){
            if(a[j]==i){
                i=a[j-1];
                sum++;
                ok=true;
                break;
            }
        }
        if(!ok){
            i--;
        }

    }
    mn=min(mn,sum);
    cout<<mn;
    return 0;
}


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

int main(void)
{
  int num;
  char *str1;
  char *str2;

  scanf("%d", &num);

  str1 = (char*)malloc(sizeof(char) * num);
  str2 = (char*)malloc(sizeof(char) * num);

  scanf("%s %s", str1, str2);

  for(int i = 0; i < num; i++){
    printf("%c", str1[i]);
    printf("%c" , str2[i]);
  }

  return 0;
}

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

int main() {
  int n, a,b,c;
  //string s;
  cin>>n>>a>>b;
  if(n*a<=b)
  {
    cout<<n*a<<endl;
  }
  else
  {
    cout<<b<<endl;
  }
  //cin>>s;
/*if(a-b ==0|| b-a==0)
{
  cout<<0<<endl;
}
else if((a+b)%2==0)
{
  cout<<(a+b)/2<<endl;
}

else
{
  cout<<"IMPOSSIBLE"<<endl;
}
  */
  //cout<<(a*a*3)<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int A[1001], B[1001];
int miniA[10000000], miniB[1000000];
bool in_A[10000000], in_B[10000000];
int canPut[10000000];	//canPut[i] はiを置けるマスの個数を表す

signed main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];

		if (in_A[A[i]]) {
			cout << "0\n";
			return 0;
		}

		in_A[A[i]] = true;
		miniA[A[i]]++;
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];

		if (in_B[B[i]]) {
			cout << "0\n";
			return 0;
		}

		in_B[B[i]] = true;
		miniB[B[i]]++;
	}

	for (int i = N*M; i > 0; i--) {
		miniA[i-1] += miniA[i];
		miniB[i-1] += miniB[i];
	}


	int put = 0, ans = 1;
	for (int i = N * M; i > 0; i--) {
		if (in_A[i] && in_B[i]) {
			ans *= 1;
		}
		else if (in_A[i]) {
			ans *= miniB[i];
			ans %= mod;
		}
		else if (in_B[i]) {
			ans *= miniA[i];
			ans %= mod;
		}
		else if (!in_A[i] && !in_B[i]) {
			ans *= ((miniA[i] * miniB[i] - put) % mod);
			ans %= mod;
		}
		put++;

	}
	cout << ans << "\n";

	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<pair<int, int>> P(N);
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    P[i] = make_pair(x, y);
  }
  vector<vector<double>> D(N, vector<double>(N, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      D[i][j] = sqrt((P[i].first - P[j].first) * (P[i].first - P[j].first) +
                     (P[i].second - P[j].second) * (P[i].second - P[j].second));
    }
  }
  vector<int> idx(N);
  iota(idx.begin(), idx.end(), 0);
  double res = 0;
  do {
    for (int i = 0; i < N - 1; i++) {
      res += D[idx[i]][idx[i + 1]];
    }
  } while (next_permutation(idx.begin(), idx.end()));
  for (int i = 1; i < N + 1; i++) {
    res /= i;
  }
  cout << fixed << setprecision(10) << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  int maxv=-INT_INF;
  int maxi;
  int minv=INT_INF;
  int mini;
  rep(i,n){
    if(chmax(maxv,a[i]))maxi=i+1;
    if(chmin(minv,a[i]))mini=i+1;
  }
  if(minv>=0){
    cout << n-1 << endl;
    rep(i,n-1)cout << i+1 << " " << i+2 << endl;
  }else if(maxv<=0){
    cout << n-1 << endl;
    rep(i,n-1)cout << n-i << " " << n-i-1 << endl;
  }else if(maxv>abs(minv)){
    cout << 2*n-1 << endl;
    rep(i,n)cout << maxi << " " << i+1 << endl;
    rep(i,n-1)cout << i+1 << " " << i+2 << endl;
  }else{
    cout << 2*n-1 << endl;
    rep(i,n)cout << mini << " " << i+1 << endl;
    rep(i,n-1)cout << n-i << " " << n-i-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//API???????????????
import java.util.Scanner;
import java.io.IOException;
class Main {
  	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();

		Node root = null;
		for(int i = 0;i < m;i++){
			String str = scan.next();
			if(str.equals("insert")){
				int temp = scan.nextInt();
				Node node = new Node(temp);
				if(root == null){
					root = node;
					continue;
				}
				insert(root, node);
			}else if(str.equals("print")){
				Print(root);
			}
		}
	}
	
	public static void insert(Node T, Node Z){
		Node parent = T;
		for(;;){
			if(Z.id < parent.id){
				if(parent.left == null){
					parent.left = Z;
					break;
				}
				parent = parent.left;
			}else{
				if(parent.right == null){
					parent.right = Z;
					break;
				}
				parent = parent.right;
			}
		}
	}
	
	public static void Print(Node root){
		StringBuilder sb = new StringBuilder();
		root.intermediateOrderCrawl(sb);
		System.out.println(sb.toString());
		sb = new StringBuilder();
		root.precedingOrderCrawl(sb);
		System.out.println(sb.toString());
	}
}

class Node{
	int id;
	Node parent;
	Node left;
	Node right;
	
	public Node(int id) {
		this.id = id;
	}
	
	public void intermediateOrderCrawl(StringBuilder sb){
		if(left != null) left.intermediateOrderCrawl(sb);
		sb.append(" " + String.valueOf(id));
		if(right != null) right.intermediateOrderCrawl(sb);
	}
	
	public void precedingOrderCrawl(StringBuilder sb){
		sb.append(" " + String.valueOf(id));
		if(left != null) left.precedingOrderCrawl(sb);
		if(right != null) right.precedingOrderCrawl(sb);
	}
}

Measured memory_bytes: 327268
def resolve():
    import sys
    
    readline = sys.stdin.readline    # 1行だけ文字列にする

    N = int(readline())

    # 赤，青点をx,y座標の2次元リストとして入力
    red = [list(map(int, readline().split())) for _ in [0] * N]
    blue = [list(map(int, readline().split())) for _ in [0] * N]

    # 赤はy座標で降順ソート，青はx座標で昇順ソート
    red.sort(key=lambda x: x[1], reverse=True)
    blue.sort()

    ans = 0
    for c, d in blue:
        for a, b in red:
            if a <= c and b <= d:
                ans += 1
                red.remove([a, b])
                break
    print(ans)


resolve()


Measured memory_bytes: 9200
#define ll long long
#define dd long double
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
//#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
dd pi = acos(-1) ;
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll fact[100] ;
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll e_gcd(ll a , ll b , ll &x , ll &y){ if(b > a) return e_gcd(b , a , y , x) ; if(b == 0){x = 1 ; y = 0 ; return a ;}
ll x1 , y1 ; e_gcd(b , a%b , x1 , y1) ; x = y1 ; y = (x1 - ((a/b) * y1)) ; return e_gcd(b , a%b , x1 , y1) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r|| (n < 0) || (r < 0)) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n
// ll seed;
//mt19937 rnd(seed=chrono::steady_clock::now().time_since_epoch().count()); // include bits


void solve()
{
    ll n ;
    cin >> n ;
    cout << 10 - (n/200) << '\n' ;
    return ;
}

int main()
{
    /*ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif*/
    
    ll t ;
    //cin >> t ;
    t = 1 ;
   
    while(t--)
    {
        solve() ;
    }
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
   int money,yen500,yen5;

   scanf("%d",&money);
                                                                                
   yen500=money/500;
   money-=500*yen500;
   yen5=money/5;

   printf("%d\n",yen500*1000+yen5*5);
}


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

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

p = 0
q = -1
list.sort(a,reverse= True)


for i in range(m):
  x = int(a[p]/2)
  a[p] = x
  if(q == -1):
    q = x

  if(p == n -1):
    q = -1
    p = 0
    list.sort(a,reverse=True)
  elif(a[p+1] < q):
    q = -1
    p = 0
    list.sort(a,reverse=True)
  else:
    p += 1


print(sum(a))

Measured memory_bytes: 63856
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void){
	int x,y,z;
	cin>>x>>y>>z;
	int a;
	a=0;
	while(x<=y){
		if(z%x==0){
			a++;
		}
		else{
		}
		x++;
	}
	cout<<a<<endl;
}

Measured memory_bytes: 1160
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int A[] = new int[3];
		for(int n=0;n<3;n++){
			A[n] = sc.nextInt();
		}
		int K = sc.nextInt();

		long v = 0;
		if(A[0] >= A[1] && A[0] >= A[2]){
			v += A[0] * Math.pow(2,K);
			v += A[1]+A[2];
		}
		else{
			if(A[1] >= A[0] && A[1] >= A[2]){
				v += A[1] * Math.pow(2,K);
				v += A[0]+A[2];
			}
			else{
				if(A[2] >= A[0] && A[2] >= A[1]){
					v += A[2] * Math.pow(2,K);
					v += A[1]+A[0];
				}
			}
		}
		

		System.out.println(v);
	}
}

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

int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

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


bool dp[100010];

int main(){
    int N,K; cin >> N >> K;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    memset(dp,0,sizeof(dp));
    for(int i=0; i <= K; i++){
        if(dp[i]) continue;
        rep(j,N){
            int x = a[j];
            if(i+x > K) continue;
            dp[i+x] = true;
        }
    }
    if(dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
typedef pair<pair<int,int>,int> triple;
#define trpl(i,j,k) make_pair(make_pair((i),(j)),(k))
#define X first.first
#define Y first.second
#define T second
const int OFFSET=60;
const int MAX_X=OFFSET*2+1;

bool obstacle[MAX_X][MAX_X];
bool checked[MAX_X][MAX_X];
int t,n,x,y;

int bfs(){
  int result=0;
  queue<triple> q;
  q.push(trpl(x,y,t));
  while(!q.empty()){
    triple tr=q.front();
    q.pop();
    if(obstacle[tr.X][tr.Y]||checked[tr.X][tr.Y])continue;
    checked[tr.X][tr.Y]=true;
    result++;
    if(tr.T>0){
      int d=tr.T-1;
      q.push(trpl(tr.X+1,tr.Y,d));
      q.push(trpl(tr.X+1,tr.Y+1,d));
      q.push(trpl(tr.X,tr.Y+1,d));
      q.push(trpl(tr.X-1,tr.Y,d));
      q.push(trpl(tr.X-1,tr.Y-1,d));
      q.push(trpl(tr.X,tr.Y-1,d));
    }
  }
  return result;
}

int main(){ _;
  int tx,ty;
  while(cin>>t>>n,(t|n)!=0){
    REP(i,MAX_X)REP(j,MAX_X)obstacle[i][j]=checked[i][j]=false;
    REP(i,n){
      cin>>tx>>ty;
      tx+=OFFSET;
      ty+=OFFSET;
      obstacle[tx][ty]=true;
    }
    cin>>x>>y;
    x+=OFFSET;
    y+=OFFSET;
    cout<<bfs()<<endl;
  }
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int a;
        cin >> a;
        a--;
        edges[a].emplace_back(i + 1);
    }
    function<int(int)> dfs = [&](int c) {
        if (edges[c].size() == 0)
            return 0;
        int maxd = 0;
        vector<int> ch;
        for (auto &v : edges[c]) {
            ch.push_back(dfs(v));
        }
        sort(ch.begin(), ch.end());
        int add = ch.size();
        for (int i = 0; i < (int)ch.size(); ++i) {
            chmax(maxd, ch[i] + add);
            add--;
        }
        return maxd;
    };
    cout << dfs(0) << endl;
    return 0;
}

Measured memory_bytes: 13568
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin>>N;
    int a;
    
    a = N/1000;
    int ans;
    ans = (a+1)*1000-N;
    if(N%1000 == 0)cout<<0<<endl;
    else{
    cout<<ans<<endl;
    }
  
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>

using namespace std;

int main(){
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx, dy = ty - sy;
	cout << string(dy, 'U') << string(dx, 'R') << string(dy, 'D') << string(dx, 'L');
	cout << "L" << string(dy + 1, 'U') << string(dx + 1, 'R') << "D";
	cout << "R" << string(dy + 1, 'D') << string(dx + 1, 'L') << "U" << endl;
	return 0;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;




int main() {

	int n, m;
	cin >> n >> m;
	map<int, int> a;
	VI same(m + 1, 0);
	VI b(m + 1, 0);


	REP(i, n) {
		int x;
		cin >> x;
		a[x]++;
		if (a[x] % 2 == 0) {
			same[x%m]++;
		}
		b[x%m]++;
	}

	int ans = b[0] / 2;

	for (int i = 1; i * 2 < m; i++) {

		int j = min(b[i], b[m - i]);
		ans += j;

		ans += min((b[i] - j) / 2, same[i]);
		ans += min((b[m - i] - j) / 2, same[m - i]);
	}

	if (m % 2 == 0) {
		ans += b[m / 2] / 2;
	}

	cout << ans << endl;




}



Measured memory_bytes: 5760
import math
import pprint
import fractions
import collections
import itertools
from decimal import *
from collections import deque
from bisect import *
N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(1,N):
    if A[i-1]>A[i]:
        cnt=cnt+(A[i-1]-A[i])
        A[i]=A[i-1]
print(cnt)



Measured memory_bytes: 97280
n, yen = [int(s) for s in input().split()]
yen //= 1000
for x in range(n + 1):
    p_x = 10 * x
    if p_x > yen:
        break
    for y in range(n + 1):
        p_x_y = p_x + 5 * y
        if p_x_y > yen:
            break
        z = n - x - y
        p_x_y_z = p_x_y + z
        if p_x_y_z == yen:
            print(x, y, z)
            exit()
print(-1, -1, -1)

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

int calc_point(int D, vector<int> c, vector<vector<int>> s, vector<int> t)
{
    int point = 0;
    vector<int> last(26);
    for (int i = 0; i < D; i++)
    {
        last.at(t.at(i) - 1) = i + 1;
        for (int j = 0; j < 26; j++)
        {
            point -= c.at(j) * (i + 1 - last.at(j));
        }

        point += s.at(i).at(t.at(i) - 1);
    }

    return point;
}

int main()
{
    clock_t start = clock();

    int D;
    cin >> D;

    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));

    for (int i = 0; i < 26; i++)
    {
        cin >> c.at(i);
    }

    for (int i = 0; i < D; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> s.at(i).at(j);
        }
    }

    vector<int> t(D);
    for (int i = 0; i < D; i++)
    {
        t.at(i) = rand() % 26 + 1;
    }

    int point = calc_point(D, c, s, t);

    int old = 0;
    int new_point = 0;

    clock_t end;

    double time;

    int d;
    int q;
    while (true)
    {
        d = rand() % D + 1;
        q = rand() % 26 + 1;
        old = t.at(d - 1);
        t.at(d - 1) = q;

        new_point = calc_point(D, c, s, t);
        if (point < new_point)
        {
            point = new_point;
        }
        else
        {
            t.at(d - 1) = old;
        }

        end = clock();
        time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;

        if (time > 1900)
        {
            break;
        }
    }

    for (int i = 0; i < D; i++)
    {
        cout << t.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 3704
#include<cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    for(int i = n - 1; i > 0; i--){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[0]);
    return 0;
}


Measured memory_bytes: 2756
using System;
using System.Collections.Generic;
using System.Linq;

namespace MaximumSum {
    class Program {
        static void Main(string[] args) {

            List<int> abc = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToList();
            int k = int.Parse(Console.ReadLine());

            int max = abc.Max();

            int peak = max;
            for(int i = 0; i < k; ++i) {
                peak *= 2;
            }

            int sum = abc.Sum() - max + peak;
            Console.WriteLine(sum);
        }
    }
}


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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String exp = sc.nextLine();
			if (exp.equals("#"))
				break;
			String[] clause = exp.split("\\|");
			for (int i = 0; i < clause.length; i++) {
				clause[i] = clause[i].replace("(", "");
				clause[i] = clause[i].replace(")", "");
			}
			// System.out.println(Arrays.toString(clause));
			boolean yes = false;
			for (int i = 0; i < clause.length; i++) {
				String[] tmp = clause[i].split("&");
				boolean flag = true;
				for (int j = 0; j < tmp.length; j++) {
					if (tmp[j].length() == 1) {
						for (int k = 0; k < tmp.length; k++) {
							if (k == j)
								continue;
							if (tmp[k].equals("~" + tmp[j])) {
								j = tmp.length;
								flag = false;
								break;
							}
						}
					}
				}
				if (flag) {
					yes = true;
					break;
				}
			}
			System.out.println(yes ? "yes" : "no");
		}
	}
}

Measured memory_bytes: 13000
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

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

//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	shuffle(permutation.begin(), permutation.end(), rng);

ll f (ll x) {
	return x * (x-1)/ 2ll;
}

int main () {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
		u[a[i]]++;
	}
	ll ans = 0;
	for (int i = 1; i <= n; i ++)
		ans += u[i] * (ll)(u[i] - 1)/ 2ll;
	for (int i = 1; i <= n; i ++) {
		ll res = ans - f(u[a[i]]);
		res += f(u[a[i]] - 1);
		printf("%lld\n", res);
	}
	return Accepted;
}

// B...a

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

using namespace std;

const long long INF = 1000000000000000000;
long long n;
int a, b, c, d;
map<long long, long long> memo;

long long rec(long long x) {
    if (x == 0) return 0;
    if (x == 1) return memo[1];
    if (memo.count(x)) return memo[x];
    long long res = INF;
    if (x <= (INF / d)) res = x * d;
    if (x % 5 == 0) {
        res = min(res, rec(x / 5) + c);
    } else if (x % 5 == 1) {
        res = min(res, rec(x / 5) + c + d);
    } else if (x % 5 == 2) {
        res = min(res, rec(x / 5) + c + d + d);
    } else if (x % 5 == 3) {
        res = min(res, rec((x / 5) + 1) + c + d + d);
    } else if (x % 5 == 4) {
        res = min(res, rec((x / 5) + 1) + c + d);
    }
    if (x % 3 == 0) {
        res = min(res, rec(x / 3) + b);
    } else if (x % 3 == 1) {
        res = min(res, rec(x / 3) + b + d);
    } else if (x % 3 == 2) {
        res = min(res, rec((x / 3) + 1) + b + d);
    }
    if (x % 2 == 0) {
        res = min(res, rec(x / 2) + a);
    } else if (x % 2 == 1) {
        res = min(res, rec(x / 2) + a + d);
        res = min(res, rec((x / 2) + 1) + a + d);
    }
    memo[x] = res;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        cin >> n;
        cin >> a >> b >> c >> d;
        memo.clear();
        memo[0] = 0;
        memo[1] = d;
        cout << rec(n) << '\n';
    }
    return 0;
}

Measured memory_bytes: 4380
import sys

n, *words = sys.stdin.read().split()
n = int(n)

def main():
    announced = set()
    last = words[0][0]
    for w in words:
        if w in announced:
            return 'No'
        elif w[0] != last:
            return 'No'
        announced.add(w)
        last = w[-1]
    return 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

using namespace std;

typedef long long int lli;

int main () {
    int N, M;
    cin >> N >> M;
    vector<int> x(N, 0);
    REP (i, 0, M) {
        int a, b;
        cin >> a >> b;
        x[a - 1]++;
        x[b - 1]++;
    }
    REP (i, 0, x.size()) {
        cout << x[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	String s;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		s = sc.next();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if ((i%2)==0) {
				if (c != 'R' && c != 'U' && c != 'D') {
					System.out.println("No");
					return;
				}
			} else {
				if (c != 'L' && c != 'U' && c != 'D') {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int q[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	long long a,b,k;
	cin>>a>>b>>k;
	if(a>=k)cout<<a-k<<" "<<b;
	else if(b>=k-a)
	{

		cout<<"0 "<<b-(k-a);
	}
	else cout<<"0 0";

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

	const int N = (int)1e6;
	vi isP(N, true);
    isP[0] = isP[1] = false;
	for(int i = 2; i * i < N; i++) if(isP[i]) for(int j = i; i * j < N; j++) isP[i * j] = false;

    int X; cin >> X;

    while(not isP[X]) X++;

    cout << X << endl;

    return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int mx=123456;
#define ll long long
#define p push_back
#define ff first
#define ss second
ll n ,s[mx],sum;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        sum+=s[i];
        sum--;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
	#include<algorithm>
	#define ll unsigned long long int
	
	using namespace std;
	
	main()
	{
		ll n,k;
		cin>>n;
		ll a[n];
		for(ll i=0;i<n;i++)
			cin>>a[i];
			
		ll ans=1000;
		
		for(ll i=0;i<n;i++)
		{
			ll j=i;
			while(j+1<n && a[j]<a[j+1])
				j++;
			if(j==i)
				continue;
			ll stock = ans/a[i];
			ans = ans - stock*a[i];
			ans = ans+stock*a[j];
			if(i!=j-1)
				i=j-1;
//				cout<<i<<" "<<j<<endl;
		}	
		cout<<ans<<endl;
	}

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

template<typename T, typename E, typename F, typename G, typename H>
class LazySegmentTree {
  int n, height;
  F f; G g; H h; const T ti; const E ei;
  vector<T> dat; vector<E> laz; vector<int> highest;

  void propagate(int k) {
    if(laz[k] != ei) {
      laz[2*k] = h(laz[2*k],laz[k]); laz[2*k+1] = h(laz[2*k+1],laz[k]);
      dat[k] = g(dat[k],laz[k],n/highest[k]);
      laz[k] = ei;
    }
  }
  inline void recalc(int k) {
    while(k >>= 1) dat[k] = f(g(dat[2*k],laz[2*k],n/highest[2*k]),g(dat[2*k+1],laz[2*k+1],n/highest[2*k+1]));
  }
  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }
public:
  LazySegmentTree(int _n, F f, G g, H h, T ti, E ei): f(f), g(g), h(h), ti(ti), ei(ei) {
    n = 1; height = 0;
    while(n < _n) n <<= 1, height++;
    dat.assign(2*n,ti); laz.assign(2*n,ei); highest.assign(2*n,0);
    int c = 1;
    for(int i = 1; i < 2*n; i++) {
      if(c*2 <= i) c <<= 1;
      highest[i] = c;
    }
  }
  void set(int k, T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int a, int b, const E x) {
    thrust(a += n); thrust(b += n-1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l],x), ++l;
      if(r & 1) --r, laz[r] = h(laz[r],x);
    }
    recalc(a); recalc(b);
  }
  T query(int a, int b) {
    thrust(a += n); thrust(b += n-1);
    T l = ti, r = ti; b++;
    while(a < b) {
      if(a & 1) l = f(l,g(dat[a],laz[a],n/highest[a])), a++;
      if(b & 1) b--, r = f(g(dat[b],laz[b],n/highest[b]),r);
      a >>= 1; b >>= 1;
    }
    return f(l,r);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  auto f = [](ll a, ll b) {return a+b;};
  auto g = [](ll a, ll b, int l) {return a+b*l;};
  LazySegmentTree<ll,ll,decltype(f),decltype(g),decltype(f)> lst(n,f,g,f,0,0);
  vector<ll> ans;
  rep(i,q) {
    ll c, s, t, x;
    cin >> c;
    if(c == 0) {
      cin >> s >> t >> x;
      s--; t--;
      lst.update(s,t+1,x);
    } else {
      cin >> s >> t;
      s--; t--;
      ans.push_back(lst.query(s,t+1));
    }
  }
  for(auto k : ans) cout << k << endl;
}


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

int main() {
  string S;
  cin >> S;
  unsigned long long int A = 0;
  unsigned long long int B = 0;
  for(int i = 0;i < S.size();i++) {
    if(i % 2 == 0) {
      if(S.at(i) == '0') {
        A = A + 1;
      }
    }
    else if(i % 2 == 1) {
      if(S.at(i) == '1') {
        A = A + 1;
      }
    }
  }
  
  for(int j = 0;j < S.size();j++) {
    if(j % 2 == 0) {
      if(S.at(j) == '1') {
        B = B + 1;
      }
    }
    else if(j % 2 == 1) {
      if(S.at(j) == '0') {
        B = B + 1;
      }
    }
  }
  if( A > B ) {
    cout << B << endl;
  }
  else if( A < B ) {
    cout << A << endl;
  }
  else {
    cout << A << endl;
  }
  
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

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

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<setprecision(15);

    //I don't care about anybody, and fuck ratings! I'll go to google!
    int n; string s; cin>>n>>s;
    int ans = 0;
    for(int i = 0; i<n-1; i++){
        if(s[i]!=s[i+1]) ans++;
    }
    ans++;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int MAX_N = 1E5 + 100;
vector<int> gr[MAX_N];
vector<int> d1(MAX_N), d2(MAX_N);
vector<bool> good(MAX_N, true);

void dfs(int x, int p, vector<int> &d) {
    for (auto y : gr[x])
        if (y != p) {
            d[y] = d[x] + 1;
            dfs(y, x, d);
        }
}

int res = 0;

void dfs2(int x, int p) {
    if (!good[x]) return;
    res = max(res, d2[x]);
    for (auto y : gr[x])
        if (y != p)
            dfs2(y, x);
}

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

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

    dfs(u, -1, d1);
    dfs(v, -1, d2);

    for (int i = 0; i < n; i++)
        if (d2[i] <= d1[i])
            good[i] = false;

    dfs2(u, -1);

    res--;
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 12032
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class CTypicalStairs {
public:
        int N, M;
        int Bad[101010];
        ll memo[101010];
        ll f(int n){
            if(n == 0 || n == 1)return Bad[n];
            if(memo[n] != -1)return memo[n];
            return memo[n] = (Bad[n-1]*f(n-1) + Bad[n-2]*f(n-2))%MOD;
        }
void solve(std::istream& cin, std::ostream& cout) {
            Fill(memo,-1);
            Fill(Bad,1);
    cin >> N >> M;
    _for(i,M){
        int t;
        cin >> t;
        Bad[t] = 0;
    }
    cout << f(N);
}
};


#undef int
int main() {
	CTypicalStairs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6144
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N, M;
int K[100001];
int to[200001], ne[200001], he[100001], num[200001];
vector<int> S1[100001], S2[100001];
int dame[100001];

int dfs(int v, int prev) {
	if (dame[v]) {
		if (dame[v] >= 2) {
			ll tmp = dfs(to[dame[v]], dame[v] ^ 1);
			int k = K[v] - num[dame[v]];
			for (int i = k - 1; i < K[v]; i++) {
				S1[v][i] = S1[v][i] * tmp % M;
			}
			S2[v][k - 1] = tmp;
			tmp = S2[v][K[v] - 1];
			for (int i = K[v] - 2; i >= 0; i--) {
				tmp = tmp * S2[v][i] % M;
				S2[v][i] = tmp;
			}
			dame[v] = -1;
		}

		ll ret = 1;
		if (prev >= 2) {
			int k = K[v] - num[prev];
			if (k >= 2) ret *= S1[v][k - 2];
			if (k < K[v]) ret *= S2[v][k];
			ret %= M;
		}
		else ret = S1[v].back();

		return ret + 1;
	}
	dame[v] = prev;
	ll ret = 1;
	int k = 0;
	for (int i = he[v]; i; i = ne[i]) {
		int tmp = 1;
		if (i != prev) {
			tmp = dfs(to[i], i ^ 1);
			ret = ret * tmp % M;
		}
		S1[v][k] = ret;
		S2[v][k++] = tmp;
	}
	if (prev == -1) {
		ll tmp2 = S2[v][K[v] - 1];
		for (int i = k - 2; i >= 0; i--) {
			tmp2 = tmp2 * S2[v][i] % M;
			S2[v][i] = tmp2;
		}
	}
	return ret + 1;
}

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


	cin >> N >> M;

	int k = 2;
	rep1(i, N - 1) {
		int x, y;
		cin >> x >> y;

		num[k] = K[x]++;
		to[k] = y;
		ne[k] = he[x];
		he[x] = k++;
		num[k] = K[y]++;
		to[k] = x;
		ne[k] = he[y];
		he[y] = k++;
	}
	rep1(i, N) {
		S1[i].resize(K[i]);
		S2[i].resize(K[i]);
	}

	rep1(j, N) {
		co(dfs(j, -1) - 1);
	}


	Would you please return 0;
}

Measured memory_bytes: 21248
#include <iostream>

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

int main(int argc,char* argv[]){
  int a, b;
  
  std::cin >> a >> b;

  std::cout << gcd(a, b) << std::endl;

  return 0;  
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
int a[30];
bool ok;
int main(){
		int a,b,h;
		cin >> a >> b >> h;
		cout << (a + b) * h / 2 << endl;
		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, s;
  char a = '1';
  string S;
  cin >> S >> K;
  for (int i = 0; i < S.size(); i++) {
    if(S[i] != '1' ){
      a = S[i];
      s = i;
      break;
    }
  }
  if(K < ++s){
    a = '1';
  }
    cout << a << endl;
  }

Measured memory_bytes: 256
'''
Created on 2020/09/09

@author: harurun
'''

def dfs(s,t,N):
  if len(s)==N:
    print(s)
  else:
    c=97
    while c<=ord(t):
      if c==ord(t):
        dfs(s+chr(c),chr(ord(t)+1),N)
      else:
        dfs(s+chr(c),t,N)
      c+=1
  return

def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  dfs("",'a',N)
  return

main()

##解説AC


Measured memory_bytes: 9180
import math
from decimal import Decimal
a,b,h,m = map(int,input().split())
h_angle = 30*h + 0.5*m
m_angle = 6 * m
angle = h_angle-m_angle
print(Decimal(a**2+b**2-2*a*b*(math.cos(math.radians(angle)))).sqrt())

Measured memory_bytes: 10276
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def gcdlist(l):
    a = l[0]
    for i in range(1,len(l)):
        a = gcd(a,l[i])
    return a

N,K = map(int,input().split())
A = list(map(int,input().split()))

g = gcdlist(A)
M = max(A)
if K > M:
    ans = 'IMPOSSIBLE'
elif K in A:
    ans = 'POSSIBLE'
elif K%g == 0:
    ans = 'POSSIBLE'
else:
    ans = 'IMPOSSIBLE'

print(ans)


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

#define N 500010

// Binary Indexed Tree
int bit[N];
void init(){
    for (int i = 0; i < N; ++i) {
        bit[i] = 0;
    }
}

void add(int i, int x){
    while(i <= N){
        bit[i] += x;
        i += i & -i;
    }
}

int sum(int i){
    int res = 0;
    while (i > 0){
        res += bit[i];
        i -= i & -i;
    }
    return res;
}

int rangesum(int l, int r){ // [l, r]
    return sum(r) - sum(l-1);
}

int c[N];
vector<int> ql[N], qid[N];
int a[N]; // 色iに対してa[i]は色iで最も右にあるものの位置を表す
int res[N];

int main(){
    int n, q;
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
        cin >> c[i];
    }
    int l, r;
    for (int i = 0; i < q; ++i) {
        cin >> l >> r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }

    init();
    for (int i = 1; i <= n; ++i) {
        a[i] = 0;
    }
    for (int i = 1; i <= n; ++i) {
        if (a[c[i]] > 0){
            add(a[c[i]], -1);
        }
        add(i, 1);
        a[c[i]] = i;
        for (int j = 0; j < ql[i].size(); ++j) {
            res[qid[i][j]] = rangesum(ql[i][j], i);
        }
    }
    for (int i = 0; i < q; ++i) {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 52996
#include <bits/stdc++.h>
using namespace std;
int ans[110][110];
int n, m;
char s[110][110];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1) continue;
            ans[i][j] = 1e9;
            if (i > 1) ans[i][j] = min(ans[i][j], ans[i - 1][j] + (s[i][j] == '#' && s[i - 1][j] == '.'));
            if (j > 1) ans[i][j] = min(ans[i][j], ans[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] == '.'));
        }
    return cout << ans[n][m] + (s[1][1] == '#') << endl, 0;
}

Measured memory_bytes: 256