akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl;


//UnionFind群
class UnionFind {
protected:
    vector<int> par;
    vector<int> data;
    int cnt;
public:
    UnionFind() : par(1), data(1), cnt(1) {};

    UnionFind(int N);

    int root(int x);

    int marge(int x, int y);

    bool same(int x, int y);

    int add();

    int add(int x);

    inline int getSize(int x) { return data.at(root(x)); };

    int allroot();

    inline bool isroot(int x) { return (par.at(x) == -1); };
};

UnionFind::UnionFind(int N) : par(N), data(N), cnt(N) {
    for (int i = 0; i < N; i++) {
        par.at(i) = -1;
        data.at(i) = 1;
    }
}


int UnionFind::root(int x) {
    if (par.at(x) == -1) return x;
    return par.at(x) = root(par.at(x)); // 経路圧縮
}

int UnionFind::marge(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return rx;
    else { // ノード数の少ない方に接続
        if (data.at(rx) < data.at(ry)) swap(rx, ry);
        par.at(ry) = rx;
        data.at(rx) += data.at(ry);
        return rx;
    }
}

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

int UnionFind::add() {
    par.push_back(cnt);
    cnt++;
    return cnt - 1;
}

int UnionFind::add(int x) {
    par.push_back(cnt);
    cnt++;
    return marge(x, cnt);
}

int UnionFind::allroot() {
    int cnt = 0;
    for (const auto it : par) {
        if (it == -1) cnt++;
    }
    return cnt;
}

struct UF {
    vector<int> par;

    UF(int N) : par(N) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        else {
            par[rx] = ry;
            return;
        }
    }

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


int main() {
    int s;
    cin >> s;
    vector<int> a;
    a.push_back(s);
    int cnt = 2;
    while (true) {
        int next;
        if (a.at(cnt - 2) % 2 == 0) {
            next = a.at(cnt - 2) / 2;
        } else {
            next = 3 * a.at(cnt - 2) + 1;
        }
        if (find(a.begin(), a.end(), next) != a.end()) break;
        a.push_back(next);
        cnt++;
    }
    cout << cnt << endl;
}










Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    vector<int> v;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        v.emplace_back(a-1);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int k = v[i];
        if(v[k] == i && v[i] == k) ans++;
    }
    cout << ans/2 << "\n";
    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0;i <n;i++){
        scanf("%d",&a[i]);
    }
    int ans[n];
    for(int i = 0;i<n;i++){
        ans[a[i] - 1] = i + 1;
    }
    for (int i = 0; i < n; i++){
        printf("%d ",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1536
n, m = map(int, input().split())
AB = sorted([[int(i) for i in input().split()] for i in range(n)])

ans = 0
for a, b in AB:
    if m > 0:
        ans += a * min(m, b)
        m -= min(m, b)
    else:
        break
        
print(ans)

Measured memory_bytes: 22372
use std::io;
use std::cmp;
use std::collections::HashMap;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let H: i32 = iter.next().unwrap().parse().unwrap();
    let W: i32 = iter.next().unwrap().parse().unwrap();

    let mut buf2 = String::new();
    std::io::stdin().read_line(&mut buf2).unwrap();
    let mut iter2 = buf2.split_whitespace();
    let h: i32 = iter2.next().unwrap().parse().unwrap();
    let w: i32 = iter2.next().unwrap().parse().unwrap();

    println!("{}", (H-h) * (W-w) );
}


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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;
int N, W;
int v[110], w[110];
int dp[110][10010];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> W;
	rep(i, N)cin >> v[i] >> w[i];
	rep(i, N) {
		rep(j, W + 1) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (j - w[i] >= 0) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i,n)cin >> a[i];

  ll m=1000;
  ll st=0;

  REP(i,n-1){
    if(a[i]==a[i+1])continue;
    if(a[i] < a[i+1] && st==0){
//      cout << i << " " << "buy" << endl;
      st += m/a[i];
      m -= st * a[i];
    }else if(a[i] > a[i+1] && st>0){
//      cout << i << " " << "sell" << endl;
      m += st * a[i];
      st = 0;
    }
  }
  if(st > 0)m += st * a[n-1];

  cout << m << endl;
}



Measured memory_bytes: 3636
n = int(input())
a, b, *L = map(int, input().split())
x = 0
for l in L:
  x ^= l
s = a+b
if s-x < 0 or (s-x)%2:
  print(-1)
  exit()
d = (s-x)//2
if d&x:
  print(-1)
  exit()
if d > a:
  print(-1)
  exit()
for i in range(50, -1, -1):
  if (x>>i)&1 and d|(1<<i) <= a:
    d |= 1<<i
if d == 0:
  print(-1)
  exit()
ans = a - d
print(ans)

Measured memory_bytes: 62104
#include <iostream>
using namespace std;
int main(){
	for (;;){
		int a,goukei=0,max=-999999999,b;
		cin>>a;
		if (a==0)break;
		int data[a+1]={0};
		for (int A=1;A<=a;A++){
			cin>>data[A];
			if (max<data[A])max=data[A];
			goukei+=data[A];
			data[A]=goukei;
			if (max<data[A])max=data[A];
		}max=-999999999;
		for (int A=1;A<=a;A++){
			b=A-2;
			for (int B=A-1;B>=0;B--){
				goukei=0;
				goukei=data[A]-data[B];
				if (goukei>max) max=goukei;
			}
		}
		cout<<max<<endl;
	}
	return 0;
}
	
		
		
			

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

using namespace std;

typedef long long ll;

struct SG{
    int n;
    vector<int> range;
    SG(string& S){
        n = S.size();
        range.resize(4*n);
        init(S, 0, n-1, 1);
    }
    int init(string& S, int arrL, int arrR, int nodeIndex){
        if(arrL == arrR){
            return range[nodeIndex] = (1 << (S[arrL] - 'a'));
        }
        int mid = (arrL + arrR) / 2;
        int left = init(S, arrL, mid, nodeIndex * 2);
        int right = init(S, mid+1, arrR, nodeIndex * 2 + 1);
        return range[nodeIndex] = (left | right);
    }
    int query(int arrL, int arrR, int nodeL, int nodeR, int nodeIndex){
        if(arrL <= nodeL && nodeR <= arrR){
            return range[nodeIndex];
        }
        if(arrL > nodeR || arrR < nodeL){
            return 0;
        }
        int mid = (nodeL + nodeR) / 2;
        int left = query(arrL, arrR, nodeL, mid, nodeIndex * 2);
        int right = query(arrL, arrR, mid+1, nodeR, nodeIndex * 2 + 1);
        return (left | right);
    }
    int query(int arrL, int arrR){
        return query(arrL, arrR, 0, n-1, 1);
    }
    int update(int arrIdx, int val, int nodeL, int nodeR, int nodeIdx){
        if(arrIdx < nodeL || arrIdx > nodeR){
            return range[nodeIdx];
        }
        if(nodeL == nodeR){
            return range[nodeIdx] = val;
        }
        int mid = (nodeL + nodeR) / 2;
        int left = update(arrIdx, val, nodeL, mid, nodeIdx * 2);
        int right = update(arrIdx, val, mid+1, nodeR, nodeIdx * 2 + 1);
        return range[nodeIdx] = (left | right);
    }
    int update(int arrIdx, int val){
        return update(arrIdx, val, 0, n-1, 1);
    }
};

int count(int val){
    int ret = 0;
    while(val > 0){
        ret += (val & 1);
        val /= 2;
    }
    return ret;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    SG chars(S);
    for(int i = 0 ; i < Q; ++i){
        int a;
        cin >> a;
        if(a == 1){
            int b; char c;
            cin >> b >> c;
            chars.update(b-1, 1 << (c - 'a'));
        }
        else{
            int b, c;
            cin >> b >> c;
            int val = chars.query(b-1, c-1);
            cout << count(val) << endl;
        }
    }


    return 0;
}

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

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

	string S;
	cin >> S;

	if (S == "Sunny")
		cout << "Cloudy";
	else if (S == "Cloudy")
		cout << "Rainy";
	else
		cout << "Sunny";

	return 0;
}

Measured memory_bytes: 256
<?php
  

//$abc = explode(" ",trim(fgets(STDIN)));
fscanf(STDIN,"%d",$n);
$count=0;

$w_li = array();
for($i=0;$i<$n;$i++){
	$w_li[] = trim(fgets(STDIN));
}

$last_word=$w_li[0][strlen($w_li[0])-1];


for($i=1;$i<$n;$i++){
  if($last_word!=$w_li[$i][0]){
    echo "No\n";
    exit;
  }
  $last_word=$w_li[$i][strlen($w_li[$i])-1];
}

$uni = array_unique($w_li);

if(count($uni)!=count($w_li)){
      echo "No\n";
}else{
  echo "Yes\n";
}



Measured memory_bytes: 4604
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    ll sum[200010] = {};
    rep(i,0,N) sum[i+1] = sum[i] + A[i];
    ll ans = INF;
    rep(i,0,N-1){
        ll v1 = sum[i+1];
        ll v2 = sum[N] - sum[i+1];
        ans = min(ans, abs(v1-v2));
    }
    print(ans);


    

}

Measured memory_bytes: 3328
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    while (true) {
      int N = sc.nextInt();
      int M = sc.nextInt();
      if (N == 0) return;
      int r = sc.nextInt();
      int timetable[][] = new int[M+1][1260+1];

      for (int i = 0; i < r; i++) {
        int t = sc.nextInt();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int s = sc.nextInt();
        if (s == 1) timetable[m][t]++;
        else timetable[m][t]--;
      }

      for (int i = 540; i < 1260+1; i++)
        for (int j = 1; j <= M; j++)
          if (i > 540)
            timetable[j][i] += timetable[j][i-1];

      int q = sc.nextInt();
      for (int i = 0; i < q; i++) {
        int ts = sc.nextInt();
        int te = sc.nextInt();
        int m = sc.nextInt();
        int count = 0;
        for (int t = ts; t < te; t++)
          if (timetable[m][t] >= 1) count++;
        System.out.println(count);
      }
    }
  }
}



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

int main() {
  int n,k;
  cin >> n >> k;

  int a[n+1];

  for(int i=1;i<=n;i++){
      a[i] =0;
  }

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

int ans =0;
  for(int i=1;i<=n;i++){
   if(a[i]==0) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a<=c&&b>=d)
        cout<<d-c<<endl;
    else if(b<=d&&c<=a)
        cout<<b-a<<endl;
    else if(c<=b&&c>=a)
        cout<<b-c<<endl;
    else if(a<=d&&a>=c)
        cout<<d-a<<endl;
    
    else
        cout<<0<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int N;
	cin >> N;
	int cnt = 0;
	Rep(1, N, n)
	{
		int f = 1;
		Rep(2, n, i)
		{
			if (n % i == 0)
			{
				f++;
			}
		}
		cnt += f == 8 && n & 1;
	}

	cout << cnt << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

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

using namespace std;

signed main(){
	int n,m; cin >> n >> m;
	vector<int> a(m);
	for(auto &e : a)cin >> e;
	set<int> s, s1;
	for(int i = 1; i <= n; i++)s1.insert(i);
	vector<int> b;
	for(auto i = a.rbegin(); i != a.rend(); ++i){
		if(s.find(*i) == s.end()){
			s.insert(*i);
			b.push_back(*i);
		}
	}
	for(auto e : b){
		s1.erase(e);
		cout << e << endl;
	}
	for(auto e : s1){
		cout << e << endl;
	}


	
		


	return 0;
}


Measured memory_bytes: 17556
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
const ll MOD=1000000007;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int N,M;
	cin>>N>>M;
	vector<int>a(M);
	for(int i=0;i<M;i++){
		cin>>a[i];
	}
	ll DP[100001]{};
	DP[0]=1;
	auto itr=a.begin();
	for(int i=0;i<=N;i++){
		if(itr!=a.end()){
			if(*itr==i){
				itr++;
				DP[i]=0;
				continue;
			}
		}
		DP[i+1]+=DP[i];
		DP[i+2]+=DP[i];
		DP[i+1]%=MOD;
		DP[i+2]%=MOD;

	}
	cout<<DP[N]<<endl;
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	string s;
	cin >> s;
	ll n = s.size();

	vll cnt(3, 0);
	for (ll i = 0; i < n; i++) cnt[s[i] - 'a']++;
  sort(all(cnt));
	if (cnt[0] < cnt[2] - 1 || cnt[1] < cnt[2] - 1) NO();
	else YES();
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(b < c || d < a) cout << 0 << endl;
    else{
        cout << min(b,d)-max(a,c) << endl;
    }
}
    



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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n; cin >> n;
    vector<pair<int,int>> v;
    for(int i = 0, x; i < n; ++i){
        cin >> x;
        pair<int,int> p = {x, i + 1};
        v.push_back(p);
    }
    sort(all(v));
    for(auto &x : v) cout << x.second << ' ';
    return  0;
}

Measured memory_bytes: 4252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e5;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	vector<pair<int,int>> vp[N];
	int a;
	rep(i,0,N){
		cin>>a; int x,y;
		rep(j,0,a){
			cin>>x>>y; x--;
			vp[i].push_back({x,y});
		}
	}
    int ans=0;
    rep(i,0,(1<<N)){
		bool flag=true;
		int A[N];int cnt=0;
		rep(j,0,N){
			if(i&(1<<j)){ A[j]=1; cnt++; }
			else A[j]=0;
		}
		rep(j,0,N){
			if(A[j]==0) continue;
			for(pair<int,int> p:vp[j]){
				if(A[p.first]!=p.second){
					flag=false;
				}
			}
		}if(flag) ans=max(ans,cnt);
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
double*q,a[80],b;char s[9];main(){for(q=a;~scanf("%s",s);getchar()<14&&printf("%f\n",*q--)){!sscanf(s,"%lf",q+1)?b=*q--,*q=*s-47?*s-42?*s-45?*q+b:*q-b:*q*b:*q/b:*++q;}}

Measured memory_bytes: 0
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x :: xs = sc.next().toCharArray.toList
  val ((_, count), _) = xs.foldLeft(x -> 1 -> false) {
    case (((before, count), shouldSplit), char) =>
      if (shouldSplit) '0' -> (count + 1) -> false
      else if (char == before) char -> count -> true
      else char -> (count + 1) -> false
  }
  println(count)
}


Measured memory_bytes: 63448
N,K=map(int,input().split())

l=[] # 寿司リスト。ただし，「おいしさ」を第1要素にする
m=[] # 寿司タプルをそのまま入れる
s=set()

for i in range(N):
    t,d=map(int,input().split())
    l.append((d,t))
l.sort(reverse=True) 

ans=K**2
t=0 # 既に食べたことのある種類の寿司を更に食べた回数

i=0 # l内を走査する際の添字
j=0 # m内を操作する際の添え字

for _ in range(K): # _番目に食べる寿司について
    while i<N and l[i][1] in s:
        m.append(l[i]) # そのままmに追加する
        i+=1 # lの先頭の要素を削除せず，
    if (i<N and (m and j<len(m)) and l[i][0]>=m[j][0]-(2*K-1-2*t)) or (not m or j>=len(m)):
        ans+=l[i][0]
        s.add(l[i][1])
        i+=1
    else:
        ans+=m[j][0]-(2*K-1-2*t)
        j+=1
        t+=1

print(ans)

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

long long int  l, r, x, y, mod, i, j, minm;

int main()
{
    cin>>l>>r;

    if(l==0 )
        mod = 0;
    else if((r-l)>=2019)
        mod = 0;
    else
    {
        minm = 2019;

        for(i=l; i<=r; i++)
        {
            for(j=i+1; j<=r; j++)
            {
                if((i*j)%2019<minm)
                {
                    minm = (i*j)%2019;
                    if(minm==0)
                    {
                        mod = 0;
                        break;
                    }
                    mod = minm;
                }
            }
        }
    }

    cout<<mod<<endl;

    return 0;
}


Measured memory_bytes: 256
# ABC061 C - Big Array
from operator import itemgetter
N,K = map(int,input().split())
A = []
B = []
AB = [[] for _ in range(N)]

for i in range(N):
    a,b = map(int,input().split())
    AB[i].append(a)
    AB[i].append(b)

AB.sort(key=itemgetter(0, 1))

ans = 0
if len(AB) == 1:
    ans = AB[0][0]
    print(ans)
    exit()

for i in range(N):
    if i == 0:
        AB[0].append(AB[0][1])
        continue
    AB[i].append(AB[i-1][2]+AB[i][1])

for i in range(N):
    if i == 0:
       f = 0
       t = AB[0][2]
       if f < K <= t:
           ans = AB[0][0]
           break
       continue
    f = AB[i-1][2]
    t = AB[i][2]
    if f < K <= t:
        ans = AB[i][0]
        break
print(ans)

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

const int mod=1e9+7;

int main() {
    int n;
    cin>>n;
    ll a[n];
    int i,j;
    for(i=0;i<n;i++) {
        cin>>a[i];
    }
    int A[n][64];
    //memset(A,0,sizeof(A));
    for(i=0;i<n;i++) {
        for(j=0;j<64;j++) {
            A[i][j]=0;
        }
    }
    for(i=0;i<n;i++) {
        ll temp=a[i];
        int count=0;
        while(temp>0) {
            A[i][63-count]=(temp%2);
            temp/=2;
            count++;
        }
    }
    ll sum=0;
    for(j=63;j>=0;j--){
        ll zero=0;
        for(i=0;i<n;i++) {
            if(A[i][j]==0) {
                zero++;
            }
        }
        ll power1=(ll)pow(2,63-j)%mod;
        ll power2=(zero%mod * (n-zero)%mod)%mod;
        ll power3=(power1 * power2)%mod;
        sum = ((sum%mod)+(power3))%mod;
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 77568
import java.util.*;

public class Main {
	public static void main(String[] args){
	Scanner scn = new Scanner(System.in);
	int a = scn.nextInt();
      int b = scn.nextInt();
      int c = scn.nextInt();
      int d = scn.nextInt();
      int x = c/b;
      int y = a/d;
      int xx = c%b;
      int yy = a%d;
      if(xx != 0){
        x = x+1;
      }
      if(yy != 0){
        y = y+1;
      }
      if(x<=y){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
	}
}

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

int main() {
	string s;
	cin>>s;
	if(s.size()==1)cout<<0;
	else 
	{
		string h1="";
		string h2="";
		for(int i=0;i<s.size();i++)
		{
			if(i%2==0)
			{
				h1+='1';
				h2+='0';
			}
			else
			{
			   h1+='0';
			   h2+='1';	
			}
		}
		int cnt1=0,cnt2=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]!=h1[i])cnt1++;
			if(s[i]!=h2[i])cnt2++;
		}
		cout<<min(cnt1,cnt2);
		
	}
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

int const INF = 1<<29;

int N, M, L, S, T;
int eat[20];
map<int, int> loc; int lcnt;
map<int, int> locrev;

typedef long long ll;

ll dp[1<<17][17];

void init() {
  loc.clear(); locrev.clear();
}

int main() {
  
  while(cin >> N >> M >> L >> S >> T && (N|M|L|S|T)) {
    S --;
    
    init();
    
    int rawg[N][N]; fill(rawg[0], rawg[0]+N*N, INF);
    
    rep(i, M) {
      int a, b, c; cin >> a >> b >> c; a--, b--;
      rawg[a][b] = rawg[b][a] = c;
    }
    
    lcnt = 0;
    rep(i, L) {
      int eattime, rawlocation;
      cin >> rawlocation >> eattime; rawlocation --;
      loc[rawlocation] = lcnt;
      eat[lcnt] = eattime;
      locrev[lcnt] = rawlocation;
      lcnt ++;
    }
    
    if(loc.find(S) == loc.end()) {
      eat[lcnt] = 0;
      loc[S] = lcnt;
      locrev[lcnt] = S;
      lcnt ++;
      // cout << "S: " << S << " loc[S]: " << loc[S] << endl;
    }
    
    rep(i, N) rawg[i][i] = 0;
    rep(k, N) rep(i, N) rep(j, N) {
      if(rawg[i][k] != INF && rawg[k][j] != INF) {
        rawg[i][j] = min(rawg[i][j], rawg[i][k]+rawg[k][j]);
      }
    }

    ll graph[lcnt][lcnt]; fill(graph[0], graph[0]+lcnt*lcnt, INF);
    
    rep(i, N) {
      if(loc.find(i) == loc.end()) { continue; }
      REP(j, i+1, N) {
        if(loc.find(j) == loc.end()) { continue; }
        graph[loc[i]][loc[j]]
          = graph[loc[j]][loc[i]]
          = rawg[i][j];
      }
    }
    
    fill(dp[0], dp[0]+(1<<17)*17, INF);
    dp[1<<loc[S]][loc[S]] = 0;
    
    rep(state, 1<<lcnt) {
      rep(i, lcnt) {
        if(!(state >> i & 1)) continue;
        rep(j, lcnt) {
          if(state >> j & 1) continue;
          int next = state | (1<<j);
          if(graph[i][j] < INF) {
            int cost = graph[i][j] + eat[j];
            if(dp[next][j] > dp[state][i] + cost) {
              dp[next][j] = dp[state][i] + cost;
            }
          }
        }
      }
    }
    
    //cerr << "Case" << endl;
    
    int ans = 0;
    rep(state, 1<<lcnt) {
      rep(i, lcnt) {
        if(dp[state][i] >= INF) continue;
        
        int sumcost = dp[state][i] + rawg[locrev[i]][S];
        if(sumcost <= T) {
          //  cerr << "PASS " << sumcost << " " << T << endl;;
          ans = max(ans, __builtin_popcount(state));
        }
      }
    }
    
    cout << ans-1 << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 18960
import java.util.Scanner;

public class Main {
	static int[][] bingo = new int[3][3];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		long c = Long.parseLong(sc.next());
		long k = Long.parseLong(sc.next());
		if (k % 2 == 0) {
			System.out.println(a - b);
		} else {
			System.out.println(b - a);
		}
	}

}


Measured memory_bytes: 22868
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;
long long a, b, c;

long long fun(long long x)
{
    if (x == 0) return 0;
    long long retval;
    retval = ((x + 1)/2)%2;
    if (x%2 == 0)
        retval = retval^x;
    return retval;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b;
    b = fun(b);
    if (a)
        a = fun(a - 1);
    c = a^b;
    cout << c << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, std::vector<long long> A){
    int x0 = 0, s = 1;
    for(int i = 0; i < N; ++i) {
        x0 += A[i] * s;
        s = -s;
    }
    x0 /= 2;
    vector<int> x;
    x.push_back(x0);
    for(int i = 1; i < N; ++i) {
        x.push_back(A[(i + N - 1) % N] - x.back());
    }

    for(int i = 0; i < N; ++i) {
        cout << x[i] * 2 << (i == N -1 ? "\n" : " ");
    }
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string st, sh;
    int t = 0;
    int h = 0;
    for(int i = 1; i <= n; i++) {
        cin >> st >> sh;
        if(st > sh) t += 3;
        else if(st < sh) h += 3;
        else { t++; h++; }
    }
    cout << t << ' ' << h << endl;
    return 0;
}


Measured memory_bytes: 3160
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    S = input().strip()
    T = input().strip()
    
    res = 0
    for s, t in zip(S, T):
        if s != t:
            res += 1

    print(res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 76136
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 2e5+10;

//head

int n;
int a[N];

bool check_u() {
	bool res = true;
	rep(i, n-1) if(a[i] >= a[i+1]) res = false;
	return res;
}

bool check(int C) {
	if(C == 1) return check_u();
	map<int, int> mp;
	rep(i, n-1) {
		if(a[i] < a[i+1]) continue;
		while(!mp.empty() and mp.rbegin()->first > a[i+1]) {
			mp.erase(prev(mp.end()));
		}
		if(mp.empty()) {
			mp[a[i+1]] = 2;
			continue;
		}
		int u = mp.rbegin()->first;
		if(u != a[i+1]) {
			mp[a[i+1]] = 2;
			continue;
		}
		for(int j = u; j >= 1; j--) {
			if(mp.count(j)) {
				if(mp[j] != C) {
					mp[j]++;
					break;
				}
				else {
					mp.erase(prev(mp.end()));
				}
			}
			else {
				mp[j] = 2;
				break;
			}
			if(j == 1) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n) cin >> a[i];

	int lb = 0, mid, ub = INF;
	while(ub-lb != 1) {
		mid = (lb+ub)>>1;
		if(check(mid)) ub = mid;
		else lb = mid;
	}

	cout << ub << endl;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
long long q, h, s, d, n;
int main() {
    cin >> q >> h >> s >> d >> n;
    s = min(s, min(q * 4, h * 2));
    cout << (n & 1 ? min(s * n, n / 2 * d + s) : min(s * n, n / 2 * d)) << endl;
    return 0;
}


Measured memory_bytes: 256
// D - People on a Line
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using VVII = vector<vector<pair<int,int>>>;

#define V_MAX 100000
vi dist(V_MAX+1, INT_MAX);

void dfs(VVII &T, int p, int w){
	if(dist[p] != INT_MAX) return;
	dist[p] = w;
	for(auto cw:T[p]){
		int np,nw; tie(np,nw) = cw;
		dfs(T, np, w+nw);
	}
}

int main(){
	int N,M; cin>>N>>M;
	if(M==0){ puts("Yes"); return 0; }

	VVII T(N+1);
	int l,r,d, L = INT_MAX, R = 0;
	rp(i, 0, M){
		cin>>l>>r>>d;
		T[l].emplace_back(r, d);
		T[r].emplace_back(l,-d);
		L = min(L, l);
		R = max(R, r);
	}

	rp(l, L, R+1){
		dfs(T, l, 0);
		for(auto rd:T[l]){
			tie(r,d) = rd;
			if(abs(d) != abs(dist[r]-dist[l])){ puts("No"); return 0; }
		}
	}
	puts("Yes");
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  int a, b, c;
  cin >> c >> a >> b;
  int s = (a - 1) / c;
  int w = b / c;
  if (s < w) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
n,d = map(int, input().split())
x = [[int(i) for i in input().split()] for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        dd = 0
        for m in range(d):
            dd += (x[i][m] - x[j][m]) ** 2
        dd = dd**0.5
        if dd.is_integer():
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[100001];
int ra[100002];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n + 1) cin >> a[i];
	
	for (i = n; i >= 0; i--) {
		ra[i] = ra[i + 1] + a[i];
	}
	
	int cnt = 1;
	int ans = 0;
	for (i = 0; i <= n; i++) {
		if (cnt < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		ans += cnt;
		cnt = min(ra[i + 1], 2 * (cnt - a[i]));
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5196
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}
int gcd (int a , int b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}
int main() {
   int N, K;
   cin >> N >> K;
   int a;
   int MAX = 0;
   int G = 1;
   cin >> G;
   MAX = G;
   for (int i = 1; i < N; i++) {
      cin >> a;
      G = gcd(G, a);
      MAX = max(MAX, a);
   }
   if (K > MAX) cout << "IMPOSSIBLE" << endl;
   else if (K % G == 0) cout << "POSSIBLE" << endl;
   else cout << "IMPOSSIBLE" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 10005

int W,N,max_num;
int dp[NUM];


int main(){

	scanf("%d %d %d",&W,&N,&max_num);

	for(int i = 1; i <= W; i++){
		dp[i] = -1;
	}
	dp[0] = 0;

	int tmp_weight,tmp_value;

	for(int i = 0; i < N; i++){

		scanf("%d %d",&tmp_weight,&tmp_value);
		if(tmp_weight > W)continue;

		//ナップザック
		for(int w = W; w-tmp_weight >= 0; w--){

			if(dp[w-tmp_weight] == -1)continue;

			dp[w] = max(dp[w],dp[w-tmp_weight]+tmp_value);
		}
	}

	for(int w = 1; w <= W; w++){
		dp[w] = max(dp[w],dp[w-1]);
	}

	for(int num_child = 1; num_child <= max_num; num_child++){
		printf("%d\n",num_child*dp[W/num_child]);
	}

	return 0;
}



Measured memory_bytes: 3256
#ifdef __APPLE__
#include <cassert>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cctype>
#include <list>
#include <cmath>
#include <limits>
#include <bitset>
#include <numeric>
#include <climits>
#include <complex>
#else
#include<bits/stdc++.h>
#endif // __APPLE__
using namespace std;
typedef pair<int,int>   II;
typedef vector<II>     VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int LL;
typedef  unsigned long long int ULL;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define ALL(c) (c).begin(),(c).end()
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)	{
cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
     const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
//C




int matrix[20][20];

int main()
{
	//fr;fw;
	fast_io;
    int n,m;
    cin>>n>>m;
    REP(i,0,m)
    {
        int u,v;
        cin>>u>>v;
        matrix[u][v]=1;
        matrix[v][u]=1;
    }
    vector<int> v;
    REP(i,2,n+1)
    {
        v.PB(i);
    }
    int cnt=0;
    do
    {
        if(matrix[1][v[0]])
        {
            bool ok=true;
           REP(i,0,n-2)
            {
                if(!matrix[v[i]][v[i+1]])
                    ok=false;
            }
            if(ok)
                cnt++;
        }
    }while(next_permutation(ALL(v)));
    cout<<cnt<<endl;



	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    lint k;std::cin>>k;
    std::vector<std::vector<lint>>dp(k+1,std::vector<lint>(2));
    dp.at(0).at(0)=1;
    for(char c:s){
        lint x=c-'0';
        std::vector<std::vector<lint>>swp(k+1,std::vector<lint>(2));
        for(lint i=0;i<=k;i++){
            if(x==0){
                swp.at(i).at(0)+=dp.at(i).at(0);//0
                swp.at(i).at(1)+=dp.at(i).at(1);//0
                if(i<k)swp.at(i+1).at(1)+=dp.at(i).at(1)*9;//1,..,9
            }else{
                swp.at(i).at(1)+=dp.at(i).at(0);//0
                if(i<k)swp.at(i+1).at(1)+=(x-1)*dp.at(i).at(0);//1..x-1
                if(i<k)swp.at(i+1).at(0)+=dp.at(i).at(0);//x
                swp.at(i).at(1)+=dp.at(i).at(1);//0
                if(i<k)swp.at(i+1).at(1)+=dp.at(i).at(1)*9;//1,..,9
            }
        }
        swp.swap(dp);
    }
    std::cout<<dp.at(k).at(0)+dp.at(k).at(1)<<'\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector< vector <int> > a(n,vector <int>(2));

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

    sort(a.begin(),a.end());

    for(int i = 0 ; i < n ; i++){
        cout << a[i][1];
        if(i < n-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  ll NUM;
  scanf("%lld", &NUM);

  vector<ll> p(NUM);
  for (ll i = 0; i < NUM; i++) {
    scanf("%lld", &p[i]);
  }

  vector<ll> q(NUM);
  for (ll i = 0; i < NUM; i++) {
    scanf("%lld", &q[i]);
  }

  vector<vector<ll>> list;

  ll indices[NUM];
  for (int i = 0; i < NUM; i++) {
    indices[i] = i + 1;
  }
  do {
    vector<ll> v(NUM);
    for (int i = 0; i < NUM; i++) {
      // cout << indices[i] << ",";
      v[i] = indices[i];
    }
    list.emplace_back(v);

  } while (next_permutation(indices, indices + NUM));

  sort(list.begin(), list.end());

  // cout << p[0] << "," << p[1] << "," << p[2] << endl;
  // cout << q[0] << "," << q[1] << "," << q[2] << endl;

  // cout << (p == q) << endl;

  ll v1, v2;
  for (ll i = 0; i < list.size(); i++) {
    auto e = list[i];
    if (e == p) {
      v1 = i;
    }
    if (e == q) {
      v2 = i;
    }
  }
  cout << abs(v1 - v2) << endl;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  ll n, x; cin >> n >> x;
  ll a = n-x, b = x;
  if (a < b) swap(a,b);
  ll ans = n;
  while (a%b) {
    ans += a/b * 2*b;
    a %= b;
    swap(a,b);
  }
  ans += a*2 - b;
  cout << ans << endl;
  return 0;
}


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

int main() {
	int t,n,s,f,sum=0;
	
	while(1){
		cin>>t;
		if(t==0) break;
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>s>>f;
			sum=f-s+sum;
		}
		if(sum>=t) cout<<"OK"<<endl;
		else cout<<t-sum<<endl;
		sum=0;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,d; cin >> n >> d;
    ll ans;
    if(n % (2*d+1) == 0) ans = n / (2*d+1);
    else ans = n / (2*d+1) + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

int n,m;
vector<int> edges[100005];
int dp[100005];
void solve() {
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  queue<int> q;
  q.push(1);
  dp[1] = 1;
  while(!q.empty()) {
    int curr = q.front(); q.pop();
    for(int out: edges[curr]) {
      if(dp[out] == dp[curr]) {
        cout << n*(n-1LL) / 2 - m << "\n";
        return;
      }
      if(dp[out] == 0) {
        dp[out] = -dp[curr];
        q.push(out);
      }
    }
  }
  ll a = 0;
  ll b = 0;
  for(int i = 1; i <= n; i++) {
    (dp[i] > 0 ? a : b)++;
  }
  cout << a*b - m << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

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


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

int nums[2000100];
int left;
int right;
int n;
char str[1024];

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%s", str);
    if( str[0] == 'i' ) {
      int t;
      scanf("%d", &t);
      nums[right] = t;
      right += 1;
    }
    else {
      if( str[6] == '\0' ) {
        int t;
        scanf("%d", &t);
        for(int j = right - 1; j >= left; --j) {
          if( nums[j] == t ) {
            nums[j] = -1;
            break;
          }
        }
      }
      else if( str[6] == 'F' ) {
        do {
          right -= 1;
        } while( left < right - 1 and nums[right] == -1 ); 
      }
      else if( str[6] == 'L' ) {
        do {
          left += 1;
        } while( left + 1 < right and nums[left-1] == -1 );
      }
    }
  }
  int i;
  for(i = right - 1; i >= left; --i) {
    if( nums[i] != -1 ) {
      printf("%d", nums[i]);
      break;
    }
  }
  for(i = i - 1; i >= left; --i) {
    if( nums[i] != -1 ) {
      printf(" %d", nums[i]);
    }
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 7088
#include <stdio.h>

int max(int a, int b) {
  return a > b ? a : b;
}

int main(void) {
  int n, x, y, b, p, i;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    int ans;
    scanf("%d%d%d%d", &x, &y, &b, &p);
    if(b >= 5 && p >= 2) ans = (x * b + y * p) / 5 * 4;
    else {
       ans = x * b + y * p;
       if(ans > (x * max(b, 5) + y * max(p, 2)) / 5 * 4) ans = (x * max(b, 5) + y * max(p, 2)) / 5 * 4;
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2752