akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdio.h>
#define MNUM 10
#define BNUM 3
 
int DescendingofTwo(int hei[],int no){
    int htemp;
    if(hei[no]>hei[no-1]){
        htemp=hei[no];
        hei[no]=hei[no-1];
        hei[no-1]=htemp;
//        printf("Changed!\n");
        return 1;
    }else{
//        printf("Not changed!\n");
        return 0;    
    }
}
 
int main(void) {
        int h[10]={};
    int flag;
    int i,j;
    for(i=0;i<MNUM;i++){
        scanf("%d",&h[i]);
    }
    for(j=1;j<MNUM;j++){
        flag=1;
//        printf("j is %d\n",j);
        for(i=j;i>0&&flag!=0;i--){
            flag=DescendingofTwo(h,i);
        }
//        printf("j is %d\n",j);
    }
    printf("%d\n%d\n%d\n",h[0],h[1],h[2]);
    
        return 0;
}

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


int main() {
  int n, bathp, poolp, batht, poolt, res, temp;

  cin >> n;

  for(int i = 0; i < n; i++) {
    cin >> bathp >> poolp >> batht >> poolt;
    res = bathp*batht + poolp*poolt;

    if(batht >= 5 && poolt >= 2) res = res * 4 / 5;

    if(batht < 5) batht = 5;
    if(poolt < 2) poolt = 2;

    temp = bathp*batht + poolp*poolt;

    if(batht >= 5 && poolt >= 2) temp = temp * 4 / 5;

    if(temp < res) res = temp;

    cout << res << endl;
    }

}

Measured memory_bytes: 1160
S = input()
N = len(S)

ans = []
RL = []
s = "R"
flag = False
for i in range(1, N):
  if S[i] == "L" or S[i] == "R" and S[i - 1] == "R":
    s += S[i]
  else:
    RL.append(s)
    s = "R"
RL.append(s)

for rl in RL:
  for i in range(len(rl)):
    if rl[i] == "R" and rl[i + 1] == "L" or rl[i] == "L" and rl[i - 1] == "R":
      if i % 2 == 1:
        ans.append(len(rl) // 2)
      else:
        ans.append((len(rl) + 1) // 2)
    else:
      ans.append(0)

for i in range(N):
  print(ans[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")

Measured memory_bytes: 8684
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD, MOD-2) % MOD;
  }

  int mod_pow(int n, int p){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;

signed main(){

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

  comb.init(200001);
  vector<int> cnt(200001, 0);
  for(int i = 0; i < n; i++){
    cnt[a[i]]++;
  }
  int sum = 0;
  for(int p : cnt){
    sum += p * (p - 1) / 2;
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    cout << sum - (cnt[a[i]] - 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 7296
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tok;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tok = null;
        }

        public InputReader(String inputFile) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(inputFile));
            tok = null;
        }

        public String nextLine() {
            String c = "";
            try {
                c = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return c;
        }

        public String next() {
            while (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(nextLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            return tok.nextToken();
        }

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

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

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

    public static void main(String args[]) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
        Task solver = new Task();
        solver.solve(in, out);
        out.flush();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = in.nextInt();
            int b[] = a.clone(); 
            for (int i = 0; i < n - 1; i++) {
                if (a[i] - a[i + 1] > 0)
                    a[i + 1] = a[i];
            }
            long stools=0;
            for(int i=0;i<n;i++){
                stools+=a[i]-b[i];
            }
            out.println(stools);
        }
    }
}

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

int main(){
 int n;		cin >> n;
  int a[n], b[n];
  int same_cnt=0;
  
  for(int i=0; i<n; i++){
    cin >> a[i] >> b[i];
  }
  
  for(int i=0; i<n; i++){
   if(a[i] == b[i]){
    same_cnt++; 
   }else{
     same_cnt = 0;
   }
    if(same_cnt >= 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> oset;

int n, m, k, arr[N];

void solve()
{
    cin >> n;
    int ans = 0;
    forn(i, 1, n)forn(j, 1, n)forn(k, 1, n)ans += __gcd(i, __gcd(j, k));
    cout << ans;
}


signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin>>t;
    forn(i, 1, t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

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

	priority_queue<int, vector<int>, greater<int> > pqueL;
	vector<int> v;
	priority_queue<int> pqueR;

	int L[N + 1] = {};
	int R[N + 1] = {};

	rep(i, N) {
		int a; cin >> a;
		pqueL.push(a);
		L[0] += a;
	}
	rep(i, N) {
		int a; cin >> a;
		v.push_back(a);
	}
	rep(i, N) {
		int a; cin >> a;
		pqueR.push(a);
		R[N] += a;
	}
	rep(i, N) {
		int minL = pqueL.top();
		if (v[i] - minL > 0) {
			L[i + 1] = L[i] + v[i] - minL;
			pqueL.pop();
			pqueL.push(v[i]);
		}
		else L[i + 1] = L[i];
	}
	rrep(i, N - 1) {
		int maxR = pqueR.top();
		if (v[i] - maxR < 0) {
			R[i] = R[i + 1] + v[i] - maxR;
			pqueR.pop();
			pqueR.push(v[i]);
		}
		else R[i] = R[i + 1];
	}
	int ans = -INF2;
	rep(i, N + 1) {
		ans = max(ans, L[i] - R[i]);
		// cout << L[i] << " " << R[i] << endl;
	}
	cout << ans << endl;




    return 0;
}


Measured memory_bytes: 4980
N=int(input())
abc=[[0 for i in range(3)] for j in range(N)]
for i in range(N):
    A=list(map(int,input().split()))
    for j in range(3):
        abc[i][j]=A[j]
dp=[[0,0,0] for i in range(N+1)]
for i in range(N):
    for j in range(3):
        buf=[]
        for h in range(3):
            if h!=j:
                buf.append(dp[i][h]+abc[i][h])
        dp[i+1][j]=max(buf)
print(max(dp[N]))


Measured memory_bytes: 44108
#include <stdio.h>

int main(){
  int x,y,r;
  int key;
  
  scanf("%d",&x);
  scanf("%d",&y);

  if(x>y){
    key=x;
    x=y;
    y=key;
  }

  r=x%y;

  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }

  printf("%d\n",y);

  return 0;
}

Measured memory_bytes: 592
n = int(input())
words = []
for i in range(n):
  words.append(input())

ans = "Yes"
  
if len(words) != len(set(words)):
  ans = "No"
else:
  for i in range(n-1):
    if words[i][-1] != words[i+1][0]:
      ans = "No"
      break
print(ans)

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

int main()
{
    int N, K;

    cin >> N >> K;

    int p[N];

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

    sort(p, p+N);

    int T = 0;

    for(int i=0; i<K; i++)
    {
        T = T + p[i];
    }

    cout << T;

    return 0;
}

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

int main()
{
	int n[3];
	int ans=0;
	
	for(int i=0;i<3;i++)
		cin >> n[i];
	
	while(!(n[0]==n[1] && n[1]==n[2]) || ans%2==1)
	{
		sort(n,n+3);
		ans++;
		n[0]++;
	}
	
	cout << ans/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    #define REP(i,n) for(int i=0;i<(int)(n);++i)
    #define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
     
    using namespace std;
    typedef long long ll;
     
    int main(){
        int A,B;
        cin >> A >> B;
        int a1,a2,a3;
        a1 = A+B;
        a2 = A-B;
        a3 = A*B;

    	
    	int ans;
    	ans = max(a1, max(a2, a3));
    	
    	cout << ans << endl;
    	
    	return 0;
    	
    }

Measured memory_bytes: 256
import org.w3c.dom.ls.LSOutput;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

public class Main {
    public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static FastReader r=new FastReader();
    public static void main(String[] args){
        int n=r.nextInt();
        double []p=new double[n+1];
        for(int i=1;i<=n;++i){
            p[i]=r.nextDouble();
        }
        double [][]dp=new double[n+5][n+5];
        dp[0][0]=1;
        for(int i=1;i<=n;++i){
            for(int num=0;num<=n;++num){
                dp[i][num+1]+=dp[i-1][num]*p[i];
//                if(i==1&&num==0) System.out.println("debug : "+dp[1][1]);
                dp[i][num]+=dp[i-1][num]*(1-p[i]);
//                if(i==1&&num==0) System.out.println("debug : "+dp[1][0]);
            }
        }
//        System.out.println("dp 1 1 : "+dp[1][1]);
        double ans=0;
        for(int head=(n+1)/2;head<=n;++head){
            ans+=dp[n][head];
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 107364
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <string>
using namespace std;
#define lli long long int
#define MAX 100000000
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char x;
    cin >> x;
    if (x == 'A')
    {
        cout << "T" << endl;
    }
    if (x == 'T')
    {
        cout << "A" << endl;
    }
    if (x == 'G')
    {
        cout << "C" << endl;
    }
    if (x == 'C')
    {
        cout << "G" << endl;
    }
    return 0;
}

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

e = []
for i in p:
    e.append(1+i)

l = 0
s = sum(e[l:k-1])
t = sum(e[l:k-1])
for i in range(n-k):
    tmp = t + e[i+k] - e[i]
    t = t + e[i+k] - e[i]
    if tmp > s:
        s = tmp
        l = i + 1

print(sum(e[l:l+k])/2)

Measured memory_bytes: 77448
while True :
    a,op,b =input().split()
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)
    else: 
        break


Measured memory_bytes: 5592
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"

const int inf = (int)1e18 + 10;

int a[1005][1005] = {{0}} , dp[1005][1005];
signed main(){
  fast;
 
  int n , m;
  cin >> n >> m;
  string s;
  for(int i = 0 ; i < n ; i++){
  	cin >>s;
  	for(int j = 0 ; j < m ; j++){
  		if(s[j] == '.') a[i+1][j+1] = 1;
  	}
  }


  for(int i = 0 ; i < n ; i++)
  	dp[0][i] = 0 , dp[i][0] = 0;

  dp[1][1] = 1;
  for(int i = 1 ; i <= n ; i++ ){
  	    for(int j = 1 ; j <=m ; j++){
  	    	if(i == 1 && j == 1)
  	    		continue;
  	    	if(a[i][j] == 1)
  	    		dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % mod;
  	    }

  }


  cout << dp[n][m] << endl;
  
}	

Measured memory_bytes: 16000
#include <stdio.h>
#include <stdlib.h>
int cmp(const int *a,const int *b){
  return *b-*a;
}
int main(){
  int f=0,i,n,m,X,Y,x[100],y[100];
  scanf("%d%d%d%d",&n,&m,&X,&Y);
  for(i=0;i<n;i++)scanf("%d",&x[i]);
  for(i=0;i<m;i++)scanf("%d",&y[i]);
  qsort(x,n,sizeof(int),cmp);
  qsort(y,m,sizeof(int),cmp);
  for(i=Y;i>X;i--)if(x[0]<i&&i<=y[m-1])f=1;
  puts(f?"No War":"War");
  return 0;
}

Measured memory_bytes: 128
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;
 
int main()
{
    ull n,ans;
    cin>>n;
    for(ull i=1;i*i<=n;i++) if(n%i==0) ans=n/i;
    cout<<(ull)floor(log10(ans))+1<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<string>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

int N, M, hd[maxn], cnt, vis[maxn], sig[maxn];
struct edge {
	int to, nxt;
} e[maxn << 1];
void add(int u, int v) {
	e[++cnt] = { v, hd[u] };
	hd[u] = cnt;
}
void bfs() {
	queue <int> q;
	q.push(1);
	vis[1] = 1;
	while (!q.empty()) {
		int now = q.front(); q.pop();
		for (int i = hd[now]; i; i = e[i].nxt) {
			int to = e[i].to;
			if (vis[to]) continue;
			vis[to] = 1;
			sig[to] = now;
			q.push(to);
		}
	}
}

int main() {
	
	// freopen("in.in", "r", stdin);
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		add(u, v); add(v, u);
	}
	vis[1] = 1;
	bfs();
	for (int i = 2; i <= N; i++) if (!sig[i]) return puts("No"), 0;
	puts("Yes");
	for (int i = 2; i <= N; i++) printf("%d\n", sig[i]);

	return 0;
}		

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

const int INF = 1e8;

// URDL = 0123

int f(vector<P> a) {
  sort(a.begin(), a.end());
  int res = INF;
  for (int i = 1; i < a.size(); ++i) {
    if (a[i-1].second == 0 && a[i].second != 0) {
      res = min(res, a[i].first-a[i-1].first);
    }
  }
  return res;
}
int f(map<int,vector<P>>& mp) {
  int res = INF;
  for (auto p : mp) {
    res = min(res, f(p.second));
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n), dir(n);
  rep(i,n) {
    char c;
    cin >> x[i] >> y[i] >> c;
    if (c == 'U') dir[i] = 0;
    if (c == 'R') dir[i] = 1;
    if (c == 'D') dir[i] = 2;
    if (c == 'L') dir[i] = 3;
  }

  int ans = INF;
  rep(ri,4) {
    { // UD
      map<int,vector<P>> mp;
      rep(i,n) {
        if (dir[i] != 0 && dir[i] != 2) continue;
        mp[x[i]].emplace_back(y[i],dir[i]);
      }
      ans = min(ans, f(mp)*5);
    }
    { // UR
      map<int,vector<P>> mp;
      rep(i,n) {
        if (dir[i] != 0 && dir[i] != 1) continue;
        mp[x[i]+y[i]].emplace_back(y[i],dir[i]);
      }
      ans = min(ans, f(mp)*10);
    }
    // rotate
    rep(i,n) {
      int px = x[i], py = y[i];
      x[i] = py;
      y[i] = -px;
      dir[i] = (dir[i]+1)%4;
    }
  }
  if (ans == INF) cout << "SAFE" << endl;
  else cout << ans << endl;
  return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

int dp[1<<18][55];

int main(){
   int n; scanf("%d",&n);
   vector<int> a(n),b(n);
   rep(i,0,n)scanf("%d",&a[i]);
   rep(i,0,n)scanf("%d",&b[i]);
   rep(i,0,1<<n)rep(j,0,51)dp[i][j]=inf;
   dp[0][0]=0; int m=1<<n;
   rep(mask,0,m)rep(i,0,51)if(dp[mask][i]!=inf){
      int pos=__builtin_popcount(mask);
      rep(nxt,0,n)if(!(mask>>nxt&1)){
         int d=abs(pos-nxt);
         int val;
         if(d&1)val=b[nxt]; else val=a[nxt];
         if(i>val)continue;
         int add=0;
         rep(j,nxt+1,n)if(mask>>j&1)add++;
         chmin(dp[mask|(1<<nxt)][val],dp[mask][i]+add);
      }
   }
   int res=inf;
   rep(i,0,51)chmin(res,dp[m-1][i]);
   printf(res==inf?"-1\n":"%d\n",res);
   return 0;
}

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

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

	int mx = 1;
	int ans = 1;
	for (int i = 1; i < n+1; i++) {
		int x = i;
		int d = 0;
		while (x%2 == 0) {
			x /= 2;
			d++;
		}
		if (max(mx, d) == d) {
			ans = i;
		}
		mx = max(mx, d);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	char p1[200], p2[100], s[100];

	scanf("%s", p1);
	strcpy(p2, p1);
	strcat(p1, p2);
	scanf("%s", s);

	if (strstr(p1, s)) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;

ll cal(map<ll, int>& m, map<ll, int>& freqs, vector<vector<ll> >& combi)
{
  ll ret = 1;
  for (map<ll, int>::iterator iter = m.begin(); iter != m.end(); ++iter) {
    ret *= combi[freqs[iter->first]][iter->second];
  }
  return ret;
}

int main()
{
  int N, A, B; scanf("%d %d %d", &N, &A, &B);
  vector<ll> V(N + 5);
  map<ll, int> freqs;
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &V[i]);
    ++freqs[V[i]];
  }
  sort(V.begin(), V.end(), greater<ll>());
  vector<ll> S(V.begin(), V.end());
  for (int i = 0; i < N - 1; ++i) {
    S[i + 1] += S[i];
  }

  vector<vector<ll>> combi(55, vector<ll>(55, 0));
  for (int i = 0; i < 55 - 1; ++i) {
    combi[i][0] = 1;
    for (int j = 0; j <= i; ++j) {
      combi[i + 1][j] += combi[i][j];
      combi[i + 1][j + 1] += combi[i][j];
    }
  }

  ll ans_nume = 0, ans_deno = 1;
  ll ans_cnt = 0;
  for (int i = A; i <= B; ++i) {
    ll sum = S[i - 1];
    ll val1 = sum * ans_deno, val2 = ans_nume * i;
    map<ll, int> cnt;
    if (val1 > val2) {
      ans_nume = sum;
      ans_deno = i;
      for (int j = 0; j < i; ++j) {
        ++cnt[V[j]];
      }
      ans_cnt += cal(cnt, freqs, combi);
    }
    else if (val1 == val2) {
      for (int j = 0; j < i; ++j) {
        ++cnt[V[j]];
      }
      ans_cnt += cal(cnt, freqs, combi);
    }
  }
  printf("%lf\n", (double)ans_nume / ans_deno);
  printf("%lld\n", ans_cnt);
  return 0;
}


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

int main() {
int n,W;
cin>>n>>W;
vector<int> w(n);
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>w.at(i)>>v.at(i); 
}
  vector<vector<long long int>> dp(n +1, vector<long long int>(W+1));
  for(int j=0;j<=W;j++){
dp.at(0).at(j)=0;
}
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= W; j++) {
      if(j>=w.at(i)){
      dp.at(i +1).at(j)=max(dp.at(i).at(j-w.at(i))+v.at(i),dp.at(i).at(j));
      }
      else{
      dp.at(i+1).at(j)=dp.at(i).at(j);
      }
    }
  }
cout<<dp.at(n).at(W)<<endl;
}


Measured memory_bytes: 80256
def main():
    N = input_int()
    S = input()

    count = 1

    for i in range(1, N):
        if S[i-1] != S[i]:
            count += 1

    print(count)


def input_int():
    return int(input())


def input_int_tuple():
    return map(int, input().split())


def input_int_list():
    return list(map(int, input().split()))


main()


Measured memory_bytes: 67344
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize ("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

template<typename T> // order_of_key(), *find_by_order()
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = int;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll) ((ld) a * b / mod) * mod;
        if (val < 0)
            val += mod;
        if (val >= mod)
            val -= mod;
        return val;
    }

    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2)
                val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }

    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 2e6 + 6;

ll fact[maxn];

ll C(ll n, ll k) {
    return mul(fact[n], inv(mul(fact[n - k], fact[k])));
}

ll f(ll x, ll y) {
    ll ans = 0;
    ll n = x;
    if (x == 0) return y + 1;
    else if (y == 0) return x + 1;
    for (ll j = 1; j <= y + 1; j++) {
        (ans += C(n + j, n)) %= mod;
    }

    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    fact[0] = 1;
    for (ll i = 1; i < maxn; i++) {
        fact[i] = mul(fact[i - 1], i);
    }
    ll r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;

    ll ans = 0;

    ans += f(r2, c2);
    ans -= f(r1 - 1, c2);
    ans -= f(r2, c1 - 1);
    ans += f(r1 - 1, c1 - 1);
    ans %= mod;
    if (ans < 0) ans += mod;

    cout << ans << endl;
    return 0;
}

/*


*/

Measured memory_bytes: 8064
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int s, w;
    cin >> s >> w;
    if(s <= w){
        cout << "unsafe";
    }else{
        cout << "safe";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long f[101][100001];
int w[101],v[101];
int main()
{
	int n,m=0,W,i,j;
	scanf("%d %d",&n,&W);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d",&w[i],&v[i]);
		m+=v[i];
	}
	for(i=0;i<=n;i++)
		for(j=0;j<=m;j++)
			f[i][j]=INT_MAX;
	f[0][0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(j>=v[i])
				f[i][j]=min(f[i-1][j],f[i-1][j-v[i]]+w[i]);
			else
				f[i][j]=f[i-1][j];
		}
	}
	for(i=m;i>=1;i--)
		if(f[n][i]<=W)
			break;
	printf("%d",i);
	return 0;
}

Measured memory_bytes: 79104
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int m[555][555];
int main()
{
	int num;
	scanf("%d", &num);
	if (num == 1)
	{
		printf("1\n1\n");
		return 0;
	}
	int x = (num + 3) / 4 * 2;
	printf("%d\n", x);
	for (int i = 0; i < x; i++)for (int j = 0; j < x; j++)m[j][(i + j) % x] = i + x*(j % 2) + 1;
	for (int i = 0; i < x; i++)for (int j = 0; j < x; j++)if (m[i][j]>num)m[i][j] = m[(i + 1) % x][(j + 1) % x];
	for (int i = 0; i < x; i++)
	{
		for (int j = 0; j < x; j++)
		{
			printf("%d ", m[i][j]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli vis[N];
lli get(lli x) {

    if(x == vis[x])
        return x;
    return vis[x] = get(vis[x]);
}

void solve()
{

    lli n, m;
    cin>>n>>m;
    vector<pair<lli, lli> > v;
    for(int i = 0; i < n; i ++) {
        lli a, b;
        cin>>a>>b;
        if(a <= m) {
            v.push_back({b, a});
        }
    }
    for(int i = 1; i <= m; i ++) {
        vis[i] = i;
    }
    vis[m + 1] = m + 1;
    sort(v.rbegin(), v.rend());
    lli ans = 0, cnt = 0;
    for(int i = 0; i < (lli)v.size(); i ++) {
//        cout<<v[i].ss<<' ';
        lli X = get(v[i].ss);
  //      cout<<X<<endl;
        if(X <= m) {
            vis[X] = X + 1;
            ans += v[i].ff;
        }
    }
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

//Nails
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int[][] t = new int[n+1][];
		for(int i=1;i<=n;i++){
			t[i] = new int[i+1];
			Arrays.fill(t[i], -1);
		}
		while(m--!=0){
			int a = sc.nextInt(), b = sc.nextInt(), x = sc.nextInt();
			t[a][b] = Math.max(t[a][b], x);
		}
		int res = 0;
		for(int i=1;i<=n;i++)for(int j=1;j<=i;j++){
			if(i>1){
				if(i!=j)t[i][j] = Math.max(t[i][j], t[i-1][j]-1);
				if(j!=1)t[i][j] = Math.max(t[i][j], t[i-1][j-1]-1);
			}
			res+=t[i][j]>=0?1:0;
		}
		System.out.println(res);
	}

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

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>

using namespace std;
//debug

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

#define pb push_back

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;



#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()



int main() {
	ll N,K;
	cin >> N>>K;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];
	
	ll m = *min_element(all(A));
	ll cnt =N- count(all(A), m);
	if (cnt % (K - 1) == 0) cout << cnt / (K - 1);
	else cout <<( cnt - (cnt % (K - 1))) / (K - 1) + 1;
	return 0;
}

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

int main(){
    int r;
    cin >> r;
    double a = 3.14159265;
    cout << fixed << setprecision(10);
    cout << 2*r*a << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll Ai, Bi;
    priority_queue<array<ll,2>> q;
    for(int i=0;i<N;i++){
        cin >> Ai >> Bi;
        q.push(array<ll,2>{-Ai, Bi});
    }
    ll res = 0;
    ll c = 0;
    while(!q.empty()){
        auto v = q.top(); q.pop();
        if(c + v[1] < M){
            res += -v[0] * v[1];
            c += v[1];
        }else{
            res += -v[0] * (M - c);
            break;
        }
    }
    cout<<res<<endl;

    return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  string S[2];
  cin >> S[0] >> S[1];
  llvec dp(N, 0);
  if(S[0][0]==S[1][0]){
    dp[0] = 3;
  }else{
    dp[0] = 6;    
  }
  
  rep(i, N-1){
    if(S[0][i+1]==S[0][i] and S[1][i+1] == S[1][i]){
      // aa
      // bb
      dp[i+1]=dp[i];
    }else{
      // ac
      // bc
      if(S[0][i+1]!=S[0][i] and S[1][i+1] != S[1][i] and S[1][i]!=S[0][i] and S[1][i+1]==S[0][i+1]){
        dp[i+1] = mod(dp[i], MOD);
      }
      // ac
      // bd
      if(S[0][i+1]!=S[0][i] and S[1][i+1] != S[1][i] and S[1][i]!=S[0][i] and S[1][i+1]!=S[0][i+1]){
        dp[i+1] = mod(3*dp[i], MOD);
      }
      // ac
      // ac
      if(S[0][i+1]!=S[0][i] and S[1][i+1] != S[1][i] and S[1][i]==S[0][i] and S[1][i+1]==S[0][i+1]){
        dp[i+1] = mod(2*dp[i], MOD);
      }
      // ab
      // ac
      if(S[0][i+1]!=S[0][i] and S[1][i+1] != S[1][i] and S[1][i]==S[0][i] and S[1][i+1]!=S[0][i+1]){
        dp[i+1] = mod(2*dp[i], MOD);
      }
    }
    
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 3632
N = int(raw_input())
A=map(int, raw_input().split(' '))
A.sort()
flug = 0
if N % 2 == 0:
    for i in range(N):
        if not A[i] == 2*(i/2)+1:
            flug = 1
            break

else:
    for i in range(N):
        if i % 2 == 0:
            if not A[i] == i:
                flug =1
                break
        else:
            if not A[i] == i+1:
                flug = 1
                break
if flug == 0:
    print(pow(2, N/2))%(pow(10,9)+7)
else:
    print 0



Measured memory_bytes: 11304
import java.util.*;
import java.io.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
        //コード
      	Scanner sc = new Scanner(System.in);
      	String[] week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
      	
      	String str = sc.next();
      
      	for (int i = 0; i < 7; i++) {
          	if(week[i].equals(str)) {
              	System.out.println(7-i);
              	System.exit(0);
            }
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
 
#define DEBUG 0
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

vector<lli> makePrimeList(lli n){
	vector<lli> primeNums;
	bool isMultiple;
	for(lli i=2;i<=n;i++){
		isMultiple = false;
		lli size = primeNums.size();
		for(lli j=0;j<size;j++){
			if(i%primeNums[j]==0){
				isMultiple=true;
				break;
			}
		}
		if(!isMultiple){
			primeNums.push_back(i);
		}
	}
	return primeNums;
}

void func(lli n,vector<lli> &primeList,vector<lli> &yakusu){
	lli nowN = n;
	lli size = primeList.size();
	
	while(nowN > 1){
		REP(i,size){
			lli prime = primeList[i];
			if(nowN % prime == 0){
				yakusu[prime]++;
				nowN /= prime;
				break;
			}
		}
	}
}

int main(){

	lli n;
	cin>>n;
	vector<lli> primeList;
	vector<lli> yakusu(n+1);
	lli cnt3=0;
	lli cnt5=0;
	lli cnt15=0;
	lli cnt25=0;
	lli cnt75=0;

	primeList = makePrimeList(1000);

	for(lli i=1;i<=n;i++){
		func(i,primeList,yakusu);
	}
	for(lli i=0;i<=n;i++){
		if(yakusu[i])yakusu[i]++;
		if(DEBUG)cout<<"i="<<i<<" yakusu="<<yakusu[i]<<endl;
	}

	for(lli i=0;i<=n;i++){
		if(yakusu[i]>=75)cnt75++;
		if(yakusu[i]>=25)cnt25++;
		if(yakusu[i]>=15)cnt15++;
		if(yakusu[i]>=5)cnt5++;
		if(yakusu[i]>=3)cnt3++;
	}
	if(DEBUG)cout<<cnt5<<"<- cnt5, cnt3-> "<<cnt3<<endl;
	lli sum = (cnt5)*(cnt5-1)/2 * (cnt3-2);
	sum += cnt75;
	sum += cnt25*(cnt3-1);
	sum += cnt15*(cnt5-1);
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const int MOD = 1000000007;
int main() {
    int s;
    cin >> s;
    //dp[s]を求める、dp[i] = 最後に切った場所がi　であるような分け方
    //今回は前切ったところから3つ以上離れている必要がある。例えばdp[6] = dp[0]+d[1]+d[2]+dp[3]
    ll dp[2005] = { 0 };
    for (int i = 3; i <= s; i++)dp[i] = 1;
    for (int i = 3; i <= s;i++) {
        for (int j = 0; j <= i - 3;j++) {
            dp[i] += dp[j];
            dp[i] %= MOD;
        }
   }
   
    cout << dp[s] << endl;

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  string t = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

typedef long long int64;

// void array_dump(int64 *arr, int len) {
//   for (int i = 0; i < len; i++) {
//     eprintf("arr[%d] = %d ", i, arr[i]);
//   }
//   eprintf("\n");
// }

int main(int argc, const char *argv[])
{
  int n, m;
  scanf("%d%d", &n, &m);
  // int64 *a = (int64 *)malloc((n + 1) * sizeof(int64));
  int64 a[100001];

  for (int i = 0; i <= n; i++) {
    // -1 means "not processing yet"
    a[i] = -1;
  }

  int tmp, ltmp = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d", &tmp);
    if (tmp == ltmp - 1 || tmp == n ) {
      printf("0\n");
      return 0;
    }
    // 0 means broken stair
    a[tmp] = 0;
    ltmp = tmp;
  }

  a[0] = 1;
  if(a[1] == -1)
    a[1] = 1;

  for (int i = 2; i <= n; i++) {
    if(a[i] != -1)
      continue;
    a[i] = (a[i-1] + a[i-2])  % 1000000007;
  }
  // array_dump(a, n+1);
  // free(a);
  printf("%llu\n", a[n]);

  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  int m;
  cin >> m;
  vint b(m);
  rep(i, m) cin >> b[i];
  vint res;
  set_union(all(a), all(b), inserter(res, res.end()));
  for(int x : res) cout << x << endl;

  return 0;
}



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

int main() {
	int m = 0, W[10], T[10], i;
	for (i = 0; i<10; i++) {
		cin >> W[i];
	}
	sort(W, W + 10);
	for (i = 7; i<10; i++)
		m += W[i];
	cout << m << " ";
	m = 0;
	for (i = 0; i<10; i++) {
		cin >> T[i];
	}
	sort(T, T + 10);
	for (i = 7; i<10; i++)
		m += T[i];
	cout << m << endl;
}

Measured memory_bytes: 1180
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		int L=sc.nextInt();
		ArrayList<String> cc =new ArrayList<>(N);
		for(int i=0;i<N;i++) {
			cc.add(sc.next());
		}
		Collections.sort(cc);
		String ans="";
		for(String i:cc) {
			ans=ans+i;
		}
		p(ans);
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int ans = INF;
	int cnt = 0;
	rep(i, N) {
		while (A[i]%2==0&&A[i] > 0) {
			cnt++;
			A[i] /= 2;
		}
		ans = min(ans, cnt);
		cnt = 0;
	}
	cout << ans << endl;
	return 0;
}


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


int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+5];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int sum=0;
    for(int i=1;i<=k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std ;
#define N 110
int main()
{
      int i,j,m,flag=1;
      char x[N];
      scanf("%s",x);
      m=strlen(x);
      int y[26];
      memset(y,0,sizeof(y));
      for(i=0;i<m;i++)
      {
          y[x[i]-'a']++;
      }
      for(j=0;j<26;j++)
      {
          if(y[j]%2!=0)
          {
              flag=0;
              break;
          }
      }
      if(flag) printf("Yes");
      else printf("No");
    return 0;
}



Measured memory_bytes: 128
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	ans := 1
	for i := 1; i*i <= M; i++ {
		if M%i == 0 {
			if M/i >= N {
				ans = i
			} else {
				break
			}
			q := M / i
			if M/q >= N {
				ans = q
				break
			}
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 640