akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

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

type kv struct {
	key   int
	count int
}

func main() {
	n := nextInt()
	n1 := map[int]int{}
	n2 := map[int]int{}

	for i := 0; i < n; i++ {
		v := nextInt()
		if i%2 == 0 {
			n1[v]++
		} else {
			n2[v]++
		}
	}

	var n1max, _n1max, n2max, _n2max kv
	for k, item := range n1 {
		if item > n1max.count {
			n1max.key = k
			n1max.count = item
		} else {
			if item > _n1max.count {
				_n1max.key = k
				_n1max.count = item
			}
		}
	}

	for k, item := range n2 {
		if item > n2max.count {
			n2max.key = k
			n2max.count = item
		} else {
			if item > _n2max.count {
				_n2max.key = k
				_n2max.count = item
			}
		}
	}

	// fmt.Printf("%#v %#v %#v %#v\n", n1max, _n1max, n2max, _n2max)

	if len(n1) == 1 && len(n2) == 1 && n2max.key != n1max.key {
		fmt.Printf("%#v\n", 0)
		return
	}

	var _re1, _re2 int
	if n1max.key != n2max.key {
		for k, item := range n1 {
			if k != n1max.key {
				_re1 += item
			}
		}
		for k, item := range n2 {
			if k != n2max.key {
				_re2 += item
			}
		}
		fmt.Printf("%#v\n", _re1+_re2)
	} else {
		for k, item := range n1 {
			if k != n1max.key {
				_re1 += item
			}
		}
		for k, item := range n2 {
			if k != _n2max.key {
				_re1 += item
			}
		}

		for k, item := range n1 {
			if k != _n1max.key {
				_re2 += item
			}
		}
		for k, item := range n2 {
			if k != n2max.key {
				_re2 += item
			}
		}

		if _re1 > _re2 {
			fmt.Printf("%#v\n", _re2)
		} else {
			fmt.Printf("%#v\n", _re1)
		}
	}
}


Measured memory_bytes: 5632
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    println(if(isEcho(s)) "Yes" else "No")
}

fun isEcho(txt:String):Boolean {
    if(txt.length % 2 != 0) {
        return false
    }
    return txt.take(txt.length / 2).let { it + it } == txt
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const int MAX = 310000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

  COMinit();

  int n;
  ll a, b, k;
  cin >> n >> a >> b >> k;

  ll ans = 0;
  rep(i, n+1){

    int j;
    if((k - a * i) >= 0 && (k - a * i ) % b == 0){
      j = (k - a * i ) / b;
      ans = (ans + (COM(n, i) * COM(n, j)) % MOD) % MOD;
    }
  
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d=0;
    cin>>n;
    int a[n];
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
        if(i%2==1&&a[i]%2==1)
            ++d;
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3632
sub main {
    chomp(my $N = <STDIN>);
    print solver($N);
}
main() unless caller;

sub solver {
    my ($N) = @_;
    my $inf = 10 ** 9 + 7;
    my $ans = 1;
    for my $i(1..$N){
        $ans = $i * $ans % $inf; 
    }
    return $ans;
}

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

const int N = 100005;

int k, vis[N], dist[N];

int main(){
	scanf("%d", &k);

	deque<int> dq;

	for(int i = 0; i < k; i++) dist[i] = k;
	dist[1] = 0;
	dq.push_back(1);

	while(!dq.empty()){
		int cur = dq.front();
		dq.pop_front();
		if(vis[cur]) continue;
		vis[cur] = 1;

		int plus = (cur + 1) % k;
		if(dist[plus] > dist[cur] + 1){
			dist[plus] = dist[cur] + 1;
			dq.push_back(plus);
		}

		int mult = cur * 10 % k;
		if(dist[mult] > dist[cur]){
			dist[mult] = dist[cur];
			dq.push_front(mult);
		}
	}

	printf("%d\n", dist[0] + 1);
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec;
  for(int i=0; i<(n-1); i++){
    int num;
    cin >> num;
    vec.push_back(num);
  }
  int res = 0;
  res += vec[0];
  for(int i=0; i<(n-2); i++){
    res += min(vec[i], vec[i+1]);
  }
  res += vec[n-2];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = Integer.parseInt(in.next());
        int cofTrain = Integer.parseInt(in.next());
        int cofTaxi = Integer.parseInt(in.next());
        in.close();
        int ans = num * cofTrain < cofTaxi ? cofTrain * num : cofTaxi;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
#include <iostream>

using namespace std;


int main()
{
	int H, R;
	cin >> H >> R;

	if (H * R == -R * R)
	{
		cout << "0" << endl;
	}
	else if (H * R >= 0)
	{
		cout << "1" << endl;
	}
	else if (H * R < 0)
	{
		cout << "-1" << endl;
	}
	

		return 0;
	
}


Measured memory_bytes: 3028
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Prediction and Restriction
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

enum { R, S, P };

/* typedef */

/* global variables */

int scs[3];
char t[MAX_N + 4];
bool wins[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  for (int i = 0; i < 3; i++) scanf("%d", scs + i);
  scanf("%s", t);

  int sum = 0;
  for (int i = 0; i < n; i++)
    if (i < k || ! wins[i - k] || t[i] != t[i - k]) {
      switch (t[i]) {
      case 'r': sum += scs[P]; break;
      case 's': sum += scs[R]; break;
      case 'p': sum += scs[S]; break;
      }
      wins[i] = true;
    }

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


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	ll n;cin >> n;
	vector<ll> a(n);REP(i, n)cin >> a[i];
	vector<ll> b(n);REP(i, n)cin >> b[i];

	priority_queue<P> pq;
	REP(i, n)if(b[i] > a[i])pq.push(MP(b[i], i));
	ll ans = 0;

	while(!pq.empty()){
		auto now = pq.top();pq.pop();
		ll id = now.SE;
		ll num = now.FI - a[id];
		ll mai = b[(id+1)%n] + b[(id+n-1)%n];
		ans += num / mai;
		num %= mai;
		if(b[id] == a[id] + num){
			cout << -1 << endl;
			return 0;
		}
		b[id] = a[id] + num;
		if(num != 0){
			pq.push(MP(a[id]+num, id));
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  for(int i = 111; i <= 999; i += 111)
  {
    if  (n <= i)
    {
      cout << i;
      return;
    }
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
#include<map>
#include <cassert>
#include<sstream>
#include<fstream>
#include <cstring>
using namespace std;
typedef pair<int, string>p;
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX =1;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long ans = 0;
	int k;
	cin >> k;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int x = 1; x <= k; x++) {
				ans += gcd(x, gcd(i, j));
			}
		}
	}
	cout << ans;
}



Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<string.h>

using namespace std;

int lcs(char x[],char y[]);

int main(){
	char x[1000],y[1000];
	int n,*memo; cin>>n;
	memo = new int[n];
	for(int i=0;i<n;i++){
		cin>>x>>y;
		memo[i] = lcs(x,y);
	}
	for(int i=0;i<n;i++)
		cout<<memo[i]<<endl;

	delete [] memo;
}

int lcs(char x[],char y[]){
	int m = strlen(x), n = strlen(y);
	int **c,a;
	c = new int*[m+1]; for(int i=0;i<=m;i++) c[i] = new int[n+1];
	for(int i=0;i<=m;i++) c[i][0] = 0;
	for(int j=1;j<=n;j++) c[0][j] = 0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(x[i-1]==y[j-1]){
				c[i][j] = c[i-1][j-1]+1;
				if(i==m&&j==n){
					a = c[i][j];
					//cout<<c[i][j]<<endl;
				}
			}else{
				if(c[i-1][j]>=c[i][j-1]){
					c[i][j] = c[i-1][j];
					if(i==m&&j==n){
						a = c[i][j];
						//cout<<c[i][j]<<endl;
					}
				}else{
					c[i][j] = c[i][j-1];
					if(i==m&&j==n){
						a = c[i][j];
						//cout<<c[i][j]<<endl;
					}
				}
			}
		}
	}
	for(int i=0;i<=strlen(x);i++) delete [] c[i]; delete [] c;
	return a;
}

Measured memory_bytes: 6676
import sys
#import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
#import math
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
import numpy as np

h, w, k = rl()
a=[list(rs()) for _ in range(h)]
ans=0
for i in range(1<<h+w):
    c = np.array(a[:])
    for n in range(h+w):
        if i>>n&1:
            if n>=h:
                c[:,n-h-1]="*"
            else:
                c[n-1,:]="*"
    cnt=0
    for y in range(h):
        for x in range(w):
            if c[y][x]=="#":
                cnt+=1
    if cnt==k:
        ans+=1
print(ans)

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 1005;
int ans[N][N];

int main()
{
	//freopen("1.out", "w", stdout);
	int k = read();
	if (k <= 500)
	{
		printf("%d\n", k);
		for (int i = 1; i <= k; ++i) 
		{
			for (int j = 1; j <= k; ++j) printf("%d ", i);
			puts("");
		}
	}
	else
	{
		int n = 500;
		printf("%d\n", n);
		for (int i = 1; i <= n; ++i)
			for (int x = 1, y = i; x <= n; ++x, y = y % n + 1)
				ans[x][y] = i;
		for (int i = n + 1; i <= k; ++i)
			for (int x = 1, y = (i - 1) % n + 1; x <= n; ++x, y = y % n + 1)
				if (i + x & 1) ans[x][y] = i;
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 1; j <= n; ++j)
				printf("%d ", ans[i][j]);
			puts("");
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  ll x = 0;
  for(ll i=40; i>=0; --i) {
    ll cnt0 = 0, cnt1 = 0;
    REP(j, n) {
      if(a[j]&1LL<<i) cnt1++;      
      else cnt0++;
    }
    // cout << cnt0 << " " << cnt1 << " " << (x|(1LL<<i)) << endl;
    if(cnt0 > cnt1 && ((x|(1LL<<i)) <= k)) x |= 1LL<<i;
  }
  // cout << x << endl;

  ll ret = 0;
  REP(i, n) ret += a[i]^x;
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 1024
import itertools
while True:
    n,x = list(map(int,input().split()))
    if n==x==0: break
    li = list(itertools.combinations([i+1 for i in range(n)],3))
    ret = 0
    for i in range(len(li)):
        if sum(li[i]) == x: ret+= 1
    print(ret)

Measured memory_bytes: 33308
list1=[1]
for i in range(2,1000):
    list1.append(list1[i-2]+i)
    
#print(list1[0:5])

line=input()
line=line.rstrip().split(" ")
a=int(line[0])
b=int(line[1])

print(list1[b-a-1]-b)

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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	int N, C, K;
	cin>>N>>C>>K;

	vector<int> T(N);
	for(int i=0; i<N; i++){
		cin>>T[i];
	}

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

	int ans=0, t=0, c=0;
	for(int i=0; i<N; i++){
		if(t==0){
			t=T[i];
			c=1;
			ans++;
		}else{
			if(T[i] <= t+K && c < C){
				c++;
			}else{
				t=T[i];
				ans++;
				c=1;
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,b,a[li],k,flag,cev,x[li],y[li],visit[li];
string s;
map<PII,lo> vis;
vector<lo> v[li];

void dfs(lo node){
	if(visit[node]==1) return ;
	visit[node]=1;
	for(lo i=0;i<(lo)v[node].size();i++){
		lo go=v[node][i];
		if(vis[mp(node,go)]==1 || vis[mp(go,node)]==1) continue;
		dfs(go);
	}
}

int main(void){
	scanf("%lld %lld",&n,&m);
	for(lo i=1;i<=m;i++){
		scanf("%lld %lld",&x[i],&y[i]);
		v[x[i]].pb(y[i]);
		v[y[i]].pb(x[i]);
	}
	for(int i=1;i<=m;i++){
		memset(visit,0,sizeof(visit));
		vis[mp(x[i],y[i])]=1;
		dfs(1);
		FOR{
			if(visit[i]==0){cev++;break;}
		}
		vis[mp(x[i],y[i])]=0;
		//~ vis[x[i]]=1;
	}
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll x, i, h, f500, f5;

    cin >> x;

    f500 = x / 500;
    x -= (500 * f500);

    f5 = x / 5;

    cout << f500 * 1000 + (f5 * 5) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	string s;
	cin >> s;
	int summ = 0;
	for(char c : s){
		summ += c - '0';
	}
	if(summ % 9 == 0) cout << "Yes" << newl;
	else cout << "No" << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n; cin >> n;
    int a[n];
    int idx[n];
    rep(i,n) {
        cin >> a[i];
        a[i]--;
        idx[a[i]] = i;
    }
    //rep(i,n) {printf("%d ", idx[i]);} printf("\n");
    multiset<int> Set;
    for (ll i = -1; i < n+1; i++) Set.insert(i);
    Set.insert(-1); Set.insert(n);
    ll ans = 0;
    rep(i,n-1) {
        int p = idx[i];
        auto itr = Set.find(p);
        auto itr2 = itr; itr2--;
        auto itr3 = itr; itr3++;
        auto itr1 = itr2; itr1--;
        auto itr4 = itr3; itr4++;
        int p1 = (*itr1);
        int p2 = (*itr2);
        int p3 = (*itr3);
        int p4 = (*itr4);
        //printf("%d %d %d %d %d\n", p1,p2,p,p3,p4);
        ans += ((ll)i+1)*((p2-p1)*(p3-p)+(p4-p3)*(p-p2));
        //cout << ans << endl;
        Set.erase(p);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9064
import java.util.*;
public class Main {
	static int ans = 0;
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n,m,k;
		n = Integer.parseInt(scan.next());
		m = Integer.parseInt(scan.next());
		int[][] s = new int[m][n];
		int[] p = new int[m];
		for (int i = 0;i < m; ++i){
			Arrays.fill(s[i], 0);
			k = Integer.parseInt(scan.next());
			for (int j = 0;j < k; ++j){
				s[i][Integer.parseInt(scan.next())-1] = 1;
			}
		}
		for (int i = 0;i < m; ++i){
			p[i] = Integer.parseInt(scan.next());
		}

		int ans = 0;
		int count;
		boolean[] on = new boolean [n];
		boolean ok ;
		for (int i = 0;i < 1<<n; ++i){
			Arrays.fill(on, false);
			for (int j = 0;j < n; ++j){
				if ((1 & i>>j) == 1){
					on[j] = true;
				}
			}
			ok = true;
			for (int j = 0;j < m; ++j){
				count = 0;
				for (int l = 0;l < n; ++l){
					if (s[j][l] == 1 && on[l])++count;
				}
				if (count%2 != p[j])ok = false;
			}
			if (ok)++ans;

		}

		System.out.print(ans);


	}

}


//end

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    string s;
    cin >> s;
    int n = s.length();

    int res = 0;
    bool flag = false;
    int cnt = 0;
    REPR(i,n-1){
        if(s[i] == 'C'){
            if(flag) cnt = 0;
            flag = true;
        }
        else if(s[i] =='B'){
            if(flag) cnt ++ ;
            else{
                cnt = 0;
            }
            flag = false;
        }
        else{
            if(not flag) res += cnt;
            else{
                cnt = 0;
                flag = false;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int A, B, C;
    cin >> A;
    cin >> B;
    cin >> C;
    if ((A == B && B == C) || (A != B) && (B != C) && (A != C))
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:] for m in range(m)]
p=list(map(int,input().split()))
cnt=0
for i in range(1<<n):
    for j in range(m):
        switch=0
        for k in range(n):
            if (i>>k)&1 and k+1 in s[j]:
                switch+=1
        if switch%2!=p[j]:
            break
    else:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
N,M = map(int,input().split())
AC = 0
WA = 0
tmp_WA = [0]*N
lst = []
for _ in range(M):
    lst.append(list(input().split()))
#print(lst)

#ques = [[0,0]]*N # lest:AC right:WA
ques = [0]*N
#print(ques)

#tries = []
for i in range(M):
#    print(lst[i] in tries)
#    tries.append(lst[i])
    if ques[int(lst[i][0])-1] != 1:
        if lst[i][1] == 'WA':
            tmp_WA[int(lst[i][0])-1] += 1
        else:
            AC += 1
            ques[int(lst[i][0])-1] = 1
for j in range(N):
    if ques[j] != 1:
        tmp_WA[j] = 0

print(str(AC) + ' ' + str(sum(tmp_WA)))



Measured memory_bytes: 27468
#include<stdio.h>
#define N 100000
#define Q 50000

int main(){
  int i, j, n, q, left = 0, right, mid, ans=0, key, S[N], T[Q];
  
   scanf("%d",&n);
  for(i=0 ; i<n ; i++){
  scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i=0 ; i<q ; i++){
  scanf("%d",&T[i]);
  }

  for(j=1 ; j<n ; j++){
    key = S[j];
    i = j-1;
    while(i >= 0 && S[i] > key){
      S[i+1] = S[i];
      i = i-1;
    }
    S[i+1] = key;
  }

 

  for(i=0 ; i<q ; i++){
    left = 0;
    right = n;
    
    while(left < right){

      mid = (left + right)/2;

      if(S[mid] == T[i]){
	
      ans++;
      break;
    }
      else if(S[mid] > T[i]){
	right = mid;

      }
      else {
	left = mid + 1;
	
      }
    }
  }
  
  printf("%d\n",ans);
  return 0;
}




Measured memory_bytes: 2292
#include <bits/stdc++.h>
     
    using namespace std;
     
    const int N = 100005;
     
    int n;
     
    vector<int> g[N];
     
    vector<int> bfs(int s){
        vector<int> dist(n+1, -1);
        queue<int> q;
        q.push(s);
        dist[s] = 0;
        
        while(!q.empty()){
            int u = q.front(); q.pop();
            for(int v: g[u]){
                if(dist[v] == -1){
                    dist[v] = dist[u]+1;
                    q.push(v);
                }
            }
        }
        return dist;
    }
     
    int main(){
     
        scanf("%d", &n);
     
        for(int i = 1; i < n; i++){
            int a, b;
            scanf("%d %d", &a, &b);
            g[a].push_back(b);
            g[b].push_back(a);
        }
     
        vector<int> d1 = bfs(1);
        vector<int> d2 = bfs(n);
     
        int l = 0, r = 0;
        for(int i = 1; i <= n; i++){
            if(d1[i] <= d2[i]) l++;
            else r++;
        }
     
        if(l > r) printf("Fennec\n");
        else if(r >= l) printf("Snuke\n");
     
     
     
     
        return 0;
    }

Measured memory_bytes: 6656
gets
a=gets.split.map(&:to_i)
min=a[0]
max=a[0]
sum=0
a.each{|i|
    if(i<min)
        min=i
    end
    if(i>max)
        max=i
    end
    sum+=i
}
printf("%d %d %d\n",min,max,sum)


Measured memory_bytes: 7168
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        x: u64, y: u64
    }

    println!("{}", x + y/2);
}

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

int main(){
    int N,M; cin>>N>>M;
    vector<int> AC(N,0);
    vector<int> WA(N,0);

    int t1;
    string t2;
    for(int i=0;i<M;i++){
        cin>>t1>>t2;
        
        if(t2=="AC"){
            AC.at(t1-1) += 1;
        }else if(AC.at(t1-1)==0){
            WA.at(t1-1) += 1;
        }
    }

    int Ans1=0, Ans2=0;
    for(int i=0;i<N;i++){
        if(AC.at(i)>=1){
            Ans1 += 1;
            Ans2 += WA.at(i);
        }
    }
    cout<<Ans1<<" "<<Ans2<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;
const int MAX_N = 200000;
typedef long long int64;
int N;
int A[MAX_N+1];
int64 dp[3][MAX_N+1];
int64 solve(){
	memset(dp,0x3f,sizeof(dp));

	for (int i = 0; i < N; ++i){
		dp[0][i] = A[i];
		if(i-2 >= 0)	dp[0][i] += dp[0][i-2];
	}

	//dp[1][1] = A[0]+A[1];
	for (int i = 0; i < N; ++i){
		if(i-1 >= 0)	dp[1][i] = min(dp[1][i],dp[0][i-1]+A[i]);
		if(i-2 >= 0)	dp[1][i] = min(dp[1][i],dp[1][i-2]+A[i]);
	}

	//dp[2][2] = A[0]+A[1]+A[3];
	for (int i = 0; i < N; ++i){
		if(i-1 >= 0)	dp[2][i] = min(dp[2][i],dp[1][i-1]+A[i]);
		if(i-2 >= 0)	dp[2][i] = min(dp[2][i],dp[2][i-2]+A[i]);
	}

	int64 total = 0;
	for (int i = 0;i < N; ++i)
		total += A[i];

	int64 ret = dp[0][N-1];
	if( N % 2 == 0){
		ret = min(ret,dp[0][N-2]);
		ret = min(ret,dp[1][N-2]);
		return total - ret;
	}

	ret = min(ret,dp[1][N-1]);
	ret = min(ret,dp[1][N-2]);

	ret = min(ret,dp[2][N-2]);




	return total - ret;
}
int main(){
	scanf("%d",&N);
	for (int i = 0; i < N; ++i)
		scanf("%d",A+i);
	int64 ans = solve();
	printf("%lld\n",ans);
}


Measured memory_bytes: 7196
#include <stdio.h>
#include <functional>
#include <vector>
using namespace std;

const int N = 1e5 + 10;

int c[N];
vector<pair<int, int>> g[N];

void dfs(int u, int pr, long long dist) {
  if (dist & 1) {
    c[u] = c[0] ^ 1;
  } else {
    c[u] = c[0];
  }
  for (int i = 0; i < (int) g[u].size(); i++) {
    if (g[u][i].first != pr) {
      dfs(g[u][i].first, u, dist + g[u][i].second);
    }
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    u--; v--;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }
  dfs(0, -1, 0);
  for (int i = 0; i < n; i++) {
    printf("%d\n", c[i]);
  }
  return 0;
}

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

  int n,cnt=0;
  cin>>n;

  int a[101];

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


  for(int i=0;i<n;i++){
    for(int j=0;j<n-i-1;j++){
      if(a[j]>a[j+1]){
	cnt++;
	int temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }

  for(int i=0;i<n;i++){
    if(i==n-1){
      cout<<a[i]<<endl;
    }else{
      cout<<a[i]<<" ";
    }
  }

  cout<<cnt<<endl;
  return 0;

}



Measured memory_bytes: 3104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[n - 1] - a[0]);
  }
}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>>key;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		int s=0;
		for (int j = 0; j < b; j++) {
			int c;
			cin >> c;
			c--;
			s |= 1<<c;
		}
		key.emplace_back(s,a);
	}
	vector<int>dp(1<<n,0X3F3F3F3F);
	dp[0] = 0;
	for(int s=0;s<1<<n;s++)
		for (int i = 0; i < m; i++) {
			int t = s | key[i].first;
			int cost = dp[s] + key[i].second;
			dp[t] = min(dp[t], cost);
		}
	int ans = dp.back();
	if (ans == 0X3F3F3F3F)
		cout << -1;
	else
		cout << ans;
	return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    rep(i,k){
        if(b<=a){
            b*=2;
        }else if(c<=b){
            c*=2;
        }
        if(b>a&&c>b){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


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

long long w = 0, k = 1, ans = 0;
int main() {
	scanf("%lld", &w);
    while (w) {
        w /= 2;
        ans += k;
        k *= 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,D,X;
  cin >> N >> D >>X;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >>vec.at(i);
  }
  int answer=0;
  for(int i=0;i<N;i++){
    int j=0;
    while(1+j*vec.at(i)<D+1){
      answer=answer+1;
      j=j+1;
    }
  }
  cout << answer+X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int g = 0, w = 0, y = 0, p = 0;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "G"){
      g = 1;
    }else if(S == "W"){
      w = 1;
    }else if(S == "Y"){
      y = 1;
    }else{
      p = 1;
    }
  }
  int sum = g + w + y + p;
  if(sum == 3){
    cout << "Three" << endl;
  }else{
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
def conv(s):
    if s.find('.') == -1:
        s += '.'
    s = s.rstrip('0')
    t = len(s) - s.find('.') - 1
    a = int(s.replace('.', ''))
    if a == 0:
        return (0, 0)
    x, y = -t, -t
    while a % 5 == 0:
        x += 1
        a //= 5
    while a % 2 == 0:
        y += 1
        a //= 2
    return (x, y)


N, *A = open(0).read().split()
N = int(N)

d = {}
for a in A:
    t = conv(a)
    d.setdefault(t, 0)
    d[t] += 1

result = 0
xs = list(d.keys())
for i in range(len(xs)):
    x, y = xs[i]
    t = d[xs[i]]
    if x >= 0 and y >= 0:
        result += t * (t - 1) // 2
    for j in range(i + 1, len(xs)):
        m, n = xs[j]
        if x + m >= 0 and y + n >= 0:
            result += t * d[xs[j]]
print(result)

Measured memory_bytes: 114880
#include <iostream>

typedef long long ll;

ll N, K;

int main() {
  std::cin >> N >> K;
  if (K == 0)
    std::cout << N*N << "\n";
  else {
    ll ans = 0;
    for (ll b = K+1; b <= N; ++b) {
      //std::cout << b << " " << N/b << " " << b - K << " " << N%b - K + 1<< "\n";
      //std::cout << (N/b)*(b - K) + std::max(N%b - K + 1, 0LL) << "\n";
      ans += (N/b)*(b - K) + std::max(N%b - K + 1, 0LL);
    }
    std::cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime> 
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#include <iomanip>
#define y1 y11
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define skip continue
#define all(x) x.begin(), x.end()
#define NAME "code"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<pii, ll> piii;

const ld pi = 2 * acos(0.0);
const ll prime = 31;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll maxn = 3e5 + 11;
const ll dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const ll dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

ll n, m, f[maxn], u[maxn], cnt, q[maxn];
vector<pii> g[maxn];

void dfs(int v, int dist){
	u[v] = 1;
	q[v] = dist;
	for(pii to : g[v]){
		if(u[to.fr]) skip;
		dfs(to.fr, dist + to.sc);
	}
}

int main(){

// freopen(NAME".in","r",stdin); 
// freopen(NAME".out","w",stdout);

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

cin >> n >> m;

for(int i = 0, u, v, c; i < m; ++i){
	cin >> u >> v >> c;
	f[v] = 1;
	g[u].pb({v, c});
}

for(int i = 1; i <= n; ++i){
	if(!u[i] && !f[i]) dfs(i, 0);
}

for(int i = 1; i <= n; ++i){
	for(pii to : g[i]){
		if(q[i] + to.sc != q[to.fr]){
			cout << "No";
			return 0;
		}
	}
}

cout << "Yes";

return 0;
}

Measured memory_bytes: 20224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int h = Integer.parseInt(lines[0]);
      int w = Integer.parseInt(lines[1]);
      boolean[][] mat = new boolean[h][w];

      String line;
      for(int y=0; y<h; y++) {
        line = in.readLine();
        for(int x=0; x<w; x++) {
          mat[y][x] = line.charAt(x) == '#' ? true : false;
        }
      }

      int[] rx = {0,0,-1,1};
      int[] ry = {-1,1,0,0};
      boolean result = true;
      boolean isPossible = false;
      for(int y=0; result && y<h; y++) {
        for(int x=0; result && x<w; x++) {
          if(mat[y][x]) {
            for(int i=0; i<4; i++) {
              if(y+ry[i] > -1 && y+ry[i] < h && x+rx[i] > -1 && x+rx[i] < w)
                if(mat[y+ry[i]][x+rx[i]]) {
                  isPossible = true;
                  break;
                }
            }
            if(isPossible) isPossible = false;
            else {
              result = false;
              // System.out.println( y + " " + x);
            }
          }
        }
      }

      String ans = result ? "Yes" : "No";
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

int main() {

	int n, m;
	cin >> n >> m;

	vector<int> a(n + 1);

	for (int i = 0; i < m; i++) {
		int num;
		cin >> num;
		a[num] = 1;
	}

	vector<int> dp(n + 2);

	int mod = 1000000007;

	dp[n] = 1;

	for (int i = n-1; i >= 0; i--) {
		if (a[i]) {
			dp[i] = 0;
			continue;
		}
		dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
	}

	cout << dp[0] << endl;
}


Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int result = 0;
		int N = sc.nextInt();
		HashMap<String,Integer> map = new HashMap<String,Integer>();
		for(int i = 0; i < N; i++) {
			String s = sc.next();
			if(map.containsKey(s)) {
				map.replace(s, map.get(s) +1);
			}else {
				map.put(s, 1);
			}
		}

		int M = sc.nextInt();
		for(int i = 0; i < M; i++) {
			String t = sc.next();
			if(map.containsKey(t)) {
				map.replace(t, map.get(t) -1);
			}
		}

		for(int num : map.values()) {
			result = Math.max(result, num);
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(a[i]%2!=0){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    ll ma = 0;
    ll ans = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(ma < a) {
            ma = a;
        }
        else {
            ans += ma - a;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int a, b, c; cin >> a>> b>> c;
        int rm= c- a;
        cout << max(0ll, a- c) << " "<< max(0ll, b- (rm>= 0? rm: 0));
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

void dfs(const vector<vector<int>>& graph, vector<int>& dist, int node) {
    rep(i, 0, graph[node].size()) {
        if (dist[graph[node][i]] >= 0) continue;
        dist[graph[node][i]] = dist[node] + 1;
        dfs(graph, dist, graph[node][i]);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, U, V;
    cin >> N >> U >> V;
    --U, --V;
    int A, B;
    vector<vector<int>> graph(N);
    rep(i, 0, N - 1) {
        cin >> A >> B;
        --A, --B;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }
    vector<int> dist1(N, -1);
    dist1[V] = 0;
    dfs(graph, dist1, V);
    int max_node = -1;
    int max_dist = -1;
    rep(i, 0, N) {
        if (max_dist < dist1[i]) {
            max_node = i;
            max_dist = dist1[i];
        }
    }
    vector<int> dist2(N, -1);
    dist2[U] = 0;
    dfs(graph, dist2, U);
    if (dist1[max_node] > dist2[max_node]) {
        cout << dist1[max_node] - 1 << endl;
    }
    else {
        int max_dist = 0;
        rep(i, 0, N) {
            if (dist1[U] <= dist1[i] && dist1[i] > dist2[i]) {
                max_dist = max(max_dist, dist1[i]);
            }
        }
        cout << max_dist - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10368
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	if (K < 0) {
		M *= -1;
		K *= -1;
	}
	if (!K) {
		if (!M)cout << 1 << endl;
		else cout << N + 1 << endl;
		return 0;
	}
	map<long long int, set<pair<long long int, long long int>>>st;
	long long int ans = 1;
	st[0].insert({ 0,0 });
	for (long long int i = 1; i <= N; i++) {
		L = i * (i - 1) / 2;
		R = (N - 1)*i - L;
		long long int sum = M * i;
		long long int md = sum;
		if (md < 0) {
			md += abs(sum) / K * K;
			md += K;
		}
		md %= K;
		if (sum >= 0) {
			L += sum / K;
			R += sum / K;
		}
		else {
			L -= abs(sum) / K;
			R -= abs(sum) / K;
			if (abs(sum) % K) {
				L--, R--;
			}
		}
		st[md].insert({ -MOD * MOD * 2,-MOD * MOD * 2 });
		//cout <<i<<" "<< md << " " << L << " " << R << endl;
		while (1) {
			auto it = st[md].lower_bound(make_pair(L, -MOD * MOD * 2));
			if (it == st[md].end())break;
			if (it->first > R + 1)break;
			ans -= it->second - it->first + 1;
			R = max(R, it->second);
			st[md].erase(it);
		}
		while (1) {
			auto it = st[md].lower_bound(make_pair(L, -MOD * MOD * 2));
			if (it == st[md].begin())break;
			it = prev(it);
			if (it->second < L - 1)break;
			ans -= it->second - it->first + 1;
			L = it->first;
			R = max(R, it->second);
			st[md].erase(it);
		}
		ans += R - L + 1;
		st[md].insert({ L,R });
	//	cout << ans << endl;
	}
	cout << ans << endl;
}

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


int main(void)
{
    int n,m,i,max=0,j,c=0,i2,j2,l2;
    char s[100][11],t[100][11];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",s[i]);
    }   
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%s",t[i]);
    }   
    for(i=0;i<n;i++){
        c=1;
        for(j=i+1;j<n;j++){
            if(strcmp(s[i],s[j])==0) c++;
    
        }
        for(j=0;j<m;j++){
            if(strcmp(s[i],t[j])==0) c--;
        }
        if(max<c) max=c;
    }
        
    if(max<0) printf("0\n");
    else printf("%d\n",max);
        


    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	LLONG N, M; cin >> N >> M;
	if (N == 1 && M == 1)
	{
		cout << 1 << endl;
	}
	else if (N == 1)
	{
		cout << M - 2 << endl;
	}
	else if (M == 1)
	{
		cout << N - 2 << endl;
	}
	else
	{
		cout << (N - 2) * (M - 2) << endl;
	}
}

Measured memory_bytes: 3624
n,k=map(int,input().split())
t=[0]*n
for i in range(k):
  a=int(input())
  b=list(map(int,input().split()))
  for j in range(a):
    c=b[j]-1
    t[c]+=1
count=0
for l in range(n):
  if t[l]==0:
    count+=1
print(count)

Measured memory_bytes: 9192
#include<cstdio>
#include<algorithm>
using namespace std;
int p[100010];
int cst[100010];
int find(int u)
{
	if (u == p[u])return u;
	return p[u] = find(p[u]);
}
void merge(int u, int v)
{
	u = find(u), v = find(v);
	p[u] = v;
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &cst[i]);
		p[i] = i;
	}
	for (int i = 0; i < m; i++)
	{
		int q, w;
		scanf("%d %d", &q, &w);
		merge(q, w);
	}
	int dap = 0;
	for (int i = 1; i <= n; i++)
	{
		if (find(i) == find(cst[i]))
			dap++;
	}
	printf("%d", dap);
}

Measured memory_bytes: 896
#include <iostream>

using namespace std ;

int max(int a, int b){
    if (a>b)
        return a ;
    else
        return b ;
}

int maxPoints(int a[], int b[], int c[], int n){
    
    int points[n][3] ;
    points[0][0] = a[0] ;
    points[0][1] = b[0] ;
    points[0][2] = c[0] ;

//    if (n==1)
//        return (max(a[0], b[0]), c[0]) ;
    for (int i=1 ; i<n ; i++){
        points[i][0] = max(points[i-1][1], points[i-1][2]) + a[i] ;
        points[i][1] = max(points[i-1][0], points[i-1][2]) + b[i] ;
        points[i][2] = max(points[i-1][0], points[i-1][1]) + c[i] ;
    }
    
    return max(max(points[n-1][0], points[n-1][1]), points[n-1][2]) ;
    
}

int main(){
    int n ;
    cin >> n ;
    int a[n], b[n], c[n] ;
    
    for (int i=0 ; i<n ; i++)
        cin >> a[i] >> b[i] >> c[i] ;
    
    cout << maxPoints(a, b, c, n) ;
    
    
    return 0 ;
}


Measured memory_bytes: 2560
n=int(input())
a=list(map(int,input().split()))
max1=0
i=0
w=0
while(i<n-1):
    if(a[i]>=a[i+1]):
        i+=1
        max1+=1
    else:
        w=max(w,max1)
        max1=0
        i+=1
print(max(w,max1))
        


Measured memory_bytes: 14252