akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
long long ll_pow(long long x, long long n) {
	long long ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x;
		x = x * x;
		n = n >> 1;
	}
	return ans;
}


int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	if (0 < c - a - b) {
		if (4 * a * b < ll_pow(c - a - b, 2)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


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


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x;
    cin >> x;
    int d = 0;
    int cur = 100;
    while (true) {
    	if (cur >= x) {
    		cout << d << '\n';
    		return 0;
    	}
    	cur += cur / 100;
    	++d;
    }
}

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

using namespace std;

const int maxn = 5*(int)1e5+100;
int n, a[maxn], b[maxn], t[maxn*42], lt[maxn*42], rt[maxn*42], tVal[maxn*42], tot;
int lst[maxn];    //记录离散化后数组的上次出现位置
int q;

void init() {
    tot = 0;
    memset(lst, -1, sizeof(lst));
}
int build(int l, int r) {
    int node = ++tot;
    tVal[node] = 0;
    int mid = (l + r) >> 1;
    if (l < r) {
        lt[node] = build(l, mid);
        rt[node] = build(mid+1, r);
    }
    return node;
}
int update(int l, int r, int par, int p, int val) {
    int node = ++tot;
    lt[node] = lt[par]; rt[node] = rt[par]; tVal[node] = tVal[par] + val;
    int mid = (l + r) >> 1;
    if (l < r) {
        if (p <= mid) lt[node] = update(l, mid, lt[par], p, val);
        else rt[node] = update(mid+1, r, rt[par], p, val);
    }
    return node;
}
int query(int l, int r, int p, int node) {
    if (l == r) return tVal[node];
    int mid = (l + r) >> 1;
    if (p <= mid) return (query(l, mid, p, lt[node]) + tVal[rt[node]]);
    else return query(mid+1, r, p, rt[node]);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    init();
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int len = unique(b + 1, b + 1 + n) - b;
    for (int i = 1; i <= n; ++i)
        a[i] = lower_bound(b + 1, b + 1 + len, a[i]) - b;

    t[0] = build(1, n);
    for (int i = 1; i <= n; ++i) {
        if (lst[a[i]] == -1) t[i] = update(1, n, t[i-1], i, 1);
        else {
            int temp = update(1, n, t[i-1], lst[a[i]], -1);
            t[i] = update(1, n, temp, i, 1);
        }
        lst[a[i]] = i;
    }
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << query(1, n, l, t[r]) << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256624
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int N;
bool check(vector<string> vs, int x){
  vector<string> vs2(vs.size());
  FOR(i,0,N){
    string s="";
    FOR(j,0,N){
      int k=(j+x)%N;
      s+=vs[i][k];
    }
    vs2[i]=s;
  }
  FOR(i,0,N){
    FOR(j,0,N){
      if(vs2[i][j]!=vs2[j][i]){
        return false;
      }
    }
  }
  return true;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>N;
  vector<string> vs(N);
  FOR(i,0,N)cin>>vs[i];
  ll ans=0;
  FOR(i,0,N){
    if(check(vs,i))ans++;
  }
  cout<<ans*N<<endl;
}

Measured memory_bytes: 696
#include<iostream>
#include<string>
#include<queue>
using namespace std;
struct Point{int x,y,d,m;};
int main(){
  int r,c;
  cin >> r >> c;
  string st[25];
  int i,j,k;
  for(i=0;i<r;i++) cin >> st[i];
  Point p,b;
  int ax[]={1,0,-1,0};
  int ay[]={0,1,0,-1};
  p.x=0;p.y=0;p.d=0;p.m=0;
  queue <Point> q;
  q.push(p);
  bool f=true;
  int vi[25][25][5][20]={{{{}}}};

  while(!q.empty()){
    p=q.front();q.pop();
    if(vi[p.x][p.y][p.d][p.m]==1) continue;
    vi[p.x][p.y][p.d][p.m]=1;
    char x=st[p.y][p.x];
    if(x=='<'){
      p.d=2;
    }else if(x=='>'){
      p.d=0;
    }else if(x=='^'){
      p.d=3;
    }else if(x=='v'){
      p.d=1;
    }else if(x=='_'){
      if(p.m==0) p.d=0;
      else p.d=2;
    }else if(x=='|'){
      if(p.m==0) p.d=1;
      else p.d=3;
    }else if(x=='?'){
      for(i=0;i<4;i++){
        b.d=i;
        b.x=(p.x+c+ax[b.d])%c;
        b.y=(p.y+r+ay[b.d])%r;
        b.m=p.m;
        q.push(b);
      }
      continue;
    }else if(x=='.'){
    }else if(x=='@'){
      f=false;
      break;
    }else if(x>='0'&&x<='9'){
      p.m=x-'0';
    }else if(x=='+'){
      p.m=(p.m+1)%16;
    }else if(x=='-'){
      p.m=(p.m+15)%16;
    }
    b.d=p.d;
    b.x=(p.x+c+ax[b.d])%c;
    b.y=(p.y+r+ay[b.d])%r;
    b.m=p.m;
    q.push(b);
  }
  if(f) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

const int limit = 100010;
using edge = struct
{
  int to;
  ll cost;
};

vector<edge> tree[limit];

ll depth[limit];

void dfs(int v, int p, ll d)
{
  depth[v] = d;
  for (auto &e : tree[v])
  {
    if (e.to == p)
      continue;
    dfs(e.to, v, d + e.cost);
  }
}

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

  for (int i = 0; i < N - 1; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }

  int q, k;
  cin >> q >> k;
  k--;

  dfs(k, -1, 0);

  for (int i = 0; i < q; i++)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << depth[x] + depth[y] << endl;
  }

  return 0;
}

Measured memory_bytes: 16000
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  ll a,b;char c;cin>>a>>c>>b;

  if(c=='+')out(a+b)
  else out(a-b)

  return 0;
}


Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())
s = input()
flag = True
for i in range(a - 1, max(c, d) - 1):
    if s[i:i+2] == "##":
        flag = False
        break
if flag == False:
    print("No")
else:
    if c < d:
        print("Yes")
    else:
        flag2 = False
        for i in range(b - 2, min(c, d) - 1):
            if s[i:i+3] == "...":
                flag2 = True
                break
        if flag2 == True:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 3572
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
    cout << V[0];
    ll L = V.size();
    FOR(i, 1, L){
        cout << " " << V[i];
    }
    cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> P(N);
    FOR(i, 0, N){
        cin >> P.at(i);
    }

    vector<ll> A(N);
    FOR(i, 0, N){
        // A[i] = 50000 * (i+1);
        A[i] = 45000 * (i+1);
    }
    
    vector<ll> B(N);
    FOR(i, 0, N){
        B[i] = 1000000000 - A[i];
    }

    FOR(i, 0, N){
        ll index = P[i]-1;
        ll minus = N-i;
        A[index] -= minus;
        B[index] -= minus;
    }

    vprint(A);
    vprint(B);

    return 0;
}

Measured memory_bytes: 1152
from math import factorial
large_p = 10**9 + 7

def main():
    n, m = map(int, input().split())
    if (abs(n-m)) >= 2:
        print(0)
    else:
        np = factorial(n)
        mp = factorial(m)

        if abs(n-m) == 1:
            r = (np * mp) % large_p
            print(r)
        else:
            r = ((np * mp) * 2) % large_p
            print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5180
#include <iostream>
#include <map>

using namespace std;

long long int K, A[200005];
int N;

long long int a[200005];

map<long long int, int> C;

int main(void) {

	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	long long int sum = 0;
	a[1] = 0;
	for (int i = 2; i <= N; i++) {
		a[i] = (a[i-1]+A[i-1]-1) %K ;
	}

	long long int ans = 0;

	long long int tmp = 0;

	for (int i = 1; i <= N; i++) {
		C[a[i]]++;
		if (i >= K ) { C[a[i - K+1]]--; }

		tmp += A[i] - 1;
		tmp %= K;
		ans += C[tmp];
		//cout << "ans= " << ans << endl;
	}

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

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll h, w; cin >> h >> w;
	vl map(26);
	rep(i, h*w){
		char temp; cin >> temp;
		map[temp - 'a']++;
	}
	if (!(h % 2) && !(w % 2)){
		rep(i, 26){
			map[i] %= 4;
			if (map[i]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	else if (!(h % 2 && w % 2)){
		ll guu;
		if (h % 2){
			guu = w;
		}
		else guu = h;
		ll count = 0;
		rep(i, 26){
			map[i] %= 4;
			if (map[i] == 2) count++;
			if (map[i] % 2){
				cout << "No" << endl;
				return 0;
			}
		}if (!(1 <= count && count <= guu / 2)){
			cout << "No" << endl;
			return 0;
		}
	}
	else{
		ll count = 0;
		ll end_count = 0;
		rep(i, 26){
			map[i] %= 4;
			if (map[i] % 2){
				end_count++;
				if (end_count > 1){
					cout << "No" << endl;
					return 0;
				}
			}if (map[i] == 2){
				count++;
			}
		}if (abs(h - w) % 4){
			if (!(1 <= count && count <= (h + w - 2) / 2)){
				cout << "No" << endl;
				return 0;
			}
		}
		else{
			if (!(0 <= count && count <= (h + w - 2) / 2)){
				cout << "No" << endl;
				return 0;
			}
		}
	}cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

int N;

const int NAC = 0;
const int NWA = 1;
const int NTLE = 2;
const int NRE = 3;
const int NKIND = 4;

long long tbl[NKIND] = {0};

int main(){
    cin >> N;
    cin.ignore();
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        cin.ignore();
        if(s == "AC"){
            ++(tbl[NAC]);
        } else if(s == "WA"){
            ++(tbl[NWA]);
        } else if(s == "TLE"){
            ++(tbl[NTLE]);
        } else {
            ++(tbl[NRE]);
        }
    }

    cout << "AC x " << tbl[NAC] << endl;
    cout << "WA x " << tbl[NWA] << endl;
    cout << "TLE x " << tbl[NTLE] << endl;
    cout << "RE x " << tbl[NRE] << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

long long n, ans = 0;
vector<long long> a, sa;
int main() {
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i > 0)
			sa.push_back(a[i] - a[i - 1]);
	}
	long long p = 1;

	for (int i = 0; i < n; i++) {
		if (a[i] > p) {
			ans += (a[i] - 1) / p;
			long long po = (a[i] - 1) / p;
			a[i] -= ans*p;
			if (a[i] == p)
				a[i] = 1;
			p = max(p, a[i] + 1);
		}
		else if (a[i] == p) {
			p++;
		}
	}

	cout << ans << endl;
	//cin >> n;
	return 0;
}

Measured memory_bytes: 2296
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;

int K;  int g[501][501],cnt;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	K=read(); int N=min(500,K);
	int lf=K-N; cnt=1;
	for(int i=1;i<=N;i++){
		int x=1,y=i;
		for(int j=1;j<=N;j++){
			if(i<=lf){
				if(x&1) g[x][y]=cnt;
				else g[x][y]=cnt+1;
			} else g[x][y]=cnt;
			++x; y=y%N+1;
		} cnt+=(i<=lf)?2:1;
	}
	printf("%d\n",N);
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++)
			printf("%d ",g[i][j]); printf("\n");
	}
	return 0;
}




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

int main(){

	  int a,b,c ;
	  cin >> a >> b >> c;

	  int x=c;
	  set<int> s;
	  while( c % (a+b) > a ) {
			c = c%(a+b);
			c += 60; 
			if( s.count(c) != 0){
				  cout << -1 << endl; return 0;
			}
			s.insert(c);
	  }
	  cout << x+(60*s.size()) << endl;
	  return 0;

}

Measured memory_bytes: 1196
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

vector<Int> OutDivisor(Int n) {
    vector<Int> ret;
    for(Int i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main(){
    Int ans = 1;
    Int N, M; cin >> N >> M;
    vector<Int> v = OutDivisor(M);
    for (auto i : v){
        if (M / i >= N){
            ans = max(ans, i);
        }
    }
    cout << ans << endl;
    return 0;

} 


Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int digit(int n) { return (int)(log10(n) + 1); }

// 152-d
int main() {
    int n, m;
    cin >> n >> m;

    int sucsum = 0, missum = 0;

    int p;
    string s;
    vector<int> miscnt(n, 0);
    vector<bool> misflg(n, false);
    rep(i, 0, m) {
        cin >> p >> s;
        p--;
        if (s == "AC" && misflg[p] == false) {
            sucsum++;
            missum += miscnt[p];
            misflg[p] = true;
        } else {
            miscnt[p]++;
        }
    }
    cout << sucsum << " " << missum << endl;
    return 0;
}



Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
 
    // N matchsticks
    int N = scanner.nextInt();
    // M: Every digit in the integer must be one of the digits A1~AM
    int M = scanner.nextInt();
    int[] a = new int[M];
    for (int i = 0; i < M; i++)
    {
      a[i] = scanner.nextInt();
    }
      
    int[] cost = new int[] {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int[] dp = new int[N + 1];
    
    // dp[1]~dp[N] = -1
    for (int i = 1; i <= N; i++) 
    {
      dp[i] = -1;
    }
    
    // Trace from the a[i] with smallest cost
    for (int i = 1; i <= N; i++)
    {  
      for (int j = 0; j < M; j++)
      {  
        if (i >= cost[a[j]]) 
          dp[i] = Math.max(dp[i], dp[i - cost[a[j]]] + 1);
      }
    }
    int k = dp[N];
    List<Integer> list = new ArrayList<>();


    for (int i = 0; i < k; i++) 
    {
      int d = 0;
      for (int j = 0; j < M; j++)
      {
        if (N >= cost[a[j]] && dp[N] == dp[N - cost[a[j]]] + 1)
        {
          d = Math.max(d, a[j]);
        }
      }
      list.add(d);
      N -= cost[d];
    }
    Collections.sort(list);
    StringBuilder sb = new StringBuilder();
    for (int i = list.size() - 1; i >= 0; i--) 
    {
      sb.append(list.get(i));
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 23892
def intMap(): return map(int,input().split())
def intList(): return list(map(int, input().split()))

n,k = intMap()
a = intList()
for i in range(n): a[i] -= 1 # 0-base にしておく

moveUntilLoop = 0
loopStart = 0
loopSize = 0

def getLoopInfo(): # ループまでの手数、ループのスタート位置、ループのサイズを得る
    global moveUntilLoop
    global loopStart
    global loopSize
    visited = [0]*n # 訪れた事がある場合は最初に訪れるまでの手数
    moveTime = 0
    pos = 0 # 現在の位置
    
    #ループのスタート位置と、そこまでの手数
    while 1:
        if visited[pos]: break # 過去に訪れた事があれば検索中止
        visited[pos] = moveTime # visited[] に、ここまでの手数を入れる
        moveTime += 1
        pos = a[pos]
    loopStart = pos
    moveUntilLoop = visited[loopStart]

    #ループの長さ
    while 1:
        pos = a[pos]
        loopSize += 1
        if pos == loopStart: break

# k が n より小さい -> 10^5 以下の場合は、実際にやってみる
if k <= n:
    pos = 0
    for i in range(k): pos = a[pos]
    print(pos+1) # 0-base にしたので print 時に戻しておく
    exit()
    
# k > n の場合
getLoopInfo()

# k > n なので k > (loopStart + loopSize)
k -= moveUntilLoop
goal = k % loopSize
pos = loopStart
for _ in range(goal): pos = a[pos]

print(pos+1) # 0-base にしたので print 時に戻しておく


Measured memory_bytes: 31016
N = int(input())
c = list(input())
Wnum = c.count("W")
if Wnum == 0 or Wnum == N:
    print(0)
else:
    F = "R" * (N - Wnum) + "W" * Wnum
    t = 0
    for i in range(N):
        if c[i] != F[i]:
            t += 1
    print(t//2 + t%2)
            

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int dy[4] = {1, 0, -1, 0};
int dx[4] = {0, 1, 0, -1};
char maze[23][23];
bool flag[23][23];
int ans[23][23];
int h, w;

int bfs(P start, P goal) {
  memset(flag, false, sizeof(flag));
  memset(ans, 0, sizeof(ans));
  queue<P> que;
  flag[start.first][start.second] = 1;
  que.push(P(start.first, start.second));
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    rep(i, 4) {
      int x = p.second + dx[i];
      int y = p.first + dy[i];
      if (0 <= x && x <= w && 0 <= y && y <= h && !flag[y][x] &&
          maze[y][x] == '.') {
        flag[y][x] = 1;
        ans[y][x] = ans[p.first][p.second] + 1;
        que.push(P(y, x));
      }
    }
  }
  return ans[goal.first][goal.second];
}

int main() {
  cin >> h >> w;
  rep(i, h) {
    rep(j, w) { cin >> maze[i][j]; }
  }
  int res = 0;
  P start;
  P goal;
  rep(i, h) {
    rep(j, w) {
      rep(l, h) {
        rep(m, w) {
          if (maze[i][j] == '.' && maze[l][m] == '.') {
            start = P(i, j);
            goal = P(l, m);
            res = max(res, bfs(start, goal));
          }
        }
      }
    }
  }
  out(res);
}


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

signed main(){
    int N;
    int ans=0;
    cin >>N;
    int p[N];
    REP(i,N){
        cin>>p[i];
    }
    for(int i=1;i<N-1;i++){
        if((p[i]>p[i-1]&&p[i+1]>p[i])||(p[i]<p[i-1]&&p[i+1]<p[i])) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
x, n = map(int,input().split())
if n > 0:
  l = set(map(int,input().split()))
  for i in range(100):
    if x-i not in l:
        print(x-i)
        break
    if x+i not in l:
        print(x+i)
        break
else:
  print(x)
    



Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int main() {
	int k, a, b;
	cin >> k >> a >> b;
	if (a % k == 0 || b % k == 0)cout << "OK" << endl;
	else if ((b / k) - (a / k) >= 1)cout << "OK" << endl;
	else cout << "NG"<< endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
    int a,b;
    while(~scanf("%d%d",&a,&b)){
        int x=b,ans=1;
        while(x){
           x/=10;
           ans*=10;
        }
        int c=a*ans+b;
        int d=sqrt(c*1.0);
        if(d*d==c) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


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

using namespace std;

int main()
{
	while(true)
	{
		int length;
		cin >> length;
		if(length == 0)
			break;

		auto numbers = vector<int>(length);
		for(auto& i : numbers)
			cin >> i;

		int max = -2000001;
		for(int i = 0; i < length; i++)
		{
			int current = 0;
			for(int j = i; j < length; j++)
			{
				current += numbers[j];
				if(max < current)
					max = current;
			}
		}

		cout << max << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin>>s;
  if(s=="AAA" || s=="BBB")
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a,b,c, d[10];
void solve(){
	cin >> n >> a >> b >> c;
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	
	int ans = INF;
	for(int i = 0; i < (1<<(n*2)); i++){
		int sum[4] = {0}, cc[4] = {0};
		for(int j = 0; j < n; j++){
			sum[(i>>(j*2))%4] += d[j];
			cc[(i>>(j*2))%4]++;
		}
		if(cc[0]==0||cc[1]==0||cc[2]==0) continue;
		int cnt = 0;
		cnt += abs(sum[0]-a) + (cc[0]-1)*10;
		cnt += abs(sum[1]-b) + (cc[1]-1)*10;
		cnt += abs(sum[2]-c) + (cc[2]-1)*10;
		chmin(ans,cnt);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n = I()
s = S()
r = 0
g = 0
b = 0
for i in s:
    if i == 'R':
        r += 1
    elif i == 'G':
        g += 1
    else:
        b += 1

ans = r * g * b
for gap in range(2000):
    for start in range(4000):
        if start + gap * 2 >= len(s):
            break
        else:
            if s[start] != s[start + gap] != s[start + gap * 2] != s[start]:
                ans -= 1


print(ans)


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

ll n,m,L,R;


int main(){
  ll ans=0;
  cin >> n >> m;
  ll ansmax=0;
  ll ansmin=n;
  REP(i,m){
    cin >> L >> R;
    ansmax=max(ansmax,L-1);
    ansmin=min(ansmin,R-1);
  }

  ans=max(ansmin-ansmax+1,0LL);
  cout<<(ans)<<endl;
  return 0;
}

Measured memory_bytes: 256
module app;

import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto input = parseInput();
	auto result = main2(input);
    writefln("%d", result);
}

int main2(Input input)
{
    int count = 0;
    for (int i = 0; i < input.n; i++)
    {
        int a = 0;
        if (i == 0)
            a = input.b[0];
        else if (i == input.n - 1)
            a = input.b[$-1];
        else
            a = min(input.b[i-1], input.b[i]);
        count += a;
    }
    return count;
}

unittest
{
    Input input = {3, [2,5]};
    auto result = main2(input);
    assert(result == 9);
}
unittest
{
    Input input = {2, [3]};
    auto result = main2(input);
    assert(result == 6);
}
unittest
{
    Input input = {6, [0,153,10,10,23]};
    auto result = main2(input);
    assert(result == 53);
}

struct Input
{
	uint n;
	int[] b;
}

Input parseInput()
{
	Input input = void;
	input.n = readln().strip().to!uint;
	input.b = readln().strip().split().map!(s => s.to!int).array;
	return input;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<set>
#define ll long long
#define mod 1000000007
#define Mod1(x) (x>=mod?x-mod:x)
#define Mod2(x) (x<0?x+mod:x)
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
const int size=4010,inv2=(mod+1)>>1;
int fac[2*size],inv[2*size];
int dp[size][size];
int a[maxn],b[maxn];
int n,tot;
inline ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
inline ll C(ll n,ll m){return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read(); b[i]=read();
		++dp[2000-a[i]][2000-b[i]];
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++){
			if(i)dp[i][j]=Mod1(dp[i][j]+dp[i-1][j]);
			if(j)dp[i][j]=Mod1(dp[i][j]+dp[i][j-1]);
		}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=Mod1(ans+dp[2000+a[i]][2000+b[i]]);
	fac[0]=inv[0]=1;
	for(int i=1;i<=8000;i++)
		fac[i]=(ll)fac[i-1]*i%mod,inv[i]=power(fac[i],mod-2);
	for(int i=1;i<=n;i++)
		ans=Mod2(ans-C(2*a[i]+2*b[i],2*a[i]));
	writeln((ll)ans*inv2%mod);
	return 0;
}

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

int main(){
	int n , m , k;
	cin >> n >> m ;
	int a[m+1] = {0} ;
	for(int i = 0 ; i < n ; i++){
		cin >> k ;
		for(int j = 0 ; j < k ; j++){
			int t ;
			cin >> t ;
			a[t]++ ;
		}
	}
	int cnt = 0 ;
	for(int i : a){
		if(i==n)	
			cnt++ ;
	}
	cout << cnt << endl ;
}


Measured memory_bytes: 256
// code by Juan Torres
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = x/500;
		int z = (x%500)/5;
		int ans = y*1000 + z*5;
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/
void solve()
{
    ll s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";
}

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


Measured memory_bytes: 3648
#include <stdio.h>
#define N 44

int fibonacci(int);

int main(){
  int f[N], num, i;
  f[0] = 1;
  f[1] = 1;

  scanf("%d", &num);

  for(i = 2; i <= num; i++){
    f[i] = f[i - 2] + f[i - 1];
  }
  printf("%d\n", f[num]);

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
    using namespace std;
     
    void frog1(vector<int>&cost){
    	int n = cost.size();
    	if(n == 0){
    		cout << 0 << endl;
    	}
    	int dp[n];
    	//memset(dp,10000, sizeof(dp));
    	dp[0] = 0;
    	dp[1] = abs(cost[1]-cost[0])+dp[0];
    	int j;
    	for(int i=2; i<n; i++){
			int mn=1e9+5;
    		for(int k=0; k<2; k++){
    			mn = min(mn , abs(cost[i]-cost[i-k-1])+dp[i-k-1]);
    		}
			dp[i]=mn;
    	}
    	cout << dp[n-1] << endl;
    }
     
    int main(){
    	int n;
    	cin >> n;
    	vector<int> cost;
    	int  val;
    	for(int i=0; i<n; i++){
    		cin >> val;
    		cost.push_back(val);
    	}
    	frog1(cost);
    	return 0;
    }

Measured memory_bytes: 1144
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	stack<char>st;
	for (auto i : s) {
		if (st.empty())st.push(i);
		else {
			if (st.top() == 'S'&&i == 'T')st.pop();
			else st.push(i);
		}
	}
	cout << st.size() << endl;
	return 0;
}

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

#define fi first
#define se second
#define sz(v) (int)((v).size())
#define pb push_back
#define sq(x) (x)*(x)
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAX = 1e5 + 5, IFTY=1e8;

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

	int n,m,x;
	cin >> n >> m >> x;
	vector<int> C(n);
	vector<vector<int>> A(n,vector<int>(m));
	for (int i=0; i<n; i++){
		cin >> C[i];
		for (int j=0; j<m; j++)
			cin >> A[i][j];
	}
	int ans = IFTY;
	for (int b=1; b<=(1<<n); b++){
		int cout=0;
		vector<int> skill(n);
		for (int i=0; i<n; i++){
			if ((b>>i)&1){
				cout += C[i];
				for (int j=0; j<m; j++)
					skill[j]+=A[i][j];
			}
		}
		bool val=true;
		for (int j=0; j<m; j++)
			val &= skill[j]>=x;
		if (val)
			ans = min(ans,cout);
	}

	if (ans==IFTY)
		cout << "-1\n";
	else
		cout << ans << "\n";
}


Measured memory_bytes: 3660
use std::io::BufRead;
fn main() {
    let stdin = std::io::stdin();
    let mut handle = stdin.lock();
    let mut input1 = String::new();
    handle.read_line(&mut input1).unwrap();
    let mut input2 = String::new();
    handle.read_line(&mut input2).unwrap();
    println!("{}", input1.chars().zip(input2.chars()).filter(|(a, b)| a != b).count());
}

Measured memory_bytes: 2520
N = gets.to_i
a = gets.split.map { |e|  e.to_i}
min_total = (200 ** 2) * 100

-100.upto 100 do |avg_tmp|
	total_tmp = 0
	N.times do |n|
		total_tmp += (a[n] - avg_tmp) ** 2
	end
	if total_tmp < min_total
		min_total = total_tmp
	end
end
puts min_total


Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ll N; cin>>N;
  string S,T; cin>>S>>T;
  string ans=""; rep(i,N) ans+="  ";
  for(int i=0;i<2*N;i+=2) ans[i]=S[i/2];
  for(int i=1;i<2*N;i+=2) ans[i]=T[i/2];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        String t = sc.next();
        
        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();
        int count = 0;
        for(int i = 0; i < 3; i++){
            if(cs[i] == ct[i]){
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 21712
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	n := readInt()
	x := readInt64()
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = readInt64()
	}

	var ans int64
	for i := 1; i < n; i++ {
		s := a[i-1] + a[i]
		if s <= x {
			continue
		}

		d := s - x
		ans += d
		if a[i] > d {
			a[i] -= d
		} else {
			a[i] = 0
		}
	}
	println(ans)

}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <deque>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    map<int, int>a;
    int N, x;
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x;
        a[x]++;
    }

    for (auto itr = a.begin(); itr != a.end(); itr++) {
        if (itr->first == itr->second) {
            continue;
        } else if (itr->first < itr->second) {
            ans += itr->second - itr->first; 
        } else if (itr->first > itr->second) {
            ans += itr->second;
        }
    }
    cout << ans << endl;
}


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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] c = new long[n];
        long sum = 0;
        for(int i=0;i<n;i++){
            long a = sc.nextLong(), b = sc.nextLong();
            sum -= b;
            c[i] = a+b;
        }
        Arrays.sort(c);
        for(int i=n-1;i>=0;i-=2) sum += c[i];
        System.out.println(sum);
    }
}


Measured memory_bytes: 89292
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int x;
signed main(){
	x=read();
	int ans=(x/500)*1000,tmp=x%500;
	printf("%d\n",ans+(tmp/5)*5);
	return 0;
}


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

"""code-fes-2017-qual-c-b"""


import sys

from functools import reduce

def solve(str):
    """Solve."""
    i = int(str)

    if i % 2 == 0:
        return 2
    else:
        return 1


def main():
    """Main function."""
    N = int(input())
    As = map(solve, input().split())
    comp = reduce(lambda a, b: a * b, As)

    print(pow(3, N) - comp)


if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 3700
package main

import "fmt"

func main() {
	var N int
	var s string
	var t string
	fmt.Scan(&N, &s, &t)
	var ans int
	ans = len(s) + len(t)
	for i := 0; i < N+1; i++ {
		// fmt.Println(s[N-i:], t[:i])
		if s[N-i:] == t[:i] {
			ans = min(ans, N*2-i)
		}
		if s[:i] == t[N-i:] {
			ans = min(ans, len(s)+len(t)-i*2)
		}
	}
	fmt.Println(max(N, ans))
	return
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

int main(){
  ll k, n;
  cin >> k >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  vector<ll> b(n);
  rep(i, n){
    if(i != n-1)b.at(i) = a.at(i+1) - a.at(i);
    else b.at(i) = k - a.at(n-1) + a.at(0);
  }
  sort(b.begin(), b.end());
  cout << accumulate(b.begin(), b.end() - 1, 0) << endl;
}

Measured memory_bytes: 3456
import itertools
import copy

H,W,K = map(int,input().split())
Map = []
for i in range(H):
  c = list(input())
  tmp = []
  for j in range(W):
    if(c[j] == '.'): tmp.append(0)
    else: tmp.append(1) 
  Map.append(tmp)
  
# 全探索
# i番目の列または行を選ぶ
A = list(itertools.product([0,1],repeat=H))
B = list(itertools.product([0,1],repeat=W))

ans = 0
for a_l in A:
  for b_l in B:
    tmp_Map = copy.deepcopy(Map)
    
    for a in range(len(a_l)):
      if(a_l[a] == 1):
        # a行目を0にする
        for j in range(W):
         tmp_Map[a][j] = 0
        
    for b in range(len(b_l)):
      if(b_l[b] == 1):
        # b列目を0にする
        for i in range(H):
         tmp_Map[i][b] = 0
        
    # 残っている1がK個のときans+1
    tmp = 0
    for i in range(H):
      tmp += sum(tmp_Map[i])
      
    if(tmp == K):
      ans += 1

print(ans)      

Measured memory_bytes: 9364