akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef unsigned long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 1e5+7;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/
ll ncr(ll n,ll r)
{
  ll i;
  if(n==0 || r==0 || n==r)
    return 1;
  ll num = 1,deno=1;
  for(i=1;i<=r;i++)
  {
    num*=(n-(i-1));
    num%=hell;
    deno*=i;
    deno%=hell;
  }
  num*=power(deno,hell-2,hell);
  num%=hell;
  return num;
}
void solve()
{
  ll n,a,b;
  cin>>n>>a>>b;
  ll sub = ncr(n,a)+ncr(n,b)+1;
  // trace2(ncr(n,a),ncr(n,b) );
  sub%=hell;
  ll ans = power(2,n,hell);
  ans = (ans-sub+hell)%hell;
  cout<<ans;
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 256
N = input()
K = int(input())

L = len(str(N))
N2 = list(str(N))
dp1 = [[0 for i in range(L+1)] for j in range(3+1)]
dp2 = [[0 for i in range(L+1)] for j in range(3+1)]
dp1[0]=[1]*(L+1)
temp = 0
for i in range(L):
    #print(temp)
    if (N2[i] != "0" and temp <= K-1):
        temp += 1
        dp2[min(temp,K)][i+1] += 1
    elif (N2[i] == "0" and dp2[min(temp,K)][i] == 1):
        dp2[min(temp,K)][i+1] += 1
#print(dp2)

dp1[1][1] = int(N2[0])-1
for i in range(1,K+1):
    for j in range(2,L+1):
        if (N2[j-1] != "0" and i == 1 ):
            dp1[i][j] += dp1[i-1][j-1]*9+dp1[i][j-1]+dp2[i][j-1]
        elif (N2[j-1] != "0" and i == 2):
            dp1[i][j] += dp1[i-1][j-1]*9+dp1[i][j-1]+dp2[i-1][j-1]*(int(N2[j-1])-1)+dp2[i][j-1]
        elif (N2[j-1] != "0" and i == 3):
            dp1[i][j] += dp1[i-1][j-1]*9+dp1[i][j-1]+dp2[i-1][j-1]*(int(N2[j-1])-1)+dp2[i][j-1]
        else:
            dp1[i][j] += dp1[i-1][j-1]*9+dp1[i][j-1]
#print(dp1)
print(dp1[K][-1]+dp2[K][-1])

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    int n ; cin >> n;
    string ans;
    if ( n % 10 == 9 || n/10 == 9) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000000
#define MAX1 500000

void merge(int*, int, int, int);
void mergeSort(int*, int, int);

int count=0;

int main (){
    int n,S[MAX1],i;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&S[i]);
    }
    mergeSort(S, 0, n);
    for(i=0; i<n; i++){
        if(i==n-1)printf("%d\n",S[i]);
        else printf("%d ",S[i]);
    }
    printf("%d\n",count);
    return 0;
}
void merge(int S[], int left, int mid, int right){
  int L[MAX1],R[MAX1],i,j,n1,n2,k;
  n1 = mid - left;
  n2 = right - mid;
  for(i=0; i<=n1; i++){
      L[i]=0;
  }
  for(i=0; i<=n2; i++){
      R[i]=0;
  }
  for(i=0; i<n1; i++){
    L[i] = S[left + i];
  }
  for(i=0; i<n2; i++){
    R[i] = S[mid + i];
  }
  L[n1] = MAX;
  R[n2] = MAX;
  i = 0;
  j = 0;
  for(k=left; k<right; k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i = i + 1;
    }else{ 
      S[k] = R[j];
      j = j + 1;
    }
    count++;
  }
}
void mergeSort(int S[], int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S, left, mid, right);
  }
}



Measured memory_bytes: 5620
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    A, B = map(int, input().split())
    XA = prime_factorize(A)
    XB = prime_factorize(B)
    sum = 1
    for i in XA:
        if i in XB:
            XB.remove(i)
        sum *= i

    for j in XB:
        sum *= j

    print(sum)

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [0 for _ in range(S+1)]
visited = [0]
dp[0] = 1
dp = tuple(dp)
for k in range(N):
  a = A[k]
  nextdp = list(dp)
  nextvisit = []
  for item in visited:
    #process1
    if item + a <= S:
      if nextdp[item+a] == 0:
        nextvisit.append(item+a)
      nextdp[item+a] += dp[item]
      nextdp[item+a] %= mod
    #process2
    if item <= S:
      nextdp[item] += dp[item]
      nextdp[item] %= mod
  dp = tuple(nextdp)
  visited.extend(nextvisit)

print(dp[-1])


Measured memory_bytes: 100392
diagram = gets.chomp.chars

search = ->{
  max = min = height = 0
  diagram.each_with_index do |x, i|
    case x
    when "\\"
      height -= 1
      min = height if height < min
    when "/"
      height += 1
      max = height if height > max
    end
  end
  [max - min, max]
}

n, level = search.()
table = Array.new(n) {[]}

diagram.each_with_index do |x, i|
  case x
  when "\\"
    table[level] << i
    level += 1
  when "/"
    level -= 1
    a = table[level].last
    table[level] << i if a
  end
  table
end
table.map! do |one_level|
  ar = []
  one_level.each_slice(2) {|x| ar << x}
  ar.select {|x| x.size == 2}
end

exist = ->(pair, level) {
  area = pair[1] - pair[0]
  return area if level == n
  table1 = table[level]
  table[level].each do |downer_pair|
    if pair[0] < downer_pair[0] and downer_pair[1] < pair[1]
      table1 -= [downer_pair]
      area += exist.(downer_pair, level + 1)
    end
  end
  table[level] = table1
  area
}

pools = []
calc_area = ->{
  min = [[Float::INFINITY, 0], 0]
  table.each_with_index do |one_level, i|
    next if one_level.empty?
    pair = one_level[0]
    min = [pair, i] if pair[0] < min[0][0]
  end
  table[min[1]] -= [min[0]]
  pools << exist.(min[0], min[1] + 1) if min[0][0] != Float::INFINITY
  calc_area.() unless table.flatten.empty?
}

calc_area.() unless table.empty?

if pools.empty?
  puts 0, 0
else
  puts pools.inject(&:+)
  puts pools.size.to_s + " " + pools.join(" ")
end


Measured memory_bytes: 123992
object Main extends App {
 val n = readInt
 val input = readLine.split(" ").map(_.toInt).sorted
 var ans = 0
 def count(l:Array[Int],k:Int, ans:Int, ab:Int):Int = {

   if(l.length <= k)
     ans
   else if(l(k) >= ab)
     ans
   else
     count(l, k + 1, ans + 1, ab)
 }  
   
 for(i <- 0 until n) {
   for(j <- i + 1 until n) {
     var ab = input(i) + input(j)
     ans = count(input,j + 1, ans, ab)
   }
 }
  println(ans)  
}


Measured memory_bytes: 27500
from bisect import bisect_left

s = input()
t = input()

n = len(s)

c = [[] for _ in range(26)]

for i, x in enumerate(s + s):
    c[ord(x) - ord('a')].append(i)

ans = 0
p = -1
for x in t:
    d = ord(x) - ord('a')
    if len(c[d]) == 0:
        print(-1)
        exit()
    p = c[d][bisect_left(c[d], p+1)]
    if p >= n:
        p -= n
        ans += 1

print(ans * n + p + 1)

Measured memory_bytes: 13232
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

signed main(){
	string S, T;
  	cin >> S >> T;
  	cout << T << S << endl;
  	return 0;
}

Measured memory_bytes: 3560
import Control.Monad
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy.Char8 as B
--
import Data.Array.Unboxed
import Data.Array.IO

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt2 :: Parser (Int,Int)
parseInt2 = liftM2 (,) parseInt parseInt

parse :: Parser (Int, Int, [[Int]], [[Int]])
parse = do
  (n,c) <- parseInt2
  ds <- replicateM c $ replicateM c parseInt
  cs <- replicateM n $ replicateM n parseInt
  return (n,c,ds,cs)

main=do
  (n,c,ds,cs) <- fromJust.evalStateT parse <$> B.getContents
  let da = listArray ((1,1),(c,c)) $ concatMap id ds :: UArray (Int,Int) Int
  let ca = listArray ((1,1),(n,n)) $ concatMap id cs :: UArray (Int,Int) Int
  --
  cnum' <- newArray ((0,1),(2,c)) 0 :: IO (IOUArray (Int,Int) Int)
  forM_ [(i,j)|i<-[1..n],j<-[1..n]] $ \(i,j) -> do
    let c = ca ! (i,j)
    writeArray cnum' ((i+j)`mod`3, c) =<< (+1) <$> readArray cnum' ((i+j)`mod`3, c)
  cnum <- freeze cnum' :: IO (UArray (Int,Int) Int)
  --
  print $ minimum $ map (\(u,v,w) -> (cc c da cnum 0 u + cc c da cnum 1 v + cc c da cnum 2 w)) [(u,v,w)|u<-[1..c], v<-[1..c], w<-[1..c], u/=v, v/=w, u/=w]

cc c da cn k ct = sum $ map (\cf-> ((cn ! (k,cf)) * (da ! (cf,ct)))) [1..c]

Measured memory_bytes: 17916
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

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

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  double n,d;
  int m;
    cin>>n>>m>>d;
  double ans=1/n;
  if(d==0){
    cout<<1/n*(m-1)<<endl;
  }
  else{
    cout<<2*(n-d)/n*(m-1)/n<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; ll K; cin >> n >> K;

    const int N = (int)1e5;
    vll tbl(N + 1);

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

    rep(i, N + 1){
        K -= tbl[i];
        if(K <= 0){
            cout << i << endl;
            return 0;
        }
    }
    assert(false);

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <sstream>
#include <cctype>
#include <cmath>
#include <cstdio>
using namespace std;

void print(int* a,int n){
	for (int s = 0;;){
		cout << a[s];
		s++;
		if (s >= n)break;
		cout << ' ';
	}
}

void InsertionSort(int* a,int n){
	for (int i = 1; i < n;){
		int v = a[i];
		int j = i - 1;
		for (; j >= 0 && a[j] > v; j--){
			a[j + 1] = a[j];
		}
		a[j + 1] = v;

		print(a,n);

		i++;
		cout << endl;
	}
}

int main(){

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

	print(a, n); cout << endl;

	InsertionSort(a, n);

	return 0;
}


Measured memory_bytes: 3092
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n, A, B;
char a[200000];

int main()
{
	int i, j, k, l;
	cin>>n>>A>>B;
	scanf("%s", a);
	int x=0, y=0;
	for(i=0;i<n;i++)
	{
		if(a[i] == 'c') printf("No\n");
		else if(a[i] == 'a')
		{
			if(x+y < A+B)
			{
				x++;
				printf("Yes\n");
			}
			else printf("No\n");
		}
		else
		{
			if(x+y < A+B && y < B)
			{
				y++;
				printf("Yes\n");
			}
			else printf("No\n");
		}
	}
	return 0;
}
//*/

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

main()
{
    optimize();
    string a;
    cin>>a;
    if(a.find("7")!=-1) cout<<"Yes" el;
    else cout<<"No" el;
}










//Brainless_Loco Terminates Here!


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n, 0);
  rep(i, n) {
    cin >> a[i];
  }
  set<int> st;
  for (int i = n; i > 0; --i) {
    int total = 0;
    for (int j = i + i; j <= n; j += i) {
      int t  = b[j - 1];
      total += t;
    }
    if (total % 2 != a[i-1]) {
      b[i-1] = 1;
      st.insert(i);
    }
  }

  cout << st.size() << endl;
  for (auto itr : st) {
    cout << itr << " ";
  }
  END;
}


Measured memory_bytes: 8448
#include <stdio.h>
#include <string.h>
int main(){
  char s[11],r[11]={'\0'};
  scanf("%s",s);
  int n=strlen(s);
  for(int i=0;i<n;i++){
    int m=strlen(r);
    if(s[i]=='B')r[m-1]='\0';
    else r[m]=s[i];
  }
  printf("%s",r);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define pb push_back
#define ll long long
#define PI 3.14159265
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define eps 1e-7
const int mod=1e9+7;
const int maxn=1e5+5;
using namespace std;
ll n,k;
//ll a,b,x,y,z;
char a[100];
int main()
{
   //  std::ios::sync_with_stdio(false);
//    cin.tie(0);
 //   cout.tie(0);
   scanf("%s",a);
   int l=strlen(a);
   cout<<"2018";
   for(int i=4;i<l;i++)
   {
       cout<<a[i];
   }
   cout<<endl;
    return 0;
}


Measured memory_bytes: 256
N, K, Q = list(map(int, input().split()))
A = [int(input()) for i in range(Q)]
num = [0 for i in range(N)]
for i in range(Q):
        num[A[i]-1] += 1
for i in range(N):
        if Q-K < num[i]:
                print("Yes")
        else:
                print("No")

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

int main() {
    int N; cin >> N;
    vector<long long> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];
    sort(L.begin(), L.end()); // L をソートしておく (二分探索に必要)

    long long res = 0;
    
    // a と b を固定
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            // c の動ける範囲の右端を求める
            int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();

            // c の動ける範囲は、[j+1, k)
            res += max(k - (j+1), 0);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int a,b;

int main(){
	cin>>a>>b;
	cout<<a*b-a-b+1<<endl;
	return 0;
}



Measured memory_bytes: 256
A,B,C = map(int, input().split())
K = int(input())

cnt = 0
for i in range(100):
  if A >= B:
    B *= 2
    cnt += 1
    continue
  if B >= C:
    C *= 2
    cnt += 1
    continue

if cnt <= K:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[0 for i in range(5)] for j in range(L+1)]

def cost(s, a):
    if s == 0 or s == 4:
        return a
    elif s == 1 or s == 3:
        if a > 0:
            return a%2
        else:
            return 2
    else:
        return (a+1)%2

for i in range(L):
    DP[i+1][0] = min(DP[i][:1]) + cost(0, A[i])
    DP[i+1][1] = min(DP[i][:2]) + cost(1, A[i])
    DP[i+1][2] = min(DP[i][:3]) + cost(2, A[i])
    DP[i+1][3] = min(DP[i][:4]) + cost(3, A[i])
    DP[i+1][4] = min(DP[i][:5]) + cost(4, A[i])



print(min(DP[L]))

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

struct StronglyConnectedComponentDecomposition {
    vector<vector<int>> graph, igraph, sccbucket;
    vector<int> vs, sccid;
    int nscc;
    void dfs(int v) {
        sccid[v] = 0;
        for (int u : graph[v]) {
            if (sccid[u] == -1) dfs(u);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k) {
        sccid[v] = k;
        for (int u : igraph[v]) {
            if (sccid[u] == -1) rdfs(u, k);
        }
    }
    void sccd() {
        sccid.assign(graph.size(), -1);
        for (int v = 0; v < (int)graph.size(); ++v) {
            if (sccid[v] == -1) dfs(v);
        }
        sccid.assign(graph.size(), -1);
        reverse(vs.begin(), vs.end());
        nscc = 0;
        for (int v : vs) {
            if (sccid[v] == -1) rdfs(v, nscc++);
        }
        sccbucket.resize(nscc);
        for (int v = 0; v < (int)graph.size(); ++v) {
            sccbucket[sccid[v]].push_back(v);
        }
    }
};

int main() {
    int V, E;
    cin >> V >> E;
    StronglyConnectedComponentDecomposition sccd;
    sccd.graph.resize(V);
    sccd.igraph.resize(V);
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        sccd.graph[s].push_back(t);
        sccd.igraph[t].push_back(s);
    }
    int Q;
    cin >> Q;
    vector<int> u(Q), v(Q);
    for (int i = 0; i < Q; ++i) cin >> u[i] >> v[i];
    
    sccd.sccd();
    for (int i = 0; i < Q; ++i) {
        cout << (sccd.sccid[u[i]] == sccd.sccid[v[i]]) << endl;
    }
}


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

using namespace std;

#define pq priority_queue
#define MZ 1000000007

int ask(int x,int y,int z)
{
    int now=x/y;
    now=now*(y-z)+max(0,x%y-z+1);
    if(z==0)
        now--;
    return now;
}

int main()
{
    int n,k;
    long long ans=0;
    scanf("%d%d",&n,&k);
    for(int i=k+1;i<=n;i++)
        ans+=ask(n,i,k);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	string d, e, choose;
	cin >> d >> e >> a >> b >> choose;
	if(d == choose) {
		a--;
	} else {
		b--;
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const ll MOD = 1000000007;
vector<vector<int> > G;

void dfs(int v, int pa, vector<vector<ll> >& dp) {
  if (G[v].size() == 1 && G[v][0] == pa) { //葉
    dp[v][0] = 1;
    dp[v][1] = 1;
    return;
  }
  ll resw = 1, resb = 1;
  for (auto to : G[v]) {
    if (to == pa) continue;
    dfs(to, v, dp);
    resw *= (dp[to][0] + dp[to][1]) % MOD; //白黒どっちもOK
    resb *= dp[to][0] % MOD; //白だけok
    resw %= MOD;
    resb %= MOD;
  }
  dp[v][0] = resw;
  dp[v][1] = resb;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  G.resize(n);
  rep(i,n-1) {
    int x,y;
    cin >> x >> y;
    x--; y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  vector<vector<ll> > dp(n+5, vector<ll>(2,0));
  dfs(0, -1, dp);
  ll ans = (dp[0][0] + dp[0][1]) % MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19584
#include <iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	string correct = "CODEFESTIVAL2016";

	int res = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != correct[i]) {
			res++;
		}
	}
	cout << res << endl;
}

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

int main() {
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int b;
  cin>>b;
  cout<<a.at(b-1)<<endl;
}

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

using namespace std;

int main() {
    int n,m;

    cin >> n >> m;

    int wa[n]={0};
    bool ac[n]={false};

    int x=0;

    int p=0;

    for(int i = 0; i < m; i++) {
        int a;
        string s;

        cin >> a >> s;

        a=a-1;
        
        if(s=="WA"){
            if(ac[a]==false){
                wa[a]++;
            }
        }else{
            ac[a]=true;
        }
    }

    for(int i = 0; i < n; i++) {
        if(ac[i]==false){
            wa[i]=0;
        }
    }
    
    cout << accumulate(ac,ac+n,0) << " " << accumulate(wa,wa+n,0) << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>

int main(int argc, char** argv)
{
    int prev_time = 0;
    int prev_x = 0;
    int prev_y = 0;
    int n = 0;
    bool is_success = true;

    std::cin >> n;

    for(int ii = 0; ii < n; ++ii)
    {
        int cur_time, cur_x, cur_y = 0;

        std::cin >> cur_time >> cur_x >> cur_y;

        int diff_time = cur_time - prev_time;
        int diff_x = std::abs(cur_x - prev_x);
        int diff_y = std::abs(cur_y - prev_y);

        if ((diff_time % 2 != (diff_x + diff_y) % 2) ||
            (diff_time < diff_x + diff_y))
        {
            is_success = false;
        }

        cur_time = prev_time;
        cur_x = prev_x;
        cur_y = prev_y;
    }

    std::string result = is_success ? "Yes" : "No";
    std::cout << result << std::endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long Int;
Int n, dist, need;
Int a[108000],b[108000];
int main(){
	cin >> n;
	for(int i = 0;i < n;i++)cin >> a[i];
	for(int i = 0;i < n;i++)cin >> b[i];
	Int dist = 0;
	for(int i = 0;i < n;i++){
		dist += b[i] - a[i];
		if(a[i] > b[i])need += a[i]-b[i];
		else if((a[i] - b[i]) % 2 != 0)need++;
	}
	if(dist >= need)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
vector<LL>v;
LL kaizyou(LL x,LL y){
   if(x<y)return 0;
   LL ans=1;
   REP(i,y){
       ans*=(x-y+i+1);
       ans/=i+1;
   }
   return ans;
}
int main(){
        LL N,A,B;
	cin>>N>>A>>B;
	REP(i,N){
	    LL a;
	    cin>>a;
	    v.push_back(a);
	}
	sort(v.begin(),v.end(),greater<LL>());
	LL res=0;
	LL current=-1;
	REP(i,A){
	  res+=v[i];
	  if(i==A-1){
	     current=v[i];
	  }
	}
	LL count=0;
	REP(i,N){
	    if(v[i]==current)count++;
	}
	if(v[0]==current){
	   /*LL temp=min(B,count);
	   LL ans=1;
	   if(B<count){
	       LL temp2=count-B;
	       REP(i,temp2){
	           ans*=(count-temp2+i+1);
	           ans/=(i+1);
	       }
	   }
	   REP(i,temp){
	       ans*=2;
	   }
	   LL ans2=1;
	   REP(i,A-1){
	       ans2*=2;
	   }*/
	   LL ans=0;
	   for(int i=A;i<=B;i++){
	       ans+=kaizyou(count,i);
	   }
	   cout<<fixed<<res/(double)A<<endl<<ans<<endl;
	}else{
	   LL temp2=0;
	   REP(i,A){
	       if(current==v[i]){
	          temp2=A-i;
	          break;
	       }
	   }
	   LL ans=1;
	   REP(i,temp2){
	       ans*=(count-temp2+i+1);
	       ans/=(i+1);
	   }
	   cout<<fixed<<res/(double)A<<endl<<ans<<endl;
	}
	return(0);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin>>n>>m;

    vector<vi> sw(m);
    vi p(m);
    REP(i,m){
        int k;
        cin>>k;
        REP(j,k){
            int s;
            cin>>s;
            s--;
            sw[i].emplace_back(s);
        }
    }
    REP(i,m) cin>>p[i];

    ll ans = 0;
    REP(i, 1<<n){
        vector<bool> lightup(m,false);

        REP(j,m){
            int tmp=0;
            REP(k,sw[j].size()){
                if( (i>>sw[j][k]) & 1 ) tmp++;
            }
            //DEBUG2(j,tmp);
            if( tmp%2 == p[j] )
                lightup[j]=true;
        }

        bool flg=true;
        REP(j,m){
            if(!lightup[j]) flg = false;
        }

        if(flg) ans++;
    }

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

Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  int n;
  cin>>n;
  int h,maxh,count=1;
  cin>>maxh;
  for(int i=1;i<n;i++){
    cin>>h;
    if(h>=maxh){
      count++;
      maxh=h;
    }
  }
  cout<<count<<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n)cin >> h[i];
    int active = 0, ans = 0;
    rep(i, n){
        if(active >= h[i]){
            active = h[i];
        }
        else{
            ans += h[i] - active;
            active = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def inpl():
    return list(map(int, input().split()))


MOD = 10**9 + 7

N, M = inpl()
A = [False for i in range(N + 1)]
for i in range(M):
    a = int(input())
    A[a] = True
p = 1
pp = 0
ans = 0

for i in range(1, N + 1):
    if A[i] is True:
        pp = p
        p = 0
    else:
        ans = (p + pp) % MOD
        pp = p
        p = ans
    # print(ans)

print(ans % MOD)


Measured memory_bytes: 3888
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort(key=lambda a: abs(a), reverse=True)
    A_pos = []
    A_neg = []
    for a in A:
        if a >= 0:
            A_pos.append(a)
        else:
            A_neg.append(-a)
    pos_last = 0.1
    neg_last = 0.1
    ans = 1
    cnt = 0
    for a in A[:K]:
        if a >= 0:
            pos_last = a
            ans = (ans * a)%mod
        else:
            neg_last = -a
            ans = (ans * a)%mod
            cnt += 1
    if cnt%2 == 0:
        print(ans)
        exit()

    if pos_last == 0.1:
        pos_add = -1
        for i in range(K, N):
            if A[i] >= 0:
                pos_add = A[i]
                break
        if pos_add == -1:
            ans = 1
            A.reverse()
            for a in A[:K]:
                ans = (ans * a)%mod
            print(ans)
            exit()
        else:
            neg_del = neg_last
            if neg_del == 0.1:
                print(ans)
            else:
                print(((-ans) * pos_add * pow(neg_del, mod-2, mod))%mod)
    else:
        if neg_last == 0.1:
            neg_add = 1
            for i in range(K, N):
                if A[i] < 0:
                    neg_add = -A[i]
                    break
            if neg_add == 1:
                assert False
            else:
                print(((-ans) * neg_add * pow(pos_last, mod - 2, mod)) % mod)
        else:
            pos_add = -1
            for i in range(K, N):
                if A[i] >= 0:
                    pos_add = A[i]
                    break
            neg_add = 1
            for i in range(K, N):
                if A[i] < 0:
                    neg_add = -A[i]
                    break
            if pos_add == -1 and neg_add == 1:
                print(ans)
            elif pos_add == -1:
                print(((-ans) * neg_add * pow(pos_last, mod - 2, mod)) % mod)
            elif neg_add == 1:
                print(((-ans) * pos_add * pow(neg_last, mod - 2, mod)) % mod)
            else:
                if pos_add * pos_last > neg_add * neg_last:
                    print(((-ans) * pos_add * pow(neg_last, mod - 2, mod)) % mod)
                else:
                    print(((-ans) * neg_add * pow(pos_last, mod - 2, mod)) % mod)


if __name__ == '__main__':
    main()


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

    vector<string>a(n);

    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    for(int i=0; i<n; i++){

        cout << a.at(i) ;
}
}


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

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

void sol( ){
    ll n ;
    cin >> n ;
    vector<ll>a, b ;
    for(ll i=0;i<n;i++){
        ll x, y ;
        cin >> x >> y ;
        a.pb(x+y) ;
        b.pb(x-y) ;
    }
    sort(all(a)) ;
    sort(all(b)) ;
    ll ans = max( a.back()-a[0], b.back()-b[0] ) ;
    cout << ans << nl ;
}

signed main( ){
  timesaver ;
//  int t = 1 ; cin >> t ; while(t--)
  {
      sol( );
  }
}

Measured memory_bytes: 6688
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<lint> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    sort(all(x));
    vector<lint> d(m - 1);
    for (int i = 0; i < m - 1; i++) {
        d[i] = x[i + 1] - x[i];
    }
    sort(all(d), greater<lint>());
    lint shortcut = 0;
    for (int i = 0; i < n - 1 && i < m - 1; i++) {
        shortcut += d[i];
    }
    cout << x[m - 1] - x[0] - shortcut << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	string s, ans = "Yes";
	cin >> s;
	rep(i, 0, 4) {
		int count = 0;
		rep(j, 0, 4) {
			if (s[i] == s[j]) {
				count++;
			}
		}
		if (count != 2) {
			ans = "No";
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll A, B;
        cin >> A >> B;
        rep(i, 1, 10000) {
            if (floor(i*0.08) == A and floor(i*0.1) == B) {
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
}



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

using namespace std;

int main(){
    long long int A,B,C,K;
    cin >> A >> B >> C >> K;

    if(K<=A){
        cout << K << endl;
    }else if(K<=A+B){
        cout << A << endl;
    }else{
        cout << A-(K-A-B) << endl;
    }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

template<class T>
ostream& operator<<(ostream& os,const vector<T>& a)
{
	os<<'[';
	rep(i,a.size())
		os<<(i?" ":"")<<a[i];
	return os<<']';
}

bool canput(vvi& grid,int x,int y,int bw,int bh,int index)
{
	int h=grid.size(),w=grid[0].size();
	if(x<0 || w<x+bw || y<0 || h<y+bh)
		return false;
	bool flg=false;
	rep(i,bh) rep(j,bw){
		int cell=grid[y+i][x+j];
		if(cell!=-1 && cell!=index)
			return false;
		flg|=cell==index;
	}
	return flg;
}

void put(vvi& grid,int x,int y,int bw,int bh,int index)
{
	rep(i,bh) rep(j,bw)
		grid[y+i][x+j]=index;
}

vvi res;
int solve(vvi& grid,const vi& bs,const vi& ks,const vector<pii>& ps,int index)
{
	if(index==bs.size()){
		if(res.empty())
			res=grid;
		return 1;
	}
	
	int x=ps[index].first,y=ps[index].second;
	int area=ks[index];
	int res=0;
	repi(bh,1,area+1) if(area%bh==0){
		int bw=area/bh;
		rep(i,bh) rep(j,bw){
			int left=x-j,top=y-i;
			if(canput(grid,left,top,bw,bh,index)){
				put(grid,left,top,bw,bh,index);
				res+=solve(grid,bs,ks,ps,index+1);
				put(grid,left,top,bw,bh,-1);
				grid[y][x]=index;
			}
		}
	}
	return res;
}

int main()
{
	for(int w,h,n;cin>>w>>h>>n,w|h|n;){
		vi bs(n),ks(n);
		rep(i,n) cin>>bs[i]>>ks[i];
		
		vvi grid(h,vi(w));
		rep(i,h) rep(j,w) cin>>grid[i][j];
		
		if(accumulate(all(ks),0)!=w*h){
			cout<<"NA"<<endl;
			continue;
		}
		
		vector<pii> ps(n);
		rep(i,h) rep(j,w){
			if(grid[i][j]==0)
				grid[i][j]=-1;
			else{
				grid[i][j]=find(all(bs),grid[i][j])-bs.begin();
				ps[grid[i][j]]=mp(j,i);
			}
		}
		
		res.clear();
		int cnt=solve(grid,bs,ks,ps,0);
		if(cnt!=1)
			cout<<"NA"<<endl;
		else
			rep(i,h) rep(j,w)
				cout<<bs[res[i][j]]<<(j==w-1?'\n':' ');
	}
	
	return 0;
}

Measured memory_bytes: 1220
let N = stdin.ReadLine() |> int
let H = stdin.ReadLine().Split() |> Array.map int

let solver =
    let rec loop t r i =
        if i = N then r
        elif H.[i] >= t then loop (max H.[i] t) (r + 1) (i + 1)
        else loop (max H.[i] t) r (i + 1)
    loop H.[0] 0 0

solver |> stdout.WriteLine


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

class Main{
    public static void main(String[] args) throws IOException{
	Scanner s=new Scanner(System.in);
	int i,n,m,gt=0;

	Queue<String>q=new LinkedList<String>();
	Queue<Integer>time=new LinkedList<Integer>();

	n=s.nextInt();
	m=s.nextInt();

	for(i=0;i<n;i++){
	    q.add(s.next());
	    time.add(s.nextInt());
	}

	while(0<q.size()){
	    if(0<(time.peek()-m)){
		q.add(q.poll());
		time.add(time.poll()-m);
		gt=gt+m;
	    }
	    else{
		gt=gt+time.poll();
		System.out.println(q.poll()+" "+gt);
	    }
	}
    }
}



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


void solve(long long N, std::string S){
    string alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for(int i=0;i<S.size();i++){
        for(int j=0;j<alphabets.size();j++){
            if(S[i] == alphabets[j]){
                S[i] = alphabets[(j+N)%alphabets.size()];
                break;
            }
        }
    }
    cout << S << endl;


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC129().SolveC(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  class ABC129
  {
  	public void SolveC(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var m = cin.ReadInt;
            var A = new int[m];
            for (int i = 0; i < m; i++)
            {
                A[i] = cin.ReadInt;
            }
            int MOD = (int)Pow(10, 9) + 7;
            var count = new int[n + 1];
            for (int i = 0; i < n + 1; i++)
            {
                count[i] = 1;
            }
            for (int i = 0; i < m; i++)
            {
                count[A[i]] = 0;
            }
            for (int i = 2; i < n + 1; i++)
            {
                if (count[i] == 0) continue;
                count[i] = (count[i - 1] + count[i - 2]) % MOD;
            }
            WriteLine(count[n]);
            ReadLine();
        }
  }
  
}


Measured memory_bytes: 17364