akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
struct Data{
    int x,y,dir,cost;
};
const int INF = 1e18;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
signed main(){
    int h,w,k;cin >> h >> w >> k;
    vector<vector<vector<int>>> dist(h,vector<vector<int>> (w,vector<int> (4,INF)));
    int sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
    sx--;sy--;gx--;gy--;
    vector<string> f(h);
    rep(i,h)cin >> f[i];
    auto comp = [](const Data &a,const Data &b){
        return a.cost > b.cost;
    };
    priority_queue<Data,vector<Data>,decltype(comp)> pq{comp};
    auto push = [&](int x,int y,int dir,int cost){
        if(x < 0 || y < 0 || x > h-1 || y > w-1)return;
        if(dir < 0 || dir > 3)return;
        if(f[x][y] == '@')return;
        if(dist[x][y][dir] <= cost)return;
        // trace(x,y,dir,cost);
        dist[x][y][dir] = cost;
        pq.push((Data){x,y,dir,cost});
    };
    rep(i,4)push(sx,sy,i,0);
    while(pq.size()){
        auto now = pq.top();pq.pop();
        if(dist[now.x][now.y][now.dir] != now.cost)continue;
        rep(i,4){
            if(now.dir == i){
                int nx = now.x + dx[i],ny = now.y + dy[i];
                push(nx,ny,i,now.cost + 1);
            }
            else push(now.x,now.y,i,(now.cost + k-1)/k * k);
            
        }
    }
    int ret = INF;
    rep(i,4)ret = min(ret,dist[gx][gy][i]);
    if(ret == INF)cout << -1 << endl;
    else cout << (ret + k-1)/k << endl;
    // trace(dist[gx][gy]);
    return 0;
}

Measured memory_bytes: 143912
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

vector<vector<int>> to(100000);
map<P, int> weight;
vector<int> color(100000);

void dfs(int u, int p = -1, int len = 0){
  if(len) color[u] = 1;

  for(int v : to[u]){
    if(v == p) continue;
    int w = weight[P(u, v)];
    dfs(v, u, len xor w);
  }
}

int main(void){
  int n;
  cin >> n;
  REP(i, n-1){
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    w %= 2;
    to[u].emplace_back(v);
    to[v].emplace_back(u);
    weight[P(u, v)] = w;
    weight[P(v, u)] = w;
  }

  dfs(0);
  REP(i, n) cout << color[i] << endl;
  return 0;
}

Measured memory_bytes: 23168
#include<iostream>
using namespace std;
int main(){
    int k,a,b,check,ans=0;
    cin>>k>>a>>b;
    check=b-a;
    for(int i=0;i<=check;i++){
        if(a%k==0){
            ans=1;
            break;
        }
        a++;
    }
    if(ans==1)
        cout<<"OK\n";
    else
        cout<<"NG\n";
}

Measured memory_bytes: 3576
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
//?¶????????????????????????????????????§??????????????????????¢????????????????
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	int n;
	while (cin >> n&&n) {
		bool treasure[21][21] = {};
		int x, y;
		for (int i = 0; i < n; i++) {
			cin >> x >> y;
			treasure[y][x] = true;
		}
		int m;
		cin >> m;
		char c;
		int a;
		int ans = 0;
		int posx = 10, posy = 10;
		for (int i = 0; i < m; i++) {
			cin >> c >> a;
			if (c == 'S') {
				for (int count = 1; count <= a; count++) {
					if (treasure[posy - count][posx])ans++, treasure[posy - count][posx] = false;
				}
				posy = posy - a;
			}
			if (c == 'N') {
				for (int count = 1; count <= a; count++) {
					if (treasure[posy + count][posx])ans++, treasure[posy + count][posx] = false;
				}
				posy = posy + a;
			}
			if (c == 'E') {
				for (int count = 1; count <= a; count++) {
					if (treasure[posy][posx + count])ans++, treasure[posy][posx + count] = false;
				}
				posx = posx + a;
			}
			if (c == 'W') {
				for (int count = 1; count <= a; count++) {
					if (treasure[posy][posx - count])ans++, treasure[posy][posx - count] = false;
				}
				posx = posx - a;
			}
		}
		cout << (ans == n ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 3088
from math import ceil
N, K = map(int, input().split())
S = 'x' + input() + 'x'

ans = 0
X = ''
ns = ''

for i, s in enumerate(S[1:-1], start=1):
    if s == 'L':
        if S[i - 1] == 'L':
            ans += 1
        else:
            X += s

    else:
        if S[i + 1] == 'R':
            ans += 1
        else:
            X += s


target = 'L' if X[0] == 'R' else 'R'
k_cnt = 0
for i, x in enumerate(X):
    if x == target and k_cnt < K:
        k_cnt += 1
        if i == len(X) - 1:
            ans += 1
        else:
            ans += 2

print(ans)


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

using namespace std;

const long long MOD=1e9+7;

int main() {
    int N,M; cin>>N>>M;

    vector<int> oks(N+1,true);
    for (int i=0;i<M;i++) {
        int a; cin>>a;
        oks[a]=false;
    }

    vector<long long int > dp(N+1);
    dp[0]=1;
    for (int now=0;now<N;now++){
        for (int next=now+1;next<=min(N,now+2);next++){
            if (oks[next]) {
                dp[next]+=dp[now];
                dp[next]%=MOD;
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <cstring>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
int n,p,px,py,o;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        int t,x,y;
        cin>>t>>x>>y;
        int d=abs(x-px)+abs(y-py),c=t-p;
        if(c<d||(d-c)%2){
            o=1;
            break;
        }
        px=x;
        py=y;
        p=t;
    }
    if(o)cout<<"No\n";
    else cout<<"Yes\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    string S;
    int cnt = 0;

    cin >> S;

    for(int i = 0;i < S.length();i++){
        if(S[i] == 'o')cnt++;
    }

    if(cnt + (15 - S.length()) >= 8)cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

int main() {
  string S;
  int Q;
  
  cin >> S >> Q;
  
  vector<int> T(Q);
  vector<int> F(Q);
  vector<string> C(Q);
  
  for(int i = 0; i < Q; i++){
    cin >>  T.at(i);
    if(T.at(i) == 2){
      cin >> F.at(i) >> C.at(i);
    }
  }
  
  double parity = 1;
  
  for(int i = 0; i < Q; i++){
    if(T.at(i) == 1){
      parity *= -1;
    }else if(T.at(i) == 2){
      if(F.at(i) == 1 && parity == 1 || F.at(i) == 2 && parity == -1){
        S.insert(0, C.at(i));
      }else{
        S.append(C.at(i));
      }
    }
  }
  
  if(parity == -1){
    reverse(S.begin(), S.end());
  }

  
  cout << S << endl;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int a,b;
  a=0;
  b=0;
  for(int j=0;j<N;j++){
    if(j%2==0){
      a+=vec.at(N-1-j);
    }
    if(j%2==1){
      b+=vec.at(N-1-j);
    }
  }
  cout << a-b << endl;}
    
  

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 100
#define INF 1e8

int main(){
  int N,i,j,k,l,q,r[MAX_N],c[MAX_N],p[MAX_N+1];
  int dp[MAX_N+1][MAX_N+1];
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d%d",&r[i],&c[i]);
  }
  p[0] = r[0];
  for(i = 1 ; i <= N ; i++){
    p[i] = c[i-1];
  }
  N++;
  for(i = 0 ; i < N ; i++){
    dp[i][i] = 0;
  }
  for(l = 2 ; l < N ; l++){
    for(i = 1 ; i < N-l+1 ; i++){
      j = i + l - 1;
      dp[i][j] = INF;
      for(k = i ; k <= j-1 ; k++){
        q = dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j];
        if(q < dp[i][j]){
          dp[i][j] = q;
        }
      }
    }
  }
  printf("%d\n",dp[1][N-1]);
  return 0;
}

Measured memory_bytes: 1064
def f(x, y):
	if y == 0:
		return 0
	return [3, 5, 7][x % 3] + f(int(x / 3), y - 1) * 10

N = int(input())
ans = 0
for i in range(3, 10):
	if 10 ** (i - 1) > N:
		break
	for j in range(3 ** i):
		a = f(j, i)
		if a <= N:
			if set(str(a)) == set("357"):
				ans = ans + 1
		else:
			break
print(ans)

Measured memory_bytes: 3064
function main(input) {
    var arr = input.replace(/\r?\n/g, "").split(" ");
    const A = arr[0], B = arr[1], C = arr[2];
    var flg = false;
    if (A == B && B != C) flg = true;
    if (B == C && C != A) flg = true;
    if (C == A && A != B) flg = true;
    if (flg) console.log("Yes");
    else console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int n; cin >> n;
  vector<vector<int>> e(n);
  rep(i, n - 1){
    int a, b; cin >> a >> b;
    a--; b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());

  int cid = 0;
  vector<int> t(n, -1);
  t[0] = c[cid];
  cid++;
  queue<int> q;
  q.push(0);
  int ans = 0;
  while(q.size() > 0){
    int now = q.front(); q.pop();
    for(int next : e[now]){
      if(t[next] != -1) continue;
      q.push(next);
      t[next] = c[cid];
      ans += c[cid];
      cid++;
    }
  }
  cout << ans << endl;
  rep(i, n){
    cout << t[i] << " ";
  }
  return 0;
}


Measured memory_bytes: 4016
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))



int main(){
	char a, b;
	cin >> a >> b;

	if ( a == b ) cout << "H" << endl;
	if ( a != b ) cout << "D" << endl;

}


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

int main(){
  string s;
  long long K;
  cin >> s >> K;
  for (int i=0; i<K; i++){
    if (s[i] != '1'){
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << '1' << endl;
}


Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll N,M,x[1001],y[1001],z[1001];
    std::cin >> N>>M;
    ll sum_ppp[1001];//mmm
    ll sum_ppm[1001];//mmp
    ll sum_pmp[1001];//mpm
    ll sum_mpp[1001];//pmm
    
    for (int i = 0; i < N; i++) {
        cin >>x[i]>>y[i]>>z[i];
        sum_ppp[i]=x[i]+y[i]+z[i];
        sum_ppm[i]=x[i]+y[i]-z[i];
        sum_pmp[i]=x[i]-y[i]+z[i];
        sum_mpp[i]=-x[i]+y[i]+z[i];
    }
    sort(sum_ppp,sum_ppp+N);
    sort(sum_ppm,sum_ppm+N);
    sort(sum_pmp,sum_pmp+N);
    sort(sum_mpp,sum_mpp+N);
    
    ll res=0;
    
    ll tmp_res1=0;
    ll tmp_res2=0;
    ll tmp_res3=0;
    ll tmp_res4=0;
    ll tmp_res5=0;
    ll tmp_res6=0;
    ll tmp_res7=0;
    ll tmp_res8=0;

    for (int i = 0; i < M; i++) {
        tmp_res1+=sum_ppp[i];
        tmp_res2+=sum_ppm[i];
        tmp_res3+=sum_pmp[i];
        tmp_res4+=sum_mpp[i];

        tmp_res5+=sum_ppp[N-M+i];
        tmp_res6+=sum_ppm[N-M+i];
        tmp_res7+=sum_pmp[N-M+i];
        tmp_res8+=sum_mpp[N-M+i];
    }

    res=max(res,abs(tmp_res1));
    res=max(res,abs(tmp_res2));
    res=max(res,abs(tmp_res3));
    res=max(res,abs(tmp_res4));
    res=max(res,abs(tmp_res5));
    res=max(res,abs(tmp_res6));
    res=max(res,abs(tmp_res7));
    res=max(res,abs(tmp_res8));
    
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
(* 配列版素集合データ構造 *)
module UnionFind : sig
  type t

  module Class : sig
    type t
    val compare : t -> t -> int
  end

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> Class.t
  (* 与えられた集合同士を合併する *)
  (* 破壊的操作であるため注意 *)
  val unite : t -> Class.t -> Class.t -> unit
  (* 与えられた集合に属する要素の数を求める *)
  val cardinal : t -> Class.t -> int
end = struct
  type t = int array

  module Class = struct
    type t = int
    let compare = compare
  end

  let make n = Array.make n (-1)

  let rec find uf x =
    if uf.(x) < 0 then x
    else begin
      let y = find uf uf.(x) in
      uf.(x) <- y; y
    end

  let unite uf x y =
    if x <> y then begin
      let x, y = if uf.(x) <= uf.(y) then x, y else y, x in
      uf.(x) <- uf.(x) + uf.(y);
      uf.(y) <- x
    end

  let cardinal uf x = ~- (uf.(x))
end

module ClassSet = Set.Make (UnionFind.Class)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let uf = UnionFind.make n in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d %d\n" @@ fun x y _ ->
      UnionFind.unite uf
        (UnionFind.find uf (x - 1))
        (UnionFind.find uf (y - 1))
  done;
  Printf.printf "%d\n" @@
  ClassSet.cardinal @@
  Array.fold_right ClassSet.add (Array.init n @@ UnionFind.find uf) ClassSet.empty

Measured memory_bytes: 7296
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 1000000000000000 //1e16
 
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}


const int maxn=1e6+5;
vi Union(maxn),Size(maxn);

void initialize(int N)
{
    for(int i=0;i<=N;i++)
    {
        Union[i]=i;
        Size[i]=1;
    }
}

int root(int i)
{
    if(i==Union[i]) return i;
    return Union[i]=root(Union[i]);
}

void unite(int A ,int B)  //for setting custom root, lets for 
{                         //lexicographically smallest something
    int root_A=root(A);       
    int root_B=root(B);  
    Union[root_A]=root_B; 
}

void weightedUnion(int A,int B)
{
    int a=root(A);
    int b=root(B);
    if(a!=b) 
    {
        if(Size[a]<Size[b])
        {
            swap(a,b);
        }
        Union[b]=a;
        Size[a]+=Size[b];
    }
}

bool find(int A,int B)
{
    if(root(A)==root(B)) 
    {
        return true;
    }
    else
    {
        return false;
    }
}

void solve()
{
    int n,m,t,i,k,r,l,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T; 
    int d;
    cin>>n>>m;
    initialize(n+1);
    vi U(m),V(m);
    rep(i,0,m)
    {
        cin>>u>>v;
        weightedUnion(u,v);
        U[i]=u;
        V[i]=v;
    }
    rep(i,0,m)
    {
        weightedUnion(U[i],V[i]);
    }
    map<int,int> cnt;
    rep(i,1,n+1) cnt[root(i)]++;
    int ans=0;
    for(auto x:cnt)
    {
        ans=max(ans,x.S);
    }
    cout<<ans;
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 31352
var N = 0
var A = 0

fun main(args: Array<String>) {
    readLine()?.split(" ")?.map {
        it.toInt()
    }?.let {
        N = it[0]
        A = it[1]
    }


    val x = Array(N + 1) { 0 }
    readLine()?.split(" ")?.map {
        it.toInt()
    }?.forEachIndexed { i, n ->
        x[i + 1] = n
    }

    val dp = Array(N + 1) {
        Array(N + 1) {
            Array(N * A + 1) { 0L }
        }
    }
    for (i in 0..N) {
        dp[i][0][0] = 1
    }

    for (i in 1..N) {
        for (j in 1..i) {
            for (k in 1..(N * A)) {
                dp[i][j][k] = if (k < x[i]) {
                    dp[i - 1][j][k]
                } else {
                    dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]
                }
            }
        }
    }

    var ans = 0L
    for (j in 1..N) {
        ans += dp[N][j][j * A]
    }

    println(ans)
}



Measured memory_bytes: 63512
import std.stdio;
import std.string;
import std.conv;

void main(){
    int n;
    while((n = readln.chomp.to!int) != 0){
        string input = readln.chomp;
        foreach(Unused; 0..n){
            input = input.operate;
        }
        input.writeln;
    }
}

string operate(string input){
    string res;
    char current = input[0];
    int count = 1;
    foreach(c; input[1..$]){
        if(current == c){
            ++count;
        }else{
            res ~= text(count, current);
            current = c;
            count = 1;
        }
    }
    res ~= text(count, current);
    return res;
}

Measured memory_bytes: 2072
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define N 100010
#define ll long long
using namespace std;
int n, d[N], m, s[N], x, b[N], pos[N], p[N], flag[N], l;
ll w[N], k;
vector<int>son[N];
inline void dfs(int x){
	son[l].push_back(x); flag[x]=1; p[x]=l; pos[x]=son[l].size()-1;
	if(!flag[b[x]])dfs(b[x]);
}
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)scanf("%lld", &w[i]);
	for(int i=1; i<=n-1; i++)d[i]=w[i+1]-w[i];
	scanf("%d%lld", &m, &k);
	for(int i=1; i<=n-1; i++)b[i]=i;
	for(int i=1; i<=m; i++){scanf("%d", &x); swap(b[x-1], b[x]);}
	for(int i=1; i<=n-1; i++)pos[b[i]]=i; memcpy(b, pos, sizeof(b));
	l=0; memset(flag, 0, sizeof(flag));
	for(int i=1; i<=n-1; i++)if(!flag[i]){l++; son[l].clear(); dfs(i);}
	for(int i=1; i<=n-1; i++){
		x=(k+pos[i])%son[p[i]].size();
		s[son[p[i]][x]]=d[i];
	}
	for(int i=1; i<=n-1; i++)w[i+1]=w[i]+s[i];
	for(int i=1; i<=n; i++)printf("%lld\n", w[i]);
	return 0;
}

Measured memory_bytes: 9856
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    count = 0
    for i in h:
        if i >= K:
            count += 1
    print(count)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


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

#define int        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<int>
#define v2d        vector<vector<int>>
#define vip        vector<pair<int,int> >
#define v1s        vector<string>
#define pa         pair<int,int>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<"\n";
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define endl       "\n"
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();
int lb = 1000;
#define Exit    lb--;if(lb<0){cout<<"exit";exit(0);}

void azmuth(int n=12){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout<<setprecision(n)<<fixed;
	#ifndef ONLINE_JUDGE
		 freopen("input.txt",  "r",  stdin);
		 freopen("output.txt", "w", stdout);
	#endif
}

//____________________________________________________________________________________


void solve(){
	long double a,b;cin >> a >> b;
	int ans = a*b;
	cout << ans;
}

int32_t main(){
	//azmuth();
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	


	return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>
int main(){
  char S[3];
  int count=0;
  setbuf(stdout,NULL);
  scanf("%s",S);
  if(S[0]=='R'){
    count++;
    if(S[1]=='R'){
      count++;
      if(S[2]=='R'){
        count++;
      }
    }
  }
  else if(S[1]=='R'){
    count++;
    if(S[2]=='R'){
      count++;
    }
  }
  else if(S[2]=='R'){
    count++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1724
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  6 18:01:32 2019

@author: Yamazaki Kenichi
"""

n = int(input())
A = [list(map(int,input().split())) for i in range(n)]
INFTY = 10**6
T = [-1 for i in range(n)]
d = [INFTY for i in range(n)]
p = [0 for i in range(n)]
d[0], p[0] = 0, -1
for j in range(n):
    mincost = 10**6
    for i in range(n):
        if T[i] != 1 and d[i] < mincost:
            mincost = d[i]
            u = i
    T[u] = 1
    for v in range(n):
        if T[v] != 1 and A[u][v] != -1:
            if A[u][v] < d[v]:
                d[v] = A[u][v]
                p[v] = u
                T[v] = 0
print(sum(d))



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

int n;
vector<int> a;

int check(int m){
    map<int,int> mp;
    rep1(i,n-1){
        if(a[i-1] < a[i]) continue;
        if(m == 1) return false;
        int pos = a[i];
        mp.erase(mp.upper_bound(pos), mp.end());
        while(true){
            if(mp[pos] < m - 1){
                mp[pos]++;
                mp.erase(mp.upper_bound(pos), mp.end());
                break;
            }
            pos--;
            if(pos == 0) return false;
        }
    }
    return true;
}

int main(void){
    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a[i];
    int l = 0, r = n;
    while(l+1 < r){
        int m = (l+r)/2;
        if(check(m)){
            r = m;
        }else{
            l = m;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {
    FastIO sc;
    int n;
    int[] dp;
    int M = 1000000007;

    void solve() throws Exception {
        int n = sc.nextInt();
        System.out.println(2*Math.PI*n);
    }

    void run() {
        try {
            sc = new FastIO();
            solve();
            sc.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(abs(-1));
        }
    }

    public static void main(String[] args) {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception ignore) {
        }
        new Main().run();
    }

    class FastIO extends PrintWriter {
        private BufferedReader in;
        private StringTokenizer stok;

        FastIO() {
            super(System.out);
            in = new BufferedReader(new InputStreamReader(System.in));
        }

        FastIO(String s) throws FileNotFoundException {
            super("".equals(s) ? "output.txt" : s + ".out");
            in = new BufferedReader(new FileReader("".equals(s) ? "input.txt" : s + ".in"));
        }

        @Override
        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }

        String next() {
            while (stok == null || !stok.hasMoreTokens()) {
                try {
                    stok = new StringTokenizer(in.readLine());
                } catch (Exception e) {
                    return null;
                }
            }
            return stok.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            try {
                return in.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        char[] nextCharArray() {
            return next().toCharArray();
        }
    }

    class Pair {
        int mon, fac;

        Pair(int mon, int fac) {
            this.mon = mon;
            this.fac = fac;
        }
    }

    void randomShuffle(int[] a) {
        Random random = new Random();
        for (int i = 1; i < a.length; i++) {
            int x = random.nextInt(i + 1);
            int xchg = a[i];
            a[i] = a[x];
            a[x] = xchg;
        }
    }

    static boolean even(int n) {
        int r = n & 1;
        return r != 1 ? true : false;
    }
}

Measured memory_bytes: 33276
#include <stdio.h>

int idx(int *a, int len, int n)
{
  for (int i=0; i<len; i++)
    if (a[i]==n) return i;
  return -1;
}


int main()
{
  int i, j, k, t, m, n[6];
  scanf("%d %d %d %d %d %d", n, n+1, n+2, n+3, n+4, n+5);
  int p[6][4] = {{2,3,5,4}, {3,1,4,6}, {2,6,5,1},
		 {1,5,6,2}, {1,3,6,4}, {2,4,5,3}};
  scanf("%d", &k);
  for (i=0; i<k; i++) {
    scanf("%d %d", &t, &m);
    t = idx(n, 6, t);
    m = idx(n, 6, m) + 1;
    printf("%d\n", n[p[t][(idx(p[t], 4, m)+1)%4]-1]);
  }

  return 0;
}



Measured memory_bytes: 2104
import sys
from heapq import heapify, heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline

H, W = map(int, readline().split())
s = tuple(map(str, read().split()))
INF = 10 ** 10
grid = [[INF] * W for _ in range(H)]
if s[0][0] == '#':
    start = (1, (0, 0))
else:
    start = (0, (0, 0))
heap = [start]
heapify(heap)
while heap:
    d, (x, y) = heappop(heap)
    if grid[x][y] != INF:
        continue
    grid[x][y] = d
    for i, j in ((0, 1), (1, 0)):
        new_x = x + i
        new_y = y + j
        if new_x == H or new_y == W:
            continue
        if grid[new_x][new_y] <= d:
            continue
        if s[x][y] == '.' and s[new_x][new_y] == '#':
            heappush(heap, (d + 1, (new_x, new_y)))
        else:
            heappush(heap, (d, (new_x, new_y)))

print(grid[-1][-1])


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

int main(){
    long long a,b,k;
    cin >> a >> b >> k;

    if (a-k >= 0){
        cout << a-k << " " << b << endl;
    }else if (a-k < 0 && b-k+a >= 0){
        cout << 0 << " " << b-k+a << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	static BufferedReader br;

	public static void main(String[] args) {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			String S = br.readLine();
			long length = S.length();
			long sum = 0;
			for (int i = 0; i < length; i++) {
				long left = (long) Math.ceil(Math.pow(2, i - 1));
				for (int j = i + 1; j < length + 1; j++) {
					sum += (long) left * Long.valueOf(S.substring(i, j))
							* Math.ceil(Math.pow(2, length - j - 1));
				}
			}
			System.out.println(sum);
		} catch (Exception e) {
			System.err.println("Error : " + e.getMessage());
		}
	}
}


Measured memory_bytes: 8272
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

dp = np.array([0] * N)

for i in range(1, N):
    j = max(0, i-K)
    dp[i] = (dp[j:i] + np.abs(h[i] - h[j:i])).min()


print(dp[-1])

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

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

    int A, B;
    cin >> A >> B;

    if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
        cout << A * B << endl;
        return 0;
    }

    cout << -1 << "\n";
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int a=0;
    rep(i,3){
        a += (s[i]==t[i]);
    }
    cout << a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
 int c=0,flag=0;
 cin>>s;
 if(s[0]==s[1]&&s[1]==s[2])
 	flag=1;
if(s[3]==s[1]&&s[1]==s[2])
 	flag=1;
 if(flag)
 cout<<"Yes"<<endl;
else
	cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, k;
	cin >> n >> k;
	vll a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}

	ll now = 0;
	vll v(1, 0);
	vll visit(n, -1);
	visit[0] = 0;
	for (ll i = 0; i < k; i++) {
		now = a[now];
		if (visit[now] > -1) {
			ll cnt = i + 1;
			ll prev = visit[now];
			k -= prev;
			cout << v[prev + k % (cnt - prev)] + 1 << endl;
			return 0;
		}
		v.push_back(now);
		visit[now] = i + 1;
	}
	cout << v.back() + 1 << endl;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

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

    int x, i = 0;
    while (cin >> x)
    {
        if (x == 0)
        {
            break;
        }

        ++i;
        cout << "Case " << i << ": " << x << endl;
    }

    return 0;
}



Measured memory_bytes: 3192
s, t = input(), input()
n, m = len(s), len(t)
dp = [[0]*-~m for _ in [0]*-~n]
for i in range(n):
  for j in range(m):
    dp[i+1][j+1] = dp[i][j] + 1 if s[i] == t[j] else max(dp[i][j+1], dp[i+1][j])
R = ""
while n and m:
  if   dp[n][m] == dp[n-1][m]:n -= 1
  elif dp[n][m] == dp[n][m-1]:m -= 1
  else:n -= 1;m -= 1;R = s[n] + R
print(R)

Measured memory_bytes: 144604
package main

import "fmt"

func main() {
	var a, b int
	var op string
	for {
		fmt.Scanln(&a, &op, &b)
		if op == "?" {
			break
		}
		switch op {
		case "+":
			fmt.Println(a + b)
		case "-":
			fmt.Println(a - b)
		case "*":
			fmt.Println(a * b)
		default:
			if b != 0 {
				fmt.Println(a / b)
			}
		}
	}
	return
}



Measured memory_bytes: 1132
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] L = new int[N];
            for (int i = 0; i < N; i++) {
                L[i] = in.nextInt();
            }
            Arrays.sort(L);

            long sum = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    for (int k = j + 1; k < N; k++) {
                        if (L[i] + L[j] <= L[k]) {
                            break;
                        }
                        sum++;
                    }
                }
            }
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22356
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int sum=0;
	rep(i,a+1){
		rep(j,b+1){
			rep(k,c+1){
				if(x==i*500+j*100+k*50)sum++;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	ll 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;
}
// END

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N;
  map<int, int> mp;
  rep(i,N) { int a; cin >> a; mp[a]++; }
  int ans = 0;
  
  if(mp.size() %2 == 0) ans = mp.size()-1;
  else ans = mp.size();
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int moji = 0;
    if(N==1){
        cout << "a" << endl;
        return 0;
    }
    deque<string> deq;
    deque<int> cnt;
    cnt.push_back(1);
    deq.push_back("a");
    vector<string> ans;
    while(deq.size()!=0){
        string tmp = deq.back();
        deq.pop_back();
        int tmp_c = cnt.back();
        cnt.pop_back();
        for(int i=0;i<=tmp_c;i++){
            char c = 'a'+ i;
            string s = tmp + c;
            if(s.size()==N){
                ans.push_back(s);
                continue;
            }
            deq.push_back(s);
            if(i==tmp_c){
                cnt.push_back(tmp_c+1);
            }else{
                cnt.push_back(tmp_c);
            }
        }
    }
    sort(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++){
        cout << ans[i] << endl;
    }    
    return 0;
}

Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  if (S.size() % 2 == 1) {
    S.erase(S.size() - 1);
  } else {
    S.erase(S.size() - 1);
    S.erase(S.size() - 1);
  }
  for (int i = S.size(); i >= 0; i-=2) {
    bool judge = true;
    for (int j = 0; j < i / 2; j++) {
      if (S[j] != S[j + (i / 2)]) judge = false;
    }
    if (judge) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    string s;
    cin >> s;
    int r = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R') r++;
    }
    if(r == 2)
    {
        if(s[1] != 'R') cout << 1 << endl;
        else cout << 2 << endl;
    }
    else cout << r << endl;
}




Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>

int main() {
    int n, buf, ans = 0;
    cin >> n;
    map<int, int> ma;
    
    rep(i, n) {
        cin >> buf;
        ma[buf]++;
    }
    
    for (auto u : ma) {
        if (u.first <= u.second) {
            ans += u.second - u.first;
        }
        else {
            ans += u.second;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPul(i, n) for (ull i = 0; i < (ull)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define REPRul(i, n) for(ull i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define FORul(i, m, n) for(ull i = m; i < (ull)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}


#if 0
map<ll,ull> fList;
ull f(ll x){
  if(fList.find(x)==fList.end()){
    if(x==-1){
      fList[-1]=0;
    }else if(x==0){
      fList[0]=1;
    }else{
      ll x_1=f(x-1);
      ll x_2=f(x-2);
      fList[x]=(x_1+x_2)%1000000007;
    }
  }
  return fList[x];
}
#else
ull f(ll x){
  map<ll, ull> fList;
  fList[-1]=0;
  fList[0]=1;
  FORl(i,1,x+1){
    fList[i]=(fList[i-2]+fList[i-1])%1000000007;
  }
  return fList[x];
}
#endif

int main() {
  ull n,m;cin>>n>>m;
  vector<ll> a(m+2);
  a[0]=-1;
  FORl(i,1,m+1){
    ll b;cin>>b;
    a[i]=b;
  }
  a[m+1]=n+1;
  
  ull ans=1;
  REPl(i,m+1){
    ull tmp=f(a[i+1]-a[i]-2);
    ans*=tmp;
    ans%=1000000007;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6528
h, w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
ans = []
for i in range(h):
  for j in range(w-1):
    if a[i][j] % 2 == 1:
      a[i][j] -= 1
      a[i][j+1] += 1
      ans.append([i+1, j+1, i+1, j+2])
for i in range(h-1):
  if a[i][w-1] % 2 == 1:
    a[i][w-1] -= 1
    a[i+1][w-1] += 1
    ans.append([i+1, w, i+2, w])
print(len(ans))
for p in ans:
  print(*p)

Measured memory_bytes: 32444
#include <iostream>
#include <cstdio>

using namespace std;

int main() {

	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if ((x+y) % 2 == 0) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

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

using ll = long long;

// ModCombination
namespace MC {
    const int MAX_N = 1000010;   // 10^6
    const ll MOD = 1000000007;  // 10^9+7

    array<ll, 2 * MAX_N + 1> fact;
    array<ll, 2 * MAX_N + 1> inv_fact;  // n!の逆元

    ll pow(ll a, ll b) {
        if (b == 0) return 1;
        else if (b % 2 == 0) {
            ll d = pow(a, b / 2);
            return (d * d) % MOD;
        } else {
            return (a * pow(a, b - 1)) % MOD;
        }
    }

    ll factorial(ll n) {
        return fact[n];
    }

    ll inverse(ll n) {
        return pow(n, MOD - 2);
    }

    ll inverse_factorial(ll n) {
        return inv_fact[n];
    }

    ll nPk(ll n, ll k) {
        if (n < 0 || n < k) return 0;
        else return (factorial(n) * inverse_factorial(n - k)) % MOD;
    }

    ll nCk(ll n, ll k) {
        if (n < 0 || n < k) return 0;
        else return (nPk(n, k) * inverse_factorial(k)) % MOD;
    }

    ll nHk(ll n, ll k) {
        if (n < 0 || k < 0) return 0;
        else if (k == 0) return 1;
        else return nCk(n + k - 1, k);
    }

    // 要素がn個あるとき
    void initialize(int n) {
        if (2 * n > 2 * MAX_N) {
            cerr << "現在のfactのサイズでは足りない可能性があります" << endl;
            exit(1);
        }

        // 階乗%MODを計算
        fact[0] = 1;
        for (ll i = 1; i <= 2 * MAX_N; i++) {
            fact[i] = (i * fact[i - 1]) % MOD;
        }
        // mod逆元の階乗を計算
        inv_fact[2 * MAX_N] = inverse(factorial(2 * MAX_N));
        for (ll i = 2 * MAX_N - 1; i >= 0; i--) {
            inv_fact[i] = ((i + 1) * inv_fact[i + 1]) % MOD;
        }
    }
};

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

    vector<int> a(n + 1), cnt(n + 1, 0);

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

    int l = -1, r = -1;
    for (int i = 0; i < n + 1; i++) {
        if (a[i] == dup_num) {
            if (l < 0) l = i;
            else r = i;
        }
    }

    MC::initialize(n + 1);

    for (int k = 1; k <= n + 1; k++) {
        ll ans = MC::nCk(n + 1, k);
        ans = (ans + MC::MOD - MC::nCk(l + (n + 1 - r - 1), k - 1)) % MC::MOD;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 33280
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD (long long)1e9+7
#define LINF (long long)4e18

int main(){
    int H,W; cin >> H >> W;
    vector<vector<char>> a(H,vector<char>(W));
    rep(i,H)rep(j,W) cin >> a[i][j];

    vector<bool> gyou(H,false);
    vector<bool> retu(W,false);

    rep(i,H){
        rep(j,W){
            if(a[i][j] == '#') gyou[i] = true;
        }
    }
    rep(i,W){
        rep(j,H){
            if(a[j][i] == '#') retu[i] = true;
        }
    }
    rep(i,H){
        rep(j,W){
            if(gyou[i] && retu[j]) cout << a[i][j];
        }
        cout << endl;
    }
}
   

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
 
	public static void main(String[] args)throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int A = Integer.parseInt(st.nextToken());
		int Q = Integer.parseInt(st.nextToken());
		String S = br.readLine();
		int []PrefixSumArr = new int[S.length() + 1];
		for(int i =1; i<S.length(); i++) {
			if(S.charAt(i-1)=='A' && S.charAt(i) == 'C') {
				PrefixSumArr[i]++;
			}
		}
		
		for(int i = 1; i<=S.length(); i++) PrefixSumArr[i] += PrefixSumArr[i-1];
		for(int i =0; i<Q; i++) {
			st = new StringTokenizer(br.readLine());
			int length = Integer.parseInt(st.nextToken());
			int row = Integer.parseInt(st.nextToken());
			int counter = PrefixSumArr[row-1] - PrefixSumArr[length-1];
			System.out.println(counter);
		}
			
		
	}
 
}

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

int main(){
  string s;
  int color[][3] = {
                    {0, 0, 0}, //black
                    {0, 0, 0xff}, //blue
                    {0, 0xff, 0}, //lime
                    {0, 0xff, 0xff}, //aqua
                    {0xff, 0, 0}, //red
                    {0xff, 0, 0xff}, //fuchsia
                    {0xff, 0xff, 0}, //yellow
                    {0xff, 0xff, 0xff} //white
  };
  string ans[] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};
  while(std::cin >> s, s != "0"){
    double min_val = 1e9;
    int num = -1;
    for (int i = 0; i < 8; i++) {
      double val = 0;
      unsigned int tmp;
      string type;
      // type = "0x" + s.substr(1, 2);
      type = s.substr(1, 2);
      // std::cout << type << std::endl;
      // sscanf("0x" + s.substr(), "%x", tmp);
      sscanf(type.c_str(), "%x", &tmp);
      // std::cout << type << std::endl;
      val += (color[i][0] - tmp)*(color[i][0] - tmp);
      
      type = "0x" + s.substr(3, 2);
      sscanf(type.c_str(), "%x", &tmp);
      val += (color[i][1] - tmp)*(color[i][1] - tmp);
      
      type = "0x" + s.substr(5, 2);
      sscanf(type.c_str(), "%x", &tmp);
      val += (color[i][2] - tmp)*(color[i][2] - tmp);
      if(min_val > val){
        min_val = val;
        num = i;
      }
    }
    std::cout << ans[num] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3284