akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,k;
  cin >> n >> k;
  vl a(n);
  
  ll sum_a=0;
  rep(i,n){
    cin >> a[i];
    sum_a+=a[i];
  }
  vector<ll>yakusu;
  for(ll i=1;i*i<=sum_a;i++){
    if(sum_a%i==0){
      yakusu.push_back(i);
      ll j=sum_a/i;
      if(j!=i)yakusu.push_back(j);
    }
  }
  
  ll ans=1;
  rep(i,yakusu.size()){
    ll d=yakusu[i];
    vector<ll>r;
    rep(j,n){
      if(a[j]%d!=0)r.push_back(a[j]%d);
    }
    sort(r.begin(),r.end());
    
    ll need=1e18;
    ll sum_l=0,sum_r=0;
    rep(i,r.size())sum_r+=d-r[i];
    rep(i,r.size()){
      sum_r-=d-r[i];
      sum_l+=r[i];
      need=min(need,max(sum_r,sum_l));
    }  
    if(need<=k)chmax(ans,d);
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(void){
  int x;
  cin >> x;
  if (x == 1) cout << "Hello World";
  else if (x == 2) {
    int a,b;
    cin >>a;
    cin >>b;
    cout << a+b;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import math
import decimal


N = int(input())
tn,an = [1,1]
for _ in range(N):
  t,a = map(int, input().split())
  x = max(math.ceil(decimal.Decimal(tn)/decimal.Decimal(t)),math.ceil(decimal.Decimal(an)/decimal.Decimal(a)))
  tn,an = [t*x,a*x]
print(tn+an)

Measured memory_bytes: 5076
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    a,b,c,d = list(map(int, S()))
    s = ["-","+"]
    for i in range(2):
        for j in range(2):
            for k in range(2):
                if eval(str(a)+s[i]+str(b)+s[j]+str(c)+s[k]+str(d)) == 7:
                    print(str(a)+s[i]+str(b)+s[j]+str(c)+s[k]+str(d)+"=7")
                    quit()
#D
def D():
    h,w = LI()
    d = [None for i in range(10)]
    for i in range(10):
        d[i] = LI()
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    ans = 0
    for i in range(h):
        s = LI()
        for k in s:
            if k != -1:
                ans += d[k][1]
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


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

int main()
{
vector<string> v(3);
cin >> v[0] >> v[1] >> v[2] ;
sort(v.begin(),v.end());
do{
vector<bool> a(v[0].size()+1000);
vector<bool> b(v[0].size()+1000);
vector<bool> c(v[1].size()+1000);
rep(i,v[0].size())rep(j,v[1].size())if(i+j<v[0].size()&&v[0][i+j]!='?'&&v[1][j]!='?'&&v[0][i+j]!=v[1][j]){a[i]=1;break;}
rep(i,v[0].size())rep(j,v[2].size())if(i+j<v[0].size()&&v[0][i+j]!='?'&&v[2][j]!='?'&&v[0][i+j]!=v[2][j]){b[i]=1;break;}
rep(i,v[1].size())rep(j,v[2].size())if(i+j<v[1].size()&&v[1][i+j]!='?'&&v[2][j]!='?'&&v[1][i+j]!=v[2][j]){c[i]=1;break;}
rep(i,v[0].size()+1000)rep(j,v[1].size()+1000){
  if(!a[i]&&((i+j>v[0].size())||(!b[i+j]))&&!c[j])ans=min(ans,max({(ll)v[0].size(),(ll)v[1].size()+i,(ll)v[2].size()+i+j}));
}
}while(next_permutation(v.begin(),v.end()));
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] = a[i] * -1
heapify(a)
for _ in range(m):
    minval = heappop(a)
    heappush(a, math.ceil(minval / 2))
ans = 0
for i in range(n):
    ans += int(a[i])
print(-ans)

Measured memory_bytes: 14532
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long ll;
ll N;
ll T[100001];
ll A[100001];
int main(){
	cin>>N;
	REP(i,N){
	    cin>>T[i];
	}
	REP(i,N){
	   cin>>A[i];
	}
	if(A[0]!=T[N-1]){
	   cout<<0<<endl;
	   return 0;
	}
	
	ll p=1;
	int b=0;
	REP(i,N-1){
	    if(i==0)continue;
	    if((A[i]-A[i-1]!=0)&&(T[i]-T[i-1]!=0)){
	        p*=(A[i]==T[i]);
	        break;
	    }
	    if(T[i]-T[i-1]!=0){
	        p*=T[i]<=A[i];
	       continue;
	    }
	    if(A[i]-A[i+1]!=0){
	       p*=A[i]<=T[i];
	       continue;
	    }
	    ll a=min(A[i],T[i]);
	    p=(p*a)%1000000007;
	}
        cout<<p%1000000007<<endl;
	return(0);
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    string s;
    cin >> s;
    if(s[0] != 'A') {
        cout << "WA";
        return;
    }
    int cnt = 0;
    int pos = 0;
    for(int i = 1; i < s.size(); i++){
        if(s[i] >= 'A' && s[i] <= 'Z') {
            cnt++;
            pos = i;
        }
    }
    if(s[1] == 'C' || s[s.size() - 1] == 'C'|| cnt != 1 || s[pos] != 'C') cout << "WA";
    else cout << "AC";
}


int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int times = sc.nextInt();
			TreeMap<String, Long> map = new TreeMap<>();
			for (int i = 0; i<times; i++){
				int query = sc.nextInt();
				String key = sc.next();
				switch (query) {
				case 0:
					long x = sc.nextLong();
					map.put(key,x);
					break;
				case 1:
					if (map.get(key)!=null) {
						System.out.println(map.get(key));
					} else System.out.println(0);
					break;
				case 2:
					map.remove(key);
					break;
				case 3:
					String large = sc.next();
					SortedMap<String,Long> submap = map.subMap(key,true,large,true);
					for (String s : submap.keySet()) {
						System.out.println(s + " " + submap.get(s));   //回数があるだけ出力
					}
					break;
				}
			}
		}
	}
}


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

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

	int N,A,B; cin>>N>>A>>B;

	int ct=0;
	for(int i=1; i<=N; i++){
		int num = i, sum=0;
		while(num>0){
			sum += num%10;
			num /= 10;
		}
		if(A<=sum && sum<=B){
			ct += i;
		}
	}

	cout << ct << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll a,b;cin>>a>>b;
    cout<<a*b<<endl;
    
    return 0;
}





Measured memory_bytes: 3688
//Battle

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int A,B,C,D;cin>>A>>B>>C>>D;
    while(true){
        C-=B;
        if(C<=0){
            cout << "Yes" << endl;
            break;
        }
        A-=D;
        if(A<=0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

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

const int MAX = 510000;

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;



int main(){
    int N;
    cin>>N;
    cout<<(N-2)*180<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
int main() {
    int n;
    cin >> n;
    vector<double> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    // upto n1th coins, n2 head coins (tail: n1-n2)
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
    dp[0][0] = 1.0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            dp[i][j] += (1 - p[i - 1]) * dp[i - 1][j];
            dp[i][j + 1] += p[i - 1] * dp[i - 1][j];
        }
    }
    double ret = 0.0;
    for (int i = n / 2 + 1; i <= n; ++i) {
        ret += dp[n][i];
    }
    cout << fixed << setprecision(10) << ret << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const int MOD = 1e9 + 7;

ll f(ll a, ll b)
{
	if(a > b) swap(a, b);
	if(a == b) return a;
	ll q = b/a;
	if(q == 1) return (a*2LL+f(a, b - a));
	return (a*2LL*(q-1) + f(a, b - (q-1)*a));
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n, x;
	cin >> n >> x;
	cout << f(x, n - x) + n;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	int N, i;
	cin >> N >> i;

	cout << N - i + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for (int i = 0; i < 12; ++i){
    cout << s[i];
    if(i==3) cout << " ";
  }cout << endl;
}


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

struct item
{
	int wt;
	int val;
};

ll solve(vector<item> ar, int n, int W)
{
	ll dp[n + 1][W + 1];

	//for first item other than weight of item is zero
	for (int w = 0; w <= W; w++)
		dp[1][w] = 0;

	dp[1][ar[1].wt] = ar[1].val;

	//bottom up approach now
	for (int i = 2; i <= n; i++)
	{
		//calculating best possible answer for given weight
		for (int w = 0; w <= W; w++)
		{
			dp[i][w] = dp[i - 1][w];//not taking the item
			if (ar[i].wt > w)
				continue;
			dp[i][w] = max(dp[i][w], ar[i].val + dp[i - 1][w - ar[i].wt]);//taking the item
		}
	}
	return *max_element(dp[n], dp[n] + W + 1);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, w;
	cin >> n >> w;
	vector<item> ar(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> ar[i].wt >> ar[i].val;
	cout << solve(ar, n, w);
}

Measured memory_bytes: 81692
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
def return_4(x, k):
    four_hairetu = [0 for i in range(k)]
    for i in range(k):
        four_hairetu[i] = x%4
        x = x//4
    return four_hairetu
min_mp = 1000000
for i in range(4**N):
    ABC = [0,0,0,0] #[not,A,B,C] = [0,1,2,3]
    zABC = return_4(i,N)
    if zABC.count(1)==0 or zABC.count(2)==0 or zABC.count(3)==0:
        continue
    else:
        kouho_mp = (zABC.count(1)-1)*10 + \
                   (zABC.count(2)-1)*10 + \
                   (zABC.count(3)-1)*10
        for j in range(N):
            ABC[zABC[j]] += l[j]
        kouho_mp += abs(ABC[1]-A) + abs(ABC[2]-B) + abs(ABC[3]-C)
        min_mp = min(min_mp, kouho_mp)
print(min_mp)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

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

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
   q.empty();
*/
//座標　corrdinateト深さヲ保持スルタメノ構造体
struct Coor{
  ll y;
  ll x;
  ll depth;
};
 ll N,M;  
 ll sy,sx,gy,gx;
 ll y,x,depth;//キューから取り出した座標
vector<string> vec;
queue<Coor> q;
vector<ll> y_vec={0,0,-1,+1};//technique
vector<ll> x_vec={-1,+1,0,0};

int BFS(){
  while(!q.empty()){
    Coor now=q.front();q.pop();//キューの先頭を取り出す
    y=now.y,x=now.x,depth=now.depth;
    
    //停止条件
    if(y==gy&&x==gx){return depth;}
    
    //上下左右４方向を探索、進むことができればキューに格納
    for(int i=0;i<4;i++){
      Coor next={y+y_vec[i],x+x_vec[i],depth+1};
      if(0<=next.y&&next.y<=N-1&&0<=next.x&&next.x<=M-1&&vec[next.y][next.x]=='.'){
        vec[next.y][next.x]='x';//同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}
                   
  


int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);

int A,B,C,D;cin>>A>>B>>C>>D;
  cout<<min(A,B)+min(C,D)<<endl;
 

  
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll g;
  int n;
  cin >> n;
  vector<ll> t(n);
  ll ans = 1;
  rep(i, n){
    ll in;
    cin >> in;
    t.at(i) = in;
    if(i == 0){
      g = in;
      ans = in;
    }else{
      g = __gcd(in, ans);
      ans = ans / g * t.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol n; cin >> n;
    lol x, y; cin >> x >> y;
    vector<lol> a(n, 0);
    FOR(i, 1, n-1)
    {
        FOR(j, i+1, n)
        {
            lol way1 = j - i;
            lol way2 = abs(y-j)+abs(x-i)+1;
            a[min(way1, way2)]++;
        }
    }
    FOR(i, 1, n-1)
    {
        cout << a[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define reg register

char s[10];

inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}
inline void ChkMax(int &aa, int bb) {
	if(aa < bb) aa = bb;
	return;
}
inline void ChkMin(int &aa, int bb) {
	if(aa > bb) aa = bb;
	return;
}

int main() {
//	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> s;
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
		puts("Bad");
	else
		puts("Good");
	return 0;
}

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

using namespace std;

int N;
string S;

int main(void) {

	cin >> N >> S;

	string ans="No";

	if (N % 2 == 1) { ans = "No"; }
	else {
		string T="";
		for (int i = 0; i < N / 2; i++) { T += S[i]; }
		if (S == (T + T)) { ans = "Yes"; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;
ll all =0;


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

    for(int i=1;i<=n ; i++){
        if(i % 2 == 1){
        for(int j=1;j<=n;j++){
            if(i % j == 0) cnt++;
        }
        if(cnt == 8){
            all++;
        }
        cnt =0;
        }
    }

    cout << all << endl;
  
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] /= 2;
    ll s = a[0];
    rep1(i, n-1) s = lcm(s, a[i]);
    bool ok = true;
    rep(i, n) if ((s/a[i])%2==0) ok = false;
    if (!ok) cout << 0 << endl;
    else {
        cout << (((m/s)+1)/2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3688
loop{
  n, m = readline.split.map{|c| c.to_i}
  break if n == 0 && m == 0

  anq = []
  n.times{
    anq << readline.split.map{|c| c.to_i}
  }
  sum = anq.transpose.map{|v| v.inject(:+) }
  idx = (0...m).to_a
  i = 0
  puts idx.sort_by{|v| [-sum[v], i+1]}.map{|c| c+1}.join(" ")
}

Measured memory_bytes: 10528
#include <bits/stdc++.h>
#define MAX_N 200000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
char s[MAX_N+5]; bool mrk[MAX_N+5];
int n, m, c[MAX_N+5], d[MAX_N+5][2];
vector <int> G[MAX_N+5]; queue <int> que;
int main() {
	read(n), read(m), scanf("%s", s+1);
	for (int i = 1; i <= n; i++) c[i] = s[i] == 'B';
	for (int i = 1, u, v; i <= m; i++)
		read(u), read(v), 
		G[u].push_back(v), d[v][c[u]]++, 
		G[v].push_back(u), d[u][c[v]]++;
	for (int i = 1; i <= n; i++)
		if (!d[i][0] || !d[i][1])
			que.push(i), mrk[i] = true;
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int v : G[u])
			if (!mrk[v] && !--d[v][c[u]])
				que.push(v), mrk[v] = true;
	}
	for (int i = 1; i <= n; i++)
		if (!mrk[i]) return puts("Yes"), 0;
	return puts("No"), 0;
}

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

int main(){
    int n,k;
    int sum=0;
    cin >> n >> k;
    vector<int> data(n);
 
    for (int i = 0; i < n; i++) {
        cin >> data.at(i);
    }

    for(int j=0;j<n;j++){
        sum += min(data.at(j),k-data.at(j));
    }

    cout << 2*sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-12;
template<typename T>
inline void read(T &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
int n,k;
ll ans;
inline ll Pow(ll a,int b) {return a*a*a;}
signed main() {
	read(n); read(k);
	int t=n/k;
	if(k&1) ans=Pow(t,3);
	else {
		ans=Pow(t,3);
		t=t+(n%k>=k/2 ? 1 : 0);
		// printf("%d\n",t);
		ans+=Pow(t,3);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int m = n%10;
    if(m == 3){
        cout << "bon";
    }else if(m == 0 || m == 1 || m == 6 || m == 8){
        cout << "pon";
    }else{
        cout << "hon";
    }
    cout << endl;
}

Measured memory_bytes: 3532
N = gets.chomp.to_i
a = Array.new(N)
for i in 0...N do
    a[i] = gets.chomp.to_i
end

max_n = a[0]
max_i = 0
second = 0

for i in 1...N do
    if a[i] > max_n
        second = max_n
        max_n = a[i]
        max_i = i
    elsif a[i] > second
        second = a[i]
    end
end

for i in 0...N do
    if i == max_i
        puts second
    else
        puts max_n
    end
end

Measured memory_bytes: 4732
X, Y = gets.split.map(&:to_i)

prize = [300000, 200000, 100000]
ans = 0

if X <= 3
  ans += prize[X - 1]
end

if Y <= 3
  ans += prize[Y - 1]
end

if X == 1 && Y == 1
  ans += 400000
end

puts ans


Measured memory_bytes: 1788
ss = input()

ans = []
for c in 'abcdefghijklmnopqrstuvwxyz':
    ansC = 0
    num = 0
    for s in ss:
        if s != c:
            num += 1
        else:
            ansC = max(ansC, num)
            num = 0
    ansC = max(ansC, num)
    ans.append(ansC)

print(min(ans))


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

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> bs;

	if(a < b)
	{
		for(int i = 1; i <= b; i++)
		{
			if(a % i == 0 and b % i == 0)
				bs.push_back(i);
		}
	}
	else
	{
		for(int i = 1; i <= a; ++i)
			if(a % i == 0 and b % i == 0)
				bs.push_back(i);
	}
	sort(bs.begin(), bs.end(), greater<int>());
	cout << bs[c-1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void orz(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
/***********************************************************************/

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i <= x + k - 1; ++i) cout << i << " ";
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count = 0;
  int max = 0;
  for ( int i = 0; i < 10; i++ )
  {
    if ( S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T' )
    {
      count++;
    }
    else {
      if ( count > max ) max = count;
      count = 0;
    }
  }
     if ( count > max ) max = count;
    cout << max;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    int y = Integer.parseInt(sc.next());

    if (n < k) {
      System.out.println(n * x);
    } else {
      System.out.println(k * x + (n - k) * y);
    }
  }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;


int N,M;
ll D[202020];
pair<int,int> P[202020];
vector<pair<int,int>> E[101010];
int ret[202020],fix[101010];
string S;

void dfs(int cur,int pre,int i) {
	if(i) S[cur]='B';
	else S[cur]='W';
	FORR(e,E[cur]) if(e.first!=pre && ret[e.second]<1<<30) dfs(e.first,cur,i^1);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>D[i];
		P[i]={D[i],i};
	}
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back({y-1,i});
		E[y-1].push_back({x-1,i});
		ret[i]=1<<30;
	}
	sort(P,P+N);
	FOR(i,N) {
		x=P[i].second;
		FORR(e,E[x]) if(uf[e.first]!=uf[x] && (D[e.first]==D[x] || (D[e.first]<D[x]&&fix[e.first]))) {
			ret[e.second]=D[x];
			if(D[e.first]==D[x]) fix[e.first]=1;
			fix[x]=1;
			uf(x,e.first);
		}
	}
	
	int num=0;
	FOR(i,N) if(uf[i]==i) num++;
	if(num>1) return _P("-1\n");
	
	S.resize(N);
	dfs(0,0,0);
	
	cout<<S<<endl;
	FOR(i,M) {
		if(ret[i]==1<<30) ret[i]=1000000000;
		cout<<ret[i]<<endl;
	}
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 18288
/**Bismillahir Rahmanir Rahim.**/
/*gcd=--gcd(a,b);*/
/*double p =log(a);
    p=p-floor(p);
    int x=pow(10,p);    m s di
 int x =floor(log10(a)) + 1;  d co
 a=ceil(log2(n)) == floor(log2(n)); pow of 2*/

#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
int main()
{
    long long int a,b,c,d=0,i,x,y=0,j,n,xx;
    char s[1000000];
    in>>a>>b>>c;
    for(i=a;i<=b;i++)
    {
        if(i%c==0)
        {
            y++;
        }
    }
    out<<y<<nl;


}


Measured memory_bytes: 3508
import pprint
H, W, M = map(int, input().split())
bombs = set()
hCount = [0]*H
vCount = [0]*W

for i in range(M):
    h, w = map(int, input().split())
    h -= 1; w -= 1;
    hCount[h] += 1
    vCount[w] += 1
    bombs.add((h, w))

hMax = max(hCount)
vMax = max(vCount)
hMaxIndex = [i for i, x in enumerate(hCount) if x==hMax]
vMaxIndex = [i for i, x in enumerate(vCount) if x==vMax]

ans = -1
for x in vMaxIndex:
    for y in hMaxIndex:
        if (y, x) in bombs:
            continue
        else:
            print(hMax + vMax)
            exit()
print(hMax + vMax - 1)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n;
ll a,b,c,d;

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>a>>b>>c>>d;
  bool ok=false;
  rep(i,n){
    ll hi=a+d*(n-1)-(c+d)*i;
    ll lo=hi-(d-c)*(n-1);
    if(lo<=b&&b<=hi)ok=true;
  }
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define n_max 105


int main(){
    int n;
    cin >> n;
    int T[n_max]={};
    int sum=0;
    REP(i,n){
        cin >> T[i];
        sum+= T[i];
    }
    int m;
    cin >> m;
    int p,x;
    REP(i,m){
        cin >> p >> x;
        cout << sum + (x - T[p-1]) << endl;
    }
}

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

int main(){
  int N=0,K=0;
  cin>>N>>K;
  
  vector<int> a(N+1,1);
  for(int i=0;i<K;++i){
    int d;
    cin>>d;
    for(int j=0;j<d;++j){
      int A;
      cin>>A;
      a[A]=0;
    }
  }
  
  int ans=0;
  
  for(int i=1;i<=N;++i) ans += a[i];
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3624
from time import time
start = time()
import random
from sys import stdin
input = stdin.readline
D = int(input())
*c, = map(int, input().split())
S = []
for _ in [None] * D:
    *s, = map(int, input().split())
    S += s,
INF = float("inf")

def Tread(D):
    return [int(input()) for i in [None] * D]

def check(T):
    M = 0
    MM = []
    last = [-1] * 26
    for d, t in enumerate(T):
        M += S[d][t] - sum((d - last[i]) * c[i] for i in range(26) if i != t)
        last[t] = d
        # MM += M,
    return M # MM

def 貪欲():
    M = 0
    T = []
    last = [-1] * 26
    for d in range(D):
        m = -INF
        for j in range(26):
            Q = S[d][j] - sum((d - last[i]) * c[i] for i in range(26) if i != j)
            if m < Q:
                t, m = j, Q
        T += t,
        last[t] = d
        M += m
        # print(M)
    return T, M

def 局所探索():
    T, M = 貪欲()
    # print(T, M)
    while time() - start < 1.91:
        d, q = random.randrange(D), random.randrange(26)
        Check = T[:]
        Check[d] = q
        C = check(Check)
        if C > M:
            M, T = C, Check
    for s in T:print(s + 1)
    # print(M)

局所探索()


Measured memory_bytes: 85072
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, m = Is()
SC = LIR(m)

ans = [INF]*n
for s, c in SC:
    s -= 1
    if ans[s] == INF:
        ans[s] = c
    elif ans[s] == c:
        continue
    else:
        print("-1")
        exit()

if n == 1 and ans[0] == INF:
    ans[0] = 0

for i in range(n):
    if i == 0 and ans[0] == INF and n != 1:
        ans[0] = 1
    elif ans[i] == INF:
        ans[i] = 0

if ans[0] == 0 and len(ans) != 1:
    print("-1")
    exit()

print("".join(map(str, ans)))


Measured memory_bytes: 63724
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

vvint cnt;
int ee[10][10];

void mainmain(){
	int n,m;
	cin>>n>>m;
	vvint vv(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--,b--;
		vv[a].PB(b);
		vv[b].PB(a);
		ee[a][b] = ee[b][a] = 1;
	}
	int ans = 0;
	vint v(n);
	rep(i,n) v[i] = i;
	do{
		if(v[0] != 0) continue;
		bool ok = true;
		rep(i,n-1){
			if(ee[v[i]][v[i+1]]==0) ok=false;
		}
		ans+=ok;
	}while(next_permutation(ALL(v)));
	cout<<ans<<endl;
	// initvv(cnt, n, 1<<n);
	// cnt[0][1] = 1;
	// queue<pii> q;
	// q.push(pii(0,1));
	// set<pii> used;
	// used.insert(pii(0,1));
	// while(q.size()){
	// 	pii top = q.front();
	// 	q.pop();
	// 	int state = top.S;
	// 	for(int x: vv[top.F]){
	// 		if(state&(1<<x)) continue;
	// 		cnt[x][state|(1<<x)] += cnt[top.F][top.S];
	// 		if(used.find(pii(x,state|(1<<x)))!=used.end()){
	// 			q.push(pii(x,state|(1<<x)));
	// 			used.insert(pii(x,state|(1<<x)));
	// 		}
	// 	}
	// }
	// int ans = 0;
	// rep(i,n){
	// 	ans += cnt[i][(1<<n)-1];
	// }
	// cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int main() {
    int a, b;
    cin >> a >> b;

    int ans = (a + b) / 2;
    if ((a + b) % 2 == 1)
        ++ans;

    cout << ans << endl;

    return 0;
}


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

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

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

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

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	if (N % 2 == 1)
	{
		cout << B[N / 2] - A[N / 2] + 1;
	}
	else
	{
		cout << (B[N / 2] + B[N / 2 - 1]) - (A[N / 2] + A[N / 2 - 1]) + 1;
	}
	return 0;
}

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

int main()
{
    int a,b,c,d;
    cin >> a;
    b = a/3600;
    c = (a%3600)/60;
    d = a - (b*3600) - (c*60);
    cout << b << ":" << c << ":" << d << endl;
    
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string t;
  cin>>t;

  using P = pair<Int, Int>;
  vector<P> vp;
  vp.emplace_back(0,0);
  for(char c:t){
    Int k=c-'0';
    if(vp.back().first!=k)
      vp.emplace_back(k,0);
    vp.back().second++;
  }
  if(vp.back().first!=0)
    vp.emplace_back(0,0);

  Int cnt=0;
  for(char c:t)
    if(c=='1') cnt++;

  Int ans=0;
  for(Int i=0;i<cnt;i++)
    ans+=(i+1)/2;

  Int num=t.size()-cnt;
  Int tmp=0;
  Int add=1;
  for(auto p:vp){
    if(p.first==0){
      tmp+=p.second;
      continue;
    }
    if(p.first==1){
      ans+=(p.second/2)*num;
      if(p.second&1){
        ans+=(tmp+add)/2;
        ans+=(num-tmp);
        add^=1;
      }
    }
  }

  for(Int i=0;i<(Int)t.size();i++)
    if(~i&1) ans+=t[i]-'0';

  cout<<ans<<newl;
  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  ll sum = 0;
  for (int i = 0; i < m; ++i) {
    ll a;
    cin >> a;
    sum += a;
  }

  if (sum > n) {
    puts("-1");
  } else {
    ll ans = n - sum;
    cout << ans << '\n';
  }
  return 0;
}



Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[10000];
int vis[10000];
int main()
{
	int x,n;
	scanf("%d%d",&x,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		vis[a[i]]=1;
	}
	int dis=INF,ans=0;
	for(int i=0;i<=300;i++){
		if(vis[i])
		continue;
		if(abs(i-x)<dis){
			dis=abs(i-x);
			ans=i;
		}
	}
	printf("%d",ans);
}


Measured memory_bytes: 3824
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input()) - 1
print(l[k])

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

int main() {
  int a, b;
  cin >> a >> b;
  if((a + b) % 2 == 0){
    cout << (a + b) / 2 << endl;
  }else{
 	cout << ((a + b) / 2) + 1 << endl;
  }
}

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

using namespace std;

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

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) ((n%m + m) % m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 3e5 + 5;
int w[N], e[N];

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

	int n;
	cin >> n;
	string x;
	cin >> x;

	erep(i, 1, n)
		if (x[i-1] == 'W')
			w[i] = 1;
		else
			e[i] = 1;

	erep(i, 1, n)
		w[i] += w[i-1], e[i] += e[i-1];

	int mn = 1e9;
	erep(i, 1, n)
	{
		int before = w[i-1], after = e[n] - e[i];
		mn = min(mn, before + after);
	}
	cout << mn << endl;

	return 0;
}



Measured memory_bytes: 2964
/**
ID: albert.28
LANG: C++14
PROB: poetry
**/

#include <bits/stdc++.h>

/**
Mod operations in O(lg n)
Source: Benjamin Qi, https://github.com/bqi343/USACO/blob/master/Implementations/11%20-20(4)/Operators/modOp.cpp?fbclid=IwAR0m2afS-1xVg9kgeF8q8EJIeP9TP3Lct8dYb_hPJuI5gqHP1Utp5EkiOQ8
**/

using namespace std;

#define MAXN 100005
#define MOD 1000000007

#define FOR(g,i,n) for(int i = g; i < n; i++)
#define FORD(g,i,n) for(int i = g; i >= n; i--)

#define apple() ios_base::sync_with_stdio(0)
#define hentai() cin.tie(); cout.tie()

#define mp make_pair
#define pb push_back
#define	ll long long
// #define int ll
#define INF (1e9*1)+5
#define LL_INF (1e18*1)+5
#define bitinc(s) (s&-s)
#define endl '\n'

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mi;
#define f first
#define s second
typedef vector<pii> vii;
typedef set<pii> sii;
typedef map<pii, pii> mii;

void fileio(char* in, char* out)
{
	freopen(in, "r", stdin);
	freopen(out, "w", stdout);
}

namespace modOp
{
    int ad(int a, int b, int mod = MOD) { return (a+b)%mod; }
    int sub(int a, int b, int mod = MOD) { return (a-b+mod)%mod; }
    int mul(int a, int b, int mod = MOD) { return (ll)a*b%mod; }

    int AD(int& a, int b, int mod = MOD) { return a = ad(a,b,mod); }
    int SUB(int& a, int b, int mod = MOD) { return a = sub(a,b,mod); }
    int MUL(int& a, int b, int mod = MOD) { return a = mul(a,b,mod); }

    int po (int b, int p, int mod = MOD) { return !p?1:mul(po(mul(b,b,mod),p/2,mod),p&1?b:1,mod); }
    int inv (int b, int mod = MOD) { return po(b,mod-2,mod); }

    int invGeneral(int a, int b) { // 0 < a < b, gcd(a,b) = 1
        if (a == 0) return b == 1 ? 0 : -1;
        int x = invGeneral(b%a,a);
        return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
    }
}

using namespace modOp;

int p, q, r;
int main()
{
	cin >> p >> q >> r;
	cout << (p+q+r) - max(p, max(q,r));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ll long long
using namespace std;

vector<int>dp(100002, 1e9);

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i = 0; i < n; i++)cin>>a[i];
    dp[1] = 0;
    for(int i = 1; i <= n; i++){
       for(int j = 1; j <= k; j++){
        if(i + j <= n){
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i-1] - a[i - 1 + j]));
        }
       }
    }
    cout<<dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    string S;
    cin >> S;
    int N = S.size();
    long long res = 0;
    for (int bit = 0; bit < (1<<(N-1)); ++bit) {
        long long tmp = 0;
        for (int i = 0; i < N-1; ++i) {
            tmp *= 10;
            tmp += S[i] - '0';
            if (bit & (1<<i)) res += tmp, tmp = 0;
        }
        tmp *= 10;
        tmp += S.back() - '0';
        res += tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 256