akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int dp[10][2][2][2][2];

int rec(string &N,int n=0,int tight=1,int t=0,int f=0,int s=0,int o=1)
{
	if(o==0)
		return 0;
	
	if(n==N.size())
	{
		if(t&f&s)
			return 1;
		else
			return 0;
	}

	if(dp[n][tight][t][f][s]!=-1)
		return dp[n][tight][t][f][s];

	int maxi=9;
	if(tight)maxi=N[n]-'0';

	int ret=0;
	for(int i=0;i<=maxi;i++)
		ret+=rec(N,n+1,tight & i==maxi,t | i==3,f | i==5,s | i==7,
			( (i|t|f|s)==0  | (i==3 | i==5 | i==7) )
		);

	dp[n][tight][t][f][s]=ret;
	return ret;
}

int main()
{
	for(int i=0;i<10;i++)
	for(int j=0;j<2;j++)
	for(int k=0;k<2;k++)
	for(int l=0;l<2;l++)
	for(int m=0;m<2;m++)
		dp[i][j][k][l][m]=-1;

	string N;
	cin >> N;

	cout << rec(N) << endl;
	return 0;
}



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

const long long int maxKL=(1e5)*2+1;

vector<int> kv(maxKL,0);
vector<int> lv(maxKL,0);
vector<int> Gk[maxKL];
vector<int> Gl[maxKL];
int np;

int dfsk(int p){
	for(int i=0;i<Gk[p].size();i++){
		if(kv[Gk[p][i]]==0){
			kv[Gk[p][i]]=np;
			dfsk(Gk[p][i]);
		}
	}
	return 0;
}

int dfsl(int p){
	for(int i=0;i<Gl[p].size();i++){
		if(lv[Gl[p][i]]==0){
			lv[Gl[p][i]]=np;
			dfsl(Gl[p][i]);
		}
	}
	
	return 0;
}

int main(){
	int n,k,l;
	cin>>n>>k>>l;
	int a,b;
	for(int i=0;i<k;i++){
		cin>>a>>b;
		a--;
		b--;
		Gk[a].push_back(b);
		Gk[b].push_back(a);
	}
	for(int i=0;i<l;i++){
		cin>>a>>b;
		a--;
		b--;
		Gl[a].push_back(b);
		Gl[b].push_back(a);
	}
	np=1;
	for(int i=0;i<n;i++){
		if(kv[i]==0){
			kv[i]=np;
			dfsk(i);
			np++;
		}
	}
	np=1;
	for(int i=0;i<n;i++){
		if(lv[i]==0){
			lv[i]=np;
			dfsl(i);
			np++;
		}
	}
	
	map<pair<int,int>,int > mp;
	for(int i=0;i<n;i++)mp[make_pair(kv[i],lv[i])]++;
	for(int i=0;i<n;i++){
		if(i)cout<<" ";
		cout<<mp[make_pair(kv[i],lv[i])];
	}
	cout<<endl;
	
	
	/*
	for(int i=0;i<n;i++){
		cout<<"k"<<i+1<<" "<<kv[i]<<endl;
	}
	for(int i=0;i<n;i++){
		cout<<"l"<<i+1<<" "<<lv[i]<<endl;
	}
	*/
	
	
	return 0;
}

Measured memory_bytes: 27904
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		int n1 = (s.length-1)/2;
		int n2 = (s.length+3)/2;
		boolean flg = true;
		for(int i = 0;i < s.length/2;i++){
			if(!s[i].equals(s[s.length-1-i])){
				System.out.println("No");
				return;
			}
		}
		for(int i = 0;i < n1/2;i++){
			if(!s[i].equals(s[n1-1-i])){
				System.out.println("No");
				return;
			}
		}
		for(int i = n2-1;i < s.length/2;i++){
			if(!s[i].equals(s[n2-1-i])){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22996
using System;

namespace AtCoder.ABC114 {
    class B {
        static void Main() => Solve();

        static void Solve() {
#if DEBUG
            global::Common.ChangeStdIn();
#endif
            var s = Console.ReadLine();
            var ans = 1000;
            for (int i = 0; i < s.Length - 2; i++) {
                var val = int.Parse(s[i].ToString()) * 100 +
                          int.Parse(s[i + 1].ToString()) * 10 +
                          int.Parse(s[i + 2].ToString());
                ans = Math.Min(ans, Math.Abs(753 - val));
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll n; cin >> n;

    ll ans = n-1;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) ans = (n / i - 1) + i - 1;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
local N, M = io.read("n", "n")
local C = {}
for i=1,M do
  C[i] = true
end
for i=1,N do
  local K = io.read("n")
  local b = {}
  for j=1,M do
    b[j] = false
  end
  for j=1,K do
    local a = io.read("n")
    b[a] = true
  end
  for j=1,M do
    C[j] = C[j] and b[j]
  end
end
local ans = 0
for i=1,M do
  if C[i] then
    ans = ans + 1
  end
end
print(ans)

Measured memory_bytes: 2796
#define DEBUG 0

/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 3/16/2019, 9:13:03 PM
 * Powered by Visual Studio Code
 */

#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>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

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;

ll N;
int X[200010];
vector<int> C;
ll dp[200010];
ll table[200010];

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> X[i];
    X[i]--;
  }
  C.push_back(X[0]);
  for (auto i = 1; i < N; i++)
  {
    if (C.back() != X[i])
    {
      C.push_back(X[i]);
    }
  }
  N = C.size();
  fill(dp, dp + 200010, 0);
  fill(table, table + 200010, 0);
  dp[0] = 1;
  dp[1] = 1;
  table[C[0]] = 1;
  for (auto i = 2; i <= N; i++)
  {
    dp[i] = dp[i - 1] + table[C[i - 1]];
    dp[i] %= M;
    table[C[i - 1]] += dp[i - 1];
    table[C[i - 1]] %= M;
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 5108
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    ll n;
    cin >> n;
    cout << (n/500)*1000 + (n%500)/5 *5 << "\n";
    return 0;
}

Measured memory_bytes: 888
def ans(a, b, c) : 
  if c == 0 : 
    print('YES')
    
  elif a % b == 0 : 
    print('NO')
    
  else : 
    d = a % b
    for i in range(b) : 
      if (d * i) % b == c :
        print('YES')
        return
    print('NO')

a, b, c = tuple(map(int, input().split()))

ans(a, b, c)



Measured memory_bytes: 3060
import math
while 1:
    a = input().split()
    if a[0] == "#":
        break
    nengo = a[0]
    y = int(a[1])
    m = int(a[2])
    d = int(a[3])
    if y > 31:
        y -= 30
        nengo = "?"
    elif y == 31:
        if m >= 5:
            nengo = "?"
            y = 1
    print(nengo,y,m,d)


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

int main(){
	double W,H,x,y;	cin>>W>>H>>x>>y;

	double ans=W*H/2;
	//cout<<ans<<" ";
	printf("%.8lf ",ans);

	if(x==0 || y==0 || x==W || y==H)cout<<0<<endl;
	else{
	if((int)W%(int)x==0 && (int)H%(int)y==0)cout<<1<<endl;
	else cout<<0<<endl;
	}
	


	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cassert>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> pb(n);
    vector<int> pw(n);
    for (int i = 0; i < 2 * n; i++) {
        string s;
        cin >> s;
        int x;
        cin >> x;
        x--;
        if (s == "B") pb[x] = i; else pw[x] = i;
    }

    vector<vector<int>> ppb(2 * n, vector<int>(n + 1));
    vector<vector<int>> ppw(2 * n, vector<int>(n + 1));
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            ppb[pb[i]][j + 1]++;
            ppw[pw[i]][j + 1]++;
        }
    }

    for (int i = 1; i < 2 * n; i++) {
        for (int j = 0; j <= n; j++) {
            ppb[i][j] += ppb[i - 1][j];
            ppw[i][j] += ppw[i - 1][j];
        }
    }

//    for (int i = 0; i < 2 * n; i++) {
//        for (int j = 0; j < n; j++) {
//            cout << ppb[i][j] << " ";
//        }
//        cout << "\n";
//    }
//    cout << "\n";
//
//    for (int i = 0; i < 2 * n; i++) {
//        for (int j = 0; j < n; j++) {
//            cout << ppw[i][j] << " ";
//        }
//        cout << "\n";
//    }
//    cout << "\n";

//    for (int i = 0; i < n; i++) cout << pb[i] << " ";
//    cout << "\n";
//    for (int i = 0; i < n; i++) cout << pw[i] << " ";
//    cout << "\n";
    int d[n + 1][n + 1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (i == 0 && j == 0) {
                d[i][j] = 0;
                continue;
            }
            d[i][j] = MAX_INT;
            if (i > 0) {
                int x = pw[i - 1];
                int dd = x - ppw[x][i] - ppb[x][j] + 1;
                d[i][j] = std::min(d[i][j], d[i - 1][j] + dd);
            }
            if (j > 0) {
                int x = pb[j - 1];
                int dd = x - ppw[x][i] - ppb[x][j] + 1;
                d[i][j] = std::min(d[i][j], d[i][j - 1] + dd);
            }
//            cout << i << " " << j << " " << d[i][j] << "\n";
        }
    }
    int res = d[n][n];
    cout << res << "\n";

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int a[2][n];
    for (int i = 0; i < 2; i++) {
        rep(j, n) cin >> a[i][j];
    }

    int sum = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            sum += a[0][j];
        }
        for (int k = i; k < n; k++) {
            sum += a[1][k];
        }
        ans = max(ans, sum);
        sum = 0;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    
    // 1. 入力情報.
    int a[6];
    rep(i, 6) scanf("%d", a + i);
    
    // 2. 経路情報を保存.
    rep(i, 6) town[--a[i]]++;
    
    // 3. 判定.
    // 〇 1 1 2 2
    // × 0 2 2 2
    // × 1 1 1 3
    int ans = 1;
    rep(i, 4) ans *= town[i];
    
    // 4. 出力.
    if(ans == 4) puts("YES");
    else         puts("NO");
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

#define MAX 200000
ll fac[MAX];
ll finv[MAX];
ll inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    repr(i,2,MAX){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll COM(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;
}


int N,K;
vector<vector<int>> G;
ll ans = 1;

void dfs(int u,int p){
    int t = G[u].size();
    if(u == 0) ans *= COM(K-1,t)*fac[t]%MOD;
    else if(t >= 1) ans *= COM(K-2,t-1)*fac[t-1]%MOD;
    ans %= MOD;

    for(int v : G[u]){
        if(v == p) continue;
        dfs(v,u);
    }
}

int main(){
    COMinit();
    cin >> N >> K;
    G.resize(N);
    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ans *= K;
    dfs(0,-1);
    cout << ans << endl;
}


Measured memory_bytes: 13952
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

const int mod = 1000000007;
struct mint {
    ll x; // using long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;
    ll n = sz(s);

    vector<vector<mint>> dp(n + 1, vector<mint>(13));
    dp[0][0] = 1;
    rep(i, n) rep(j, 13) {
        if (s[i] == '?') {
            rep(k, 10) dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
            continue;
        }
        dp[i + 1][(j * 10 + s[i] - '0') % 13] += dp[i][j];
    }

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

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

using namespace std;

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

const int MAXN = 505;

int N;
int C[MAXN];
int F[MAXN];
int S[MAXN];

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

    cin >> N;
    for(int a = 0; a < N - 1; a++){
        cin >> C[a] >> S[a] >> F[a];
    }

    for(int a = 0; a < N; a++){
        int tm = 0;
        int idx = a;
        while (idx != N - 1) {
            if (tm <= S[idx]) {
                tm = S[idx];
            } else if (tm % F[idx] != 0){
                tm -= tm % F[idx];
                tm += F[idx];
            }
            tm += C[idx];
            idx++;
        }
        cout << tm << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

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

lli n, m;
lli a[MAXN], dp[MAXN];

lli f(lli x) {
    if (x > n) return 0;
    if (x == n) return 1;
    if (dp[x] != -1) return dp[x];

    lli ans = 0;
    if (!binary_search(a, a + m, x + 1))
        ans = (ans + f(x + 1) % MOD) % MOD;
    if (!binary_search(a, a + m, x + 2))
        ans = (ans + f(x + 2) % MOD) % MOD;
    return dp[x] = ans;
}

void solve() {
    cin >> n >> m;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    sort(a, a + m);
    lli ans = f(0);
    cout << ans << endl;
}

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

Measured memory_bytes: 4224
#include <iostream>
#include <map>
#include <set>
using namespace std;
using ll = long long;
ll MOD = 1000000007;
map<int, set<int>> g;


int dfs(int v, int* visited) {
    int numParts = 1;
    visited[v] = 1;
    for(int i: g[v]) {
        if(!visited[i]) numParts += dfs(i, visited);
    }
    return numParts;
}

int main() {
    int n, m, x, y;
    cin >> m >> n;
    for(int i=0; i<n; i++) {
        cin >> x >> y;
        g[x].insert(y);
        g[y].insert(x);
    }

    int visited[m+1] = {0};
    int maxLen = 0;
    for(int i=1; i<=m; i++) {
        if(!visited[i]) {
            maxLen = max(maxLen, dfs(i, visited));
        }
    }
    cout << maxLen;
    return 0;
}


Measured memory_bytes: 60676
#include <bits/stdc++.h>
#define all(r) r.begin(),r.end()
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vll a(n);
        for (int i = 0; i < n; i++) {
            in >> a[i];
        }
        sort(all(a));
        ll ans = 1;
        for (int i = 0; i < n - 1; i++) {
            if (a[i + 1] > a[i]) {
                ans++;
            }
        }
        out << ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i ++)
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    map<int,int> s;
    multiset<int> p;
    rep(i, w) s[i] = i;
    rep(i, w) p.insert(0);
    
    rep(i, h){
        int a, b;
        cin >> a >> b;
        --a;
        auto it = s.lower_bound(a);
        int r = -1;
        while(it != s.end() && it->first <= b){
            r = max(r, it->second);
            p.erase(p.find(it->first - it->second));
            s.erase(it ++);
        }
        if(r != -1 && b < w){
            p.insert(b - r);
            s[b] = r;
        }
        int ans = -1;
        if(p.size() > 0){
            ans = *p.begin() + (i + 1);
        }
        printf("%d\n", ans);
        
    }
    
    return 0;
}


Measured memory_bytes: 21916
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    // Input numbers
    string a,b,c;
    cin >> a >> b >> c;

    vector<int> leng{stoi(a), stoi(b), stoi(c)};
    vector<int> haiku{5, 5, 7};
    sort(leng.begin(), leng.end());

    string ans = (leng == haiku) ? "YES" : "NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
v = list(map(int,input().split()))
v.sort()
ans,tmp = [],[]
gab = (v[0]+v[1])/2
tmp.append(gab)
j = 0
if n == 2:
  print(tmp[0])
  sys.exit()
for i in range(2,n):
  tmp.append((v[i] +tmp[j])/2)
  j += 1
print(tmp[-1])

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

int main() {
  int x,y;cin>>x>>y;
  int ans=0;
  if(x==3)ans+=100000;
  if(y==3)ans+=100000;
  if(x==2)ans+=200000;
  if(y==2)ans+=200000;
  if(x==1)ans+=300000;
  if(y==1)ans+=300000;
  if(x==1&&y==1)ans+=400000;
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
$line = <STDIN>;
chomp $line;
$N=scalar($line);
$line = <STDIN>;
chomp $line;
@A = split(/ /, $line);

$sa=0;
$SA[0]=0;
for($i=0;$i<$N;$i++){
	$sa = $sa + $A[$i];
	$SA[$i+1]=$sa;
}

# sum_l_r a= $SA[$r+1]-$SA[$l];

$xa=0;
$XA[0]=0;
for($i=0;$i<$N;$i++){
	$xa= ($xa ^ $A[$i]);
	$XA[$i+1]=$xa;
}

# xor_l_r a= $XA[$r+1] xor $XA[$l];


$s=0;$minr=0;
for($l=0;$l<$N;$l++){
	$s+=$minr-$l+1;
	for($r=$minr+1;$r<$N;$r++){
		$sa=$SA[$r+1] - $SA[$l];
		$xa=$XA[$r+1] ^ $XA[$l];
		last if ($xa!=$sa);
		$s++;
		$minr=$r;
	}
}

print "$s\n";



Measured memory_bytes: 35404
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare_str (const void *a, const void *b) {
    return strcmp((char*)a, (char*)b);
}

int main (void) {
    int i, j;
    int n;

    scanf("%d", &n);

    char w[n][11];
    char end;

    for ( i=0; i<n; i++ )
        scanf("%s", w[i]);

    end = w[0][0];

    for ( i=0; i<n; i++ ) {
        if ( end != w[i][0] ) {
            printf("No\n");
            goto END;
        }
        for ( j=0; j<i; j++ ) {
            if ( strcmp(w[i], w[j]) == 0 ) {
                printf("No\n");
                goto END;
            }
        }
        end = w[i][strlen(w[i])-1];
    }
    printf("Yes\n");
END:
    return EXIT_SUCCESS;
}


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

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


Measured memory_bytes: 3676
from collections import deque
n, k = map(int, input().split())
td = [list(map(int, input().split())) for _ in range(n)]
res = 0
td.sort(key = lambda x:-x[1])
kind = set()
queue = deque()
for t, d in td[:k]:
    if t in kind:
        queue.append(d)
    else:
        kind.add(t)
    res += d
ans = res + len(kind)**2
point = ans
count = len(queue)
for t, d in td[k:n]:
    if count == 0:
        break
    if not t in kind:
        point += -queue.pop() + d + len(kind) * 2 + 1
        kind.add(t)
        ans = max(ans, point)
        count -= 1
print(ans)


Measured memory_bytes: 32820
#include <bits/stdc++.h>
using namespace std;
int i,o,p;
int main () {
cin >> i>>o>>p;
if (i>p) {
	cout << "NO" << endl;
} else if ((i+o)<p) {
	cout << "NO"<<endl;
} else {
	cout <<"YES"<<endl;
}
}

//semoga bisa


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

struct Graph{
    struct Node{
        vector<int> dests;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    int id(Node* n){ return n - &nodes[0]; }
    int id(Node& n){ return &n - &nodes[0]; }
    void print(){ for(auto& node : nodes){ prints(id(node), node.dests); } }
    void addEdge(int from, int dest){
        nodes[from].dests.push_back(dest);
    }
    void addEdge2(int from, int dest){
        addEdge(from, dest);
        addEdge(dest, from);
    }
    int dfs(int idx, int from = -1){
        vector<int> rets;
        for(int didx : nodes[idx].dests){
            if(didx == from){ continue; }
            rets.push_back(dfs(didx, idx));
        }
        if(rets.empty()){
            return 0;
        }else{
            sort(rets.begin(), rets.end());
            int ret = 0;
            for(size_t i = 0; i < rets.size(); i++){
                ret += max(int(bool(i)), rets[i]);
            }
            return ret;
        }
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        g.addEdge2(a, b);
    }
    int idx, maxi = 0;
    for(int i = 0; i < n; i++){
        if(maxi < (int)g.nodes[i].dests.size()){
            maxi = g.nodes[i].dests.size();
            idx = i;
        }
    }
    cout << max(1, g.dfs(idx)) << '\n';
}


Measured memory_bytes: 12288
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = Array(N) { Array(3) { sc.next().toInt() } }
        val dp = Array(N + 1) { IntArray(3) }
        for (i in 1..N) {
            for (j in 0 until 3) {
                dp[i][j] = arrayOf(dp[i][j], dp[i - 1][(j + 1) % 3] + A[i - 1][j]).max()!!
                dp[i][j] = arrayOf(dp[i][j], dp[i - 1][(j + 2) % 3] + A[i - 1][j]).max()!!
            }
        }
        pw.println(dp[N].max()!!)
    }
}


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

using namespace std;

typedef long long ll;

const int N=300000;
const ll MOD=998244353;

ll fact[N+5];

ll expow(ll a,ll b)
{
    ll ans=1;
    while(b>0)
    {
        if(b%2==1)
            ans=(ll)ans*a%MOD;
        b/=2;
        a=(ll)a*a%MOD;;
    }
    return ans;
}

ll comb(ll n,ll k)
{
    return fact[n]*expow(fact[k]*fact[n-k]%MOD,MOD-2)%MOD;
}

ll sol=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    fact[0]=1;
    for(ll i=1;i<=N;i++)
        fact[i]=(ll)i*fact[i-1]%MOD;
    ll n,a,b,k;
    cin>>n>>a>>b>>k;
    for(ll x=0;x<=n;x++)
    {
        ll dif=k-x*a;
        if(dif%b==0)
        {
            ll y=dif/b;
            if(0<=x && 0<=y && x<=n && y<=n)
            {
                sol+=(comb(n,x)*comb(n,y))%MOD;
                sol%=MOD;
            }
        }
    }
    cout<<sol<<"\n";
    return 0;
}
/**

**/



Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int m,n,o,cnt;
int main(){
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    if(n<m){
      o=n;
      n=m;
      m=o;
    }
    cnt=0;
    while(m!=0){
      cnt++;
      o=n%m;
      n=m;
      m=o;
    }
    cout<<n<<' '<<cnt<<endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define lson rt<<1
#define rson rt<<1|1
#define scd(x) scanf("%d",&x)
#define scdd(x,y) scanf("%d%d",&x,&y)
const int maxn=3e5+10;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
multiset<int>s;
vector<int>vec;
int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif // LOCAL
    ll n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;

}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int result = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      result++;
    }
  }

  cout << result << endl;
  return 0;
}


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

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

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

VI s;

signed main()
{
    string p;
    cin >> p;
    REP(i, 4){
        s.push_back(p[i]-'A');
    }
    sort(ALL(s));

    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;


void solve() {
	string S; cin >> S;
	vector<char>v;
	int N = S.size();
	REP(i, N) {
		if (S[i] == 'B') {
			if(v.size() > 0)v.pop_back();
		}
		else {
			v.push_back(S[i]);
		}
	}
	REP(i, v.size())cout << v[i];
	cout << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 384
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
char str[max_n];
void reads(string& s){scanf(" %s",str);s=str;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int a[10];
int main(){
    for(int i=1;i<=5;i++)scanf("%d",a+i);
    for(int i=1;i<=5;i++){
        if(a[i]==0)printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> NODE;
#define pos first
#define distance second

int n;
bool info[100][100];

int bfs(int s,int d){
	queue<NODE> Q;
	bool done[100]={false};
	
	Q.push( make_pair(s,0) );
	while( !Q.empty() ){
		NODE now = Q.front();
		Q.pop();
		done[now.pos] = true;

		if(now.pos == d){
			return now.distance;
		}

		for(int next=0;next<n;next++){
			if(info[now.pos][next] && !done[next]){
				Q.push( make_pair(next,now.distance+1) );
			}
		}
	}
	return INT_MAX;
}

int main(){
	int r,k,t,p,s,d,v;
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> r >> k;
		r--;
		for(int j=0;j<k;j++){
			cin >> t;
			t--;
			info[r][t] = true;
		}
	}	
	
	cin >> p;
	for(int i=0;i<p;i++){
		cin >> s >> d >> v;
		s--;d--;
		if(v > bfs(s,d) )cout << bfs(s,d)+1 << endl;
		else cout << "NA" << endl;
	}
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 1000000007;

void solve(long long N){
    LL ans = 1;
    REP1(i, N+1) {
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll h,w; cin>>h>>w;
    vector<string> c(h);
    rep(i,h) cin>>c[i];
    rep(i,h){
        cout<<c[i]<<endl;
        cout<<c[i]<<endl;
    }

    return 0;
}

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

#define X first
#define Y second
#define ll long long
#define MP make_pair
#define PB push_back

using namespace std;

const int MAXN=1e5;
ll MOD=1e9+7;

ll dp[4194307];
ll n,mat[25][25];
string s;
ll pot=1;
ll pom,br;
vector <ll> cije[25];

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

	cin>>n;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin>>mat[i][j];
		}
		pot*=2;
	}
	dp[pot-1]=1;
	for(int j=0; j<pot; j++){
		pom=j;
		br=0;
		while(pom>0){
			br+=(pom%2);
			pom/=2;
		}
		cije[n-br].PB(j);
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<cije[i].size(); j++){
			pom=cije[i][j];
			s="";
			while(pom>0){
				s+=('0'+(pom%2));
				pom/=2;
			}
			while(s.size()<n){
				s+='0';
			}
			pom=cije[i][j];
			for(int k=0; k<n; k++){
				if(mat[i][k]==1 && s[k]=='1'){
					dp[pom-(1<<k)]+=dp[pom];
					dp[pom-(1<<k)]%=MOD;
				}
			}
		}
	}
	cout<<dp[0];
	
	return 0;
}

Measured memory_bytes: 38096
using System;

namespace ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int n = int.Parse(str1);

            int i;
            char suit;
            int card_num;
            char[] suit_num = new char[4] { 'S', 'H', 'C', 'D' };
            bool[,] cards = new bool[4,13];

            for (i = 0; i < n; i++)
            {
                string[] str2 = Console.ReadLine().Split(' ');
                suit = char.Parse(str2[0]);
                card_num = int.Parse(str2[1]);
                switch(suit)
                {
                    case 'S':
                        cards[0,card_num - 1] = true;
                        break;
                    case 'H':
                        cards[1,card_num - 1] = true;
                        break;
                    case 'C':
                        cards[2,card_num - 1] = true;
                        break;
                    case 'D':
                        cards[3,card_num - 1] = true;
                        break;
                }
            }

            for (int j = 0; j < 4; j++)
            {
                for (i = 0; i < 13; i++)
                {
                    if (!cards[j,i])
                        Console.WriteLine("{0} {1}",suit_num[j], i + 1);
                }
            }
        }
    }
}

Measured memory_bytes: 19620
from math import sqrt

if __name__ == "__main__":
    n = int(input())
    xy = list()
    for i in range(n):
        xy.append(list(map(int, input().split())))

    ans = 0
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            ans += sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)

    print(ans/n)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    char S[N+1];
    scanf("%s",S);
    if(N%2==0){
        for(int i=0;i<N/2;i++){
            if(S[i]!=S[i+N/2]){
                printf("No\n");
                return 0;
            }
        }
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int dp[2000][2000] = {};
int main() {
	string a, b;
	cin >> a >> b;
	a = ' ' + a;
	b = ' ' + b;
	for (int i = 0;i < a.length();++i) {
		dp[0][i] = i;
	}
	for (int q = 0;q < b.length();++q) {
		dp[q][0] = q;
	}
	for (int i = 1;i < b.length();++i) {
		for (int q = 1;q < a.length();++q) {
			int now = min(dp[i][q - 1], dp[i - 1][q]) + 1;
			if (a[q] == b[i]) {
				now = min(now, dp[i - 1][q - 1]);
			}
			else now = min(now, dp[i - 1][q - 1] + 1);
			dp[i][q] = now;
		}
	}
	cout << dp[b.length() - 1][a.length()-1] << endl;
	return 0;
}


Measured memory_bytes: 10948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, K;
  cin >> N >> K;
  
  int a, i;
  a = 1;
  i = 0;
  
  while (a * 2 < a + K && i < N) {
    a *= 2;
    i++;
  }
  
  a += K * (N - i);
  cout << a << endl;
  
}

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


int main() {

    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int d[n];
  for(int i=0; i<n; i++)
    cin >> d[i];

  set<int> values;
  for(int i=0; i<n; i++)
    values.insert(d[i]);

  cout << values.size() << endl;
}


Measured memory_bytes: 256
whxy = list(map(int, list(input().split())))

w = whxy[0]
h = whxy[1]
x = whxy[2]
y = whxy[3]

s = w * h / 2

if x == w / 2 and y == h / 2:
    yesno = 1
else:
    yesno = 0

print(s, yesno)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> to[MAXV];
int id[MAXN][MAXN];
int toId(int i, int j){
	if(i > j) swap(i, j);
	return id[i][j];
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV];
int dfs(int v){
	if(visited[v]){
		if(!calculated[v]) return -1;
		return dp[v];
	}
	visited[v] = true;
	dp[v] = 1;
	for(auto u : to[v]){
		int res = dfs(u);
		if(res == -1) return -1;
		chmax(dp[v], res+1);
	}
	calculated[v] = true;
	return dp[v];
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n-1));
	rep(i,n)rep(j,n-1){
		cin >> a[i][j];
		a[i][j]--;
	}
	int V = 0;
	rep(i,n)rep(j,n){
		if(i < j){
			id[i][j] = V++;
		}
	}
	rep(i,n){
		rep(j,n-1){
			a[i][j] = toId(i, a[i][j]);
		}
		rep(j,n-2){
			to[a[i][j+1]].push_back(a[i][j]);
		}
	}
	int ans = 0;
	rep(i,V){
		int res = dfs(i);
		if(res == -1){
			cout << -1 << endl;
			return 0;
		}
		chmax(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 38528
/**
*    created: 12.05.2020 00:42:41
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
as=gets.split.map(&:to_i).sort
nums=[]
cur=as[0]
num=0
n.times do |i|
  if as[i]==cur
    num+=1
  else
    nums.push(num)
    cur=as[i]
    num=1
  end
  nums.push(num) if i==n-1
end
l=nums.size
puts l>k ? nums.sort[0..l-k-1].inject(:+):0


Measured memory_bytes: 21476
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>
#include <numeric>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n;
	cin >> n;
	vector<pair<pair<string, int>, int>> sp(n);
	rep(i, n) {
		cin >> sp[i].first.first >> sp[i].first.second;
		sp[i].first.second *= -1;
		sp[i].second = i + 1;
	}

	sort(allof(sp));

	rep(i, n) {
		cout << sp[i].second << endl;
	}
	return 0;
}


Measured memory_bytes: 256