akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int L, N;
int solve(vector<int> &X, vector<int> &rX) {
    deque<int> leftQ, rightQ;
    leftQ.push_back(X[0]);
    rightQ.push_back(rX[1]);
    int leftNum = 1;
    int rightNum = N - 1;
    int leftCost = X[0];
    int rightCost = rX[1] * 2;
    int rightPt = 2;
    int ret = leftCost + rightCost;

    REP(now, 1, N - 2) {
        leftNum++;
        rightNum--;
        int leftActNum = min(leftNum, rightNum + 1);
        int rightActNum = min(leftNum, rightNum);

        leftCost += X[now] + X[now - 1];
        leftQ.push_front(X[now]);

        while (leftQ.size() > leftActNum) {
            leftCost -= 2 * leftQ.back();
            leftQ.pop_back();
        }

        rightCost -= 2 * rightQ.front();
        rightQ.pop_front();

        while (rightQ.size() < rightActNum) {
            rightCost += 2 * rX[rightPt];
            rightQ.push_back(rX[rightPt]);
            rightPt++;
        }

        //cerr << "now:" << now << endl;
        //cerr << " leftQ : ";
        //for (int num : leftQ) cerr << num << " ";
        //cerr << endl;
        //cerr << " rightQ: ";
        //for (int num : rightQ) cerr << num << " ";
        //cerr << endl;
        //cerr << " leftCost : " << leftCost << endl;
        //cerr << " rightCost: " << rightCost << endl;
        //cerr << " leftActNum : " << leftActNum << endl;
        //cerr << " rightActNum: " << rightActNum << endl;

        ret = max(ret, leftCost + rightCost);
    }

    return ret;
}

signed main() {
    cin >> L >> N;
    vector<int> X, rX;

    inputVector(X, N);

    if (N == 1) {
        cout << max(X[0], L - X[0]) << endl;
        return 0;
    }

    rX.resize(N);
    rep(i, N) {
        rX[i] = L - X[i];
    }

    int ret = solve(X, rX);

    reverse(all(X));
    reverse(all(rX));

    swap(X, rX);

    ret = max(ret, solve(X, rX));

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 5120
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

signed main() {
	ll n, k;
	double ans = 0;

	cin >> n >> k;

	REP(i, n) {
		if (i + 1 >= k) {
			ans += 1.0 / (double)n;
		}
		else {
			ll now = i + 1;
			double cnt = 1.0;
			while (now < k) {
				now *= 2;
				cnt = cnt / 2;
			}
			ans += 1.0 * cnt / (double)n;
		}
	}

	std::cout << std::setprecision(10) << std::scientific << ans << std::endl;
}

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

int oddsolve(int n){
	int ans=0;
	if(n < 10)return n;
	if(n < 100)return 9;
	if(n < 1000)return n-90;
	if(n < 10000)return 909;
	if(n < 100000)return n-9090;
	else return 90909;
}

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

	cout<<oddsolve(n);
}

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())))
THE_NUM = 10**6 + 1

dp = [True] * THE_NUM

prev_num = -1
for i in A:
  # if the same number appears as before, that number cannot be counted in the answer.
  if prev_num != i:
    for j in range(i * 2, THE_NUM, i):
      dp[j] = False
  else:
    dp[i] = False
  prev_num = i

ans = 0
for i in A:
  # the same number after the second will not counted in the answer.
  if dp[i] == True:
    ans += 1

print(ans)


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, W;
    cin >> H >> W;
    if(H == 1 || W == 1) cout << 1;
    else cout << H * W / 2 + H * W % 2;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int n,N;
vector<int> v;

void init(){
    N=1;
    while(N<n) N*=2;
    v.assign(2*N-1,-1); //変更点
}

void init_u(){
    for(int i=N-2;i>=0;i--)
    v[i]=max(v[2*i+1],v[2*i+2]); //変更点
}

void update(int k,int a){
    k+=N-1;
    v[k]=a;
    while(k>0){
        k=(k-1)/2;
        v[k]=max(v[k*2+1],v[k*2+2]); //変更点
    }
}

//query(a,b,0,0,N);
int query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l) return -1; //変更点
    if(a<=l && r<=b) return v[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr); //変更点
}

int main(){
    cin>>n;
    vector<pp> dat(n+1);
    rep(i,n){
        int x,d; cin>>x>>d;
        dat[i]=mk(x,d);
    }
    dat[n]=mk(inf,0);
    vector<ll> dp(n+1,0);
    sort(al(dat));
    dp[n]=1;
    init();
    rep(i,n) v[i+N-1]=i;
    init_u();
    int l,r,c;
    for(int i=n-1;i>=0;i--){
        l=i; r=n;
        while(l!=r){
            c=(l+r)/2;
            if(dat[i].first+dat[i].second<=dat[c].first)
            r=c;
            else
            l=c+1;
        }
        update(i,query(i,l,0,0,N));
        dp[i]=(dp[i+1]+dp[v[i+N-1]+1])%mod;
    }
    cout<<(dp[0]+mod)%mod<<endl;
}

Measured memory_bytes: 5376
def gcd(a,b):
	return max(a,b) if min(a,b)==0 else gcd(min(a,b),max(a,b)%min(a,b))
a,b,c,d=map(int,input().split())
l=c*d//gcd(c,d)
cc=b//c-(a-1)//c
dd=b//d-(a-1)//d
ll=b//l-(a-1)//l
print(b-a+1-(cc+dd-ll))

Measured memory_bytes: 61936
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int main(){

    ll a,b;
    cin >> a >> b;

    ll cnt = 1;

    //  a = 1000000007;
    //   b =  1000000007;
    
    ll k = gcd(a,b);

    ll i = 2;
    while(k > 1 && k >= i){
	if(sqrt(k) < i){
	    i = k;
	}
	if( k%i == 0){
	    cnt++;
	    while(k%i == 0)k /= i;
	}
	i++;
    }

  
    P(cnt);
    return  0;
}


Measured memory_bytes: 256
k,n=map(int,input().split())
l=list(map(int,input().split()))
l.sort()

l.append(k+l[0]);
maxdiff=0
for i in range(n):
	if(l[i+1]-l[i]>maxdiff):
		maxdiff=l[i+1]-l[i]
print(k-maxdiff)



Measured memory_bytes: 77516
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    s, t = input(), input()

    for i in range(len(s)):
        if s[i:] + s[:i] == t:
            print("Yes")
            break

    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int a[N],k;
void solve(){
  int n,c=0;cin>>n>>k;
  rep(i,1,n)cin>>a[i];
  sort(a+1,a+1+n);
  rep(i,1,k)c+=a[i];
  cout<<c;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3652
use std::io::*;
use std::str::*;


// while let Some(x)=read(cin) { ... }
fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}


fn read_to_vec<T :FromStr>(s: &mut StdinLock) -> Vec<T> {
    let mut v : Vec<T> =Vec::new();
    while let Some(x) = {let d = s.by_ref().bytes().map(|c| c.unwrap() as char)
                         .skip_while(|c| c.is_whitespace())
                         .take_while(|c| !c.is_whitespace())
                         .collect::<String>();
                         d.parse::<T>().ok()} {
        v.push(x);
    }
    v
}


fn main(){
    let cin = stdin();
    let mut cin = cin.lock();
    let cin = &mut cin;
    
    let x:i32 = read(cin).unwrap();
    let a:i32 = read(cin).unwrap();
    let b:i32 =read(cin).unwrap();
    println!("{}",(x-a)%b);

    
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
using namespace std;
template<typename T> inline void gmax(T &x, T y){x = x > y ? x : y;}
template<typename T> inline void gmin(T &x, T y){x = x < y ? x : y;}
const int MAXN = 200010;
int a[MAXN];
int n;
LL ans;
int main(){
	scanf("%d", &n);
	for(int i = 0, j = 0, sum = 0; i < n; i++){
		scanf("%d", &a[i]);
		while(sum & a[i]) sum -= a[j++];
		ans += i - j + 1;
		sum += a[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,m;
  cin >> n >> m;
  if(n==1&&m==1) {
    cout << 1 << endl;
  }
  else if(n==1&&m>1) {
    cout << m-2 << endl;
  }
  else if(n>1&&m==1) {
    cout << n-2 << endl;
  }
  else if(n>1&&m>1) {
    cout << (n-2)*(m-2) << endl;
  }
}

Measured memory_bytes: 256
h, w = map(int,input().split())
s = []

for i in range(h):
    i = list(input())
    s.append(i)

dx = [-1, 0, 1, -1, 1, -1, 0, 1]
dy = [1, 1, 1, 0, 0, -1, -1, -1]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue

        tmp = 0
        for t in range(8):
            ni = i + dx[t]
            nj = j + dy[t]
            if ni < 0 or h <= ni: continue
            if nj < 0 or w <= nj: continue
            if s[ni][nj] == '#':
                tmp += 1

        s[i][j] = str(tmp)

for i in s:
    print(''.join(i))

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

int main() {
	string s;
	cin >> s;

	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
		cout << "Yes" << endl;
	}
	else if (s[0] == s[2] && s[0] != s[1] && s[1] == s[3]) {
		cout << "Yes" << endl;
	}
	else if (s[0] == s[3] && s[0] != s[1] && s[1] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	k := nextInt()
	x := nextInt()
	if k*500 >= x {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = (int)1e5 + 5;
ll dist[MAX_N];
vector<P> G[MAX_N]; // P(vertex, length)

void dfs(int u, int p, ll len){
	dist[u] = len;
	rep (i, (int)G[u].size()){
		int v = G[u][i].first;
		if (v == p) continue;
		dfs(v, u, len + G[u][i].second);
	} // end rep
}

int main()
{
	memset(dist, 0LL, sizeof(dist));
	rep (i, MAX_N) G[i].clear();

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int N; cin >> N;
	rep (i, N - 1){
		int a, b; ll c; cin >> a >> b >> c;
		--a, --b;
		G[a].push_back(P(b,c));
		G[b].push_back(P(a,c));
	} // end rep

	int Q, K; cin >> Q >> K;
	--K;
	dfs(K,-1,0LL);

	rep (i, Q){
		int x, y; cin >> x >> y;
		--x, --y;
		ll ans = dist[x] + dist[y];
		cout << ans << endl;
	} // end rep

	return 0;
}

Measured memory_bytes: 17408
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <forward_list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n);
    VI cnt(1'000'001);
    for(int i = 0; i < n; ++i){
        make(int, q);
        cnt[q]++;
    }
    int ans = 0;
    VI ok(cnt.size(), 1);
    for(int i = 1; i < cnt.size(); ++i){
        if (cnt[i] > 0){
            if (ok[i] && cnt[i] == 1){
                ans++;
            }
            for(int j = i + i; j < cnt.size(); j += i){
                ok[j] = 0;
            }
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 18828
#include <stdio.h>
int main(void)
{
	double n;
	scanf("%lf", &n);
	if ((int)n % 2 == 1)
		printf("%12.10f", (n / 2 + 0.5) / n);
	else
		printf("%12.10f", (n / 2) / n);
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

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

	switch x {
	case 7:
		fmt.Println("YES")
	case 5:
		fmt.Println("YES")
	case 3:
		fmt.Println("YES")
	default:
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#!/usr/bin/python3
# -*- coding: utf-8 -*-

from operator import itemgetter, attrgetter

N = int(input())
#S = [0] * N
#P = [0] * N
score_chart = []
for i in range(N):
    array = list(input().strip().split())
    array.append(i+1)
    score_chart.append(array)
for i in range(N):
    score_chart[i][1] = int(score_chart[i][1])
s = sorted(score_chart, key=itemgetter(1),reverse=True)
s = sorted(s, key=itemgetter(0))

#print(score_chart)
for i in range(N):
    print(s[i][2])

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(ll x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=1e5+5;
int a[3][N];
ll f[3][N];
int main()
{
	int n=ri(),i,j,k;
	for(i=1;i<=n;i++)	a[0][i]=ri(),f[0][i]=i;
	for(i=1;i<=n;i++)	a[1][i]=ri();
	for(i=1;i<=n;i++)	a[2][i]=ri();
	for(j=0;j<3;j++)	sort(a[j]+1,a[j]+1+n);
	for(j=1;j<3;j++)
	{
		for(i=1;i<=n;i++)
		{
			k=lower_bound(a[j-1]+1,a[j-1]+1+n,a[j][i])-a[j-1]-1;
			f[j][i]=f[j-1][k]+f[j][i-1];
		}
	}
	wi(f[2][n]);putchar('\n');
	return 0;
}


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

using namespace std;

int main(){
  int N,T;
  cin>>N>>T;
  vector<int> d(N);
  while(N--){
    cin>>d[N];
  }
  sort(begin(d),end(d));
  vector<int> v;
  long long ans=1;
  for(auto e:d){
    ans=ans*(end(v)-lower_bound(begin(v),end(v),e-T)+1)%1000000007;
    v.push_back(e);
  }
  cout<<ans<<endl;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

struct Edge {
	int to, dist, next;
};

struct HeapNode {
	int d, u;
	HeapNode(int d, int u) : d(d), u(u) {}
	bool operator < (const HeapNode &rhs) const {
		return d > rhs.d;
	}
};

int head[maxn];
int tot;

struct Dijkstra {
	int n;
	Edge edges[maxn]; // 注意是maxm 最大边数
	int d[maxn];
	bool done[maxn];

	void init(int n) {
		this->n = n;
		for (int i = 0; i < n; i++) {
			d[i] = inf;
			done[i] = 0;
		}
	}

	void addEdge(int from, int to, int dist) {
		edges[tot].to = to;
		edges[tot].dist = dist;
		edges[tot].next = head[from];
		head[from] = tot++;
	}

	void dijkstra(int s) {
		priority_queue<HeapNode> Q;
		d[s] = 0;
		Q.push(HeapNode(0, s));
		while (Q.size()) {
			HeapNode x = Q.top();
			Q.pop();
			int u = x.u;
			if (done[u]) continue;
			done[u] = true;
			for (int i = head[u]; i != -1; i = edges[i].next) {
				int id = edges[i].to;
				if (d[id] > d[u] + edges[i].dist) {
					d[id] = d[u] + edges[i].dist;
					Q.push(HeapNode(d[id], id));
				}
			}
		}
	}
}dj;

ll res[maxn];

void solve() {
    memset(head, -1, sizeof(head));
    tot = 0;
    ll n, x, y, tmp = 0;
    cin >> n >> x >> y;
    dj.init(n + 1);
    for (int i = 1; i < n; i++) dj.addEdge(i, i + 1, 1), dj.addEdge(i + 1, i, 1);
    dj.addEdge(x, y, 1);
    dj.addEdge(y, x, 1);
    for (int i = 1; i <= n; i++) {
        dj.dijkstra(i);
        for (int j = 1; j <= n; j++) res[dj.d[j]]++;
        dj.init(n + 1);
    }
    for (int i = 1; i < n; i++) cout << res[i] / 2 << endl;
}

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


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

#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll=long long;
using ld=long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using vlll = vector<vector<vector<ll>>>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class CHSI {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, m;
	    in >> n >> m;

	    out << (1900 * m + 100 * (n-m)) * pow(2, m) << enl;
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	CHSI solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N, M;
cin >> N ;

vector<int> vec(N);
for (int k = 0; k < N; k++) {
  cin >> vec.at(k);
}

for (int i = 0; i < 30; i++) {

for (int j = 0; j < N; j++) {
 vec.at(j) /= 2;
if (vec.at(j) % 2 != 0) {
M = i;
 goto LABEL ;
}
}

}
LABEL:;

if (M != 0 ){                       
M++;
}
cout << M << endl;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
Las = 2 * N - 1
NO = "No"
YES = "Yes"

if N == 2:
	if x == 2:
		print(YES)
		for i in range(1, 3+1):
			print(i)
	else:
		print(NO)
else:
	if x >= 3 and x <= Las - 2:
		print(YES)

		cnt = 1
		for i in range(1, N-2):
			if cnt == x - 2:
				cnt += 5
				print(cnt)
				cnt += 1
			else:
				print(cnt)
				cnt += 1
		print(x-2)
		print(x+1)
		print(x)
		print(x-1)
		print(x+2)
		for i in range(1, N-2):
			if cnt == x - 2:
				cnt += 5
				print(cnt)
				cnt += 1
			else:
				print(cnt)
				cnt += 1
	elif x == 2:
		print(YES)
		flag = True
		for i in range(1, Las + 1):
			if i == N - 1:
				print(1)
			elif i == N:
				print(2)
				flag = False
			elif flag:
				print(i + 2)
			else:
				print(i)
	elif x == Las - 1:
		print(YES)
		flag = True
		for i in range(1, Las + 1):
			if i == N - 1:
				print(Las)
			elif i == N:
				print(Las - 1)
				flag = False
			elif flag:
				print(i)
			else:
				print(i-2)
	else:
		print(NO)


Measured memory_bytes: 4688
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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 int MAX = 2010000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 前処理 COMinit();
// 計算例 cout << COM(100000, 50000) << endl;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll S; cin>>S;
  
  COMinit();
  ll ans=0;
  for(int i=1;i<=S/3;i++){
    ans+=COM(S-3*i+i-1,i-1);
    ans%=MOD;
  }
  
  cout<<ans<<'\n';
  
  return 0;
}

Measured memory_bytes: 50756
#include <cstdio>
#include <iostream>
#include <string.h>

using namespace std;

char S[100010];

pair<int,int> solve() {
    int n = strlen(S);
    for (int i = 0; i < n-1; i++) if (S[i] == S[i+1]) return {i+1, i+2};
    for (int i = 0; i < n-2; i++) if (S[i] == S[i+2]) return {i+1, i+3};
    return {-1, -1};
}

int main() {
    scanf("%s", S);
    auto ans = solve();
    printf("%d %d\n", ans.first, ans.second);
    return 0;
}

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

const long long MAX = pow(10, 18);

int main(){
  int n;
  long long num, ans = 1;
  bool ng = false;
  
  cin >> n;
  
  for(int i = 0; i < n; i++){
    cin >> num;
    if(num == 0){
      cout << 0 << endl;
      return 0;
    }
    if(__int128(ans) * num > MAX){
      ng = true;
    }
    ans *= num;
  }
  
  if(ng) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3640
import sys
input = sys.stdin.readline

n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n-1)]

graph = [[] for _ in range(n)]
for i in range(n-1):
    graph[uvw[i][0]-1].append((uvw[i][1]-1, uvw[i][2]))
    graph[uvw[i][1]-1].append((uvw[i][0]-1, uvw[i][2]))

stack = [0]
ans = [-1]*n
ans[0] = 0
while stack:
    node = stack.pop()
    for child in graph[node]:
        if ans[child[0]]!=-1:
            continue
        
        stack.append(child[0])
        if child[1]%2 == 0:
            ans[child[0]] = ans[node]
        else:
            ans[child[0]] = (ans[node]+1)%2

for a in ans:
    print(a)

Measured memory_bytes: 82524
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N =sc.nextInt();//生徒数
      int kids[] = new int[N+1];
      
      //出席番号でまわす
      for(int i=1; i<=N; i++){
      	int s = sc.nextInt();
        kids[s] =  i;
      }
      //Arrays.sort(kids);
      
      for(int i=1; i<=N; i++){
        System.out.print(kids[i]+" ");
      //System.out.println(index_i);
      }
    }
}

Measured memory_bytes: 61320
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;

int main()
{
    ll n,t=0,y=0;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n;i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end(),greater<ll>());
    bool flagb = true;
    bool flags = true;
    ll count = 0;
    for (ll i = 0; i < n - 1; i++)
    {
        if(flagb&&a[i]==a[i+1]){
            t = a[i];
            flagb = false;
        }
        else if(flags&&count>=2&&a[i]==a[i+1]){
            y = a[i];
            flags = false;
            break;
        }
        if(!flagb)
        {
            count++;
        }
    }
    cout << y * t << endl;

}


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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    cout << ((e - a) <= k ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 256
S = input()
T = input()
l = len(S)
lt = len(T)
ok = False
if l >= lt:
    for i in range(l - lt, -1, -1):
        SS = S[i:i+lt]
        can_replace = True
        for j, ss in enumerate(SS):
            can_replace *= (SS[j] == T[j] or SS[j] == '?')
        if can_replace:
            ok = True
            t_i = i
            break
if ok:
    S = S.replace('?', 'a')
    print(S[:t_i] + T + S[t_i + lt:])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 9108
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, s := scanInt(), scanInt()
	a := scanInts(n)

	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, s+3030)
	}

	dp[1][0] = 1
	dp[1][a[0]] = 1
	for i := 1; i < n; i++ {
		dp[i+1][a[i]] += dp[i][0]
		for j := 0; j < s+1; j++ {
			dp[i+1][j] += dp[i][j] * 2
			dp[i+1][j+a[i]] += dp[i][j]
			dp[i+1][j] %= mod
			dp[i+1][j+a[i]] %= mod
		}
	}

	fmt.Fprintln(wr, dp[n][s])
}

const mod = 998244353


Measured memory_bytes: 95548
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long f[100001]={2},n;
    for(long long i=1;i<=100001;i++)
    {
        f[i]=f[i-1]*2+2;
    }
    cin>>n;
    cout<<f[n]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int w,h,n;
	cin>>w>>h>>n;
	
	int left=0,right=w,up=h,down=0;
	int area=(up-down)*(right-left),ans=area;
	for(int i=0;i<n;++i){
		int x,y,a;
		cin>>x>>y>>a;
		if(a==1){
			if(x>left)left=x;
		}else if(a==2){
			if(x<right)right=x;
		}else if(a==3){
			if(y>down)down=y;
		}else {
			if(y<up)up=y;
		}
		area=(up-down)*(right-left);
		if(up<=down || right<=left)area=0;
		if(area<0)area=0;
		if(area<ans)ans = area;	
	}	
	area=(up-down)*(right-left);
	if(up<=down || right<=left)area=0;
	if(area<0)area=0;
	if(area<ans)ans = area;	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    long long n,k,r,ans;

    cin>>n>>k;

    r=n%k;

    if(r>0)
    {
        ans=abs(r-k);
        n=min(r,ans);
    }
    else
        n=0;

    cout<<n<<endl;

    return 0;
}


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

int main() {
  int N, M, c=0, i=0;
  long long ans = 0;
  cin >> N >> M;
  vector<pair<int, int>> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i].first >> A[i].second;
  }
  sort(A.begin(), A.end());
  while(c < M){
    if(A[i].second > 0){
      c++;
      A[i].second--;
      ans += A[i].first;
    }else{
      i++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 1024
# li = list(map(int, input().split()))
N, K = map(int, input().split())
A_N = list(map(int, input().split()))


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


next = A_N[0]
for i in range(len(A_N)):
    next = gcd(A_N[i], next)

if K > max(A_N):
    print('IMPOSSIBLE')
elif next == 1:
    print('POSSIBLE')
elif K % next ==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 14224
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);

/*
ll nCr(int n, int r) {
	ll ln = (ll)n;
	ll lr = (ll)r;

	ll res = 1;

	for (int count = 0; count < lr; count++) {
		res *= ln;
		res %= 1000000007;
		ln--;
	}
	for (int count = 1; count <= lr; count++)
		res /= count;
	return res % 1000000007;
}

ll get_route(int n) {
	if (n <= 0) return 0;
	if (n == 1) return 1;
	int res = 1;
	for (int c = 1; c <= n / 2; c++) {
		res += nCr(n - c, c);
	}
	return res;
}
*/

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	//cout << get_route(5) << endl;

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

	vector<int> dp(N + 1,1);
	vector<bool> ok(N + 1, true);
	//vector<int> a(M);
	int tmp;
	rep(i, M) {
		cin >> tmp;
		dp[tmp] = 0;
		ok[tmp] = false;
	}

	for (int i = 2; i < N + 1; i++) {
		if (ok[i] != false) {
			dp[i] = dp[i - 1] + dp[i - 2];
			dp[i] %= 1000000007;
		}
	}

	cout << dp[N] << endl;


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

int sum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int min(vector<int> v) {
	int min = INT32_MAX;
	for(auto it = v.begin();it != v.end();it++) 
		min = std::min(min,*it);
	return min;
}
int max(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}


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

int main(){
  int n;
  cin >> n;
  string a[5010];
  int x[5010];

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

  int group[5010];
  for(int i=0;i<n;i++){
    group[i] = i;
  }

  int m;
  cin >> m;
  for(int i=0;i<m;i++){
    string s,t;
    cin >> s >> t;

    int id1 = -1, id2 = -1;
    for(int j=0;j<n;j++){
      if(s == a[j]) id1 = j;
      if(t == a[j]) id2 = j;
    }

    id1 = group[id1];
    id2 = group[id2];
    
    for(int i=0;i<n;i++){
      if(group[i] == id1) group[i] = id2;
    }
  }

  for(int i=0;i<n;i++){
    x[group[i]] = min(x[group[i]], x[i]);
  }

  int ans = 0;
  for(int i=0;i<n;i++){
    ans += x[group[i]];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1544
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string S;
  cin >> S;
  cout << (S>"2019/04/30" ? "TBD" : "Heisei") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll a,b,q,s,t,x;
    cin>>a>>b>>q;
    vector<ll> S,T;
    rep(i,a) cin>>s,S.push_back(s);
    rep(i,b) cin>>t,T.push_back(t);
    rep(i,q){
        cin>>x;
        ll sa,sb,ta,tb;
        if(x<S[0]) sa=-1;
        else sa=x-*(--upper_bound(S.begin(),S.end(),x));
        if(x>S[a-1]) sb=-1;
        else sb=*lower_bound(S.begin(),S.end(),x)-x;
        if(x<T[0]) ta=-1;
        else ta=x-*(--upper_bound(T.begin(),T.end(),x));
        if(x>T[b-1]) tb=-1;
        else tb=*lower_bound(T.begin(),T.end(),x)-x;
        ll ans[4],INF=1e18;
        if(sa!=-1&&tb!=-1) ans[0]=min(sa,tb)*2+max(sa,tb);
        else ans[0]= INF;
        if(ta!=-1&&sb!=-1) ans[1]=min(ta,sb)*2+max(ta,sb);
        else ans[1]=INF;
        if(sa!=-1&&ta!=-1) ans[2]=max(sa,ta);
        else ans[2]=INF;
        if(sb!=-1&&tb!=-1) ans[3]=max(sb,tb);
        else ans[3]=INF;
        sort(ans,ans+4);
        cout<<ans[0]<<endl;
    }
}

Measured memory_bytes: 3060
//#pragma  GCC optimize("Ofast")

//#ifdef  DEBUG
//#define _GLIBCXX_DEBUG
//#endif

// -Ofast
// -O3
// -O2
// -fsanitize=address
// -fsanitize=undefined

// add_compile_options()

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#include <cassert>
#include <random>

using namespace std;
//using namesparsace __gnu_pbds;

void solve();

int main() {
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

#define ld double
#define int long long

const int maxN = 1e5 + 10, maxK = 1e5 + 10, inf = 1e15 + 10, base = 223;

int mod;

struct segment_tree {
    vector < int > t;



    void set(int n) {
        for (int i = 0; i < 4 * n; i++) t.push_back(1);
    }

    void update(int v, int l, int r, int pos, int val) {
        if (l == r) {
            t[v] = val % mod;
        } else {
            int m = (r + l) / 2;
            if (pos <= m) update(v * 2, l, m, pos, val);
            else update(v * 2 + 1, m + 1, r, pos, val);
            t[v] = (t[v * 2] * t[v * 2 + 1]) % mod;
        }
    }

    int get(int v, int l, int r, int tl, int tr) {
        if (l >= tl && r <= tr) {
            return t[v];
        }
        if (l > tr || r < tl) return 1;
        int m = (r + l) / 2;
        return (get(v * 2, l, m, tl, tr) * get(v * 2 + 1, m + 1, r, tl, tr)) % mod;
    }

};

int n, dp[maxN], updp[maxN];
vector < int > a[maxN];
segment_tree tree[maxN];

void dfs(int v, int p) {
    dp[v] = 1;
    for (int i = 0; i < a[v].size(); i++) {
        int to = a[v][i];
        if (to == p) continue;
        dfs(to, v);
        dp[v] = (dp[v] * (dp[to] + 1)) % mod;
        tree[v].update(1, 0, a[v].size() - 1, i, dp[to] + 1);
    }
}

void dfs1(int v, int p) {
    for (int i = 0; i < a[v].size(); i++) {
        int to = a[v][i];
        if (to == p) continue;
        int e = 1;
        if (i) e = e * tree[v].get(1, 0, a[v].size() - 1, 0, i - 1) % mod;
        if (i + 1 < a[v].size()) e = e * tree[v].get(1, 0, a[v].size() - 1, i + 1, a[v].size() - 1) % mod;
        updp[to] = ((updp[v] + 1) * e) % mod;
        dfs1(to, v);
    }
}

void solve() {
    cin >> n >> mod;
    for (int i = 0; i < n - 1; i++) {
        int f, s;
        cin >> f >> s;
        f--, s--;
        a[f].push_back(s);
        a[s].push_back(f);
    }
    for (int i = 0; i < n; i++) {
        tree[i].set(a[i].size());
    }
    dfs(0, -1);
    dfs1(0, -1);
    for (int i = 0; i < n; i++) {
        cout << (dp[i] * (updp[i] + 1)) % mod << '\n';
    }
}

Measured memory_bytes: 31232
#include<bits/stdc++.h>
#define int long long
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000009
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r,int m){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%m)*(p%m))%m;
	 }
	 r=r>>1;
     p=((p%m)*(p%m))%m;
	}
	return ans;
}
signed main() {
	garou;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=(a*c);
	x=max(x,a*d);
	x=max(x,b*c);
	x=max(x,b*d);
	cout<<x;
}

Measured memory_bytes: 3648
from collections import deque
N, M = map(int, input().split())
V = {i: [] for i in range(1,N+1)}
for _ in range(M):
    a, b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)

def zen(V):
    W = []
    q = deque()
    q.append(1)
    vstd = {i: 0 for i in range(1,N+1)}

    while q:
        u = q.popleft()
        if vstd[u]:
            continue
        vstd[u] = True
        W.append(u)
        for v in V[u]:
            if vstd[v]:
                continue
            q.append(v)
    return W

if M % 2 != 0:
    print(-1)
else:

    U = zen(V)
    W = {i: [] for i in range(1,N+1)}

    for u in U[::-1]:
        for v in V[u]:
            if v in W[u] or u in W[v]:
                continue
            if len(W[u]) % 2 == 0:
                W[v].append(u)
            else:
                W[u].append(v)

    for w in W:
        for v in W[w]:
            print(w, v)


Measured memory_bytes: 97892
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 1e9, MAX = 20005, N = 120005;
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int h, w, n;

signed main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	int ans = 0;
	cin >> h >> w >> n;
	if (h < w) swap(h, w);
	while (n > 0) ++ans, n -= h;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256