akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

    using namespace std;

    int main(){
        long long N ;
        cin >> N;
        string res;
        // N--;
        while (N > 0) {
            N--;
            // int t = N / 26;
            res += ('a'+N%26);
            N = N/26;
        
        }
        reverse(res.begin(), res.end());
        cout << res << endl;
        return 0;
    }

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

struct Process{
  char name[101];
  int t;
};

struct Process Q[1001];
int n,head=1,tail=1;

void enqueue(struct Process x){
  Q[tail] = x;
  if(tail == n) tail = 1;
  else tail++;
}

struct Process dequeue(){
  struct Process x;

  x = Q[head];

  if(head == n) head = 1;
  else head++;

  return x;
}

int main(void){
  int i,q,cou=0,time=0;
  struct Process k;

  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  while(cou != n){
    k = dequeue();

    if(k.t <= q){
      time += k.t;
      printf("%s %d\n",k.name,time);
      cou++;
    }

    else{
      time += q;
      k.t -= q;
      enqueue(k);
    }    
  }  

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
int n, Q;
priority_queue<int>q[1010];
int main() {
	cin >> n >> Q;
	while (Q--) {
		int z, t, x;
		cin >> z >> t;
		if (z == 0) {
			cin >> x;
			q[t].push(x);
		}
		if (z == 1 && !q[t].empty())cout << q[t].top() << endl;
		if (z == 2 && !q[t].empty())q[t].pop();
	}
	getchar();getchar();
	return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  ll a;
  double b;
  cin >> a >> b;
  ll c = b * 100 + 0.5;
  cout << a * c / 100 << endl;
  return 0;
}


Measured memory_bytes: 3728
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
    }
    sortup(a,n);
    printf("%lld ",a[n-1]);
    rep(i,0,n-1){
        ll b = min2(a[i],a[n-1]-a[i]);
        if(b>ans) ans=a[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


# def gen_counter(stop=10):
#     index = 1
#     while True:
#         if stop < index:
#             break
#         yield index
#         index += 1


N = int(input())
res = (N - 1) * N // 2
print(res)


# arr = np.arange(1, N + 1)
# t_arr = np.append(arr[1:], arr[0])
# print(sum(arr % t_arr))



Measured memory_bytes: 38256
sx, sy, tx, ty = gets.split.map(&:to_i)
(ty - sy).times { putc 'U' }
(tx - sx).times { putc 'R' }
putc 'U'
(tx - sx + 1).times { putc 'L' }
(ty - sy + 1).times { putc 'D' }
putc 'R'

(tx - sx).times { putc 'R' }
(ty - sy).times { putc 'U' }
putc 'R'
(ty - sy + 1).times { putc 'D' }
(tx - sx + 1).times { putc 'L' }
putc 'U'
putc "\n"


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>

using namespace std;

#define MAXN 100005

int h[MAXN], dp[MAXN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for(int i = 3; i <= n; i++) {
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		for(int j = 2; j <= k; j++) {
			if(i - j < 1) break;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n] << '\n';
	
	return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll n;
ll a[200000];
int b[200000];

int bit[600000];

void add(int k,int x){
	k+=300000;
	while(k<600000){
		bit[k]+=x;
		k+=k&-k;
	}
}
int sum(int k){
	k+=300000;
	int res=0;
	while(k){
		res+=bit[k];
		k-=k&-k;
	}
	return res;
}
ll C(ll t){
	ll cnt=0;
	rep(i,n){
		if(a[i]<=t)b[i]=1;
		else b[i]=-1;
	}
	memset(bit,0,sizeof(bit));
	int d=0;
	add(0,1);
	rep(i,n){
		d+=b[i];
		cnt+=sum(d-1);
		add(d,1);
	}
	return cnt;
}
signed main(){
	cin>>n;
	rep(i,n)scanf("%lld",&a[i]);
	ll m=(n+1)*n/2;
	ll l=0,r=INT_MAX;
	while(r-l>1){
		ll t=(l+r)/2;
		if(C(t)<m/2+1)l=t;
		else r=t;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 4352
from itertools import product


def main():
    X = int(input())
    A, B, C, D, E= [(X // p) + 1 for p in range(100, 105)]

    P = product(range(A), range(B), range(C), range(D), range(E))
    flag = 0
    if X >= 100:
        for a, b, c, d, e in P:
            f = X - (a * 100 + b * 101 + c * 102 + d * 103 + e * 104)
            if f >= 0 and f % 105 == 0:
                flag = 1
                break

    print(flag)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <cstdio>

using namespace std;

int main() {
    int x, sum = 0, i;
    
    scanf("%d", &x);
    
    for (i = 1; ; i++) {
        sum += i;
        
        if (sum >= x) break;
    }
    
    printf("%d\n", i);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

const long long MOD = 998244353;

long long dp[3001][3001];

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

	int N, S;
	cin >> N >> S;

	vector<long long> numlist(N + 1, 0);
	for (int i = 1; i <= N; i++)
	{
		cin >> numlist[i];
		dp[i][numlist[i]] = i;
	}

	long long result = 0;
	for (int i = 1; i <= N; i++)
	{
		for (int j = 0; j <= S; j++)
		{
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
			if (j >= numlist[i])
				dp[i][j] = (dp[i][j] + dp[i - 1][j - numlist[i]]) % MOD;
		}

		result = (result + dp[i][S]) % MOD;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;

    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    int rest = sum;
    int presum = 0;
    int mini = sum;
    rep(i, n){
        rest -= a[i];
        presum += a[i];
        int absnum = abs(rest - presum);
        mini = min(mini, absnum);
    }

    cout << mini << endl;

}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(int64)(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(int64)(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,k;
    cin >> n >> k;
    map<int32,int32> compression;
    int32 variationsCnt = 0;
    vector<vector<int32>> td;
    REP(i,n){
        int32 t, d;
        cin >> t >> d;
        if(compression[t] == 0){
            compression[t] = variationsCnt+1;
            variationsCnt++;
            td.pb(vector<int32>(1, d));
        }else{
            td[compression[t]-1].pb(d);
        }
    }
    vector<int32> mx;
    vector<int32> others;
    REP(i,td.size()){
        sort(ALL(td[i]),greater<int32>());
        mx.pb(td[i][0]);
        FOR(j,1,td[i].size())
            others.pb(td[i][j]);
    }
    sort(ALL(mx),greater<int32>());
    sort(ALL(others), greater<int32>());
    vector<int64> mxRuiseki(mx.size()+1);
    mxRuiseki[0] = 0;
    REP(i,mx.size()){
        mxRuiseki[i+1] = mxRuiseki[i] + mx[i];
    }
    vector<int64> othersRuiski(others.size()+1);
    othersRuiski[0] = 0;
    REP(i,others.size()){
        othersRuiski[i+1] = othersRuiski[i] + others[i];
    }
    int64 ans = 0;
    FOR(i,max<int64>(1, k - others.size()),min<int64>(k,mx.size())+1){
        ans = max(ans, mxRuiseki[i] + othersRuiski[k - i] + i * i);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 13744
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << "  " << y << endl
#define dbg3(x, y, z) cout << x << "  " << y << "  " << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    ll diff1 = n%k;
    ll diff2 = k - diff1;
    if(diff1 < diff2){
        cout << diff1 << endl;
    }
    else {
        cout << diff2 << endl;

    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[1000000];
char b[1000000];
int main()
{
long long t=1,n,m,i,j,k,l;
cin>>n;
cin>>b;
m=strlen(b);
for(i=1;i<m;i++)
{
 if(b[i]!=b[i-1])
 {
    t++;
 }

}
cout<<t<<endl;


}


Measured memory_bytes: 384
n, x, m = map(int, input().split())
amr = []
for i in range(n):
    if i == 0:
        x %= m
        amr.append(x)
        continue
    x = pow(x, 2, m)

    if x in amr:
        break
    if x == 0:
        break
    amr.append(x)

if x == 0:
    print(sum(amr[:n]))
else:
    idx = amr.index(x)

    loop = sum(amr[idx:])
    l = len(amr[idx:])

    if n >= idx:
        cnt = (n-idx)//l
        print(cnt*loop + sum(amr[:idx]) + sum(amr[idx:idx+n-idx-cnt*l:]))
    else:
        print(sum(amr[:n]))



Measured memory_bytes: 68636
s = input()
a = int(s[:2])
b = int(s[-2:])
if 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1 <= b <= 12:
    print('YYMM')
elif 1 <= a <= 12:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 38256
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == 'o')
		{
			count++;
		}
	}
	cout << count * 100 + 700 << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

const int N = 300005, P = 1000000007;
int f[N][3][3];
char s[N];

void upd(int &x, int y) {
	x = x + y >= P ? x + y - P : x + y;
}

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	f[0][0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= 2; ++j)
			for (int k = 0; k <= (s[i] == '?'); ++k)
				upd(f[i][2][j], f[i - 1][2][j]);
		if (s[i] == '?' || s[i] == '0')
			for (int j = 0; j < 2; ++j) {
				upd(f[i][j][1], f[i - 1][j][0]);
				upd(f[i][j][2], f[i - 1][j][1]);
				upd(f[i][j][1], f[i - 1][j][2]);
			}
		if (s[i] == '?' || s[i] == '1')
			for (int j = 0; j < 2; ++j) {
				upd(f[i][j + 1][0], f[i - 1][j][0]);
				for (int k = 0; k < 2; ++k)
					upd(f[i][j][k], f[i - 1][j][k + 1]);
			}
	}
	int ans = 0;
	for (int x = 0; x <= 2; ++x)
		for (int y = 0; y <= x; ++y)
			upd(ans, f[n][x][y]);
	printf("%d\n", ans);
	return 0;
}


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


int main(){
  int N,L;
  cin >>N>>L;
  
  int R=L+N-1;
  
  int eat;
  if(R<=0)eat=R;
  else if(L>=0)eat=L;
  else eat=0;
  
  int answer=(R+L)*(R-L+1)/2-eat;
  
  cout <<answer<<endl;
}
      


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a,b,c,d;
    ll A[MAX_N];
    ll answer;

    cin >> a;// >> b >> c >> d;
    //rep(i, N) cin >> A[i];

    if (a<105) cout << 0<<endl;
    else if (a<135) cout << 1<<endl;
    else if (a<165)cout << 2<<endl;
    else if (a<189)cout << 3<<endl;
    else if (a<195)cout << 4<<endl;
    else cout << 5<<endl;

    //cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;

namespace ALDS1_8_B {
    class Node {
        public int Key { get; set; }
        public Node Parent { get; set; }
        public Node Left { get; set; }
        public Node Right { get; set; }

        public Node(int key = default(int), Node parent = null) {
            Key = key;
            Parent = parent;
        }

        public Node(Node node) {
            this.Key = node.Key;
            this.Parent = node.Parent;
            this.Left = node.Left;
            this.Right = node.Right;
        }
    }

    class Problem {
        private Node _root;
        private StringBuilder _sb;

        public void Run() {
            _sb = new StringBuilder();
            int n = int.Parse(Console.ReadLine());
            SetRoot();
            for (int i = 1; i < n; i++) {
                string[] input = Console.ReadLine().Split(' ');

                switch (input[0]) {
                    case "insert":
                        Insert(int.Parse(input[1]));
                        break;
                    case "print":
                        Inorder(_root);
                        _sb.AppendLine();
                        Preorder(_root);
                        _sb.AppendLine();
                        break;
                    case "find":
                        _sb.AppendLine(Find(int.Parse(input[1])) != null ? "yes" : "no");
                        break;
                }
            }
            Console.Write(_sb);
        }

        private Node Find(int key) {
            Node ret = new Node(_root);
            while (ret != null && key != ret.Key) {
                ret = key < ret.Key ? ret.Left : ret.Right;
            }
            return ret;
        }
        
        private void Insert(int key) {
            Node x = _root;
            Node y = null;
            while (x != null) {
                y = x;
                x = key < x.Key ? x.Left : x.Right;
            }

            if (key < y.Key)
                y.Left = new Node(key, parent: y);
            else
                y.Right = new Node(key, parent: y);
        }

        private void Inorder(Node node) {
            if (node == null)
                return;
            Inorder(node.Left);
            _sb.Append(" " + node.Key);
            Inorder(node.Right);
        }

        private void Preorder(Node node) {
            if (node == null)
                return;
            _sb.Append(" " + node.Key);
            Preorder(node.Left);
            Preorder(node.Right);
        }
        
        private void SetRoot() {
            string[] input = Console.ReadLine().Split(' ');
            _root = new Node(int.Parse(input[1]));
        }
    }

    class Program {
        static void Main(string[] args) {
            Problem p = new Problem();
            p.Run();
        }
    }
}

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

public class Main {

	static BufferedReader reader;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String[] strings = readLine();
		long N = Long.parseLong(strings[0]);
		int c2 = 0;
		long c5 = 0;
		if(N%2==1) {
			print(0);
		}else {
			long t = N/10;
			/*while(t>0) {
				c2+=t;
				t/=2;
			}
			t = N;*/
			while(t>0) {
				c5+=t;
				t/=5;
			}
			print(c5);
		}
		
		//String[] s = readLine();
		//print(num);
	}
	
	//functions here
	//note that all methods should be STATIC

	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}

Measured memory_bytes: 22740
fun main(arr: Array<String>) {
    println(readLine()!!.split(" ").map { it.toLong() }.let { getAns(it[0], it[1].toInt()) })
}

fun getAns(num:Long, base:Int):Int {
    var n = base.toLong()
    var ans = 1
    while (num >= n) {
        n*=base
        ans++
    }
    return ans
}

Measured memory_bytes: 36312
#include<iostream>
using namespace std;
long long gcd(unsigned long long a,unsigned long long b){
    if(!b)return a;
    return gcd(b,a%b);

}
int main(){
    unsigned long long n,m,c;
    while(cin>>n>>m){
        c = gcd(n,m);
        cout << c << endl;
    }
    return 0;
}

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


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

int main() {
    int n, x;
    cin >> n >> x;
    int a;
    cin >> a;
    int ans = abs(a - x);
    for (int i = 1; i < n; i++) {
        cin >> a;
        ans = gcd(ans, abs(a - x));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int index = 1;
        long min = Long.MAX_VALUE;
        for (int i = 1; i < n; i++) {
            long l = sum[i];
            long r = sum[n] - sum[i];
            long dis = Math.abs(l-r);
            if (dis < min) {
                index = i;
                min = dis;
            }
        }

        long l = sum[index];
        long r = sum[n] - sum[index];
        long dis = Math.abs(l-r);
        System.out.println(dis);
    }
}

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

int main(void){
  int n, y;
  cin >> n >> y;
  int ansx, ansy, ansz;
  ansx = ansy = ansz = -1;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= n - i; j++){
      int k = n - i - j;
      if(i * 1000 + j * 5000 + k * 10000 == y){
	ansx = i;
	ansy = j;
	ansz = k;
	break;
      }
    }
  }
  cout << ansz << " " << ansy << " " << ansx << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 99999999

using namespace std;


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





ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll cum[100010][4];
int main() {
	REP(i, 4) {
		cum[0][i] = 0;
	}
	ll m = 1000000007;
	string S;
	cin >> S;
	int l = S.length();
	REP(i, l) {
		REP(j, 4) {
			cum[i + 1][j] = cum[i][j];
		}
		if (S[i] == 'A')cum[i + 1][0]++;
		if (S[i] == 'B')cum[i + 1][1]++;
		if (S[i] == 'C')cum[i + 1][2]++;
		if (S[i] == '?')cum[i + 1][3]++;
	}
	ll ans = 0;
	REP(i, l) {
		if (S[i] == 'B' || S[i] == '?') {
			ll la = cum[i][0], lh = cum[i][3];
			ll rc = cum[l][2] - cum[i + 1][2], rh = cum[l][3] - cum[i + 1][3];
			ll Lres = (myPow(3, lh, m)*la)%m;
			if (lh > 0)Lres += (myPow(3, lh - 1, m)*lh) % m;
			ll Rres= (myPow(3, rh, m)*rc)%m;
			if (rh > 0)Rres += (myPow(3, rh - 1, m)*rh) % m;
			ans += (Lres*Rres) % m;
		}
	}
	ans = ans % m;
	cout << ans << endl;
}

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

int main(){
	int n, a ;
	cin >> n;
	int day[n];
	for(int i = 0; i < n; i++){
		cin >> a;
		day[i] = a;
	}
	for(int i = 0; i < n; i++){
		int b = n - i - 1;
		printf("%d", day[b]);
		if(b != 0){
			printf(" ");
		}	
	}
	printf("\n");
	return 0;
	 }
	

Measured memory_bytes: 1140
a, b = map(int, input().split())

print(100, 100)

ans = [["" for i in range(100)] for j in range(100)]
for i in range(50):
    for j in range(100):
        ans[i][j] = "."
for i in range(50, 100):
    for j in range(100):
        ans[i][j] = "#"

a -= 1
b -= 1

for i in range(0, 49, 2):
    for j in range(100):
        if b == 0:
            break
        if (i+j) % 2 == 0:
            ans[i][j] = "#"
            b -= 1
    else:
        continue
    break

for i in range(51, 100, 2):
    for j in range(100):
        if a == 0:
            break
        if (i+j) % 2 == 1:
            ans[i][j] = "."
            a -= 1
    else:
        continue
    break

tans = ["" for i in range(100)]
for i in range(100):
    for j in range(100):
        tans[i] += ans[i][j]

for i in range(100):
    print(tans[i])

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

const int maxN = 16;

int n;

int a[maxN];
int x[maxN][maxN];
int y[maxN][maxN];

int countBits(int x){
    int res = 0;
    while(x != 0){
        if(x&1){
            res++;
        }
        x >>= 1;
    }

    return res;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        for(int j = 0; j < a[i]; j++){
            int p, q;
            cin >> p >> q;
            p--;
            x[i][j] = p;
            y[i][j] = q;
        }
    }

    int sol=0;

    int lim = (1<<n);
    for(int mask = 0; mask < lim; mask++){
        bool ok = true;
        for(int i = 0; i < n; i++){
            if(mask&(1<<i)){
                for(int j = 0; j < a[i]; j++){
                    if(((mask >> x[i][j])&1)^y[i][j]){
                        ok = false;
                    }
                }
            }
        }

        if(ok == true){
            sol = max(sol, countBits(mask));
        }
    }

    cout << sol;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] matrix = new int[n][n];
		
		for(int i = 0; i < n; i++) {
			int u = sc.nextInt() - 1;
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				matrix[u][sc.nextInt() - 1] = 1;
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.print(matrix[i][0]);
			for (int j = 1; j < n; j++) {
				System.out.print(" ");
				System.out.print(matrix[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 24844
#include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  double a,b;
  cin>>n;
  while(n--){
    scanf("%lf:%lf",&a,&b);
    a*=5;
    a+=b/12;
    double y=abs(b-a),x=abs(60.0-max(a,b)+min(a,b));
    if(min(y,x)<5)cout<<"alert"<<endl;
    else if(min(y,x)<15)cout<<"warning"<<endl;
    else cout<<"safe"<<endl;
  }
}

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

int main() {
	
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int a_min = a[min_element(a.begin(), a.end()) - a.begin()];
	int a_max = a[max_element(a.begin(), a.end()) - a.begin()];
	int ans = 2147483647;;
	for (int i = a_min; i <= a_max; i++) {
		int tmp = 0;
		for (int j = 0; j < n; j++) {
			tmp += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

typedef long long ll;

using namespace std;

int main(){
  string S;
  cin>>S;
  char buf=S[0];
  int ans=0;
  for(int i=1;i<S.size();i++){
    if(S[i]!=buf){
      ans++;
      buf=S[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(v,n){for(int i=0;i<n;++i){int tmp;scanf("%d", &tmp); v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  scanf("%d", &n);

  map<int, int> mp;
  REP(i,n){
    int t;
    scanf("%d", &t);
    mp[t]++;
  }

  vector<pii> v;
  REPI(itr,mp){
    v.pb(MP(itr->first, itr->second));
  }

  sort(ALL(v), greater<pii>());

  llong edge1 = -1, edge2;
  REPI(itr,v){
    if(itr->second >= 4&& edge1 == -1){
      edge1 = edge2 = itr->first;
      break;
    }else if(itr->second >= 2){
      if(edge1 == -1){
        edge1 = itr->first;
      }else{
        edge2 = itr->first;
        break;
      }
    }
  }
  llong ans = 0;
  if(edge1 != -1)
    ans = edge1 * edge2;
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 6136
while True:
    H,W = [int(x) for x in input().split()]
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i % 2 == 0:
            for j in range(W):
                if j % 2 == 0:
                    print('#',end='')
                else:
                    print('.',end='')
        else:
            for j in range(W):
                if j % 2 == 0:
                    print('.',end='')
                else:
                    print('#',end='')
        print('')
    print('')



Measured memory_bytes: 7020
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#include <queue>

#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) (a)>0?(a):(-(a))
template <typename QvQ> inline QvQ Min2(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max2(QvQ a,QvQ b){if(a>b) return a;return b;}
template <typename QvQ> inline QvQ Abs2(QvQ a){if(a>0) return a;return -a;}

#define n1kw 10000000
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void
#define inb inline bool
#define ini inline int

#define bl putchar(' ')
#define ed putchar('\n')
#define test std::cout<<"this:"
#define card system("pause")

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

//char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)

template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
#define MAXN 100005
#define MAXM 200005
int n;
int main()
{
	read(n); int ans=1;
	for(rei i=2;i<=n;++i)
	{
		int dq=i,dqd=0;
		while(dq) dq/=10,++dqd;
		if(dqd&1) ++ans;
	}
	write(ans);
	return 0;
}

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

int main(void){
    std::vector<std::vector<int>> vec(10,vector<int>(10,0));
    int x,y,s;
    char c;
    while (cin>>x>>c>>y>>c>>s) {
        if (s==1) {
            vec.at(y).at(x)++;
            if (y-1>=0) { //上
                vec.at(y-1).at(x)++;
            }
            if (x-1>=0) { //左
                vec.at(y).at(x-1)++;
            }
            if (x+1<=9) { //右
                vec.at(y).at(x+1)++;
            }
            if (y+1<=9) { //下
                vec.at(y+1).at(x)++;
            }
        } else if (s==2) {
            vec.at(y).at(x)++;
            if (y-1>=0&&x-1>=0) { //左上
                vec.at(y-1).at(x-1)++;
            }
            if (y-1>=0) { //上
                vec.at(y-1).at(x)++;
            }
            if (y-1>=0&&x+1<=9) { //右上
                vec.at(y-1).at(x+1)++;
            }
            if (x-1>=0) { //左
                vec.at(y).at(x-1)++;
            }
            if (x+1<=9) { //右
                vec.at(y).at(x+1)++;
            }
            if (x-1>=0&&y+1<=9) { //左下
                vec.at(y+1).at(x-1)++;
            }
            if (y+1<=9) { //下
                vec.at(y+1).at(x)++;
            }
            if (x+1<=9&&y+1<=9) { //右下
                vec.at(y+1).at(x+1)++;
            }
        } else if (s==3) {
            vec.at(y).at(x)++;
            if (y-1>=0&&x-1>=0) { //左上
                vec.at(y-1).at(x-1)++;
            }
            if (y-1>=0) { //上
                vec.at(y-1).at(x)++;
            }
            if (y-1>=0&&x+1<=9) { //右上
                vec.at(y-1).at(x+1)++;
            }
            if (x-1>=0) { //左
                vec.at(y).at(x-1)++;
            }
            if (x+1<=9) { //右
                vec.at(y).at(x+1)++;
            }
            if (x-1>=0&&y+1<=9) { //左下
                vec.at(y+1).at(x-1)++;
            }
            if (y+1<=9) { //下
                vec.at(y+1).at(x)++;
            }
            if (x+1<=9&&y+1<=9) { //右下
                vec.at(y+1).at(x+1)++;
            }
            if (y-2>=0) { //最上
                vec.at(y-2).at(x)++;
            }
            if (x+2<=9) { //最右
                vec.at(y).at(x+2)++;
            }
            if (x-2>=0) { //最左
                vec.at(y).at(x-2)++;
            }
            if (y+2<=9) { //最下
                vec.at(y+2).at(x)++;
            }
        }
    }
    int count=0;
    int max=0;
    for (int i=0;i<10;i++) {
        for (int j=0;j<10;j++) {
            if (vec.at(i).at(j)==0) {
                count++;
            }
            if (vec.at(i).at(j)>max) {
                max=vec.at(i).at(j);
            }
        }
    }
    cout<<count<<endl;
    cout<<max<<endl;
}



Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d,i,j,n,m ;
	cin>>n>>m ;
	long long arr[n][m] ;
	char str[n][m] ;
	for(i=0 ; i<n ; i=i+1)
	{
		for(j=0 ; j<m ; j=j+1)
		{
			cin>>str[i][j] ;
		}
	}
	c = 0 ;
	for(i=0 ; i<n ; i=i+1)
	{
		if(str[i][0]=='.' &&  c==0)
		{
			arr[i][0] = 1 ;
		}
		else
		{
			arr[i][0] = 0 ;
			c = 1 ;
		}
	}
	c = 0 ;
	for(j=0 ; j<m ; j=j+1)
	{
		if(str[0][j]=='.' && c==0)
		{
			arr[0][j] = 1 ;
		}
		else
		{
			arr[0][j] = 0 ;
			c = 1 ;
		}
	}
	long long mod1 = 1e9+7 ;
	for(i=1 ; i<n ; i=i+1)
	{
		for(j=1 ; j<m ; j=j+1)
		{
			if(str[i][j]=='#')
			{
				arr[i][j] = 0 ;
			}
			else
			{
				arr[i][j] = ( arr[i][j-1]%mod1 + arr[i-1][j]%mod1 )%mod1;
			}
		}
	}
	cout<<arr[n-1][m-1]%mod1 ;
}

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

int main() {
int n,a;
//boolean???0??§????????????
//?????¨map??§????????¨?????????????????????????????????????????°??????????????§????????¨??????????°????????????????
/*????????????????????????????????????????????????for??§????????????????????????????????¨??§???????????????????????¨??¨ture??\???????\´???????????¨??????
??????????????????????????¨??????????°????????????????*/
bool cards[4][14]={};
char suit;
cin>>n;
for (int i = 0; i < n; ++i) {
	cin>>suit>>a;
	if(suit=='S'){cards[0][a]=1;}
	if(suit=='H'){cards[1][a]=1;}
	if(suit=='C'){cards[2][a]=1;}
	if(suit=='D'){cards[3][a]=1;}
}

for (int i = 0; i < 4; ++i) {
	for (int j = 1; j <= 13; ++j) {
		if(cards[i][j]==1)continue;
		if(i==0){cout<<"S"<<" "<<j<<endl;}
		if(i==1){cout<<"H"<<" "<<j<<endl;}
		if(i==2){cout<<"C"<<" "<<j<<endl;}
		if(i==3){cout<<"D"<<" "<<j<<endl;}
	}
}


return 0;
}

Measured memory_bytes: 3076
n_k_str = input()
n_k_list = n_k_str.split(" ")
N = int(n_k_list[0])
K = int(n_k_list[1])
S = list(input())

pre_s = S.pop(0)
pre_index = -1
result = 0
for i,s in enumerate(S):
    if s != pre_s:
        temp = i - pre_index - 1
        result += temp
        pre_index = i
    pre_s = s

temp = len(S) - pre_index - 1
result += temp

result += K*2
if result >= N:
    result = N - 1

print(result)

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

int main(){
    int h, w;
    cin >> h >> w;

    char a[h][w];
    int flag[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
            flag[i][j] = 0;
        }
    }

    int ans = 0;
    int now_x = 0;
    int now_y = 0;
    while(1){
        if(now_x == h - 1 && now_y == w - 1){
            flag[now_x][now_y] = 1;
            break;
        }
        flag[now_x][now_y] = 1;
        if(a[now_x + 1][now_y] == '#'){
            now_x++;
        }else if(a[now_x][now_y + 1] == '#'){
            now_y++;
        }else{
            break;
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#' && flag[i][j] == 0){
                ans = 1;
                break;
            }
        }
    }

    if(ans == 1){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;
    }
}

Measured memory_bytes: 256
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf: VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf: VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn nextN<T>(&mut self, n: usize) -> Vec<T> where T: FromStr, T::Err: Debug {
            let mut vec: Vec<T> = Vec::with_capacity(n);
            for i in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

mod data {
    pub struct UnionFind {
        root : Vec<usize>
    }

    impl UnionFind {
        pub fn new(size : usize) -> UnionFind {
            UnionFind {root : (0..size).collect()}
        }

        pub fn find(&mut self, x : usize) -> usize {
            let xroot = self.root[x];
            if x != xroot {
                self.root[x] = self.find(xroot);
            }
            self.root[x]
        }

        pub fn unite(&mut self, x : usize, y : usize) {
            let xroot = self.find(x);
            self.root[xroot] = self.find(y);
        }

        pub fn same(&mut self, x : usize, y : usize) -> bool {
            self.find(x) == self.find(y)
        }
    }
}

fn with_large_stack(func : fn() -> ()) {
    use std::thread::Builder;
    let builder = Builder::new();
    let th = builder.stack_size(10000000);

    th.spawn(move || {
        func();
    }).unwrap().join();
}

fn main() {
    with_large_stack(_main);
}

fn f(s: String, open: char) -> usize {
    let mut nest = 0;
    let mut cnt = 0;
    for c in s.chars() {
        if c == open {
            nest += 1;
        } else if nest > 0{
            nest -= 1;
        } else {
            cnt += 1;
        }
    }    
    cnt
}

fn _main() {
    let mut reader = reader::Reader::new();

    let _: i32 = reader.next();
    let s: String = reader.next();
    let pre = f(s.clone(), '(');
    let suf = f(s.clone().chars().rev().collect::<String>(), ')');
    println!("{}{}{}", std::iter::repeat("(").take(pre).collect::<String>(), s, std::iter::repeat(")").take(suf).collect::<String>());
}

Measured memory_bytes: 8572
#!/usr/bin/env python
# encoding: utf-8


class Solution:
    """
    @param prices: Given an integer array
    @return: Maximum profit
    """

    @staticmethod
    def bubble_sort():
        # write your code here
        array_length = int(input())
        unsorted_array = [int(x) for x in input().split()]

        flag = 1
        count = 0
        while flag:
            flag = 0
            for j in range(array_length - 1, 0, -1):
                if unsorted_array[j] < unsorted_array[j - 1]:
                    unsorted_array[j], unsorted_array[j - 1] = unsorted_array[j - 1], unsorted_array[j]
                    flag = 1
                    count += 1
        print(" ".join(map(str, unsorted_array)))
        print(str(count))


if __name__ == '__main__':
    solution = Solution()
    solution.bubble_sort()

Measured memory_bytes: 7700
N, M = map(int, input().split())
A = [1] * (N+2)
for _ in range(M):
    a = int(input())
    A[a+1] = 0
dp = [0] * (N+2)
dp[1] = 1
e = 1e9 + 7
for i in range(2, N+2):
    if A[i]:
        dp[i] = (dp[i-1] + dp[i-2]) % e
print(int(dp[-1]))

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		long[] arr = new long[200000];

		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextLong();
		}

		Arrays.sort(arr);

		for (int i = 1; i < 200000; i++) {
			if (arr[i] > 0) {
				if (arr[i] == arr[i - 1]) {
					System.out.println("NO");
					break;
				}
			}
			if (i == 200000 - 1) {
				System.out.println("YES");
			}
		}
	}
}

Measured memory_bytes: 61844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll T[2], A[2], B[2];
	REP(i, 2) cin >> T[i];
	REP(i, 2) cin >> A[i];
	REP(i, 2) cin >> B[i];
	
	if (A[0] < B[0]) {
		REP(i, 2) swap(A[i], B[i]);
	}
	
	// A[0] > B[0]
	if (A[1] > B[1]) {
		cout << 0 << endl;
		return 0;
	}
	
	// A[0] > B[0]
	// A[1] < B[1]
	
	ll l[2] = { (A[0] - B[0]) * T[0], (B[1] - A[1]) * T[1] };
	// +l[0], -l[1]
	ll ans = 0;
	if (l[0] == l[1]) {
		puts("infinity");
		return 0;
	}
	
	if (l[0] > l[1]) {
		ans = 0;
	}
	else {
		
		if (debug) {
			puts("K");
				cout << l[0] << " " << l[1] << endl;
		}
		// l[0] < l[1]
		ll d = l[1] - l[0];
		ll p = -d;
		ans = 0;
		ans++;
		if (p + l[0] >= 0) {
			ans++;
			p += l[0];
			
			ans += p / d * 2;
			if (p % d != 0) ans++;
		}
		
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647;
const long long int llINF = 9223372036854775807;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll r, D, x;
  cin >> r >> D >> x;
  REP(i, 10) {
    x = (r * x) - D;
    cout << x << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, ans = INT_MIN, temp, count, y;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        temp = i;
        count = 0;
        while(temp) {
            if(!(temp%2))
                count++;
            temp /= 2;
        }
        if (count > ans) {
            y = i;
            ans = count;
        }
    }
    cout << y << endl;
    return 0;
}


Measured memory_bytes: 256