akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long N, K, A; cin >> N >> K;
  vector<long long> Kbin(40,0);
  for (int i=0; i<40; i++) Kbin[39-i] = 1&(K>>i);
  
  vector<vector<long long>> Abin(N, vector<long long>(40,0));
  for (int n=0; n<N; n++) {
    cin >> A;
    for (int i=0; i<40; i++) Abin[n][39-i] = 1&(A>>i);
  }
  vector<long long> Abinnum(40,0);
  for (int i=0; i<40; i++) {
    long long tmp=0;
    for (int j=0; j<N; j++) tmp += Abin[j][i];
    Abinnum[i]=tmp;
  }

  vector<vector<long long>> dp(41, vector<long long>(2,0));
  //dp[桁数][上限ギリギリ]=上限ギリギリと上限未満それぞれの各桁までのXor最大
  for (int i=0; i<40; i++) {
    if (dp[i][0]>0) {
      dp[i+1][0] = dp[i][0]+max(Abinnum[i],N-Abinnum[i])*(1ull<<(39-i));
    }
    if(Kbin[i]==1){
      long long tmp=dp[i][1]+Abinnum[i]*(1ull<<(39-i));
      dp[i+1][0] = max(dp[i+1][0], tmp);
      dp[i+1][1] = dp[i][1]+(N-Abinnum[i])*(1ull<<(39-i));
    }
    else {
      dp[i+1][1] = dp[i][1]+Abinnum[i]*(1ull<<(39-i));
    }
  }
  cout << max(dp[40][0], dp[40][1]) << "\n";    
}

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

int main(void) {
  int N, a;
  cin >> N;
  vector<int> v;
  while (cin >> a) {
    v.push_back(a);
  }
  std::sort(v.begin(), v.end());
  cout << v.back() - v.front() << "\n";
}


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

int main()
{
    int n;
    int a[200001] = {0};
    vector<int> b(200001, 0);
    cin >> n;
    int input;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end(), std::greater<int>());
    for (size_t i = 0; i < n; i++)
    {
        if (a[i] == b[0])
        {
            cout << b[1] << endl;
        }
        else
        {
            cout << b[0] << endl;
        }
    }

    return 0;
}

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

using namespace std;

struct UF {
    vector<int> data;

    UF(int n) {
        data.resize(n, -1);
    }
    
    int root(int i) {
        return data[i] < 0 ? i : data[i] = root(data[i]);
    }

    int sz(int i) {
        return -data[root(i)];
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);

        if (x == y) return;
        if (sz(x) < sz(y)) swap(x, y);

        data[x] += data[y];
        data[y] = x;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int n, k;
bool c[100010];

int main()
{
    while (cin >> n >> k, n) {
        fill_n(c, 100010, false);
        bool f = false;

        for (int i = 0; i < k; ++i) {
            int a; cin >> a; --a;
            if (a == -1) f = true;
            c[a] = true;
        }

        int ans = 0;
        int cur = 0;

        for (int i = 0; i < n; ++i) {
            if (c[i]) cur++;
            else cur = 0;

            ans = max(ans, cur);
        }

        if (f) {
            if (ans < n) ans++;

            UF uf(n+1);

            for (int i = 0; i < n - 1; ++i) {
                if (c[i] && c[i + 1]) uf.unite(i, i + 1);
            }

            for (int i = 1; i < n; ++i) {
                if (c[i]) continue;
                int l = 0, r = 0;

                if (c[i - 1]) l = uf.sz(i - 1);
                if (c[i + 1]) r = uf.sz(i + 1);

                ans = max(ans, l + r + 1);
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 3260
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 2000;

int n, sa, sb;
int v[MAXN];

int dpa[MAXN]; // dpa[i] = maximum achievable value for a when the first available value is i (so b has i-1 (or sb))
int dpb[MAXN];

void run() {
	scanf("%d%d%d", &n, &sa, &sb); REP(i, n) scanf("%d", &v[i]);

	for (int i = n - 1; i >= 0; --i) {
		int pa = i == 0 ? sa : v[i - 1];
		int pb = i == 0 ? sb : v[i - 1];
		dpa[i] = abs(pb - v[n - 1]);
		FOR(j, i + 1, n) dpa[i] = max(dpa[i], dpb[j]);
		dpb[i] = abs(pa - v[n - 1]);
		FOR(j, i + 1, n) dpb[i] = min(dpb[i], dpa[j]);
	}
	printf("%d\n", dpa[0]);
}

int main() {
	run();
	return 0;
}


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

#define ipair pair<int,int>
#define rep(n) for(int i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	vi a;
	int n, i, j;
	int sum;

	cin >> n;
	a.resize(n);

	sum = 0;
	rep(n) {
		cin >> a[i];
		sum += a[i];
	}

	j = 0;

	rep(n) {
		if (abs(sum - a[j]*n) > abs(sum - a[i]*n))
			j = i;
	}

	cout << j;

	return 0;
}

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

int64_t solve(vector<int> &nums,int64_t &tasu){
    int64_t res =0,tmp = nums.at(0);
    rep(i,nums.size()-1){
        if(tasu & (1 << i)){
            res += tmp;
            tmp = nums.at(i+1);
        }else{
            tmp = tmp*10 + nums.at(i+1);
        }
    }
    res += tmp;
    return res;
}

int main(){
    string S;
    cin >> S;
    vector<int> nums(S.size());
    rep(i,S.size()){
        nums.at(i) = S.at(i) - '0';
    }

    int64_t sum = 0;
    for(int64_t i=0; i < (1<< (S.size()-1)); i++){
        sum += solve(nums,i);
    }

    cout << sum << endl;
}   

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;


void print() { std::cout << std::endl; }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail){
  std::cout << head << ",";
  print(std::forward<Tail>(tail)...);
}

using namespace std;

uint64_t INF = 1ll<<60;
int main(int argc, char **argv)
{
  uint64_t N, K;
  scanf("%lld%lld",&N, &K);
  vector<uint64_t> w(N);
  vector<uint64_t> d(N);

  // print(N,K);
  FOR(i,0,N){
    scanf("%lld%lld",&w[i],&d[i]);
    // print(w[i], d[i]);
  }

  uint64_t P = 0;
  uint64_t n = (K+(N-1)) / N;
  FOR(i,0,N){
    P = max(P, w[i] + n * d[i]);
  }


  uint64_t s = 1;
  uint64_t t = P;
  uint64_t c;
  
  while(s <= t) {
    c = s + (t-s)/2;
    uint64_t sum = 0;
    // uint64_t flag = 0;
    uint64_t dif = INF;
    FOR(i,0,N){
      if(c<w[i]) continue;
      sum = sum + (c-w[i])/d[i] + 1;
      dif = min(dif, (c-w[i])%d[i]);
    }
    if (sum == K ) {
      c = c - dif;
      break;
    } else if (sum < K) {
      s = c + 1;
    } else {
      t = c - 1;
    }

  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 1792
import itertools

X = int(input())
nums = []
for i in range(121):
  nums.append(i**5)

comb = itertools.combinations(nums, 2)
ans = 0

for c in comb:
  a,b = c
  if c[0]+c[1] == X:
    print(int(a**(1/5)),int(-b**(1/5)))
  elif -c[0]+c[1] == X:
    print(int(-a**(1/5)),int(-b**(1/5)))
  elif c[0]-c[1] == X:
    print(int(a**(1/5)),int(b**(1/5)))
  elif -c[0]-c[1] == X:
    print(int(-a**(1/5)),int(b**(1/5)))



Measured memory_bytes: 64744
#include <stdio.h>

int main(void)
{
	int a,b,c=0,e,g=0;
	char d[15];
	scanf("%d %d",&a,&b);
	scanf("%s",d);
	int f=a+1,h=a+b+1;
	if(d[a]=='-'){
		while(c<a){
			if(d[c]>='0'&&d[c]<='9'){
				e=0;
			}else{
				g=1;
			}
			c++;
		}
		while(f<h){
			if(d[f]>='0'&&d[f]<='9'){
				e=0;
			}else{
				g=1;
			}
			f++;
		}
	}else{
		g=1;
	}
	if(g==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	ll money;
	cin>>money;
	ll ha = 0;
	ha += money/500*1000;
	money %= 500;
	ha += money/5*5;
	cout<<ha<<endl;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
	public static void main(String[] atgs) {
		Scanner scan = new Scanner(System.in);
		int ans = 0;
		int K = scan.nextInt();
		int S = scan.nextInt();
		for(int x = 0; x <= K; x++){
			for(int y = 0; y <= K; y++){
				int z = S - x - y;
				if(0 <= z && z <= K){
					ans = ans + 1;
				}
			}
	    }
		System.out.println(ans);
		scan.close();
	}
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
        String[] array = a.split("");
		

		if(array[0].equals(array[1]) && array[1].equals(array[2])){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}

	}

	}

Measured memory_bytes: 21588
from heapq import *
n,m=map(int,input().split())
a=list(map(int,input().split()))

q=[]
for x in a:
  heappush(q,-x)
  
for i in range(m):
  temp=-heappop(q)
  heappush(q,-(temp//2))
  
print(-sum(q))

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

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    int i,j,n,m;
    ll sum;
    int arr[10001],ref[101];
    scanf("%d%d",&n,&m);
    for(i=0;i<n*m;i++)
    {
        scanf("%d",arr+i);
    }
    for(i=0;i<m;i++)
    {
        scanf("%d",ref+i);
    }
    for(i=0;i<n;i++)
    {
        sum=0;
        for(j=0;j<m;j++)
        {
            sum+=(ref[j]*arr[(i*m)+j]);
        }
        printf("%d\n",sum);
    }
    return 0;
}




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

#define rep(i,a,b)     for(int i=a;i<(b);i++)
#define lop(n)         for(int i=0;i<n;i++)
#define revlop(n)      for(int i=n-1;i>=0;i--)
#define trav(a,x)      for(auto &a :x)
#define all(x)         begin(x),end(x)
#define mod            1000000007
#define inf            1e18
#define ps(x,y)        fixed<<setprecision(y)<<x
#define w(x)           int x; cin>>x;

#define pb             push_back
#define mp             make_pair
#define lb             lower_bound
#define ub             upper_bound
#define bs             binary_search
#define F              first
#define S              second

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

void solve()
{
    string s;
    cin >> s;

    int n = s.length();
    int i = 0;
    int x = 0;
    while (i < n)
    {
        x = (x * 10 + (int)(s[i] - '0')) % 9;
        i++;
    }

    if (x == 0)
        cout << "Yes";
    else
        cout << "No";
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int test = 1;
    // cin >> test;

    while (test--)
    {
        solve();
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 3740
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (50000)

long long gcd(long long x, long long y){
	if (x > y)swap(x, y);
	if (x <= 0)return y;
	if (y%x == 0)return x;
	return gcd(y%x, x);
}

int main(void){
	long long n, a, g;
	scanf("%lld %lld", &n, &a);
	g = gcd(a, n);
	printf("%lld\n", 3 * (n - g));

	
	return 0;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

cout.precision(17);
  int n;cin>>n;
  ld ans=(n/2 + 1)/(ld)n;
  if(n%2==0)cout<<0.5<<endl;
  else cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3812
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();
        int K = sc.nextInt();
        int[] l = new int[N];
        for(int i = 0;i < N;i++){
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int sum = 0;
        for(int i = N-1;i > N-K-1;i--){
            sum += l[i];
        }
        System.out.println(sum);
    }
}


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

int main(){
    int n,l,s=0,m=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>l;
        s+=l;
        m=max(m,l);
    }
    cout<<(m<s-m?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> w(n);
  for(LL &x: w) cin >> x;
  w.insert(w.begin(),0);
  REP(i,n) w[i+1] += w[i];
  LL answer = p;
  for(LL &x: w) {
    answer = min(answer, abs(x*2-w.back()));
  }
  cout << answer << endl;
  return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {

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

	if (b < a)
		swap(b, a);

	if (a < c && c < b)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pi pair<int, int>
#define pl pair<long long, long long>
#define pld pair<long double, long double>
#define endl '\n'
#define loop(i, n) for (ll i = 0; i < n; i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define vi vector<int>
#define ml map<ll, ll>
#define vpl vector<pair<ll, ll>>
const ll mod = 1e9 + 7;

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t)
{
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t)
{
    for (auto &i : t)
        os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &t : v)
        is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v)
{
    for (pair<T1, T2> &t : v)
        is >> t.first >> t.second;
    return is;
}


int main()
{
    int n;
    cin >> n;
    vector<vi> v(n,vi());
    loop(i ,n) {
        loop(j, n){
            int a;
            cin >> a;
            if(a) v[i].emplace_back(j);
        }
    }
    vl dp(1<<n, 0);
    dp[0] = 1;
    loop(i, (1<<n) - 1) {
        int a = __builtin_popcount(i);
        for(auto x: v[a]) {
            if(!(i & (1<<x)))
                (dp[i^(1<<x)] += dp[i]) %= mod;
        }
    }
    cout << dp[(1<<n)-1] << endl;

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

    return 0;
}


Measured memory_bytes: 16640
#include <stdio.h>
#include <stdlib.h>

int ord(const void* a, const void *b){
    int x = *((int*)a), y = *((int*)b); 
    
    if (x > y)
        return 1;
    if (x < y)
        return -1;
    return 0;

}

int main() {
    int n;
    scanf("%d", &n);
    int vec[n], crt[n];
    for (int h = 0; h< n; ++h){
        scanf("%d", &vec[h]);
        crt[h] = vec[h];
    }
    
    qsort (crt, n, sizeof(crt[0]), ord);
    
    int max = crt[n-1], maxb = crt[n-2];
    
    for  (int i = 0; i < n; ++i){
        if (vec[i] == max)
            printf("%d\n", maxb);
        else
            printf("%d\n", max);
    }
    
    
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H,W;
  cin>>H>>W;
  vector<vector<int>> field(H+2, vector<int>(W+2));
  vector<vector<char>> ans(H, vector<char>(W));
  REP(i,H){
    string s;
    cin>>s;
    REP(j,W){
      if(s[j]=='#'){
        field[i+1][j+1]=1;
      }
    }
  }
  REP(i,H){
    REP(j,W){
      int cnt=0;
      if(field[i+1][j+1]==1){
        ans[i][j]='#';
      }else{
        FOR(k,-1,2){
          FOR(l,-1,2){
            if(field[i+1+k][j+1+l]==1)cnt++;
          }
        }
        ans[i][j]=cnt+'0';
      }
    }
  }
  REP(i,H){
    REP(j,W){
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int a[100001];
	scanf("%d",&n);
	for(int i=0;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int b[100001];
	long long sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		if(b[i]>a[i]+a[i+1]){
			sum=sum+a[i]+a[i+1];
			a[i+1]=0;
		}else{
			sum=sum+b[i];
			if(a[i]<b[i]){
				a[i+1]=a[i+1]-(b[i]-a[i]);
			}
		}
	}
	printf("%lld",sum);
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    String B = sc.next();
    String ans = "GREATER";
    if(A.length() < B.length()) {
      ans = "LESS";
    } else if(A.length() == B.length()) {
      boolean flg = true;
      for(int i = 0; i < A.length(); i++) {
        int a = Integer.parseInt(String.valueOf(A.charAt(i)));
        int b = Integer.parseInt(String.valueOf(B.charAt(i)));
        if(a > b) {
          flg = false;
          break;
        } else if(a < b) {
          flg = false;
          ans = "LESS";
          break;
        }
      }
      if(flg) ans = "EQUAL";
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      int n;cin >> n;
      vector<string> s(n);
      vector<int> p(n);
      rep(i,n)cin >> s[i] >> p[i];
      
      vector<int> ord(n);
      iota(ALL(ord),0);
      
      sort(ALL(ord),[&](int x,int y){
            if(s[x]==s[y]) return p[x] > p[y];
            else return s[x] < s[y];
      });

      for(auto i : ord)cout << i+1 << endl;
      return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>a;
    
    
    
    
    cout<< a+a*a+a*a*a <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using G = vector<vector<int>>;
using ll = long long;
int main(){
  int a;
  int b;
  cin >> a >> b;
  cout << a*b << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back
#define un unordered_map
#define us unordered_set
#define ll long long
#define l long 
using namespace std;
const int  mod= 1e9+7;
const int inf=1e9+3;
bool isMulOf9(ll n)
{
    // Base cases
    if (n == 0 || n == 9)
        return true;
    if (n < 9)
        return false;
 
    // if the number is greater than 9, then do this 
    return isMulOf9((int)(n>>3) - (int)(n&7));
}

 int main()
 {
   
   // 2nd
  string s;
   cin>>s;
   ll sum=0;
   for(int j=0; j<s.size(); j++)
     {
         ll k=  s[j]-'0';
         sum+=k;
     }
      if(!(sum%9))
    cout<<"Yes";
    else
    cout<<"No";
        
        
       return 0;
     
 }
  

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m;cin>>n>>m;
  int i;
  int ans=1;
  for(i=1;i*i<=m;i++)
  {
    if(m%i==0)
    {
      if(i>=n)ans=max(ans,m/i);
      if(m/i>=n)ans=max(ans,i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

char so[50001];

main(){
	memset(so,0,sizeof(so));
	
	int n,i,j,c,count;
	for(i=2;i<225;i++){
		c=50000/i;
		for(j=i;j<=c;j++){
			so[j*i]=1;
		}
	}
	
	while(~scanf("%d",&n)){
		if(n==0)break;
		count=0;
		for(i=2;i<=n/2;i++){
			if(so[i]==0 && so[n-i]==0){
				++count;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 456
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;

signed main(){
    int n;
    cin >> n;
    int cnt[n+1];
    memset(cnt,0,sizeof cnt);
    for(int i = 0;i<n;i++){
        for(int z = i+1;z<=n;z += i+1){
            cnt[z]++;
        }
    }
    int res = 0;
    for(int i =1;i<=n;i++){
        res += cnt[i]*(i);
    }
    cout << res;
}


Measured memory_bytes: 81696
import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
root=[-1]*(n+1)
def r(x):
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]
def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if root[x]>root[y]:
        x,y=y,x

    root[x]+=root[y]
    root[y]=x
def size(x):
    x=r(x)
    return -root[x]
for i in range(m):
    x,y=map(int,input().split())

    unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,size(i+1))
print(ans)


Measured memory_bytes: 75020
#include <iostream>

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  A = (A == 1) ? 14 : A;
  B = (B == 1) ? 14 : B;
  if (A > B) cout << "Alice";
  else if ( A < B) cout << "Bob";
  else cout << "Draw";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    int h[n], ans = 0;
    bool mx[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        mx[i] = true;
        ans++;
    }
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        if (h[a] == h[b]) {
            if (mx[a]) ans--;
            if (mx[b]) ans--;
            mx[a] = mx[b] = false;
        } else if (h[a] > h[b]) {
            if (mx[b]) ans--;
            mx[b] = false;
        } else {
            if (mx[a]) ans--;
            mx[a] = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int K,A,B; cin>>K>>A>>B;
  int b = A/K;
  if(A%K==0)cout<<"OK"<<endl;
  else if((b+1)*K<=B)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
  return 0;
}

Measured memory_bytes: 3636
import sys
from collections import Counter
def main():
    def input():
        return sys.stdin.readline()[:-1]
    n = int(input())
    v = list(map(int,input().split()))
    o = []
    e = []
    for k in range(n):
        if k%2 == 0:
            e.append(v[k])
        else:
            o.append(v[k])
    c = Counter(e).most_common()
    d = Counter(o).most_common()
    if c[0][0] != d[0][0]:
        print(n-c[0][1]-d[0][1])
    else:
        if len(c) >= 2 and len(d) >= 2:
            print(min(n-d[0][1]-c[1][1],n-d[1][1]-c[0][1]))
        elif len(c) >= 2 and len(d) == 1:
            print(n-d[0][1]-c[1][1])
        elif len(d) >= 2 and len(c) == 1:
            print(n-d[1][1]-c[0][1])
        else:
            print(n//2)
if __name__ == '__main__':
    main()


Measured memory_bytes: 65644
#include <stdio.h>

typedef struct
{
	int iTop;
	int iNorth;
	int iEast;
	int iSouth;
	int iWest;
	int iBottom;
}DICE;

void vdDiceRoll(DICE* stDice, char chOrder);
void vdDiceRollRight(DICE* stDice);

// ダイスの目とその上面と前面の整数が与えられ、右側の面の数字を出力
int main()
{
	DICE stDice;
	int iInputQuestionNum;
	int iQTop, iQSouth;
	int iCnt;

	// さいころの目を入力
	scanf("%d", &stDice.iTop);
	scanf("%d", &stDice.iSouth);
	scanf("%d", &stDice.iEast);
	scanf("%d", &stDice.iWest);
	scanf("%d", &stDice.iNorth);
	scanf("%d", &stDice.iBottom);

	scanf("%d", &iInputQuestionNum);
	for (iCnt = 0; iCnt < iInputQuestionNum; iCnt++)
	{
		scanf("%d %d", &iQTop, &iQSouth);
		// まずは上面を合わせる、左右の面に目的の上面の数字がないなら縦方向(N)に回転
		if (stDice.iEast != iQTop && stDice.iWest != iQTop)
		{
			while (stDice.iTop != iQTop)
			{
				vdDiceRoll(&stDice, 'N');
			}
		}
		else if(stDice.iEast == iQTop)	// 右面に目的の数字があるので横方向(W)に回転
		{
			vdDiceRoll(&stDice, 'W');
		}
		else // 左面に目的の数字があるので横方向(E)に回転
		{
			vdDiceRoll(&stDice, 'E');
		}

		// 前面をそろえる
		while (stDice.iSouth != iQSouth)
		{
			vdDiceRollRight(&stDice);
		}

		printf("%d\n", stDice.iEast);
	}

	

	return 0;
	
}

// chOrderの方角にダイスを転がす
void vdDiceRoll(DICE* stDice, char chOrder)
{
	int iTopTmp = stDice->iTop;	// Top退避用
	switch (chOrder)
	{
	case 'N':
		stDice->iTop = stDice->iSouth;
		stDice->iSouth = stDice->iBottom;
		stDice->iBottom = stDice->iNorth;
		stDice->iNorth = iTopTmp;
		break;
	case 'E':
		stDice->iTop = stDice->iWest;
		stDice->iWest = stDice->iBottom;
		stDice->iBottom = stDice->iEast;
		stDice->iEast = iTopTmp;
		break;
	case 'S':
		stDice->iTop = stDice->iNorth;
		stDice->iNorth = stDice->iBottom;
		stDice->iBottom = stDice->iSouth;
		stDice->iSouth = iTopTmp;
		break;
	case 'W':
		stDice->iTop = stDice->iEast;
		stDice->iEast = stDice->iBottom;
		stDice->iBottom = stDice->iWest;
		stDice->iWest = iTopTmp;
		break;
	default:
		// 上記以外は何もしない
		break;
	}

	return;
}

// 上面から見て時計回りにダイスを回転
void vdDiceRollRight(DICE* stDice)
{
	int iSouthTmp = stDice->iSouth;

	stDice->iSouth = stDice->iEast;
	stDice->iEast = stDice->iNorth;
	stDice->iNorth = stDice->iWest;
	stDice->iWest = iSouthTmp;
	return;
}




Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define endl "\n"
#define deb(x) cerr << #x << "=" << x << endl
#define debb(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define mod ((ll)1e9+7)
#define N ((ll)1e4)
#define pb push_back
#define in insert
#define F first
#define S second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
ll dr[] = { -1, 1, 0, 0};
ll dc[] = {0, 0, 1, -1};

/*Functions*/
ll gcd(ll a, ll b);
ll exp(ll x, ll y, ll p);
ll exp(ll x, ll y);
void InverseofNumber();
void InverseofFactorial();
void factorial();
ll Binomial(ll n, ll R);


ll factorialNumInverse[N + 1];
ll naturalNumInverse[N + 1];
ll fact[N + 1];

void fileIO() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
ll dp[10000001];
int main() {
    clock_t start, end;
    start = clock();
    speed
    // InverseofNumber(),InverseofFactorial(),factorial();
   // fileIO();
    ll n; cin >> n;
    fill(dp, dp + n + 1, 2);
    for (ll i = 2; i <= n / 2; i++) {
        for (ll j = i * 2; j <= n; j += i) {
            dp[j]++;
        }
    }
    dp[1] = 1;
    // for (ll i = 1; i <= n; i++)
    //     cout << dp[i] << " ";
    // cout << endl;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans +=  i * dp[i];
    }
    cout << ans;




    end = clock();
    double timeTaken = double(end - start) * 1000 / double(CLOCKS_PER_SEC);
    deb(timeTaken);

    return 0;
}



/*All Functions*/
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x, ll y, ll p) {
    ll res = 1;
    while (y) {
        if (y % 2)
            res = (res * x % p) % p;
        x = (x * x) % p;
        y /= 2;
    }
    return res;
}
ll exp(ll x, ll y) {
    ll res = 1;
    while (y) {
        if (y % 2)
            res = (res * x ) ;
        x = (x * x) ;
        y /= 2;
    }
    return res;
}
void InverseofNumber() {
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod;
}
void InverseofFactorial() {
    factorialNumInverse[0] = factorialNumInverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;
}
void factorial() {
    fact[0] = 1;
    for (ll i = 1; i <= N; i++)
        fact[i] = (fact[i - 1] * i) % mod;
}
ll Binomial(ll n, ll R) {
    ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod;
    return ans;
}

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector< vector<int> > a(n,vector<int>(n-1));
  vector< vector<int> > pos(n,vector<int>(n));
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n-1;j++){
      cin >> a[i][j];
      a[i][j]--;
      pos[i][a[i][j]] = j;
    }
  }
  stack<pii> st;
  vector<int> cnt(n);
  for(int i = 0;i < n;i++){
    st.push(make_pair(i,a[i][0]));
    cnt[i] = 0;
  }
  int ret = 0;
  while(!st.empty()){
    ret++;
    stack<pii> nst;
    vector<bool> already(n,false);
    while(!st.empty()){
      pii tp = st.top();
      st.pop();
      if(cnt[tp.second] == n-1)continue;
      if(a[tp.second][cnt[tp.second]] == tp.first && !already[tp.first] && !already[tp.second]){
        cnt[tp.second]++;
        cnt[tp.first]++;
        already[tp.second] = true;
        already[tp.first] = true;
        if(cnt[tp.second] != n-1){
          nst.push(make_pair(tp.second,a[tp.second][cnt[tp.second]]));
        }
        if(cnt[tp.first] != n-1){
          nst.push(make_pair(tp.first,a[tp.first][cnt[tp.first]]));
        }
      }
    }
    st = nst;
  }
  bool check = true;
  for(int i = 0;i < n;i++){
    if(cnt[i] != n-1){
      check = false;
    }
  }
  if(check)cout << ret << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 10240
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
using pint=pair<int, int>;
int n;
vector<vector<pint>>v;
// 整数 bit に対応する「決め打ち」が整合しているかを判定
bool judge(int bit) {
	// i 人目の証言を検証する
	rep(i, n) {
		// i 人目が「不親切」だったら、証言はすべて無意味
		if(!(bit&(1<<i)))continue;
		for (pint xy : v[i]) {
			int x = xy.first;
			int y = xy.second;
			// y = 1 なのに「不親切」
			if (y == 1 && !(bit & (1 << x))) return false;
			// y = 0 なのに「正直者」だったらダメ
			if (y == 0 && (bit & (1 << x))) return false;
		}
	}
	return true;
}
signed main() {
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		v[i].resize(a);
		for (int j = 0; j < a; ++j) {
			cin >> v[i][j].first >> v[i][j].second;
			v[i][j].first--; 
		}
	}
	int ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
		if (judge(bit)) {
			int cnt = 0;
			// bit に含まれる人数を数える
			rep(i, n) {
				if (bit & (1 << i))cnt++;
			}
			ans = max(ans, cnt);
		}
	}
	cout << ans << endl;
}
//https://drken1215.hatenablog.com/entry/2019/12/14/171657

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

char buf[500010];
vector <int> p1, p2;

void getfail(string s, vector <int> &fail){
	int n = s.size(), j = -1;
	fail.resize(n + 1), fail[0] = -1;
	for (int i = 1; i <= n; i++){
		while (~j && s[j] != s[i - 1]) j = fail[j];
		fail[i] = ++j;
	}
}

string read(){scanf("%s", buf); return buf;} 

int main(){
	string s = read();
	int n = s.length();
	getfail(s, p1), reverse(s.begin(), s.end());
	getfail(s, p2), reverse(s.begin(), s.end());
	int k = n - p1[n];
	if (k != n && n % k == 0){
		if (k == 1){
			printf("%d\n1\n", n);
			return 0;
		}
		int ans = 0;
		for (int i = 1; i < n; i++){
			int len = i, minpd = len - p1[len];
			if (minpd != len && len % minpd == 0) continue;
			len = n - i, minpd = len - p2[len];
			if (minpd != len && len % minpd == 0) continue;
			ans++;
		}
		printf("2\n%d\n", ans);
		return 0;
	}
	printf("1\n1\n");
	return 0;
}


Measured memory_bytes: 5656
# -*- coding: utf-8 -*-
N, M = map(int, input().split(' '))

graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

is_used = [False for _ in range(N)]
is_used[0] = True
buf = [(0, is_used)]
ans = 0

while buf:
    src, is_used = buf.pop()
    if all(is_used):
        ans += 1

    else:
        for dst in graph[src]:
            if not is_used[dst]:
                is_used2 = list(is_used)
                is_used2[dst] = True
                buf.append((dst, is_used2))

print(ans)




Measured memory_bytes: 9116
import java.util.*;
public class Main {
	public static void main(String[] args){
        
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = a * b;
        
        if(c % 2 == 1) {
            System.out.println("Odd");
        }else if(c % 2 == 0) {
            System.out.println("Even");
        }
    }
}

Measured memory_bytes: 21076
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int a,b,c;
    cin>>a>>b>>c;
    
    int s[3]={a,b,c};
    sort(s,s+3);
    
    cout<<a+b+c-s[2]<<endl;
    
    
   
    
    return 0;
}






Measured memory_bytes: 256
import heapq
import sys

N, X, Y = map(int, input().split())
a = [[] for i in range(N)]
a[X - 1].append(Y - 1)
a[Y - 1].append(X - 1)
for i in range(N - 1):
	a[i].append(i + 1)
	a[i + 1].append(i)
ans = [0] * (N - 1)
for i in range(N - 1):
	b = [[0, i]]
	c = [False] * N
	d = [sys.maxsize] * N
	d[i] = 0
	while len(b):
		e = heapq.heappop(b)
		c[e[1]] = True
		for j in a[e[1]]:
			if c[j]:
				continue
			if e[0] + 1 < d[j]:
				d[j] = e[0] + 1
				heapq.heappush(b, [d[j], j])
	j = i + 1
	while j < N:
		ans[d[j] - 1] += 1
		j += 1
for i in ans:
	print(i)

Measured memory_bytes: 62940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll i, j, k, l, m, n;
	cin>>n>>m;
	std::vector<ll> w(n+1),v(n+1);
	
	ll tots = 0;
	for(i=1; i<=n; i++)
	{
	    cin>>w[i]>>v[i];
	    tots += v[i];
	}
	
	vector<vector<ll>> ar(n+1, vector<ll>(tots+1,0));
	for(i=1; i<=tots; i++) ar[0][i] = 2000000000LL;
	
	for(i=1; i<=n; i++)
	{
	    for(j=1; j<=tots; j++)
	    {
	        if(j < v[i]) ar[i][j] = ar[i-1][j];
	        else
	        {
	            ar[i][j] = min(ar[i-1][j],ar[i-1][j-v[i]] + w[i]);
	        }
	    }
	}
	ll ans = -1;
	
	for(i=0; i<=tots; i++) if(ar[n][i] <= m) ans = max(ans,i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 80256
# https://atcoder.jp/contests/abc079/tasks/abc079_d
# D - Wall

# import pprint

H, W = map(int, input().split())
costs = []
wall = []

for i in range(10):
    cost_list = list(map(int, input().split()))
    costs.append(cost_list)
    # for j, cost in enumerate(cost_list):
    #     costs.append({"i": i, "j": j, "c": cost})

for h in range(H):
    line = list(map(int, input().split()))
    wall.append(line)

# warshall_floyd
for k in range(10):
    for i in range(10):
        for j in range(10):
            costs[i][j] = costs[i][j] if costs[i][j] < costs[i][k] + costs[k][j] else costs[i][k] + costs[k][j]

# pprint.pprint(costs)
# pprint.pprint(wall)

ans = 0 
for i, line in enumerate(wall):
    for j, cell in enumerate(line):
        if cell == -1:
            continue
        ans = ans + costs[cell][1]
print(str(ans))


Measured memory_bytes: 3444
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int main() {
	// your code goes here
    int n,k;
    cin>>n>>k;
    string ss;
    cin>>ss;
    string s = "1"+ss; 
    vector<pair<int,int> >o;
    vector<pair<int,int> >z;
    int prev = s[0];
    int c=1;
    s+="1";
    
    n=s.length();
    for(int i=1;i<n;i++)
    {
        if(s[i]==prev) { prev=s[i]; c++; continue;}
        else
        {
        if(prev=='1') o.push_back({c,i-1});
        else z.push_back({c,i-1});
        prev=s[i]; c=1;
        
        }
    }
       if(prev=='1') o.push_back({c,n-1});
        else z.push_back({c,n-1});
     //for(auto i:o) cout<<i.first<<" "<<i.second<<endl;
      
      //  for(int i=0;i<o.size();i++) cout<<o[i]<<" ";
        long long oo = o[0].first; long long zz=z[0].first;
        bool ff=true; bool f =true;
    if(o.size()>=k+1) {oo = o[k].second-(o[0].second-o[0].first);ff=false; if(o.size()==k+1) f=false;}
    else if(o.size()==1) { oo=o[o.size()-1].second+1; ff=false; f=false;} 
    else{  oo=o[o.size()-1].second-(o[0].second-o[0].first); ff=false; f=false;}
    /*if(z.size()>=k+1) zz=z[k].second-(z[0].second-z[0].first);
    else { zz=z[z.size()-1].second-(z[0].second-z[0].first);}
    */long long moo = oo;
    long long mzz = zz;
    //cout<<oo<<"Dsa";
    //bool f =true;
    for(int i=k+1;i<o.size();i++) 
    {  oo = o[i].second-( o[i-k].second-o[i-k].first);
        //oo+=o[i]-o[i-k-1];
        if(oo>moo)
        {  ff=true;
       moo=oo; if(i==o.size()-1) f=false;
        }
       // moo=max(moo,oo);
    }
    /*for(int i=k+1;i<z.size();i++) 
    {
        zz = z[i].second-( z[i-k].second-z[i-k].first);
        
        mzz=max(mzz,zz);
    }*/
   // cout<<moo;
    if(!f&&!ff) moo-=2;
    else if(!f) moo-=1;
    else if(!ff) moo-=1;
    cout<<moo<<endl;
    return 0;
}


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

int main(){
    int N,L;
    cin >> N >> L;
    int a[N] = {};
    int ans = L;
    int ansabs = abs(L);
    int sum = 0;
    for (int i = 0;i < N;i++){
        a[i] = L + i;
        sum += a[i];
        if (abs(a[i]) < ansabs) {
            ansabs = abs(a[i]);
            ans = a[i];
        }
    }
    cout << sum - ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  string S, T;
  cin >> S;
  cin >> T;
  bool ans=false;
  char work1;

  REP(i, S.size()){
    if(S == T) {
      ans = true;
      break;
    }
    work1=S[S.size()-1];
    for(int j=S.size()-1; j>0; --j) S[j]=S[j-1];
    S[0]=work1;
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vector<int> num(n);
	for(auto &x:num) cin >> x;
	int ans = 1, mn = num[0];
	for(int i=1;i<n;i++) if(num[i] <= mn) ans++, mn = num[i];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	int v=0;
	int m=0;
	if(a<b){
		v = a;
		m = b;
	}else{
		v = b;
		m = a;
	}

	string ans = "";
	for(int i = 0 ; i < m ; i++){
		ans += to_string(v);
	}
	cout << ans ;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
  char A[1000001];
  char B[10001];

  scanf("%s",A);
  scanf("%s",B);

  int temp;
  int lenght_A;
  int lenght_B;
  int count=0;

  lenght_A = strlen(A);
  lenght_B= strlen(B);
  int i;
  i=0;
  int j=0;

  while(i<lenght_A){
    if(strncmp(&A[i],B,lenght_B)==0){
      printf("%d\n",i);
    }
    i++;
  }
  return 0;
}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  int c;
  string S;
  cin >> S;
  if(S[0]==S[1] && S[2]==S[3]){
    if(S[0] == S[2]){
      cout << "No" << endl;
    }else{
      cout << "Yes"<< endl;
    }
  }else{
    if(S[0]==S[2] && S[1]==S[3]){
      if(S[0] == S[1]){
        cout << "No" << endl;
      }else{
        cout << "Yes"<< endl;
      }
    }else{
      if(S[0]==S[3] && S[1]==S[2]){
        if(S[0] == S[1]){
          cout << "No" << endl;
        }else{
          cout << "Yes" << endl;
        }
      }else{
        cout << "No" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256