akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define MAX 1010

const char *gen[5] = {
  "pre-meiji",
  "meiji",
  "taisho",
  "showa",
  "heisei"
};

int data[4][3] = {
  {1868,9,8},
  {1912,7,30},
  {1926,12,25},
  {1989,1,8}
};

int main(){
  int y, m, d;
  while(cin>>y>>m>>d){
    int ans = 0;
    REP(i, 4)
      if((y >  data[i][0]) ||
	 (y == data[i][0] && m >  data[i][1]) ||
	 (y == data[i][0] && m == data[i][1] && d >= data[i][2]))
	ans++;
    printf("%s",gen[ans]);
    if(ans != 0)
      printf(" %d %d %d", y-data[ans-1][0]+1, m, d);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 0
//approach 3--optimised approach
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int32_t main(){
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int dp[n+1][k+1];
    memset(dp,0,sizeof dp);
    //if x is greater than a[1] then there is no way to distribute x chocolates to 1st children
    //else there is 1 way
    for(int x=0;x<=k;x++){
        if(x<=a[1]){
            dp[1][x]=1;
        }
        else{
            dp[1][x]=0;
        }
    }
    //there is always a way to distribute 0 chocolates to i children
    for(int i=1;i<=n;i++){
        dp[i][0]=1;
    }
    for(int i=2;i<=n;i++){
        for(int x=1;x<=k;x++){
            
            if(x-a[i]-1>=0){
                //recurrence is given below but we can access dp[i-1][x-a[i]-1] only if x-a[i]-1>=0
                dp[i][x]=(dp[i][x-1]+dp[i-1][x]-dp[i-1][x-a[i]-1]+mod)%mod;
                
            }
            else{
                dp[i][x]=(dp[i][x-1]+dp[i-1][x])%mod;
            }
        }
    }    
    cout<<dp[n][k]<<endl;
    return 0;
}

Measured memory_bytes: 79104
import math
a,b,x = map(float,input().split())

h = x/(a**2)

if h >= b/2:
  angle = math.atan((b-h)/(a/2))
else:
  area = a*h
  c = 2*area/b
  angle = math.atan(b/c)
print(math.degrees(angle))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;
const int MAXN = 1000500;
const int MAXVALUE = 1000000500;
const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <i64> a;
vector <i64> dp;



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

    i64 n;
    cin >> n;

    i64 res = 0;

    if (n > 1) {
        i64 n0 = (i64)sqrt(n);

        vector<char> prime(n0 + 1, true);
        prime[0] = prime[1] = false;
        for (i64 i = 2; i <= n0; ++i)
            if (prime[i])
                if (i * i <= n0)
                    for (i64 j = i*i; j <= n0; j += i)
                        prime[j] = false;


        for (i64 i = 0; i < prime.size(); ++i) {
            i64 x = prime[i];
            if (x == 1) {
                i64 counter = 0;
                i64 it = 1;
                while (n % i == 0) {
                    counter += 1;
                    n /= i;
                    if (counter == it) {
                        it += 1;
                        counter = 0;
                        res += 1;
                    }
                }

            }
        }

        if (n != 1) {
            res += 1;
        }
    }

    

    

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3820
#include <stdio.h>

int main(void)
{
	int num;
	int ans = 1;
	int i;

	scanf("%d", &num);

	if(1>num&&num>100)
	{
		return 1;
	}

	for(i=0; i<3; i++)
	{
		ans *= num;
	}

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

	return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		long[] num = new long[n+1];
		long c = 0;
		for(int i = 0; i < n; i++) {
			if (s[i] == '<') c++;
		      else c = 0;
		      num[i + 1] = c;
		}
		long ans = 0;
		long count = 0;
		for(int i = n-1; i >= 0; i--) {
			if(s[i]=='>') {
				count++;
			}
			else count = 0;
			num[i] = Math.max(num[i], count);
		}
		for (long value : num) ans += value;
		System.out.println(ans);
	 }
}

Measured memory_bytes: 34100
A,B,H,M = map(int,input().split())
import math
 
d = 30*(H%12)+0.5*M -6*M
 
if d<0:
    d = -d
if d>180:
    d = 360 -d
 
 
c = A**2 + B**2 - 2*A*B*math.cos(math.radians(d))
 
print(math.sqrt(c))

Measured memory_bytes: 62428
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
#define sz(a) a.size()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;i++)cout<<s[i]<<t[i];
	cout<<endl;
	return 0;
}

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

using namespace std;
int main(void){
    int n=0;
    cin >> n;
    vector<string>vec(n, " ");
    rep(i, n){
        cin >> vec[i];
        if (count(vec.begin(), vec.end(), vec[i])==2){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=1; i<n; i++){
        if (vec[i-1].back() != vec[i][0]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n5,n7,C;
	n5 = n7 = 0;
	for(int i = 0;i < 3;i++){
        scanf("%d",&C);
	    if(C==5) n5++;
        if(C==7) n7++;
	}
	if(n5==2&&n7==1) printf("YES\n");
    else printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	
	int a, b;
	cin >> a >> b;
	
	for(int i = 1; i <= 3; i++){
		if(i != a && i != b){
			cout << i << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a;
string b = "aiueo";
int c = 0;
int i;

int main(){
  cin>>a;
  for(i=0;i<5;++i){
    if(a == b[i]){
      cout<<"vowel"<<endl;
      c = 1;
      break;
    }
  }
  if(c == 0){
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
 
  int a,b,c;
   
  scanf("%d %d %d",&a ,&b ,&c);
 
  if(a < b && b < c) printf("%d %d %d\n",a ,b ,c);
  else if(a <= c && c <= b) printf("%d %d %d\n",a ,c ,b);
  else if(b <= a && a <= c) printf("%d %d %d\n",b ,a ,c);
  else if(b <= c && c <= a) printf("%d %d %d\n",b ,c ,a);
  else if(c <= a && a <= b) printf("%d %d %d\n",c ,a ,b);
  else if(c <= b && b <= a) printf("%d %d %d\n",c ,b ,a);
 
  return 0;
 
}


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

int main(){
  long long n;
  cin >> n;
  int tmp=n,sum=0;
  while(n){
    sum+=n%10;
    n/=10;
  }
  if(tmp%sum==0){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<unordered_map>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int h[n],i;
	for(i=0;i<n;i++)
		cin>>h[i];
	int o=0,x=0;
	for(i=1;i<n;i++)
	{
		if(h[i]<=h[i-1])
			x++;
		else
		{
			o=max(o,x);
			x=0;
		}
	}
	cout<<max(x,o)<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

vector<long long int> fac;

const int mod = 1e9 + 7;

long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}

long long int myc(long long int a, long long int b) {
    return fac[a] * mypow(fac[b], mod - 2) % mod * mypow(fac[a - b], mod - 2) % mod;
}

int main() { 
    long long int n, m, k;
    cin >> n >> m >> k;
    fac.push_back(1);
    for (int i = 1; i <= n * m; i++) {
        fac.push_back(fac.back() * i % mod);
    }
    long long int res = 0;
    long long int col_dist = 0, row_dist = 0;
    long long int col_type = 0, row_type = 0;
    for (long long int i = 0; i <= m - 1; i++) {
        col_dist += i * (m - i) % mod;
        col_dist %= mod;
        col_type += m - i;
        col_type %= mod;
    }
    col_type = n * n % mod;
    for (long long int i = 0; i <= n - 1; i++) {
        row_dist += i * (n - i) % mod;
        row_dist %= mod;
        row_type += n - i;
        row_type %= mod;
    }
    row_type = m * m % mod;
    cout << (col_dist * col_type + row_type * row_dist) % mod * myc(m * n - 2, k - 2) % mod << endl;

}




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


int main(){
    string s;
    cin >> s;
    if(s[1] == 'B'){
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=300005,INF=1<<30;
int p[MAX],v[MAX],w[MAX];

vector<pair<int,int>> C[MAX];

vector<int> use[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    
    p[0]=-1;
    for(int i=2;i<=N;i++){
        p[i-1]=i/2-1;
    }
    
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }
    
    for(int i=0;i<(1<<10);i++){
        for(int j=0;j<10;j++){
            if(i&(1<<j)) use[i].push_back(j);
        }
    }
    
    int Q;cin>>Q;
    
    for(int u=0;u<min(N,511);u++){
        vector<int> A,B;
        int save=u;
        while(u!=-1){
            A.push_back(v[u]);
            B.push_back(w[u]);
            u=p[u];
        }
        u=save;
        int M=si(A);
        C[u].push_back(mp(0,0));
        
        for(int bit=0;bit<(1<<M);bit++){
            int vsum=0,wsum=0;
            for(int i:use[bit]){
                vsum+=A[i];
                wsum+=B[i];
            }
            C[u].push_back(mp(wsum,vsum));
        }
        
        sort(all(C[u]));
    }
    
    vector<int> A,B;
    
    while(Q--){
        int u,L;cin>>u>>L;
        u--;
        
        if(u<min(N,511)){
            int ans=0;
            for(int i=0;i<si(C[u]);i++){
                if(C[u][i].fi<=L) chmax(ans,C[u][i].se);
            }
            cout<<ans<<"\n";
            continue;
        }
        
        while(u>=511){
            A.push_back(v[u]);
            B.push_back(w[u]);
            u=p[u];
        }
        
        int M=si(A);
        
        vector<pair<int,int>> D(1<<M);
        
        for(int bit=0;bit<(1<<M);bit++){
            int vsum=0,wsum=0;
            for(int i:use[bit]){
                vsum+=A[i];
                wsum+=B[i];
            }
            D[bit]=(mp(L-wsum,vsum));
        }
        
        D.push_back(mp(0,0));
        D.push_back(mp(L,0));
        
        sort(all(D));
        
        for(int i=si(D)-2;i>=0;i--) chmax(D[i].se,D[i+1].se);
        
        int ans=0;
        
        int id=0;
        
        for(int i=0;i<si(C[u]);i++){
            if(C[u][i].fi>L) break;
            while(id<si(D)&&C[u][i].fi>D[id].fi) id++;
            chmax(ans,C[u][i].se+D[id].se);
        }
        
        cout<<ans<<"\n";
        
        A.clear();
        B.clear();
    }
    
}


Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a < b && b < c){
			System.out.printf("Yes\n");
		}else{
			System.out.printf("No\n");
		}
	}
}




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

void dump(vector<int>& v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if (i != (v.size() - 1))
        {
            cout << ' ';
        }
    }
    cout << endl;
}

int main(void)
{
    int n;
    cin >> n;
    vector<int> v;
    while (n-- > 0)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }

    dump(v);
    for (int i = 1; i < v.size(); i++)
    {
        int x = v[i];
        int j = i - 1;
        for (; j >= 0 && v[j] > x; j--) {
            swap(v[j+1], v[j]);
        }
        dump(v);
    }

    return 0;
}

Measured memory_bytes: 3092
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=parseMap(split(readline()))
    if a==b
        println(c)
    elseif a==c
        println(b)
    else
        println(a)
    end
end
main()

Measured memory_bytes: 166012
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#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 ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    ll c=0,x=1,g=0,n,h,w,k,m,l,ans=0,ptr=0;
    string s,s1,s2;
    cin >> n >> h;
    VI a(n);
    h*=2;
    if(n <= h)
        cout << 0 << endl;
    else cout << n-h << endl;
    return 0;
}



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

int main()
{
    string S;
    cin >> S;

    string ans = "Yes";
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0 && S[i] == 'L') {
            ans = "No";
            break;
        }
        else if (i % 2 != 0 && S[i] == 'R') {
            ans = "No";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  long H,W;
  cin>>H>>W;

  long ans=1234567890;
  for(long i=0;i<H;i++){
    long h1= i;
    long h2 = (H-i)/2;
    long h3 = H-h1-h2;
    long s1 = h1*W;
    long s2 = h2*W;
    long s3 = h3*W;
    long m=min(s1,min(s2,s3));
    long M=max(s1,max(s2,s3));
    ans = min(ans,M-m);
  }

  for(long i=0;i<W;i++){
    long w1= i;
    long w2 = (H-i)/2;
    long w3 = H-w1-w2;
    long s1 = w1*H;
    long s2 = w2*H;
    long s3 = w3*H;
    long m=min(s1,min(s2,s3));
    long M=max(s1,max(s2,s3));
    ans = min(ans,M-m);
  }

  for(long i=0;i<H;i++){
    long h1= i;
    long h2=H-i;
    long h3=H-i;
    long w1=W;
    long w2= W/2;
    long w3= W-w2;
    long s1=h1*w1;
    long s2=h2*w2;
    long s3=h3*w3;
    long m=min(s1,min(s2,s3));
    long M=max(s1,max(s2,s3));
    ans = min(ans,M-m);
  }

  for(long i=0;i<W;i++){
    long w1= i;
    long w2=W-i;
    long w3=W-i;
    long h1=H;
    long h2= H/2;
    long h3= H-h2;
    long s1=h1*w1;
    long s2=h2*w2;
    long s3=h3*w3;
    long m=min(s1,min(s2,s3));
    long M=max(s1,max(s2,s3));
    ans = min(ans,M-m);
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = A%10
b = B%10
c = C%10
d = D%10
e = E%10
l = [A,B,C,D,E]
ans = 0
for i in l:
    if i%10 == 0:
        ans += i
    else:
        ans += i-i%10+10
ans -= max((10-a)%10,(10-b)%10,(10-c)%10,(10-d)%10,(10-e)%10)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef unsigned long long ull;

using namespace std;

int sq(int a, int b) {
	return (a - b) * (a - b);
}

int main() {
	while (true) {
		int a, b;
		cin >> a >> b;
		if (!(a | b))
			break;
		int ans = 1 << 29;
		for (int i = 1; i * i <= a; i++) {
			if (a % i != 0)
				continue;
			int a1 = i;
			int a2 = a / i;
			for (int j = 1; j * j <= b; j++) {
				if (b % j != 0)
					continue;
				int b1 = j;
				int b2 = b / j;
				vector<int> tmp;
				tmp.push_back(a1);
				tmp.push_back(b1);
				tmp.push_back(a2);
				tmp.push_back(b2);
				sort(tmp.begin(), tmp.end());
				int sum = 0;
				for (int i = 0; i < 3; i++) {
					sum += sq(tmp[i], tmp[i + 1]);
				}
				ans = min(ans, sum);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

ll l_pow(ll a, ll b){
  ll result = 1;
  ll base = a;
  for(int i = 0; i < 64; i++){
    if((b & (1l << i)) != 0){
      result = (result * base) % MOD;
    }
    base = (base * base) % MOD;
  }
  return result;
}

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

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

  set< int > s;
  for(int i = 0; i < m; i++){
    s.insert(a[i]);
  }

  ll dp[n + 1];
  dp[0] = dp[1] = 1;
  for(int i = 2; i <= n; i++){
    ll d1 = (s.find(i - 1) != s.end() ? 0 : dp[i - 1]);
    ll d2 = (s.find(i - 2) != s.end() ? 0 : dp[i - 2]);
    dp[i] = (d1 + d2) % MOD;
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 6144
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>

using namespace std;
int main()
{
	int x;

	cin >> x;

	if (x <= 599) {
		cout << "8" << endl;
	}
	else if (x <= 799) {
		cout << "7" << endl;

	}
	else if (x <= 999) {
		cout << "6" << endl;
	}
	else if (x <= 1199) {
		cout << "5" << endl;
	}
	else if (x <= 1399) {
		cout << "4" << endl;

	}
	else if (x <= 1599) {
		cout << "3" << endl;

	}
	else if (x <= 1799) {
		cout << "2" << endl;

	}
	else if (x <= 1999) {
		cout << "1" << endl;

	}

	return 0;

}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  rep(i, s.size()) if(!(i%2)) cout << s[i];
  cout << endl;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
 
struct job{
	int a;
	int b;
}s[200010];
 
int cmp(job a,job b)
{
	if(a.b!=b.b)
	{
		return a.b<b.b;
	}
	else{
		return a.a<b.a;
	}
 } 
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i].a>>s[i].b;
	}
	sort(s,s+n+1,cmp);
	int t=0;
	for(int i=0;i<=n;i++)
	{
		t+=s[i].a; 
		if(t>s[i].b)
		{
			cout<<"No"<<endl;
			return 0;
		 } 
	 } 
	 cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1792
#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 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 DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m,a,b;
int d[2521];

int main(){
  scanf("%d%d%d%d",&n,&m,&a,&b);
  REP(i,n)scanf("%d",d+i);
  vi trash;
  REP(i,n){
    if(d[i]<a)break;
    trash.push_back(d[i]);
  }
  if(n-trash.size()<m){
    while(trash.size()){
      if(trash.back()<=b){
        trash.pop_back();
      }else{
        break;
      }
    }
  }
  printf("%d\n", trash.size());
  return 0;
}

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

const int MAX_N = 1005;
int N, K;
int as[MAX_N];

int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; ++i)
    scanf("%d", as + i);
  std::sort(as, as+N);
  int ans = 0;
  for (int i = 0; i < K; ++i)
    ans += as[i];
  printf("%d\n", ans);
}


Measured memory_bytes: 3832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        long N = nl();
        long K = nl();
        
        long ans = 0;
        for (long i = K; i <= N+1; i++) {
            long upp = i * (2*N - i + 1)/2;
            long low = i * (i-1)/2;
            ans += ((upp-low+1)%mod);
            ans = ans % mod;
        }
 
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);
    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33288
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
// vint divisor(ll n){ // nの約数
//   vint ret;
//   for(ll i=1;i*i<=n;i++){
//     if(n%i == 0){
//       ret.pb(i);
//       if(i*i!=n) ret.pb(n/i);
//     }
//   }
//   vsort(ret);
//   return ret;
// }
//
// ll get_digits_num(ll n){
//   ll ret=0;
//   while(n){
//     n/=10;
//     ret++;
//   }
//   return ret;
// }



int main() {
  cout<<fixed<<setprecision(10);

  ll sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  rep(i,ty-sy)cout<<'U';
  rep(i,tx-sx)cout<<'R';
  rep(i,ty-sy)cout<<'D';
  rep(i,tx-sx)cout<<'L';
  cout<<'L';
  rep(i,ty-sy+1)cout<<'U';
  rep(i,tx-sx+1)cout<<'R';
  cout<<'D';
  cout<<'R';
  rep(i,ty-sy+1)cout<<'D';
  rep(i,tx-sx+1)cout<<'L';
  cout<<'U'<<endl;


}

















//


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

using namespace std;

template<char start, int C>
struct Trie {
	struct Node {
		vector<int> nxt, accept;
		int exist;
		Node() : exist(0) { nxt.assign(C, -1); }
	};

	vector<Node> nodes;
	int root;
	Trie() : root(0) { nodes.push_back(Node()); }

	int count() const { return nodes[0].exist; }
	int size() const { return (int)nodes.size(); }

	void update_direct(int node, int id) {
		nodes[node].accept.push_back(id);
	}
	void update_child(int node, int child, int id) {
		++nodes[node].exist;
	}

	void add(const string& str, int str_index, int node_index, int id) {
		if (str_index == str.size()) {
			update_direct(node_index, id);
			return;
		}
		int c = str[str_index] - start;
		if (nodes[node_index].nxt[c] == -1) {
		   	nodes[node_index].nxt[c] = (int)nodes.size();
			nodes.push_back(Node());
		}
		add(str, str_index + 1, nodes[node_index].nxt[c], id);
		update_child(node_index, nodes[node_index].nxt[c], id);
	}
	void add(const string& str, int id) { add(str, 0, 0, id); }
	void add(const string& str) { add(str, nodes[0].exist); }

	int find(const string& str) {
		int node_index = 0;
		for (auto c : str) {
			node_index = nodes[node_index].nxt[c - start];
			if (node_index < 0) { return node_index; }
		}
		return node_index;
	}
};

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
		reverse(S[i].begin(), S[i].end());
	}

	Trie<'a', 26> trie;
	for (int i = 0; i < N; ++i) { trie.add(S[i]); }

	vector<vector<int>> vec(trie.size(), vector<int>(26, 0));
	for (auto s : S) {
		int idx = trie.find(s.substr(0, s.size() - 1));
		++vec[idx][s.back() - 'a'];
	}

	Int ans = -N;
	for (auto s : S) {
		int now = 0;
		vector<int> tmp(26, 0);
		for (int i = 0; i < s.size(); ++i) {
			for (int j = 0; j < 26; ++j) {
				tmp[j] += vec[now][j];
			}
			int c = s[i] - 'a';
			ans += tmp[c];
			tmp[c] = 0;
			now = trie.nodes[now].nxt[c];
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 436024
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int N=1001;
int h,w;
char g[N][N];
long long dp[N][N];
long long f(int i,int j)
{
    if(i==h-1 and j==w-1)
        return 1;
    if(i>=h or j>=w or g[i][j]=='#')
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    long long fi=f(i+1,j)%hell;
    long long se=f(i,j+1)%hell;
    dp[i][j]=(fi+se)%hell;
    return dp[i][j];
}

void solve()
{
    cin>>h>>w;
    rep(i,0,h) rep(j,0,w) cin>>g[i][j];
    memset(dp,-1,sizeof dp);
    cout<<f(0,0);
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

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

  set<int> Set;
  Set.insert(N);
  int cnt = 1;

  while (true) {
    if (N % 2 == 0) {
      N /= 2;
      cnt++;
      if (Set.count(N)) {
        cout << cnt << endl;
        return 0;
      }    
      Set.insert(N);
    } else {
      N = (N * 3) + 1;
      cnt++;
      if (Set.count(N)) {
        cout << cnt << endl;
        return 0;
      }    
      Set.insert(N);
    }
  }
}

Measured memory_bytes: 256
#B
import numpy as np
a = np.zeros((4,4),np.int32)
A = np.zeros((4,4),np.int32)
a0 = list(map(int, input().strip().split()))
a1 = list(map(int, input().strip().split()))
a2 = list(map(int, input().strip().split()))
a[1,1:4] = a0
a[2,1:4] = a1
a[3,1:4] = a2
N = int(input())
b = []
for n in range(N):
    b = int(input())

    for j in range(1,4):
        for i in range(1,4):
            if a[j][i] == b:
                A[j][i] = 1

if sum(A[1,:])==3 or sum(A[2,:])==3 or sum(A[3,:])==3 or sum(A[:,1])==3 or sum(A[:,2])==3 or sum(A[:,3])==3 or A[1][1] + A[2][2] + A[3][3]==3 or A[1][3] + A[2][2] + A[3][1]==3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 21388
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;

int main(){
	string S;
  cin>>S;
  int zero=0,iti=0;
  rep(i,S.size()){
  	if(S[i]=='1'&& i%2==0){
    	zero++;
    }else if(S[i]=='0' && i%2==1){
    	zero++;
    }
  }
  
  rep(i,S.size()){
  	if(S[i]=='0'&&i%2==0){
    	iti++;
    }else if(S[i]=='1' && i%2==1){
    	iti++;
    }
  }
  
  cout<<min(zero,iti);
  
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var n, k, x, y int
	fmt.Scan(&n, &k, &x, &y)

	if n <= k {
		fmt.Println(n * x)
	} else {
		fmt.Println(k*x + (n-k)*y)
	}
}


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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e6;
const int Nmax=2e5+1;
const int Nd=61;



int main(){
  int n,m; cin>>n>>m;
  vector<int> x(m);
  rep(i,m) {cin>>x[i];}
  sort(x.begin(),x.end());
  if(n>=m){
    cout<<0<<endl;
    return 0;
  }
  vector<int> l(m-1);
  rep(i,m-1) {
     l[i]=x[i+1]-x[i];
     //cout<<l[i]<<" ";
  }
  sort(l.begin(),l.end());
  int ans=x[m-1]-x[0];
  rep(i,n-1){
    ans-= l[m-2-i];
  }
  cout<<ans<<endl;





}


Measured memory_bytes: 4044
use std::io::{self,Read};
use std::str::FromStr;

pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

fn calc_fib_array(len: usize) -> Vec<u64> {
    let mut fib = vec![1; len+1];
    for i in 2..len+1 {
        fib[i] = fib[i-1] + fib[i-2];
    }
    fib
}

fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let n: usize = sc.read();
    let fib = calc_fib_array(n);

    println!("{}", fib[n]);
}



Measured memory_bytes: 5032
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll x[2][100010];
typedef tuple<int, int> point;
typedef tuple<ll, int, int> edge;

const int UFSIZE = 100010;
int union_find[UFSIZE];

void init() {
  for (auto i=0; i<UFSIZE; i++) {
    union_find[i] = i;
  }
}

int root(int a) {
  if (a == union_find[a]) return a;
  return (union_find[a] = root(union_find[a]));
}

bool issame(int a, int b) {
  return root(a) == root(b);
}

void unite(int a, int b) {
  union_find[root(a)] = root(b);
}

bool isroot(int a) {
  return root(a) == a;
}

int main () {
  init();
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> x[0][i] >> x[1][i];
  }
  vector<edge> V;
  for (auto k = 0; k < 2; ++k) {
    vector<point> W;
    for (auto i = 0; i < N; ++i) {
      W.push_back(point(x[k][i], i));
    }
    sort(W.begin(), W.end());
    for (auto i = 0; i < N-1; ++i) {
      int d0 = get<0>(W[i]);
      int p0 = get<1>(W[i]);
      int d1 = get<0>(W[i+1]);
      int p1 = get<1>(W[i+1]);
      V.push_back(edge(abs(d0 - d1), p0, p1));
    }
  }
  sort(V.begin(), V.end());
  int used = 0;
  ll ans = 0;
  auto it = V.begin();
  while (used < N-1) {
    ll cost = get<0>(*it);
    int p0 = get<1>(*it);
    int p1 = get<2>(*it);
    ++it;
    if (!issame(p0, p1)) {
      ++used;
      unite(p0, p1);
      ans += cost;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 10080
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,j;
    cin >> a >> b >> c;
    
    for(int i=a;i<=b;i++)
    {
        if(c%i==0)
        {
            j++;
        }
    }
    cout << j << endl;
    return 0;
    
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n, greater<int>());
	if(n % 2 == 0) {
		long long res = 0;
		for (int i = 0; i < n/2-1; i++)
		{
			res += a[i] * 2;
		}
		res += a[n/2-1] - a[n/2];
		for (int i = n/2+1; i < n; i++)
		{
			res -= a[i] * 2;
		}
		cout << res << endl;
	}
	else {
		long long res1 = 0, res2 = 0;
		for (int i = 0; i < n/2-1; i++)
		{
			res1 += a[i] * 2;
		}
		res1 += a[n/2-1] + a[n/2];
		for (int i = n/2+1; i < n; i++)
		{
			res1 -= a[i] * 2;
		}
		for (int i = 0; i < n/2; i++)
		{
			res2 += a[i] * 2;
		}
		res2 -= a[n/2] + a[n/2+1];
		for (int i = n/2+2; i < n; i++)
		{
			res2 -= a[i] * 2;
		}
		cout << max(res1, res2) << endl;
	}
	return 0;
}


Measured memory_bytes: 640
//Shivam gupta (Codeforces handle : shivam_1999)

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define ll long long
#define ld long double
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef pair<long long, long long> pii;
typedef vector<pair<long long, long long>> vpii;
typedef map<long long, long long> mii;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define sorta(x) sort(x.begin(),x.end())
#define sortd(v) sort(all(v), greater<ll>())
#define el cout << endl;
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define cpresent(container, element) (find(all(container), element) != container.end())
#define deb(x) cout << #x << x << endl;
#define fl(i,n) for(ll i=0;i<n;i++)
#define fls(i,x,n) for(ll i=x;i<n;i++)
#define flr(i,n)  for(ll i=n-1;i>=0;i--)
#define fla(i,v)  for(auto i:v)    
#define in(v) for(auto &i:v){cin>>i;}
#define INF 1e9+1
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define tt    \
    int T;    \
    cin >> T; \
    while (T--)

int main()
{   fast
    int h,w;
    cin >> h >> w;
    int dp[h + 1][w + 1];
    char a[h + 1][w + 1];
    fls(i,1,h+1){
        fls(j,1,w+1){
            cin >> a[i][j];
            dp[i][j] = 0;
        }
    }
    dp[1][1] = 1;
    fls(i,2,h+1){
        if(a[i][1]=='#')
            break;
        if(a[i-1][1]=='.'&&a[i][1]=='.')
            dp[i][1] = 1;
    }
    fls(i,2,w+1){
        if(a[1][i]=='#')
            break;
        if(a[1][i-1]=='.'&&a[1][i]=='.')
            dp[1][i] = 1;
    }
    fls(i,2,h+1){
        fls(j,2,w+1){
            if(a[i][j]=='.')
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])%mod;
        }
    }
    cout << dp[h][w] << endl;
}


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

int main() {
	int q1, b, c1, c2, q2;
	while (scanf("%d", &q1), q1) {
		scanf("%d%d%d%d", &b, &c1, &c2, &q2);
		for (int i = min(q2, b / c1); i >= 1; i--) {
			int d = (b - c1*i) / c2;
			if (i + d >= q1) {
				printf("%d %d\n", i, d);
				goto g;
			}
		}
		puts("NA");
	g:;
	}
}

Measured memory_bytes: 3132
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	void solve() {
		IOS;
		string s;
		cin >> s;
		if (s == "ABC") {
			s = "ARC";
		} else {
			s = "ABC";
		}
		put(s);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char s[10005];
int n,num,n1,n2,n3;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		int l=strlen(s+1);
		for(int j=2;j<=l;j++)
		  if(s[j]=='B'&&s[j-1]=='A')
		    num++;
		if(s[1]=='B'&&s[l]=='A')n3++;
		else if(s[1]=='B')n2++;
		else if(s[l]=='A')n1++;
	}
	if(n1==0&&n2==0)
	{
		if(n3)num+=n3-1;
		printf("%d\n",num);
		return 0;
	}
	num+=n3;
	num+=min(n1,n2);;
	printf("%d\n",num);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define AS(arr)  (sizeof(arr)/sizeof(arr[0]))
#define ALL(c) (c).begin(),(c).end() 
#define SIZE(a) int((a).size())
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define REP(i,n) for(int i=0;i<(int)n;++i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
 
#define pb push_back
#define mp make_pair
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef long long LL;
 
const double EPS = 1e-11;
#define EQ(a,b) (abs(a-b)<EPS)
#define EQ0(x) (abs(x)<EPS)
 
int main(void){
    string s;
    LL k;
    cin >> s;
    cin >> k;
    
    LL end = 'z' + 1;
    REP(i,s.size())
    {
        //DEBUG(k);
        if(s[i] == 'a')
            continue;
        
        LL diff = end - s[i];
        //DEBUG(diff);
        if(diff <= k)
        {
            s[i] = 'a';
            k -= diff;
            
        }
        
    }
    k = k % 26;
    
    s[s.size()-1] += k;
    if(s[s.size()-1] > 'z')
    {
        s[s.size()-1] -= 26;
    }
   cout << s << endl;
}


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

UL N;
vector<UL> E[200000];
UL P[200000];
ULL ans=0;

int main() {
 scanf("%u",&N);
 rep(i,N-1){
  UL u,v; scanf("%u%u",&u,&v); u--; v--;
  E[u].push_back(v);
  E[v].push_back(u);
 }
 rep(i,N) P[i]=~0u;
 queue<UL> Q; Q.push(0);
 while(Q.size()){
  UL p=Q.front(); Q.pop();
  for(UL e:E[p]){
   if(P[p]==e) continue;
   P[e]=p; Q.push(e);
  }
 }

 ans+=N;
 for(UL i=1; i<N; i++){
  UL a=i, b=P[i];
  ULL tmp;
  if(a<b) tmp = ULL(a+1) * (b-a);
  else tmp = ULL(N-a) * (a-b);
  ans+=tmp;
 }

 printf("%llu\n",ans);

 return 0;
}



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

int main() {
  int64_t x, a, b;
  cin >> x >> a >> b;
  if (a >= b) {
    cout << "delicious" << endl;
  } else if (x >= (b-a)) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin >> a >> b;
    
    if (a*b % 2 == 0)cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
    
    int t,d,c=0;
	long double dis=0;
    cin>>t>>d;
    while(t--)
    {
    	long double x,y;
    	cin>>x>>y;
    	dis=sqrt((x*x+y*y));
    	if(dis<=d)
    	{
    		c++;
		}
	}
	cout<<c<<endl;
    
	return 0;
}

Measured memory_bytes: 3800