akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  int i1 = input();
  int i2 = input();

  for(int i=1;i<=3;i++){
    if(i != i1 && i != i2){
      output(i);
    }
  }

  return 0;
}

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

typedef pair<int, int> pii;

const int MN = 200010;

int N;
int A[MN];
set<pii> st;

bool check(int x) {
    st.clear();
    for(int i = 1; i < N; i++) {
        if(A[i - 1] < A[i]) {
            continue;
        }
        else {
            int pos = A[i];
            while(pos) {
                auto it = st.lower_bound(pii(pos, -1));
                if(it == st.end()) {
                    st.insert(pii(pos, 1));
                    break;
                }
                pii t = *it; st.erase(t);
                if(pos < t.first) {
                    st.insert(pii(pos, 1));
                    break;
                }
                if(t.second == x - 1) {
                    pos--;
                    continue;
                }
                t.second++;
                st.insert(t);
                break;
            }
            if(!pos) return false;
            while(st.size() && st.rbegin()->first > pos) {
                st.erase(*st.rbegin());
            }
        }
    }
    return true;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    bool ok = true;
    for(int i = 1; i < N; i++) {
        if(A[i - 1] >= A[i]) {
            ok = false;
            break;
        }
    }
    if(ok) {
        printf("1");
        return 0;
    }

    int s = 2, e = N, p = -1;
    while(s <= e) {
        int m = (s + e)>>1;

        if(check(m)) {
            p = m;
            e = m - 1;
        }
        else s = m + 1;
    }
    printf("%d", p);
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

const int Maxn = 100010;
int n , m;
int f[Maxn];
bool b[Maxn];

int main() {
	
	scanf("%d%d",&n,&m);
	for(register int i=1; i<=n; i++)
		f[i] = 1;
	b[1] = true;
	for(register int x,y; m--; ) {
		scanf("%d%d",&x,&y);
		f[x] -- , f[y] ++;
		if(b[x]) {
			b[y] = true;
			if(!f[x])	b[x] = false;
		}
	}
	
	register int ans = 0;
	for(register int i=1; i<=n; i++)
		if(b[i])
			ans ++;
	printf("%d\n",ans);
	
	return 0;
	
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
using namespace std;

// int main()
// {
//     char s[10];
//     stack<int> st;
//     while (scanf("%s", s) != EOF)
//     {
//         if (s[0] == '+')
//         {
//             int x = st.top();
//             st.pop();
//             int y = st.top();
//             st.pop();
//             st.push(y + x);
//         }
//         else if (s[0] == '-')
//         {
//             int x = st.top();
//             st.pop();
//             int y = st.top();
//             st.pop();
//             st.push(y - x);
//         }
//         else if (s[0] == '*')
//         {
//             int x = st.top();
//             st.pop();
//             int y = st.top();
//             st.pop();
//             st.push(y * x);
//         }
//         else
//         {
//             st.push(stoi(s));
//         }
//     }

//     printf("%d\n", st.top());

//     return 0;
// }

int main()
{
    string s;
    stack<int> st;
    while (cin >> s)
    {
        if (s[0] == '+')
        {
            int x = st.top();
            st.pop();
            int y = st.top();
            st.pop();
            st.push(y + x);
        }
        else if (s[0] == '-')
        {
            int x = st.top();
            st.pop();
            int y = st.top();
            st.pop();
            st.push(y - x);
        }
        else if (s[0] == '*')
        {
            int x = st.top();
            st.pop();
            int y = st.top();
            st.pop();
            st.push(y * x);
        }
        else
        {
            st.push(stoi(s));
        }
    }

    cout << st.top() << endl;

    return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define CLR(A, X) memset(A, X, sizeof(A))
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
int dcmp(double x){if(fabs(x)<eps) return 0; return x<0?-1:1;}
const LL INF = 0x3f3f3f3f;
const LL MOD = 1e9+7;
const int N = 2e5+5;

int p[N], out[N], grundy[N];
vector<int> G[N];
set<int> S;

int main() {
    CLR(out, 0);
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &p[i]);
        out[p[i]]++;
        G[p[i]].pb(i);
    }
    queue<int> Q;
    for(int i = 1; i <= n; i++) if(!out[i]) {
        Q.push(i);
    }
    while(!Q.empty()) {
        int u = Q.front(); Q.pop();
        S.clear();
        for(int v:G[u]) S.insert(grundy[v]);
        int j = 0;
        while(S.count(j)) j++;
        grundy[u] = j;
        if(--out[p[u]] == 0) Q.push(p[u]);
    }
    bool flag = 0;
    for(int i = 1; i <= n; i++) if(out[i]) {
        S.clear();
        int ti;
        for(int v:G[i]) {
            if(!out[v]) S.insert(grundy[v]);
            else ti = v;
        }
        int j = 0;
        while(S.count(j)) j++;
        grundy[i] = j;
        for(int u = p[i]; ;) {
            S.clear();
            for(int v:G[u]) S.insert(grundy[v]);
            int k = 0;
            while(S.count(k)) k++;
            grundy[u] = k;
            u = p[u];
            if(u == p[i]) break;
//            printf("%d %d\n", u, grundy[u]);
        }
        if(grundy[i] == j) flag = 1;
        grundy[ti] = j;
        for(int u = i; ;) {
            S.clear();
            for(int v:G[u]) S.insert(grundy[v]);
            int k = 0;
            while(S.count(k)) k++;
            grundy[u] = k;
            u = p[u];
            if(u == i) break;
        }
        if(grundy[ti] == j) flag = 1;
        break;
    }
    printf("%s\n", flag?"POSSIBLE":"IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 12672
import java.util.*;

public class Main {



    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String str = scan.next();

        char[] carray = str.toCharArray();

        int count = 0;
        int max = 0;
        for(int i = 0; i<carray.length; i++){

            if(carray[i] == 'A' || carray[i] == 'T' || carray[i] == 'G' || carray[i] == 'C'){
                count++;
                if(max <= count) max = count;
            }else{
                if(max <= count) max = count;
                count = 0;
            }
        }

        

        System.out.println(max);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
    vector <ll> v(3);
    rep(i, 3) cin >> v.at(i);
    sort(v.begin(), v.end());
    ll res = 1;
    rep(i, 2) {
        if (v.at(i) != v.at(i+1)) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>
#include <algorithm>

using namespace std;

using veci = vector<int>;
using pii = pair<int, int>;
using vecii = vector<pii>;
using ll = long long;
using vecl = vector<ll>;
#define fi first
#define se second
#define endl '\n'

int const MAXIDX = 15;

void solve() {
    int n;
    cin >> n;

    vector<int> pos(n);
    vector<int> neg(n);
    for (int i=0; i<n; ++i) {
        int m;
        cin >> m;

        int pstate=0, nstate=0;
        int x, y;
        for (int j=0; j<m; ++j) {
            cin >> x >> y;
            if (y) {
                pstate |= (1<<(x-1));
            } else {
                nstate |= (1<<(x-1));
            }
        }
        pos[i] = pstate;
        neg[i] = nstate;
    }

    int ans = 0;
    for (int i=0; i<(1<<n); ++i) {
        bool ok = true;
        int cnt = 0;
        for (int j=0; j<n; ++j) {
            if (i&(1<<j)) {
                cnt += 1;
                if ((i & pos[j]) != pos[j] || (i & neg[j])) {
                    ok = false;
                    break;
                }
            }
        }

        if (ok) ans = max(ans, cnt);
    }
    cout << ans << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#if defined(LOCAL_TEST)
    (void)argc;
    freopen(string(argv[0]).append("-test.in").c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(ll, Q, H, S, D, N);
	H = min(H, 2 * Q);
	S = min(S, 2 * H);
	D = min(D, 2 * S);
	out((N / 2) * D + (N % 2) * S);
	return 0;
}


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

ans = float('inf')
for i in range(3):
    for j in range(3):
        if i != j:
            for k in range(3):
                if i != k and j != k:
                    ans = min(ans, abs(a[j] - a[i]) + abs(a[k] - a[j]) )
print(ans)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSimilarArrays solver = new BSimilarArrays();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSimilarArrays {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int[] a = new int[n];
            int res = (int) Math.pow(3, n);
            int min = 1;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                if (a[i] % 2 == 0) {
                    min *= 2;
                }
            }

            out.println(res - min);

        }

    }
}



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

using namespace std;
using LL = long long;
const int N = 1024;
const int INF = 1E9;
const double EPS = 1E-9;

int a[N];
int n, m;

int main() {
    ios_base::sync_with_stdio(false);

#ifdef CF_DEBUG
    freopen("../cf/input.txt","r",stdin);
#endif
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9)
        OP(a * b);
    else
        OP(-1);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,ll>;
const ll inf=1000000000007;


int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = max(max(a*c, a*d), max(b*d, b*c));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
n, m = map(int, input().split())
k = []
for _ in range(m):
    k.append(list(map(int, input().split()))[1:])
*p, = map(int, input().split())

count = 0
for i in range(2 ** n):
    res = 0
    for kc, pc in zip(k, p):
        s = sum([(i >> (j-1)) & 1 for j in kc]) % 2
        res += s == pc
    count += res == len(p)
print(count)

Measured memory_bytes: 3064
import copy
h,w,k = map(int, input().split())
lc = []
for _ in range(h):
  cw = str(input())
  tmp = []
  for i in cw:
    if i == "#":
      tmp.append(0)
    else:
      tmp.append(1)
  lc.append(tmp)

#print(lc)
ans = 0

for i1 in range(2**h):
  for j1 in range(2**w):
    lc_tmp = copy.deepcopy(lc) 
    
    for i2 in range(h):
      if (i1 >> i2) &1 == 1:
        for j in range(w):
          lc_tmp[i2][j] += 1

    for j2 in range(w):
      if (j1 >> j2) &1 == 1:
        for i in range(h):
          lc_tmp[i][j2] += 1
            #print(lc_tmp)
    cnt = 0
    for i in range(h):
      cnt += lc_tmp[i].count(0)
    ans += 1 if cnt == k else 0
print(ans)

Measured memory_bytes: 9148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define Z (128)

void mul(double (*a)[Z], const double (*b)[Z]) {
    static double t[Z][Z];
    memset(t, 0, sizeof(t));
    rep(k, Z) rep(i, Z) rep(j, Z) t[i][j] += a[i][k]*b[k][j];
    memcpy(a, t, sizeof(t));
}

void pow(double (*a)[Z], int x) {
    static double p[Z][Z];
    memcpy(p, a, sizeof(p));
    rep(i, Z) rep(j, Z) a[i][j] = i==j ? 1.0 : 0.0;
    rep(b, 32) {
        if(x&(1<<b)) mul(a, p);
        mul(p, p);
    }
}

void eqsolve(int n, double (*a)[Z]) {
    rep(k, n) {
        double mx = -1;
        int ix = -1;
        for(int i=k; i<n; i++) if(mx<fabs(a[i][k])) mx=fabs(a[i][k]), ix=i;
        if(k!=ix) rep(i, n+1) swap(a[k][i], a[ix][i]);
        const double p = a[k][k];
        for(int i=k; i<=n; i++) a[k][i] /= p;
        rep(i, n) if(i!=k) {
            const double d = a[i][k];
            for(int j=k; j<=n; j++) a[i][j] -= d*a[k][j];
        }
    }
}


double solve(int S, int N, int K) {
    static double p[Z][Z], eqs[Z][Z], mat[Z][Z];
    if(N==1) return S%K==0 ? (double)(S/K) : -1.0;

    // calc p
    p[0][0] = 1.0;
    const int M = N*K+1;
    rep(i, K) rep(j, M) rep(k, N) p[i+1][j+k+1] += p[i][j]/N;

    // solve small
    eqs[0][0] = 1;
    for(int k=1; k<M; k++) {
        eqs[k][k] = 1;
        rep(j, M) eqs[k][abs(k-j)] -= p[K][j];
        eqs[k][M] = -1;
    }
    eqsolve(M, eqs);
    if(S<M) return fabs(eqs[S][M]);

    // solve large
    rep(i, M) mat[0][i] = p[K][i+1];
    mat[0][M] = 1;
    rep(i, M-1) mat[i+1][i] = 1;
    mat[M][M] = 1;
    pow(mat, S-M+1);
    double ans = 0;
    rep(i, M) ans += mat[0][i]*fabs(eqs[M-1-i][M]);
    ans += mat[0][M];
    return ans;
}

int main() {
    int S, N, K;
    scanf("%d%d%d", &S, &N, &K);
    double ans = solve(abs(S), N, K);
    if(ans<0) printf("%d\n", -1);
    else printf("%.9f\n", ans);
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;

  vector<vector<int>> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    for (int j = 0; j < a; ++j) {
      int xx, yy;
      cin >> xx >> yy;
      x[i].push_back(--xx);
      y[i].push_back(yy);
    }
  }

  int ans = 0;
  for (int i = 1; i < (1 << n); ++i) {
    bool ok = true;
    for (int j = 0; j < n; ++j) {
      if (!(i & (1 << j))) continue;
      for (int k = 0; k < x[j].size(); ++k) {
        if (((i >> x[j][k]) & 1) != y[j][k]) {
          ok = false;
          break;
        }
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << '\n';

  return 0;
}


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

int main() 
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum = 0;
        
        if(k == a+b+c)
            sum = a-c;
        else if(k > a+b)
            sum = a - (k-a-b);
        else if(k == a+b)
            sum = a;
        else if(k >= a)
            sum = a;
        else
            sum = k;
    
    cout<<sum;
}




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

bool customFunctionOne (pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
  if(a.second.first == b.second.first) return (a.second.second < b.second.second);
  else return (a.second.first < b.second.first);
}

bool customFunctionTwo (pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
  return (a.first < b.first);
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, pair<int, int>>> py(m);
  for(int i=0;i<m;i++) {
    py[i].first = i+1;
    cin >> py[i].second.first >> py[i].second.second;
  }

  sort(py.begin(), py.end(), customFunctionOne);
  py[0].second.second = 1;
  for(int i=1;i<m;i++) {
    if(py[i].second.first == py[i-1].second.first) py[i].second.second = py[i-1].second.second + 1;
    else py[i].second.second = 1;
  }

  sort(py.begin(), py.end(), customFunctionTwo);

  for(int i=0;i<m;i++) {
    cout << setw(6) << setfill('0') << py[i].second.first;
    cout << setw(6) << setfill('0') << py[i].second.second << endl;
  }
}

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

int main() {
  int X;
  cin >> X;
  int m = 10, n = 1;
  int num, sum = 0;
  for(int i = 0; i < 10; i++){
  	num = X % m / n;
    sum += num;
    m *= 10;
    n *= 10;
  }
  if (X % sum == 0){
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  co(a*a);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class C
{
    static void Main()
    {
        var nmd = Console.ReadLine().Split(' ').Select(double.Parse).ToList();
        Console.WriteLine((nmd[1] - 1) * (nmd[2] == 0 ? nmd[0] : 2 * (nmd[0] - nmd[2])) / nmd[0] / nmd[0]);
    }
}

Measured memory_bytes: 13268
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(a % 2 == 1 && b % 2 == 1) System.out.println("Yes");
        else System.out.println("No");
    }  
}

Measured memory_bytes: 21332
M, D = map(int,input().split())

count = 0
for m in range(M+1):
    for d in range(D+1):
        d_1 = d % 10
        d_10 = d // 10
        if (d_10 >= 2 and d_1 >= 2 and m == d_10*d_1):
            count += 1

print(count)

Measured memory_bytes: 2940
def big(a,b):
    if a >= b:
        return a
    else:
        return b

n,k = map(int,input().split())
ans = 0

b = 1
while b <= n:
    p = n//b
    ans += p*big(0,b-k)
    r = n%b
    ans += big(0,r-k+1)
    b += 1

if k == 0:
    ans += -n
print(ans)

Measured memory_bytes: 3064
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    w = list(map(int, input().rstrip('\n').split()))
    t = sum(w)
    mt = 10 ** 10
    for i in range(1, n):
        lt = sum(w[:i])
        mt = min(mt, abs(lt - t + lt))
    print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;
const int mod = 1000000007;

struct mint{

  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<mint> num(k+1, 0);
  FORre(i, k+1, 1){
    num[i] = mint(k/i).pow(n);
    for(ll j = 2; i*j <= k; j++){
      num[i] -= num[i*j];
    }
  }
  mint ans = 0;
  REP(i, k+1) ans += num[i]*i;
  cout << ans << endl;
  return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}


template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

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

    int n;
    cin >> n;
    int a;
    int col[8] = {0};
    int any=0;
    rep(i, n){
        cin >> a;
        if(a>=3200) {any++; continue;}
        col[a/400]++;
    }

    rep(i, 8){
        dpp(col[i]);
    }

    int col_cnt=0;
    rep(i, 8){
        if(col[i] != 0)
            col_cnt++;
    }


    // ppp(mn << mx+any);
    cout << max(1, col_cnt) << sp << col_cnt+any << endl;


    return 0;
}


Measured memory_bytes: 256
function main(lines) {
    const input = lines.trim().split('')
    const lastNumber = input[input.length-1]
    let output = ''
    if(lastNumber == 2 || lastNumber == 4 || lastNumber == 5 || lastNumber == 7 || lastNumber == 9){
      console.log('hon')
      return;
    } else if (lastNumber == 3) {
      console.log('bon')
      return;
    } else if(lastNumber == 0 || lastNumber == 1 || lastNumber == 6 || lastNumber == 8) {
      console.log('pon')
      return;
    }
  }

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 30124
// B - Five Dishes
#include <bits/stdc++.h>
using namespace std;

int main(){
	int time = 0, max_dif = 0;
	for(int i=0; i<5; ++i){
		int a; cin>>a;
		int dif = ((a+9)/10) * 10 - a;
		max_dif = max(max_dif, dif);
		time += a + dif;
	}
	cout<< time - max_dif <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,i,n,q=0,m=0,r,p,l;
scanf("%d %d",&a,&b);
p=1;
while(p<=b){
    q++;
    p=p*2;
    if(q==a){
        break;
    }
}r=a-q;
l=(b*r+p);
   printf("%d",l);
return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   string s;
   cin >> s;
   rep(i,s.size()){
      if (s[i]==',') s[i]=' ';
   }
   cout << s << endl;



   
   return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

LL dp[45][1<<16];

int main(){
	int n,m;
	int x,y,z;
	LL a,b,c;
	int i,j,k;
	cin>>n>>x>>y>>z;
	m=x+y+z-1;
	dp[0][0]=1;
	for(i=0;i<n;i++){
		for(j=0;j<(1<<m);j++){
			for(k=0;k<10;k++){
				a=((j<<1)+1)<<k;
				b=a&((1<<m)-1);
				if((a&(1<<m))&&(a&(1<<(m-x)))&&(a&(1<<(m-x-y))))continue;
				dp[i+1][b]+=dp[i][j];
				if(dp[i+1][b]>=MAX)dp[i+1][b]%=MAX;
			}
		}
	}
	for(i=0,a=0;i<(1<<m);i++){
		a+=dp[n][i];
		if(a>=MAX)a%=MAX;
	}
	LL s=pow_mod(10,n,MAX);
	s-=a;
	if(s<0)s+=MAX;
	cout<<s<<endl;
	return 0;
}


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

using namespace std;

int main() {
	int n; cin>>n;
	int d[n];

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

	cout<<(d[n/2] - d[n/2 - 1])<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int maxn=100005;
int n,C,K,a[maxn],ans;
template<class Type>Type read(){
    Type res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
#define iread() (read<int>())
#define lread() (read<long long>())
#define ulread() (read<unsigned long long>())
int main(){
    n=iread(),C=iread(),K=iread();
    for (int i=1;i<=n;i++){
        a[i]=iread();
    }
    sort(a+1,a+n+1);
    int t=0;
    for (int i=1,j=1;i<=n;i=j+1){
        t=a[i]+K,ans++;
        while(j<=n&&a[j+1]<=t&&j-i+1<C) j++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4040
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();
		if(t.substring(0,s.length()).equals(s)) {
			
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
using namespace std;
const int N = 200010;
int n, m, a[N], pre[N], ans = 0;
int mn[19][N], mx[19][N], lg[N];
bool vis[N];

int qmn(int l, int r) { int k = lg[r - l + 1]; return min(mn[k][l], mn[k][r - (1 << k) + 1]); }
int qmx(int l, int r) { int k = lg[r - l + 1]; return max(mx[k][l], mx[k][r - (1 << k) + 1]); }
int main() {
	scanf("%d%d", &n, &m);
	rep(i, 1, n) scanf("%d", &a[i]);
	lg[0] = -1; rep(i, 1, n) lg[i] = lg[i >> 1] + 1;
	rep(i, 1, n) mn[0][i] = mx[0][i] = a[i];
	for(int j = 1; (1 << j) <= n; j++)
		for(int i = 1; i + (1 << j) - 1 <= n; i++) {
			mn[j][i] = min(mn[j - 1][i], mn[j - 1][i + (1 << j - 1)]);
			mx[j][i] = max(mx[j - 1][i], mx[j - 1][i + (1 << j - 1)]);
		}
	pre[1] = 1;
	rep(i, 2, n) {
		if(a[i] > a[i - 1]) pre[i] = pre[i - 1] + 1;
		else pre[i] = 1;
		if(pre[i] >= m) vis[i - m + 1] = 1, ans = 1;
	}
	if(!vis[1]) ++ans;
	rep(i, 2, n - m + 1) if(!vis[i]) {
		int j = i + m - 1;
		if(a[i - 1] != qmn(i - 1, j) || a[j] != qmx(i - 1, j)) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 32512
unittest
{
	assert( [ "4 12" ].parse.expand.solve == 16 );
	assert( [ "8 20" ].parse.expand.solve == 12 );
	assert( [ "1 1" ].parse.expand.solve == 2 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	return ( b % a == 0 ) ? b + a : b - a;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> d(n);
	for (int i=0; i<n; i++)
		cin>>d[i];
	int ret=0;
	for (int i=0; i<n; i++)
		for (int j=i+1; j<n; j++)
			ret+=d[i]*d[j];
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
// C - Walk on Multiplication Table
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long n;
	cin >> n;
	long long ans = n - 1;
	for (long long i = 2; i * i <= n; i++) {
		if (n % i) continue;
		long long j = n / i;
		ans = min(ans, i + j - 2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <array>
#include <iostream>
#include <set>

using namespace std;

int main() {
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = min(s1.size(), s2.size()); i > 0; --i) {
    array<int, 26> v1, v2;
    for (int j = 0; j < 26; ++j) v1[j] =v2[j] = 0;
    set<array<int, 26>> m;
    for (int j = 0; j < i; ++j) ++v1[s1[j] - 'a'];
    for (int j = 0; i + j <= (int)s1.size(); ++j) {
      m.insert(v1);
      --v1[s1[j] - 'a'];
      if (i + j != (int)s1.size()) ++v1[s1[i + j] - 'a'];
    }
    for (int j = 0; j < i; ++j) ++v2[s2[j] - 'a'];
    for (int j = 0; i + j <= (int)s2.size(); ++j) {
      if (m.count(v2)) {
        cout << i << endl;
        return 0;
      }
      --v2[s2[j] - 'a'];
      if (i + j != (int)s2.size()) ++v2[s2[i + j] - 'a'];
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),
        m = sc.nextInt(),
        x = sc.nextInt(),
        y = sc.nextInt();
    int[] x_chil = new int[n];
    int[] y_chil = new int[m];
    for (int i = 0; i < n; i++) {
      x_chil[i] = sc.nextInt();
    }
    for (int i = 0; i < m; i++) {
      y_chil[i] = sc.nextInt();
    }
    Arrays.sort(x_chil);
    Arrays.sort(y_chil);
    System.out.println(x_chil[n - 1] < y_chil[0] && x < y_chil[0] && y > x_chil[n - 1]? "No War" : "War");
  }

}


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

using ll = long long;
ll a[200010];
ll f[200010];
ll x;
ll k;
ll n;
ll ans;

void mergg(int l,int r);
void merge_sort(int l,int r)
{
    if (l < r)
    {
        int mid = l + ((r-l)>>1);
        merge_sort(l,mid);
        merge_sort(mid+1,r);
        mergg(l,r);
    }
}

void mergg(int l,int r)
{
    ll* b = new ll[r + 1];           
    int mid = l + ((r-l)>>1);
    
    for (int i = l;i <= r;i++)
        b[i] = f[i];
        
    ll i = l;
	ll j = mid + 1;
	ll k = l;
    while (i <= mid && j <= r)
    {
        if (b[i] <= b[j])
        {
            f[k++] = b[i++];
        }
        else
        {
            f[k++] = b[j++];
            ans += (mid - i + 1ll);
        }
    }
    while (i <= mid) { f[k++] = b[i++]; }
    while (j <= r)   { f[k++] = b[j++]; }
    delete []b;
}


int main()
{
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=n;i++) a[i]-=k;
    for (int i=1;i<=n;i++) f[i]=f[i-1]+a[i];

    merge_sort(0,n);
    ans=(n+1)*n/2 - ans;
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 4904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

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

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int r = sc.nextInt();
    System.out.println(2.0 * (double) r * Math.PI);
  }
}

Measured memory_bytes: 33044
#include <cstdio>
#include <iostream>
#include <stack>
#include <algorithm>
#define MAX 1400
using namespace std;

struct Rectangle {
    int height;
    int pos;
};

int getLargestRectangle(int size,int buffer[]) {
    stack<Rectangle> S;
    int maxv=0;
    buffer[size]=0;

    for(int i=0;i<=size;i++) {
        Rectangle rect;
        rect.height=buffer[i];
        rect.pos=i;
        if(S.empty()||S.top().height<rect.height)
            S.push(rect);
        else if(S.top().height>rect.height) {
            int target=i;
            while(!S.empty()&&S.top().height>=rect.height) {
                Rectangle pre=S.top();S.pop();
                int area=pre.height*(i-pre.pos);
                maxv=max(maxv,area);
                target=pre.pos;
            }
            rect.pos=target;
            S.push(rect);
        }
    }
    return maxv;
}

int H,W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle() {
    for(int j=0;j<W;j++)
        for(int i=0;i<H;i++)
            if(buffer[i][j])
                T[i][j]=0;
            else
                T[i][j]=(i>0)?T[i-1][j]+1:1;

    int maxv=0;
    for(int i=0;i<H;i++)
        maxv=max(maxv,getLargestRectangle(W,T[i]));

    return maxv;
}

int main()
{
    scanf("%d %d",&H,&W);

    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
            scanf("%d",&buffer[i][j]);

    cout<<getLargestRectangle()<<endl;
}

Measured memory_bytes: 18508
def solve():
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    worddic = {}
    for i in range(N):
        if S[i] not in worddic.keys():
            worddic[S[i]] = 1
        else:
            worddic[S[i]] += 1

    worddic_sorted = sorted(worddic.items(), key=lambda x:x[1], reverse=True)
    selected = list(filter(lambda x:x[1] == worddic_sorted[0][1], worddic_sorted))
    selected_sorted = sorted(selected, key=lambda x:x[0])
    for i in range(len(selected_sorted)):
        print(selected_sorted[i][0])

solve()


Measured memory_bytes: 51212
#include<bits/stdc++.h>
namespace FastIO{const char* ln="\n";struct Reader{char buf[1<<20],*s,*t;bool EOF_FLG;Reader():s(buf),t(buf),EOF_FLG(false) {};char gt() {return s==t&&((t=(s=buf)+fread(buf,1,1<<20,stdin))==s)?EOF:(*s++);}Reader& operator>>(char* str) {if(EOF_FLG)return *str=0,*this;while((*str=gt())!=' '&&*str!='\n'&&*str!=EOF)++str;if(*str==EOF)EOF_FLG=true;*str=0;return *this;}template<typename T>Reader&operator>>(T&x) {if(EOF_FLG)return *this;char c=0,d;while(c!=EOF&&(c<'0'||c>'9'))d=c,c=gt();if(c==EOF){EOF_FLG=true;return *this;}else x=0;while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=gt();if(d=='-')x=-x;return *this;}}in;struct Writer{char buf[1<<20],*s,*t;Writer():s(buf),t(buf+(1<<20)){}~Writer(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,1<<20,stdout),*s++=c):(*s++=c);}template<typename T>Writer&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[40],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}Writer&operator<<(const char*s) {while(*s)pt(*s++);return *this;}}out;}using namespace FastIO;
namespace ZDY{
    #define ll long long
    #define db double
    #define sht short
    #define MB template <class T>
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define fur(i,x,y) for(i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fdr(i,x,y) for(i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define inf 0x3f3f3f3f
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define l2(n) (int(log2(n)))
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define fcin ios::sync_with_stdio(false)
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>=y?x:y;}
    MB T MIN(T x,T y){return x<=y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    void SWAP(int &x,int &y){x^=y;y^=x;x^=y;}
}using namespace ZDY;using namespace std;
#define N 10001
string f[N+100];
int n,m,a[10],c[]={0,2,5,5,4,5,6,3,7,6};
void upd(string &x,string y){
    if(x=="0")return (void)(x=y);
    if(x.size()<y.size())x=y;
    if(x.size()==y.size()&&x<y)x=y;
}
int main(){
    in>>n>>m;
    Fur(i,1,m)in>>a[i];
    Fur(i,0,n)f[i]="0";
    f[0]="";
    Fur(i,0,n)if(f[i]!="0")
        Fur(j,1,m)upd(f[i+c[a[j]]],f[i]+char(a[j]+48));
    cout<<f[n]<<endl;
}

Measured memory_bytes: 45056
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

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

    int N; cin >> N;
    int L[N]; REP (i, N) cin >> L[i];
    sort(L, L+N);

    ll a = 0;
    ll b = 0;
    ll c = 0;
    ll ans = 0;

    // REP(i,N) cout << L[i]<<' ';

    for (int i=0; i<N; ++i) {
        for (int j=i+1; j<N; ++j) {
            a = L[i];
            b = L[j];
            for (int k=j+1; k<N; ++k) {
                c = L[k];
                // cout <<"\na:"<<a <<" b:"<<b <<" c:"<<c;
                if (a+b<=c) {
                    // cout << ":: Break";
                    break;
                }
                ++ans;
            }
        }
    }
    // cout << '\n';
    cout << ans  << '\n';

    return 0;
}



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

using namespace std;
using ll=long long;

void solve() {
    ll n,a,b;
    cin >> n >> a >> b;
    if ((b-a)%2==0) {
        cout << (b-a)/2;
    } else {
        ll res = (b-a)/2;
        res += min(a, n-b+1);
        cout << res;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main()
{
    int temp,a, b, c,temp1,temp2,temp3;
    cin >> a >> b >> c;

    temp1 = a;
    a = b;
    b = temp1;
    temp2 = a;
    a = c;
    c = temp2;
    cout << a << " " << b << " " << c << endl;
    //cout << b << endl;
    //cout << c << endl;
    return 0;
}

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

int main(void){
	int n;
	while(cin >> n && n){
		int a[n],i=0,s=0,t=0;
		bool first = true;
		while(i<n) cin >> a[i++];
		i=0;
		s=a[i];
		t=a[i++];
		while(i<n){
			if(a[i-1] == a[i]-1){
				t=a[i];
			}else{
				first?first=false:cout<<" ";
				if(s!=t){
					cout << s << "-" << t;
				}else{
					cout << s;
				}
				s=a[i];
				t=a[i];
			}
			i++;
		}
		first?first=false:cout<<" ";
		if(s!=t){
			cout << s << "-" << t << endl;
		}else{
			cout << s << endl;
		}
	}
}

Measured memory_bytes: 0
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	A, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	if A > 9 {
		fmt.Println("-1")
		os.Exit(0)
	}

	scanner.Scan()
	B, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}
	if B > 9 {
		fmt.Println("-1")
		os.Exit(0)
	}

	fmt.Println(A * B)

}


Measured memory_bytes: 1836
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] a = new int[h][w];
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				int now = 0;
				for(int k = 0; k < h; k++) {
					for(int l = 0; l < w; l++) {
						now += Math.min(Math.abs(i - k), Math.abs(j - l)) * a[k][l];
					}
				}
				ans = Math.min(ans, now);
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 29408
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second

using namespace std;

const ll N = 481;
const ll big = 1e18;
const ll block = 100;
const ll mod = 1e6;

ll n;
ll a[N];
ll dp[N][N];
bool was[N][N];

ll rec(ll l,ll r){
	if(was[l][r])
		return dp[l][r];
	if(l == r)
		return a[l];
	ll ans = big;
	ll ls = a[r];
	
	for(int j = l; j < r ; j++){
		ls += a[j];
		ll x = rec(l , j) + rec(j + 1 , r);
		ans = min(x, ans);
	}
	was[l][r] = 1;
	dp[l][r] = ans + ls;
	return dp[l][r];
}

int main() {
    speed;
	cin >> n;
	ll ls = 0;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i],ls += a[i];
	cout << rec(0, n - 1) - ls;
}

/*
	Code written by
	Codeforces : I_Love_Trott
	mail : dzhon.snoudin@mail.ru
*/


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

int main(){
  int N, M, i,j, a, b;
  cin >> N >> M;
  vector<vector<int>> to(N+1, vector<int>(N+1, 0));
  rep0(i, M){
    cin >> a >> b;
    to[a][b] = 1;
    to[b][a] = 1;
  } 
  
  vector<int> arr(N);
  rep(i, 1, N+1){
    arr[i-1] = i;
  }
  int ret = 0;
  do{
    if (arr[0] != 1)continue;
    bool done = true;
    rep0(i, N-1){
      if (to[arr[i]][arr[i+1]] == 0){done = false;break;}
    }
    if (done)ret++;
  }while (next_permutation(arr.begin(), arr.end()));
  cout << ret << endl;

}

Measured memory_bytes: 256