akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    map<string, int> M;
    int q; cin >> q;
    REP(i, q){
        string key, L, R;
        int op, x, y; cin >> op;
        switch(op){
            case 0:
                cin  >> key >> x;
                M[key] = x;
                break;
            case 1:
                cin >> key;
                cout << ((M.find(key) != M.end()) ?M[key] : 0) << "\n";
                break;
            case 2:
                cin >> key;
                M.erase(key);
                break;
            case 3:
                cin >> L >> R;
                for(auto itr = M.lower_bound(L); itr != M.end(); ++itr){
                    if(L <= itr->first && itr->first <= R)
                        cout << itr->first << " " << itr->second << "\n";
                    if(itr->first >= R)
                        break;
                }
                break;
        }
    }
    return 0;
}



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

#define ll long long
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1000000007;

using namespace std;

ll n,k,a[101000];
ll d[101000];
int main(){
    ios;
	cin>>n>>k;
	for (ll i=1;i<=n;i++){
		cin>>a[i];
	}
	for (ll i=0;i<=n+k;i++)d[i]=1e9;

    d[1]=0;
    for (ll i=1;i<=n;i++){
        for (ll j=i+1;j<=i+k;j++){
            d[j]=min(d[j],d[i]+abs(a[i]-a[j]));
        }
    }
    cout<<d[n];
	return 0;
}


Measured memory_bytes: 1792
import sys
from collections import deque
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = lambda x: sys.stdout.write(str(x))
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = False

def main():

    N = II()
    t = [-1] * N


    E = [  [] for _ in range(N)]
 
    reached = [False] * N
    for _ in range(N-1):
        u,v,w = LMIIS()
        u -=1
        v -=1
        E[u].append((v,w))
        E[v].append((u,w))
    dbg(E)
    t[E[0][0][0]] = 0

     
    # def search(u):
    #     for v,w in E[u]:
    #         if t[v] == -1:
    #             t[v] = t[u] if w % 2 == 0 else t[u]^1
    #             search(v)
                

    # search(E[0][0][0])
    reached = [False] * N
    q = []
    q.append(E[0][0][0])
    while q:
        u = q.pop()
        reached[u] = True
        for v,w in E[u]:
            if reached[v] != True and  t[v] == -1:
                t[v] = t[u] if w % 2 == 0 else t[u]^1
                q.append(v)

                



    for i in t:
        write(i)
        write(' ')






    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 43676
s = input()
count = 0
max = 0
for i in range(0, len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        count += 1
        if max < count:
            max = count
    else: count = 0
print(max)

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

using namespace std;

int main(){
    string a;
    cin>>a;
    int l=a.length(),s=0;
    for(int i=0,j=l-1;;i++,j--){
        if(l&1&&i==j)
            break;
        else if(!(l&1)&&i>j)
            break;
        if(a[i]!=a[j])
            s++;
    }
    cout<<s<<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++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s; cin >> s;
  int ans=0;
  REP(i,3) if (s[i]-'0') ans++;
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}

using Graph = vector<vector<int>>;
vector<bool>seen(50);
void dfs(Graph &G ,int now){
  if(seen[now]) return ;
  seen[now]=true;
  for(auto nv:G[now]){
    dfs(G,nv);
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int>a(m);
  vector<int>b(m);
  rep(i,m){
    int A,B;
    cin >> A >> B;
    A--;
    B--;
    a[i]=A;
    b[i]=B;
  }

  int ans=0;
  rep(i,m){
    Graph G(n);
    rep(j,m){
      if(i==j)continue;
      G[a[j]].push_back(b[j]);
      G[b[j]].push_back(a[j]);
    }
    rep(j,n)seen[j]=false;
    dfs(G,0);
    rep(j,n){
      if(!seen[j]){
        ans++;
        break;
      }
    }
  }
    
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<cstdlib>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)

using namespace std;

class Parsing{
private:
  string parse;
  int pos;
public:
 
  Parsing(string s){
    parse = s;
    pos = 0;
  }

  int fact(){
    if(parse[pos] == '('){
      pos++;
      int p = expression();
      pos++;
      return p;
    }else{
      int p=0;
      
      while('0' <= parse[pos] && parse[pos] <= '9'){
	p *= 10;
	p += parse[pos]-'0';
	pos++;
      }
      return p;
    }
  }
 
  int term(){
    int p = fact();
    while(parse[pos] == '*' || parse[pos] == '/'){
      if(parse[pos] == '*'){pos++;p *= fact();}
      else {pos++;p /= fact();}
    }
    return p;
  }
 
  int expression(){
    int p = term();
    while(parse[pos] == '+' || parse[pos] == '-'){
      if(parse[pos] == '+'){pos++;p+=term();}
      else {pos++;p-=term();}
    }
    return p;
  } 
 
};

string itos(int i){ stringstream ss; ss << i; return ss.str(); }

char op[] = {'+','-','*'};
int a,b,c,d;
string num[4];
bool ok;

void dfs(vector<string> exp,int cnt)
{
  int expsize = exp.size();
  if(ok)return;
  if(cnt >= 3 || exp.size() <= 1)
    {
      string line;
      rep(i,expsize)line += exp[i];
      Parsing parsing(line);
      if(parsing.expression() == 10)
	{
	  ok = true;
	  cout << line << endl;
	}
      return;
    }

  for(int i=0;i<expsize;i+=2)//start
    {
      for(int j=i+2;j<expsize;j+=2)//end
	{
	  vector<string> new_exp;
	  rep(k,i)new_exp.push_back(exp[k]);
	  string new_num = "(";
	  REP(k,i,j+1)new_num += exp[k];
	  new_num += ")";
	  new_exp.push_back(new_num);
	  REP(k,j+1,expsize)new_exp.push_back(exp[k]);
	  dfs(new_exp,cnt+1);
	  if(ok)return;
	}
    }

}

void compute()
{
  sort(num,num+4);
  ok = false;
  do
    {
      rep(i,3)
	{//<op>
	  rep(j,3)
	    {//<op>
	      rep(k,3)
		{//<op>
		  vector<string> exp(7); 
		  exp[0] = num[0], exp[1] = string(1,op[i]);
		  exp[2] = num[1], exp[3] = string(1,op[j]);
		  exp[4] = num[2], exp[5] = string(1,op[k]);  
		  exp[6] = num[3];
		  dfs(exp,0);
		  if(ok)return;
		}
	    }
	}
    }
  while(next_permutation(num,num+4));
  
}

int main()
{

  while(cin >> a >> b >> c >> d,a|b|c|d)
    {  
      num[0] = itos(a), num[1] = itos(b), num[2] = itos(c), num[3] = itos(d);
      compute();  
      if(!ok)cout << 0 << endl;
    }
  return 0;
}

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

using namespace std;

using ll = long long;

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

    ll a, b;
    cin >> a >> b;
    if (b == a || b == a - 1 || b == a + 1) cout << "Brown\n";
    else cout << "Alice\n";

    return 0;
}


Measured memory_bytes: 256
#ABC 104 B
s = list(input())

if s[0] == "A" and s[2:-1].count("C")==1:
    s.remove("A")
    s.remove("C")
    if "".join(s).islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    string s;
    cin>>s;
    int n=s.length();
    string rs;
    int i=0;
    while(i<n-1)
    {
        if(s[i]=='B' && s[i+1]=='C')
        {
            rs+="D";
            i+=2;
        }
        else
        {
            rs+=s[i];
            i+=1;
        }
        
    }
    ll dc=0;
    ll ans=0;
    for(auto v:rs)
    {
        if(v=='A')
        {
            dc++;
        }
        else if(v=='D')
        {
            ans+=dc;
        }
        else
        {
            dc=0;
        }
        
    }
    cout<<ans;
}


Measured memory_bytes: 3904
#include <stdio.h>
int main(void){
    int m,f,r,i,n,sum,nrsum;
    for(;;){
        scanf("%d %d %d",&m,&f,&r);
        sum=m+f+r;
        nrsum=m+f;
        if(sum==-3)break;
        else if(m==-1 || f==-1){
            printf("F");
        }
        else if(nrsum<30){
            printf("F");
        }
        else if(nrsum>=30 && nrsum<50){
            if(r<50){
                printf("D");
            }else{
                printf("C");
            }
        }
        else if(nrsum>=50 && nrsum<65){
            printf("C");
        }
        else if(nrsum>=65 && nrsum<80){
            printf("B");
        }
        else{
            printf("A");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 1812
/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

using namespace std;

const int maxx=10005;
int n,m,k;
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;

int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    char ch[500];
    const string a = "AKIHABARA";
    scanf("%s",ch);
    n = strlen(ch);
    for(int i = 0; i < n; i++)
    {
        if(ch[i] == 'A') cnt++;
    }
    if(n - cnt < 5) pos = -100;
    for(int i = 0; i < a.size() && pos < n; i++)
    {
        if(a[i] == ch[pos])
        {
            pos++;
        }
    }
    if(pos != n) printf("NO");
    else printf("YES\n");
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

class Team{
public:
	int id;
	int univ;
	int success;
	int penalty;

	Team() : id(0),univ(0),success(0),penalty(0){}
	Team(int id,int univ,int success,int penalty){
		this->id = id;
		this->univ = univ;
		this->success = success;
		this->penalty = penalty;
	}
};

class mycmp{
public:
	bool operator()(const Team t1,const Team t2){
		if(t1.success == t2.success
			&& t1.penalty == t2.penalty){
				return (t1.id < t2.id);
		}
		else if(t1.success == t2.success){
			return (t1.penalty < t2.penalty);
		}

		return (t1.success > t2.success);
	}
};

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		vector<Team> teams;
		for(int i=0;i<n;i++){
			int ID,U,A,P;
			scanf("%d %d %d %d",&ID,&U,&A,&P);
			teams.push_back(Team(ID,U,A,P));
		}

		map<int,bool> passedTeam;
		map<int,int> univCount;
		sort(teams.begin(),teams.end(),mycmp());
		for(int i=0;i<teams.size();i++){
			if(passedTeam.size() < 10){
				if(univCount[teams[i].univ] < 3){
					univCount[teams[i].univ]++;
					passedTeam[teams[i].id] = true;
					printf("%d\n",teams[i].id);
				}
			}
			else if(passedTeam.size() < 20){
				if(univCount[teams[i].univ] < 2){
					univCount[teams[i].univ]++;
					passedTeam[teams[i].id] = true;
					printf("%d\n",teams[i].id);
				}
			}
			else if(passedTeam.size() < 26){
				if(univCount[teams[i].univ] < 1){
					univCount[teams[i].univ]++;
					passedTeam[teams[i].id] = true;
					printf("%d\n",teams[i].id);
				}
			}
		}
	}
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(A: int, B: int, M: int, a: "List[int]", b: "List[int]", x: "List[int]", y: "List[int]", c: "List[int]"):
    m1=min(a)+min(b)
    for i in range(M):
        m1=min(m1,a[x[i]-1]+b[y[i]-1]-c[i])
        
    print(m1)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(A, B, M, a, b, x, y, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24612
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

template <class M> class segment_tree{
public:
//	using value_type = M::value_type;
	typedef typename M::value_type value_type;
	size_t n;
	vector<value_type> v;
	value_type e = M::unit();
	segment_tree(size_t size){
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		for(size_t i=1; i<n+size; ++i) v[i] = e;
	}
	segment_tree(vector<value_type> a){
		size_t size = a.size();
		n = 1;
		while(n < size) n <<= 1;
		v.resize(2*n, e);
		for(size_t i=0; i<size; ++i) v[n+i] = a[i];
		for(size_t i=n-1; i>0; --i) v[i] = M::operate(v[2*i], v[2*i+1]);
	}
	void point_update(size_t x, value_type val){
		x += n;
		v[x] = val;
		x >>= 1;
		while(x > 0){
			v[x] = M::operate(v[2*x], v[2*x+1]);
			x >>= 1;
		}
	}
	void point_operate(size_t x, value_type l){
		x += n;
		v[x] = M::operate(l, v[x]);
		x >>= 1;
		while(x > 0){
			v[x] = M::operate(v[2*x], v[2*x+1]);
			x >>= 1;
		}
	}
	value_type range_get(size_t l, size_t r){ // [l, r)
		value_type lres = e;
		value_type rres = e;
		l += n;
		r += n;
		while(l < r){
			if(l & 1){
				lres = M::operate(lres, v[l]);
				++l;
			}
			if(r & 1){
				--r;
				rres = M::operate(v[r], rres);
			}
			l >>= 1;
			r >>= 1;
		}
		return M::operate(lres, rres);
	}
};
struct plus_monoid{
	using value_type = Int;
	static value_type unit(){
		return 0;
	}
	static value_type operate(value_type l, value_type r){
		return l + r;
	}
};
struct min_monoid{
	using value_type = Int;
	static value_type unit(){
		return (1ll<<31)-1;
	}
	static value_type operate(value_type l, value_type r){
		return min(l, r);
	}
};

// AOJ DSL 2A
/*
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	segment_tree<min_monoid> st(n);
	while(q--){
		int t, x, y;
		cin >> t >> x >> y;
		if(t == 0) st.point_update(x, y);
		else cout << st.range_get(x, y+1) << "\n";
	}
}
*/
// AOJ DSL 2B

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	segment_tree<plus_monoid> st(n);
	while(q--){
		int t, x, y;
		cin >> t >> x >> y;
		--x;
		if(t == 0) st.point_operate(x, y);
		else{
			--y;
			cout << st.range_get(x, y+1) << "\n";
		}
	}
}


Measured memory_bytes: 4956
def main():
    N = input()
    F = int(N[0:2])
    L = int(N[2:])
    FisYY = (F>=0 and F<=99)
    FisMM = (F>=1 and F<=12)
    LisYY = (L>=0 and L<=99)
    LisMM = (L>=1 and L<=12)
    if (FisYY and LisMM and FisMM and LisYY):
        print('AMBIGUOUS')
    elif (FisYY and LisMM):
        print('YYMM')
    elif (LisYY and FisMM):
        print('MMYY')
    else:
        print('NA')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>

using namespace std;
int a,b,c,d,e,f,g,h,i;

bool ok(){
  int sum = a + b + c;
  if(a + b + c != sum) return false;
  if(d + e + f != sum) return false;
  if(g + h + i != sum) return false;
  if(a + d + g != sum) return false;
  if(b + e + h != sum) return false;
  if(c + f + i != sum) return false;
  if(a + e + i != sum) return false;
  if(c + e + g != sum) return false;
  return true;
}


int main(void){

  cin >> a >> b >> e;
  c = 0;

  while(true){
    int sum = a + b + c;
    i = sum - a - e;
    f = sum - c - i;
    h = sum - b - e;
    d = sum - e - f;
    g = sum - h - i;
    if(ok())break;
    c++;
  }
  cout << a << " " << b << " " << c << endl;
  cout << d << " " << e << " " << f << endl;
  cout << g << " " << h << " " << i << endl;
  return 0;
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

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

    string s; int k;
    cin >> s >> k;

    forn(i,si(s)-1) {
        int d = (26 + 'a' - s[i]) % 26;
        if (d <= k) {
            s[i] = 'a';
            k -= d;
        }
    }
    k %= 26;

    int n = si(s);
    int last = s[n-1] - 'a';
    last = (last + k) % 26;
    s[n-1] = 'a'+last;
    //s[n-1] += k; if (s[n-1] > 'z') s[n-1] -= 26;
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;
constexpr int ESP = 1e-9;
constexpr double PI = acos(-1);

int main(void) {
    int i, j, n, k;
    int mask = 0;
    cin >> n >> k;
    REP (i,k) {
        int d;
        cin >> d;
        mask |= 1 << d;
    }

    REP (i,n,100000) {
        int x = i;
        bool ok = true;
        while (x) {
            if (mask&1<<x%10) {
                ok = false;
                break;
            }
            x /= 10;
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val s = sc.nextLine()
    val sr = s.reversed()
    val n = s.length

    if(s != sr){
        println("No")
        return
    }
    val s1  =s.substring(0, (n-1)/2)
    if(s1 != s1.reversed()){
        println("No")
        return
    }
    val sr1 = sr.substring(0, (n-1)/2)
    if(sr1 != sr1.reversed()){
        println("No")
        return
    }

    println("Yes")
}

Measured memory_bytes: 31384
from collections import*
N=int(input())
if N%2:
 if Counter(map(int,input().split()))==Counter(i//2*2for i in range(1,N+1)):print(2**(N//2)%(10**9+7))
 else:print(0)
else:
 if Counter(map(int,input().split()))==Counter(i//2*2+1for i in range(N)):print(2**(N//2)%(10**9+7))
 else:print(0)

Measured memory_bytes: 16624
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN = 1e5;
typedef long long ll;

struct node{
        ll a,b;
}z[MAXN];

bool cmp(node x,node y) {
        return x.a<y.a;
}

int main() {
        int n,m;
        while(cin>>n>>m) {
                for(int i=0;i<n;++i)
                        cin>>z[i].a>>z[i].b;
                sort(z,z+n,cmp);
                ll ans = 0;
                int id = 0;
                priority_queue<ll> que;
                for(int i=1;i<=m;++i) {
                        while(z[id].a<=i && id<n) {
                                que.push(z[id].b);
                                id++;
                        }
                        if(que.empty()) continue;
                        ans += que.top();
                        que.pop();
                }
                cout<<ans<<endl;
        }
        return 0;
}


Measured memory_bytes: 2936
#include <iostream>
using namespace std;
int main( void )
{
  int w,n;
  int a[32],b[32],r[32];
  char c;
  cin >> w >> n;
  for( int i=0; i<n; i++ ) cin >> a[i] >> c >> b[i];
  for( int i=1; i<=w; i++ ) {
    int d=i;
    for( int j=n-1; j>=0; j-- ){
      if( a[j] == d ) d = b[j];
      else if( b[j] == d ) d = a[j];
    }
    r[i] = d;
  }
  for( int i=1; i<=w; i++ ) cout << r[i] << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007;
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}
#define level 22

ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

ll dp[2000][2000];
void bfs(ll p,bool vis[],vector<ll>adj[])
{
    queue<ll>q;
    q.push(p);
    ll dis=0;
    while(q.empty()==0)
    {
        ll z=q.size();
        for(int i=0;i<z;i++)
        {
            ll s=q.front();
            q.pop();
            dp[p][s]=dis;
            for(auto x:adj[s])
            {
                if(vis[x]==false)
                {
                    vis[x]=true;
                    q.push(x);
                }
            }
        }
        dis++;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
  
    ll n,x,y;
    cin>>n>>x>>y;
    vector<ll>adj[n];
    for(int i=0;i<n-1;i++)
    {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    adj[x-1].push_back(y-1);
    adj[y-1].push_back(x-1);

    bool vis[n];
    for(int i=0;i<n;i++)
    {
        memset(vis,false,sizeof(vis));
        bfs(i,vis,adj);
    }
    ll ans[n];
   /* for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    memset(ans,0,sizeof(ans));
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans[dp[i][j]-1]++;
        }
    }
    for(int i=0;i<n-1;i++)
    {
        cout<<ans[i]<<endl;
    }

    
    return 0;
}


Measured memory_bytes: 31616
import math
while True:
    n=int(input())
    if n==0:
        break
    a=math.factorial(n)
    b=str(a)
    m=len(b)
    c=0
    for i in range(m-1,-1,-1):
        if b[i]=='0':
            c+=1
        else:
            break
    print(c)


Measured memory_bytes: 5828
#include <iostream>
#include <unordered_set>
#include <string>
using namespace std;
int main(){
	int N;
	string input;
	unordered_set<string> st;
	for(cin >> N; N; N--){
		cin >> input;
		if(st.find(input) == st.end())
			st.insert(input);
	}
	cout << st.size() << endl;
}


Measured memory_bytes: 17616
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int x,a,b;
  cin >> x>>a>>b;
  x -= a;
  x -= b*(x/b);
  cout << x << endl;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

print('bust' if sum(inpl()) >= 22 else 'win' )

Measured memory_bytes: 5432
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.math.BigInteger;
    
public class Main{

static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;

public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
HashMap<String,String> map=new HashMap<String,String>();
StringBuilder sb=new StringBuilder();
while(true){
int n=ir.nextInt();
if(n==0) break;
while(n-->0) map.put(ir.next(),ir.next());
int m=ir.nextInt();
while(m-->0){
String str=ir.next();
sb.append((map.containsKey(str))?map.get(str):str);
}
out.println(sb.toString());
map.clear();
sb.setLength(0);
}
out.flush();
}

static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;

public InputReader(InputStream in) {this.in=in;}
  
public int readByte() {
if(lenbuf==-1) throw new InputMismatchException();
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}
catch (IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0)
return -1;
}
return buffer[curbuf++];
}

public boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;}

public String next() {
int b=skip();
StringBuilder sb=new StringBuilder();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
 
public int nextInt() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public long nextLong() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public int[] toIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
}
}

Measured memory_bytes: 36976
#include <iostream>
#include <vector>
using namespace std;
#define INF 1500000
typedef long long ll;
typedef pair<ll,ll> P;
ll d[16][16];
ll dp[1<<15][16];
int main(void){
    int n,e;
    cin>>n>>e;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)d[i][j]=INF;
    for(int i=0;i<e;i++){
        int s,t,c;
        cin>>s>>t>>c;
        d[s][t]=c;
    }
    for(int j=0;j<n;j++)for(int i=0;i<1<<n;i++)dp[i][j]=INF;
    dp[(1<<n)-1][0]=0;
    for(int i=(1<<n)-1;i>=0;i--){
        for(int j=0;j<n;j++){
            
                for(int k=0;k<n;k++){
                    if((i>>k&1)==0){
                        dp[i][j]=min(dp[i|1<<k][k]+d[j][k],dp[i][j]);
                    }
                }
            
        }
    }
    if(dp[0][0]>=INF)cout<<-1<<endl;
    else cout<<dp[0][0]<<endl;
}

Measured memory_bytes: 7144
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    map<ll, ll> mp;
    rep(i, N) { mp[A[i]]++; }

    ll sum = 0;
    ll cnt = 0;
    for (auto e : mp) {
        cnt++;
        // cout << e.first << ": " << e.second << endl;
        sum += (e.second - 1);
    }

    if (sum % 2 == 0) {
        cout << cnt << endl;
    } else {
        cout << cnt - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10264
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n,l=map(int, input().split())
    a = [l+i for i in range(n)]
    ans = 10000
    idx = 0
    for i in range(n):
        if abs(a[i]) < ans:
            ans = abs(a[i])
            idx = i
    print(sum(a) - a[idx])
main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

vector< vector< int > > g;
vector< vector< int > > rvs_g; //reversed_graph
vector< int > f;
vector< int > label;
priority_queue< pair< int, int > > pque;
int cnt;


void rec1(int v){
	
	f[v] = 0;
	
	for(vector< int >::iterator it = g[v].begin(); it != g[v].end(); ++it){
		if(f[*it] == -1){
			rec1(*it);
		}
	}
	
	f[v] = cnt;
	
	pque.push(make_pair(f[v], v));
	
	++cnt;
	
	return;
}

void rec2(int v, int k){
	
	label[v]= k;
	
	for(vector< int >::iterator it = rvs_g[v].begin(); it != rvs_g[v].end(); ++it){
		if(label[*it] == 0){
			rec2(*it, k);
		}
	}
}

int main(){
	int v, e, s, t, q, x, y;
	
	cin >> v >> e;
	
	g.resize(v);
	rvs_g.resize(v);
	f.resize(v);
	label.resize(v);
	
	for(int i = 0; i < e; ++i){
		cin >> s >> t;
		g[s].push_back(t);
		rvs_g[t].push_back(s);
	}
	
	for(int i = 0; i < v; ++i){
		f[i] = -1;
	}
	
	cnt = 1;
	for(int i = 0; i < v; ++i){
		if(f[i] == -1){
			rec1(i);
		}
	}
	
	while(!pque.empty()){
		int i = pque.top().second;
		pque.pop();
		
		if(label[i] == 0){
			rec2(i, f[i]);
		}
	}
	
	cin >> q;
	for(int i = 0; i < q; ++i){
		cin >> x >> y;
		
		if(label[x] == label[y]){
			cout << 1 << endl;
		}else{
			cout << 0 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
#ifdef TOPOLOGY
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
using namespace std;

struct point {
	int x, y;

	bool operator<(const point &p) const {
		return x == p.x ? y < p.y : x < p.x;
	}
} p1, p2;
int n, lis[200003];
vector<point> a;

int main() {
	scanf("%d %d %d %d %d", &p1.x, &p1.y, &p2.x, &p2.y, &n);
	if (p1.y > p2.y) swap(p1, p2);
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		if (y >= p1.y && y <= p2.y && ((x >= p1.x && x <= p2.x) || (x <= p1.x && x >= p2.x))) a.push_back({x, y});
	}
	sort(a.begin(), a.end());
	if (p1.x > p2.x) reverse(a.begin(), a.end());
	int cnt = 0;
	for (int i = 0; i < (int)a.size(); i++) {
		auto it = lower_bound(lis, lis + cnt, a[i].y);
		if (it == lis + cnt) cnt++;
		*it = a[i].y;
	}
	double ans = 100.0 * (abs(p1.x - p2.x) + abs(p1.y - p2.y));
	ans -= (20 - 5 * M_PI) * cnt;
	if (cnt - 1 == min(abs(p1.x - p2.x), abs(p1.y - p2.y))) ans += 5 * M_PI;
	printf("%.14lf\n", ans);
	/*
	long long rat = 100LL * (abs(p1.x - p2.x) + abs(p1.y - p2.y)) - 20 * cnt;
	long long irrat = 5 * cnt;
	if (cnt - 1 == min(abs(p1.x - p2.x), abs(p1.y - p2.y))) irrat += 5;
	long long PI_first = 3141592653LL, PI_second = 58979323846LL;
	long long sub = irrat * PI_first + irrat * PI_second / 100000000000LL;
	rat += sub / 1000000000LL;
	printf("%lld.%09lld%04lld\n", rat, sub % 1000000000LL, irrat * PI_second % 100000000000LL / 10000000);
	*/
	return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    char a, b;
    cin >> a >> b;
    cout << (a == b ? "H" : "D") << endl;

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(n, received):
    not_relayed = received.copy()
    for t in range(n + 1):
        if len(received) >= n:
            return t
        new_not_relayed = set()
        for person in not_relayed:
            if person >= 1:
                if (person - 1) not in received:
                    received.add(person - 1)
                    new_not_relayed.add(person - 1)
            if person <= n - 2:
                if (person + 1) not in received:
                    received.add(person + 1)
                    new_not_relayed.add(person + 1)
        not_relayed = new_not_relayed


def main():
    n, m = map(int, input().split())
    received_people = set(map(lambda x: int(x) - 1, input().split()))
    print(solve(n, received_people.copy()))


if __name__ == '__main__':
    main()

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

double N, M;
double Ai[110];
int main()
{
    cin >> N >> M;
    double Asum = 0;
    int res = 0;

    for(int i = 0; i < N; i++)
    {
        cin >> Ai[i];
        Asum += Ai[i];
    }
    for(int i = 0; i < N; i++)
    {
        if(Ai[i] >= Asum / (4 * M)) res++;
    }

    if(res < M) cout << "No";
    else cout << "Yes";
    cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> E[2020]; 
int main(){
	int N, X, Y; cin >> N >> X >> Y; 
	X--; Y--; 
	for(int i = 0; i < N-1; i++){
		E[i].push_back(i+1); E[i+1].push_back(i); 
	}
	E[X].push_back(Y); E[Y].push_back(X); 
	int ans[2020] = {}; 
	int INF = 114514; 
	for(int i = 0; i < N; i++){
		int D[2020] = {}; 
		fill(D, D+N, INF); 
		queue<int> que; 
		que.push(i); D[i] = 0; 
		while(que.size()){
			int p = que.front(); que.pop(); 
			for(int i = 0; i < E[p].size(); i++){
				if(D[E[p].at(i)] == INF){
					D[E[p].at(i)] = D[p] + 1; 
					que.push(E[p].at(i)); 
				}
			}
		}
		for(int i = 0; i < N; i++) ans[D[i]] ++; 
	}
	for(int i = 1; i < N; i++) cout << ans[i]/2 << endl; 
}

Measured memory_bytes: 384
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


//#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve() {
    string a, b;
    cin >> a >> b;
    for (int t = min(a.length(), b.length()); t >= 0; --t) {
        set<vector<int>> inputs;
        vector<int> go(26, 0);
        REP(i, a.length()) {
            go[a[i] - 'a']++;
            if (i >= t) {
                go[a[i - t] - 'a']--;
            }
            if (i + 1 >= t) {
                inputs.insert(go);
            }
        }
        int ans = -1;
        REP(q, 26) {
            go[q] = 0;
        }
        REP(i, b.length()) {
            go[b[i] - 'a']++;
            if (i >= t) {
                go[b[i - t] - 'a']--;
            }
            if (i + 1 >= t) {
                if (inputs.count(go) == 1) {
                    ans = max(ans, t);
                    break;
                }
            }
        }
 
        if (ans != -1) {
            cout << ans << endl;
            return;
        }
    }
}

#undef int
int main() {
    init();
    solve();
}



Measured memory_bytes: 3864
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
dp = [INF for _ in range(N+1)]

dp[0] = 0

for i in range(1, N+1):
    # 6
    power = 1
    while power <= N:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 6
    # 9
    power = 1
    while power <= N:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 9

print(dp[N])

Measured memory_bytes: 47472
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans int

// 左からi文字中
// j文字使って
// 総数がk
var dp = [51][51][3001]int{}

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	A, _ := strconv.Atoi(read())
	x := make([]int, N)

	for i := 0; i < N; i++ {
		x[i], _ = strconv.Atoi(read())
	}

	// 0文字目中0文字目まで使って総数0は1
	dp[0][0][0] = 1

	for i := 0; i < N; i++ {
		for j := 0; j <= i; j++ {
			for k := 0; k <= 3000; k++ {

				if 0 <= k-x[i] {
					dp[i+1][j+1][k] += dp[i][j][k-x[i]]
				}
				dp[i+1][j][k] += dp[i][j][k]

			}
		}
	}

	for j := 1; j <= N; j++ {
		ans += dp[N][j][A*j]

	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

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

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []struct {
	b, c int
}

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].c > a[j].c }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 61312
#include <bits/stdc++.h>
using namespace std;
int main() {
  string step;
  bool flag = true;
  cin >> step;
  
  for(int i= 0; i < step.size(); i++){
    if((i+1) % 2 == 0 && step.at(i) == 'R'){ 
      flag = false;
      break;
    }
    else if ((i+1) % 2 == 1 && step.at(i) == 'L'){
      flag = false;
      break;
    }
  }
  if(flag == true) cout << "Yes" << endl;
  else cout << "No" << endl;
    
}

Measured memory_bytes: 256
import numpy as np
mat = [list(map(int, input().split())) for i in range(3)]
array = np.array(mat, dtype=np.int64)
a20 = array[2]-array[0]
a10 = array[1]-array[0]
b20 = array[:,2]-array[:,0]
b10 = array[:,1]-array[:,0]
flag  = False
if (a20==a20[0]).all() and (a10==a10[0]).all() and (b20==b20[0]).all() and (b10==b10[0]).all():
    for a1 in range(0, 101):
        a2 = a1+ a10[0]
        a3 = a1 + a20[0]
        b1 = array[0,0] - a1
        b2 = b1 + b10[0]
        b3 = b1 +b20[0]
        A = np.array([[a1, a2, a3]]).T
        B = np.array([[b1, b2, b3]])
        C = A+B
        if (C == array).all():
            flag =True
            break
if flag==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12512
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let x: u32 = vec[0].parse().unwrap_or(0);
    if x < 1200 {
        println!("ABC");
    } else {
        println!("ARC");
    }
}

Measured memory_bytes: 380
//============================================================================
// Name        : ITP_1_5_B.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int H,W;
	do {
		cin >> H >> W;
		if (H==0 && W==0) break;
		for(int j=0;j<H;++j) {
			for(int i=0;i<W;++i) {
				if(j==0 || i==0 || j==H-1 || i==W-1) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	} while(1);
	return 0;
}

Measured memory_bytes: 3040
#import<cstdio>
int main(){for(int a,c,r,t;r=1,c=3,~a;~-r&&printf("%d\n",r))for(char d[]="12354",s[9];a=scanf("%s",s),*s>60;r+=*d&7)*s%6-4?t=*d,*d=~d[a+=*s%5+*s*2+c&3],d[a]=t,d[++a%4+1]=~t:c+=*s+3;}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 998244353;

struct mint {
    ll x; // typedef 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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};

ostream& operator << (ostream& os, const mint a) {
    os << a.x;

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, S;
    cin >> N >> S;

    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    mint dp[S + 1];
    REP(i, S + 1) dp[i] = 0;
    dp[0] = 1;

    REP(i, N) {
        for(int j = S; j >= 0; --j) {
            if (j + A[i] <= S) {
                dp[j + A[i]] += dp[j];
            }

            dp[j] += dp[j];
        }
    }

    print(dp[S]);
    
}


Measured memory_bytes: 3700
# C - Peaks
N,M = map(int,input().split())
H = list(map(int,input().split()))
top = [1]*N
for _ in range(M):
    A,B = map(int,input().split())
    if H[A-1]<H[B-1]:
        top[A-1] = 0
    elif H[A-1]>H[B-1]:
        top[B-1] = 0
    else:
        top[A-1] = 0
        top[B-1] = 0
print(sum(top))

Measured memory_bytes: 20000