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

const int md = 1e9 + 7;

using namespace std;

int f[301][301][301], n, m, mn[333][4], mx[333][4], ans;

void add(int &x, int y){
	x += y;
	if (x >= md) x -= md;
}

bool bad(int x, int y, int z){
	if (x == y && x) return true;
	if (x == z && x) return true;
	if (y == z && y) return true;
	int p = max(x, max(y, z));
	for(int i = 1; i <= 3; ++i){
		if (mn[p][i] &&
			((x >= mn[p][i]) + (y >= mn[p][i]) + (z >= mn[p][i]) != i || 
			(x >= mx[p][i]) + (y >= mx[p][i]) + (z >= mx[p][i]) != i)) return true; 
	}
	return false;
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= m; ++i){
		int l, r, x;
		scanf("%d%d%d",&l,&r,&x);	
		if (!mn[r][x]) mn[r][x] = l; else mn[r][x] = min(mn[r][x], l);
		mx[r][x] = max(mx[r][x], l);
	}
	f[0][0][0] = 1;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			for(int t = 0; t < n; ++t){
				if (bad(i, j, t) || f[i][j][t] == 0) continue;
				int k = max(i, max(t, j)) + 1;
				add(f[k][j][t], f[i][j][t]);
				add(f[i][k][t], f[i][j][t]);
				add(f[i][j][k], f[i][j][t]);
			}
		}
	}
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if (!bad(n, i, j)) add(ans, f[n][i][j]);
			if (!bad(i, n, j)) add(ans, f[i][n][j]);
			if (!bad(i, j, n)) add(ans, f[i][j][n]);
		}
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

const int MAXN=1e6+1;

int k,n,a[MAXN];
long long sum[MAXN]={0},ans;

int main() {
	cin>>k>>n;
	for(int i=1; i<=n; ++i) cin>>a[i];
	ans=a[n]-a[1];
	for(int i=1; i<n; ++i) ans=min(ans,1LL*k-a[i+1]+a[i]);
	cout<<ans<<endl;
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m,Q;
  cin >> n >> m >> Q;
  VVI board(n+1,VI(n+1,0));
  rep(i,m){
    int l,r;
    cin >> l >> r;
    board[l][r]++;
  }
  FOR(i,1,n+1)FOR(j,1,n + 1){
    board[i][j] += board[i-1][j];
    board[i][j] += board[i][j-1];
    board[i][j] -= board[i-1][j-1];
  }

  rep(i,Q){
    int p,q;
    cin >> p >> q;
    cout << board[q][q] - board[p-1][q] - board[q][p-1] + board[p-1][p-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


ll COM[200001][3];

void COMinit(){
    for(int i=0; i<=200000; i++){
        for(int j=0; j<=2; j++){
            if(j == 0 || j == i) COM[i][j] = 1;
            else COM[i][j] = (COM[i-1][j-1] + COM[i-1][j]);
        }
    }
}



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

    map<int, int> m;
    vector<int> v(n);
    rep(i, n){
        cin >> v[i];
        m[v[i]]++;
    }

    ll sum = 0;
    for(auto p: m){
        if(p.second >= 2) sum += COM[p.second][2];
    }

    rep(i, n){
        ll ans = sum;
        if(m[v[i]] >= 2) ans -= COM[m[v[i]]][2];
        if(m[v[i]]-1 >= 2) ans += COM[m[v[i]] - 1][2];
        cout << ans << endl;
    }
}

Measured memory_bytes: 13056
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r)
{
    int x, i, j, temp;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++)
    {
        if (A[j] <= x)
        {
            i++;
            temp = A[i];
            A[i] = A[j];
            A[j] = temp;
        }
    }
    temp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = temp;
    return i + 1;
}

int main()
{
    int i, q;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }
    q = partition(0, n - 1);
    for (i = 0; i < n; i++)
    {
        if (i)
            printf(" ");
        if (i == q)
            printf("[");
        printf("%d", A[i]);
        if (i == q)
            printf("]");
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    int ans = 1;
    vector<vector<char>> A(H);
    for (int i = 0; i < H; i++)
    {
        vector<char> tmp(W);
        for (int j = 0; j < W; j++)
        {
            cin >> tmp[j];
        }
        A[i] = tmp;
    }
    for (int i = 0; i < H; i++)
    {
        ans += count(A[i].begin(), A[i].end(), '#');
    }
    if (ans == (H + W))
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Data.Functor( (<$>))

main = do
    ls <- (takeWhile ("0 0"/=)) . lines <$> getContents
    let
	hws = (read <$>) . words <$> ls
	printRect [h,w] = putStrLn `mapM_` rect >> putStrLn ""
	  where
	    hori = take w $ repeat '#'
	    rect = take h $ repeat hori

    printRect `mapM_` hws



Measured memory_bytes: 4016
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

int main()
{
	int A, B;
	while(cin >> A >> B)
		cout << A + B << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int N = 20000;
const int M = 1e9+7;

ll num[20];

ll n,m,q;
ll a[60],b[60],c[60],d[60];
ll ans=0;
void dfs(ll p){
	// de(p);
	if (p==n+1){
		ll res=0;
		for (int i=1; i<=q; i++){
			if (num[b[i]]-num[a[i]]==c[i]) res+=d[i]; 
		}
		ans=max(ans,res);
		return;
	}
	for (int i=num[p-1]; i<=m; i++){
		num[p]=i;
		dfs(p+1);
	}
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin>>n>>m>>q;
	for (int i=1; i<=q; i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	num[0]=1;
	dfs(1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3652
#111
from collections import Counter
n=int(input())
v=list(map(int,input().split()))

c0=Counter(v[0::2]).most_common()
c1=Counter(v[1::2]).most_common()

if c0[0][0]!=c1[0][0]:#再頻出の数がRとLで同一ではない場合
    ans=n-c0[0][1]-c1[0][1]
elif len(c0)!=1 and len(c1)!=1:
    ans=n-max(c0[0][1]+c1[1][1],c0[1][1]+c1[0][1])
elif len(c0)!=1 and len(c1)==1:
    ans=n-c0[1][1]-c1[0][1]
elif len(c0)==1 and len(c1)!=1:
    ans=n-c0[0][1]-c1[1][1]
elif len(c0)==1 and len(c1)==1:
    ans=n//2
print(ans)    


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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
typedef long long ll;
using namespace std;
const int MAX = 0x7ffffff;
int t;
// 求一个数的26进制的表示形式
string dict = "abcdefghijklmnopqrstuvwxyz";
void slove()
{
	ll n;cin >> n;
	string s;
	while(n)
	{
		n--;
		int k = n % 26;
		s += dict[k];
		n /= 26;
	}
	reverse(s.begin() , s.end());
	cout << s << endl;
}
int main()
{
	SIS;
	slove();
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++)
    cin >> vec.at(i);
  
  vector<int> cost(100);
  int camp;
  
  for(int i=1; i<101; i++) {
    for(int j=0; j<n; j++) {
	camp = i;
	cost.at(i-1) += (i - vec.at(j))*(i - vec.at(j));
    }
  }
  int answer = cost.at(0);
                                  
  for(int i=0; i<99; i++) {        
    if(cost.at(i) > cost.at(i+1))
       answer = cost.at(i+1);
  }
      
    cout << answer << endl;
       
}   


Measured memory_bytes: 764
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	solve()
}

func solve() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	isPossible := true
	for i := 0; i < n; i++ {
		t, x, y := nextInt(), nextInt(), nextInt()
		d := x + y
		if t < d || ((t-d)%2 != 0) {
			isPossible = false
			break
		}
	}

	fmt.Println(anser(isPossible, "Yes", "No"))
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

int N;
int counter[10][10];

int front_digit(int a)
{
	while (a >= 10) a /= 10;
	return a;
}

signed main()
{
	cin >> N;

	rep1(i, N) counter[front_digit(i)][i % 10]++;

	int ans = 0;

	rep1(i, N) ans += counter[i % 10][front_digit(i)];

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, k, i;
    scanf("%d %d %d", &a, &b, &k);
    for(i = a; i < a + k; i++) {
        if(i > b) return 0;
        printf("%d\n", i);
    }
    for(i = b - k + 1; i <= b; i++) {
        if(i < a + k) continue;
        printf("%d\n", i);
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
int main()
{
	int n,k;
	cin>>n>>k;
	int p[n];
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	sort(p,p+n);
	ll sum=0;
	for(int i=0;i<k;i++)
	{
		sum+=p[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <math.h>                                                                          
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    float Sr1, s;
    int r;

    cin >> r;
    
    Sr1 = M_PI * 1;
    s = M_PI * r * r;

    cout << s/Sr1 << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Pg
{
    static readonly List<int> dp
        = new List<int> { 1, 2, 4 };
    const int YEAR = 365;
    const int WAYS = 10;
    static void Main()
    {
        var op = new Operate();
        var rd = new Reader();
        var list = rd.Read().ToList();

        op.Dp(3, list.Max(), dp);
        int y = YEAR * WAYS;

        list.ForEach(v => Console.WriteLine((dp[v - 1] / y) + (dp[v - 1] % y > 0 ? 1 : 0)));
    }
}
class Operate
{
    internal int Dp(int i, int n, List<int> dp)
    {
        dp.Add(dp[i - 1] + dp[i - 2] + dp[i - 3]);
        if (i == n)
            return dp[i - 1];
        else
            return Dp(i + 1, n, dp);
    }

}
class Reader
{
    internal IEnumerable<int> Read()
    {
        int n;
        while ((n = int.Parse(Console.ReadLine())) != 0)
        {
            yield return n;
        }
    }
}


Measured memory_bytes: 16284
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    vector<string> W(N);
    for (int i = 0; i < N; i++) cin >> W[i];
    bool ok = true;
    set<string> used;
    used.insert(W[0]);
    for (int i = 1; i < N; i++) {
      ok &= W[i - 1].back() == W[i].front();
      ok &= used.count(W[i]) == 0;
      used.insert(W[i]);
    }
    cout << (ok ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
tn=len(t)
ans=[]
for i in range(len(s)-tn+1):
    for j,k in zip(s[i:tn+i],t):
        if j!=k and j!='?':break
    else:ans.append(s[:i]+t+s[tn+i:])
ans.sort()
if ans:print(ans[0].replace('?','a'))
else:print('UNRESTORABLE')

Measured memory_bytes: 3064
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

H,W=MI()
h,w=MI()
print((H-h)*(W-w))

Measured memory_bytes: 3316
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    P = set(map(int, readline().split()))

    print(len(P))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9016
#include<iostream>
using namespace std;
int main()
{
int n,x=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
  for(int j=1;j<n;j++){
    if(a[j]==a[j-1])
  {x++;j++;}}
cout<<x;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a,b;

main() {
    cin >> n >> a >> b;
    if (a>b || n<1) ct(0)
    else if (n==1) {if (a==b)ct(1)else ct(0)}
    else ct((b-a)*(n-2)+1)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;

int main()
{
    fastIO
    long long a,b,c,d;
    
    cin>>a>>b>>c>>d;
    
    cout<<max(max(a*c,a*d),max(b*c,b*d));
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[1000000];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) {
        int x;
        cin>>x;
        a[x]++;
    }
    int R=n;
    int L=0;
    int num=0;
    for (int i=1;i<=100000;i++) {
        R-=a[i-1];
        L+=a[i-1];
        if (L==R)num++;
    }
    cout<<num<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N; cin >> N;

	cout << (N%2 ? N*2 : N) << endl;

	return 0;

}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

    ll x;
    cin>>x;
    ll n=100;
    long double n2 = n;

    int i=0;
    for(i;n<x;i++){
        //n2*=1.01;
        n=n*1.01;
        //n2=n;
    }
    
    cout<<i<<endl;

    return 0;
}


Measured memory_bytes: 3628
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;
vector < int > v[N];
bool visited[N];
int cnt = 0;
void dfs(int a)
{
  visited[a] = 1;
  for(auto x: v[a]) {
    if(!visited[x]) {
      dfs(x);
    }
  }
}
int main()
{
  ifalse;
  int n, m;
  cin >> n >> m;
  int a = -1, b = -1;
  for(int i = 0; i < m; i ++) {
    int x, y, w;
    cin >> x >> y >> w;
    if(i == 0) {
      a = x;
    }
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for(int i = 1; i <= n; i ++) {
    if(visited[i] == 0) {
      dfs(i);
      cnt ++;
    }
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	double n, k;
	cin >> n >> k;
	double res = 0;
	for(int i=1; i<=n; i++){
		double need = ceil(log2(k/i));
		if(need < 0)
			need = 0;
		
		res += (1.0/n) * (1.0 / pow(2.0, need));
	}
	printf("%.12f", res);

	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int N, K;
    while (cin >> N >> K && (N || K)) {
        vector<int> S(K);
        for (int i=0; i<K; ++i) cin >> S[i];
        int t;
        bool ok = true;
        for (int i=0; i<N; ++i) {
            for (int j=0; j<K; ++j) {
                cin >> t;
                S[j] -= t;
                if (S[j] < 0) {
                    ok = false;
                }
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        int i,a,b;
        int[] h,w;
        h = new int[100];
        w = new int[100];
        Scanner scan = new Scanner(System.in);
        for(i=0;i<100;i++){
            h[i] = scan.nextInt();
            w[i] = scan.nextInt();
            if(h[i]==0 && w[i]==0) break;
        }
        for(i=0;i<100;i++){
            if(h[i]==0 && w[i]==0) break;
            for(a=0;a<h[i];a++){
                for(b=0;b<w[i];b++){
                    if(a%2==0){
                        if(b%2==0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }else{
                        if(b%2==0){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
         
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
int t[52];
bool used[52];
bool dp[2521];
int prev[2521];

void nap(){
  REP(i,2521) dp[i]=false;
  REP(i,2521) prev[i]=-1;
  dp[0] = true;
  REP(i,n){
    if(used[i])continue;
    int val = t[i];
    REP(_x,2521){
      int x = 2521 - 1 - _x;
      if(x-val < 0)break;
      if(dp[x-val] && !dp[x]){
        dp[x] = true;
        prev[x] = x-val;
      }
    }
  }
}

bool check(int x){
  REP(i,n)used[i]=false;
  multiset<int> now;
  int mx;

  REP(_,3){
    nap();
    mx = x;
    while(mx>=0 && !dp[mx])--mx;
    while(prev[mx]!=-1){
      now.insert(mx-prev[mx]);
      mx = prev[mx];
    }
    // DEBUG(now.size());
    REP(_i,n){
      int i = n-1-_i;
      if(used[i])continue;
      if(t[i]==*(now.begin())){
        used[i]=true;
        // DEBUG(t[i]);
        now.erase(now.begin());
        if(now.size()==0)break;
      }
    }
    // DEBUG(now.size());
  }
  REP(i,n) if(!used[i])return false;
  return true;
}

int main(){
  cin>>n;
  REP(i,n)cin>>t[i];
  sort(t,t+n);
  reverse(t,t+n);
  int low = 0;
  int high = 2521;
  while(low+1<high){
    int mid = (low+high)/2;
    if(check(mid))high = mid;
    else low = mid;
  }
  cout<<high<<endl;
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define int long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define pii pair<int, int>
#define MOD 1000000007
#define print(x) cout<<(x)<<endl
using namespace std;


signed main()
{
    string S;

    cin>>S;
    string ups = S.substr(0,2);
    string dos = S.substr(2,2);

    int up = stoi(ups);
    int lo = stoi(dos);
    bool a = (up<=12 && up>=1);
    bool b = (lo<=12 && lo>=1);
    if (a&&b) print("AMBIGUOUS");
    else if (a) print("MMYY");
    else if (b) print("YYMM");
    else print("NA");

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(int N) {
  int ans = 0;
  int maxp = 0;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    ans += p;
    maxp = max(maxp, p);
  }
  printf("%d\n", ans - maxp / 2);
}

int main() {
  int N;
  cin >> N;
  solve(N);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
 
const int mod = 1000000007;
 
inline
int modMultiple(int a, int b){return (static_cast<long long>(a) * b) % mod;}
 
int main()
{
    int N;
    scanf("%d\n", &N);
    int result = 1;
    int k = 0;
    for (int i = 0; i < N; ++i){
        int Xi;
        scanf("%d", &Xi); getchar();
        while (Xi < k * 2 + 1){
            result = modMultiple(result, k + 1);
            --k;
        }
        ++k;
    }
    for (; k > 0; --k){
        result = modMultiple(result, k);
    }
    printf("%d\n", result);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
	int n;
	while(cin>>n,n){
		int count = 0;
		while(n!=1){
			if(n%2==0){
				n /= 2;
			}else{
				n = 3*n + 1;
			}
			count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << #x << ": " << x << '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<char> char1(n);
  vector<char> char2(n);
  for (int i = 0; i < n/2; ++i) {
    cin >> char1[i];
    debug(char1[i]);
  }
  bool ans = true;
  for (int i = 0; i < n/2; ++i) {
    cin >> char2[i];
    debug(char2[i]);
    if (char1[i] != char2[i]) ans = false;
  }
  if (ans && n%2 ==0) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e9+9;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
const int N = 2e5+9;
int a[N], cnt[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 1;
    int z = 3;
    for(int i = 1; i <= n; i++) {
        if(a[i] == 0) {
            ans = ans * z % mod;
            z--;
        } else {
            ans = ans * cnt[a[i]-1] % mod;
            cnt[a[i]-1]--;
        }
        cnt[a[i]]++;
    }
    cout << ans << "\n";





    return 0;
    
}

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

const int mod = 1e9 + 7;

int main() {
  int n; cin >> n;
  int arr[n][n];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
    	cin >> arr[i][j];
    }
  }
  int max_len = 1 << n;
  int dp[max_len];
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for(int mask = 0; mask < max_len - 1; mask++) {
    int x = __builtin_popcount(mask);
    for(int i = 0; i < n; i++) {
      if(!(mask & (1 << i)) and arr[x][i]) {
        int m2 = mask | ( 1 << i);
        dp[m2] = ((dp[m2] % mod) + (dp[mask] % mod)) % mod;
      }
    }
  }
  cout << dp[max_len - 1] << endl;
}

Measured memory_bytes: 11772
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	private static final boolean TEST = false;

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < n; i++)
			v[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			c[i] = in.nextInt();
		System.out.println(solve(v, c));
		in.close();
	}

	private static int solve(int[] v, int[] c) {
		int ans = 0;
		for (int i = 0; i < v.length; i++)
			if (v[i] > c[i])
				ans += v[i] - c[i];
		return ans;
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in();
	vector<int>a(n);
	REPC(&i, a)i = in();
	int q = in();
	REP(i, q)
	{
		int b = in(), m = in(), e = in();
		rotate(a.begin() + b, a.begin() + m, a.begin() + e);
	}
	REP(i, a.size())
	{
		if (i != 0)cout << ' ';
		cout << a[i];
	}
	cout << endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(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)

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

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

char S[25][25];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

struct pos
{
    int y;
    int x;
};

void solve()
{
    int H, W;
    cin >> H >> W;

    REP1 (i, H)
    {
        REP1 (j, W)
        {
            cin >> S[i][j];
        }
    }

    int ans = 0;

    REP1 (i, H)
    {
        REP1 (j, W)
        {
            if (S[i][j] != '.')
                continue;

            int d[25][25];
            int flg[25][25];

            REP0 (k, 25)
                REP0 (l, 25)
                {
                    d[k][l]   = INTINF;
                    flg[k][l] = 0;
                }

            d[i][j] = 0;
            queue<pos> Q;
            Q.push(pos{i, j});
            while (Q.size())
            {
                pos p = Q.front();
                Q.pop();

                REP0 (k, 4)
                {
                    if (S[p.y + dy[k]][p.x + dx[k]] == '.' and flg[p.y + dy[k]][p.x + dx[k]] == 0)
                    {
                        d[p.y + dy[k]][p.x + dx[k]]   = min(d[p.y + dy[k]][p.x + dx[k]], d[p.y][p.x] + 1);
                        flg[p.y + dy[k]][p.x + dx[k]] = 1;
                        Q.push(pos{p.y + dy[k], p.x + dx[k]});
                        ans = max(ans, d[p.y + dy[k]][p.x + dx[k]]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/

#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppl                      pair <int , pii>               
#define    sp(x)                    setprecision(x)
int fac[2000005],inv[2000005];

int power(int x, int y) 
{ 
    int res = 1;    
  
    x = x % mod; 
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % mod; 
  
        y = y>>1; 
        x = (x*x) % mod;   
    } 
    return res; 
} 

int32_t main()
{
    speed upp
    fac[0]=1;
    f(i,1,2000004)
        fac[i]=(fac[i-1]*i)%mod;
    inv[2000004]=power(fac[2000004],mod-2);
    r(i,2000003,0)
        inv[i]=(inv[i+1]*(i+1))%mod;
    int x,y,a,b,t1,t2,t3,t4;
    cin>>a>>b>>x>>y;
    t1=fac[x+y+2];
    t1=(t1*inv[x+1])%mod;
    t1=(t1*inv[y+1])%mod;
    t2=fac[x+b+1];
    t2=(t2*inv[b])%mod;
    t2=(t2*inv[x+1])%mod;
    int temp1=(t1 -t2 + mod)%mod;
    
    t1=fac[a+y+1];
    t1=(t1*inv[y+1])%mod;
    t1=(t1*inv[a])%mod;
    t2=fac[a+b];
    t2=(t2*inv[a])%mod;
    t2=(t2*inv[b])%mod;
    int temp2=(t1 -t2 + mod)%mod;
    
    int ans=(temp1 -temp2 + mod)%mod;
    cout<<ans;
}

Measured memory_bytes: 31616
S=set(input())
X={'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'}
A=list(X-S)
A.sort()
if A==[]:
  print('None')
else:
  print(A[0])

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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

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

using ll = long long;

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

	if (K <= 12)
	{
		cout << K << endl;
		return 0;
	}


	ll count = 0;
	ll ans = 0;
	rep(i, pow(10, 10))
	{
		auto digits = to_string(i);

		bool check = true;
		for (auto j = 0; j < digits.size() - 1; j++)
		{
			if (abs(digits[j] - digits[j + 1]) > 1)
			{
				auto add = digits.size() - j - 1;
				i /= pow(10, add);
				i *= pow(10, add);

				if (digits[j] > digits[j + 1])
				{
					i += pow(10, add - 1) * ((ll)digits[j] - '0' - 1);
				}
				else
				{
					i += pow(10, add);
				}

				check = false;
				i--;
				break;
			}
		}

		if (check)
		{
			count++;
		}

		if (count == K + 1)
		{
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int k;
int max_num;
vector<int> input_num(3);

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

void solve() {
    for(int i = 0; i < 3; ++i) {
        cin >> input_num[i];
    }
    cin >> k;
    int max_index = 0;
    int max_num = -1;
    for (int i = 0; i < 3; ++i) {
        if (input_num[i] > max_num) {
            max_index = i;
            max_num = input_num[i];
        }
    }
    for (int i = 0; i < k; ++i) {
        max_num *= 2;
    }
    int out_num = 0;
    for (int i = 0; i < 3; ++i) {
        if (i != max_index) {
            out_num += input_num[i];
        } else {
            out_num += max_num;
        }
    }
    cout << out_num << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int N;
	static string s;
	cin >> N >> s;
	
	static int ans[200010] = {};
	
	vector<int> vec;
	int k = 0;
	int a,b,c,d;
	for(int i = 0 ; i < 2*N-1 ; i ++){
		if(s[i] == '0'){
			if(i == 0 || s[i-1] == '1'){
				k ++;
				ans[i] = k;
			}
			else vec.pb(i);
		}
		else {
			//if(i == 2*N-2 || ( i != 0 && s[i-1] == '0')){
			if(i != 0 && s[i-1] == '0'){
				ans[i] = k;
			}
		}
	}
	
	/*for(int i = 0 ; i < 2*N ; i ++){
		printf("%d%c",ans[i],(i==2*N-1)?'\n':' ');
	}*/
	
	if(s[2*N-2] == '0'){
		ans[2*N-1] = k;
	}
	if(vec.size()%2 == 1){
		//puts("1");
		puts("No");
		return 0;
	}
	for(int i = 0 ; i < vec.size() ; i ++){
		if(i%2 == 0)k ++;
		ans[vec[i]] = k;
	}
	
	/*for(int i = 0 ; i < 2*N ; i ++){
		printf("%d%c",ans[i],(i==2*N-1)?'\n':' ');
	}*/
	
	vec.clear();
	for(int i = 0 ; i < 2*N ; i ++){
		if(ans[i] == 0)vec.pb(i);
	}
	if(vec.size()%4 != 0){
		a = -1;
		b = -1;
		for(int i = 0 ; i+1 < vec.size() ; i ++){
			if(vec[i]+1 != vec[i+1]){
				a = vec[i]+1;
				b = vec[i+1]-1;
			}
		}
		if(a == -1){
			//puts("2");
			puts("No");
			return 0;
		}
		c = -1;
		d = -1;
		for(int i = 0 ; i < 2*N ; i ++){
			if(ans[i] != 0 && (i < a || b < i)){
				if(i == 0 || ans[i-1] == 0)c = i;
				if(i == 2*N-1 || ans[i+1] == 0)d = i;
			}
		}
		if(c == -1){
			//puts("3");
			puts("No");
			return 0;
		}
		swap(ans[b],ans[d]);
		k ++;
		ans[a-1] = k;
		ans[b+1] = k;
	}
	vec.clear();
	for(int i = 0 ; i < 2*N ; i ++){
		if(ans[i] == 0)vec.pb(i);
	}
	for(int i = 0 ; i < vec.size() ; i ++){
		if(i%4 == 0 || i%4 == 2){
			ans[vec[i]] = k+1;
		}
		else ans[vec[i]] = k+2;
		if(i%4 == 3)k += 2;
	}
	
	puts("Yes");
	for(int i = 0 ; i < 2*N ; i ++){
		printf("%d%c",ans[i],(i==2*N-1)?'\n':' ');
	}
}
	



Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(n,a) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

vector<int> v[1000];
int n,m;
int ans;

void search(int k,int s,int b[]){
  if(s==n){
    ans++;
    return;
  }
  
  rep(i,v[k].size()){
    if(b[v[k][i]]) continue;
    b[v[k][i]]++;
    search(v[k][i],s+1,b);
    b[v[k][i]]--;
  }

}

int main(){
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  int b[10]={};
  b[1]=1;
  search(1,1,b);

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    long long x,y;

    //freopen("x.in","r",stdin);

    scanf("%lld %lld",&x,&y);
    if(x == y + 1 || y == x + 1 || x == y)
        puts("Brown");
    else
        puts("Alice");

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	static class InvertedIndex{		
		String v;
		TreeSet<Integer> ts;
		public InvertedIndex(String v) {
			this.v = v;
			ts = new TreeSet<Integer>();
		}
		void add(int idx){
			ts.add(idx);
		}
		boolean contain(int idx){
			return ts.contains(idx);
		}
		void remove(int idx){
			ts.remove(idx);
		}
		boolean contain(int l , int r){
			return !ts.subSet(l, true, r, true).isEmpty();
		}

	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int Q = sc.nextInt();
		InvertedIndex iss[] = new InvertedIndex[26];
		for(int i = 0 ; i < iss.length ; ++i){
			iss[i] = new InvertedIndex(String.valueOf(((char)(i + 'a'))));
		}
		for(int i = 0 ; i < S.length() ; ++i){
			char c = S.charAt(i);
			iss[c - 'a'].add(i);
		}
		for(int q = 0 ; q < Q ; ++q){
			int type = sc.nextInt();
			if(type == 1){
				int i = sc.nextInt() - 1;
				for(InvertedIndex is : iss){
					if(is.contain(i)){
						is.remove(i);
					}
				}
				char c = sc.next().charAt(0);
				iss[c - 'a'].add(i);
			}else{
				int l = sc.nextInt() - 1;
				int r = sc.nextInt() - 1;
				int cnt = 0;
				for(InvertedIndex is : iss){
					if(is.contain(l , r)){
						++cnt;
					}
				}
				System.out.println(cnt);
			}
		}
	}
}


Measured memory_bytes: 114788
S = input()
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
else:
    print(1)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(15) //15桁表示



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

	ll x;
	cin >> x;
    if(x==2)
    {
        cout<<2<<endl;
        ret;
    }
    else if(x==3)
    {
        cout<<3<<endl;
        ret;
    }
	x -= 1;
	bool g = true;
  
	while (g)
	{
		x++;
		for (int i = 2; i <= sqrt(x); i++)
		{
			if (x % i != 0)
			{
				if (i == (ll)sqrt(x))
					g = false;
				continue;
			}
			else
				break;


		}
	}
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll n,ans,a,b;
int main()
{
   cin>>n;
   cin>>a;
   for(int i=1;i<=n-1;i++)
   {
   	    cin>>b;
   	    if(b<a)  ans+=a-b;
   	    else   
		    a=b;      
   }
   cout<<ans;

return 0;
}


Measured memory_bytes: 3584
INFTY = 10**9+7
N,M = map(int,input().split())
a = 1
for i in range(2,N):
    a = (a*i)%INFTY
if abs(N-M)>=2:
    cnt = 0
elif N>M:
    cnt = (a*N)%INFTY
    cnt = (cnt*a)%INFTY
elif M>N:
    cnt = (a*N)%INFTY
    cnt = (cnt*cnt)%INFTY
    cnt = (cnt*(N+1))%INFTY
else:
    cnt = (a*N)%INFTY
    cnt = (2*cnt*cnt)%INFTY
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N;
  cin>>N;
  ll ans=0;
  if(N%2==0){
    ans=N/10;
    N/=10;
   rep(i,100){
     ans+=N/5;
     N/=5;
   }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+9, INF = 0x3f3f3f3f;
string dt1[105], dt2[105];

void selectionSort( int n ) {
    for( int i = 0; i < n; ++i ) {
        int minj = i;
        for( int j = i; j < n; ++j ) {
            if( dt1[j][1] < dt1[minj][1] ) minj = j;
        }
        if( minj != i ) swap( dt1[minj], dt1[i] );
    }
}

void bubbleSort( int n ) {
    bool ok = true;
    int j = 1;
    while( ok ) {
        ok = false;
        for( int i = n - 1; i >= j; --i ) {
            if( dt2[i][1] < dt2[i - 1][1] ) swap( dt2[i], dt2[i - 1] ), ok = true;
        }
        ++j;
    }
}

bool check( int n ) {
    for( int i = 0; i < n; ++i ) if( dt1[i] != dt2[i] ) return false;
    return true;
}

int main( void ) {
    ios::sync_with_stdio( false );
    int n;
    cin >> n;
    for( int i = 0; i < n; ++i ) cin >> dt1[i], dt2[i] = dt1[i];
    selectionSort( n );
    bubbleSort( n );
    for( int i = 0; i < n; ++i ) cout << dt2[i] << ( i == n - 1 ? '\n' : ' ' );
    cout << "Stable" << '\n';
    for( int i = 0; i < n; ++i ) cout << dt1[i] << ( i == n - 1 ? '\n' : ' ' );
    cout << ( check( n ) ? "Stable" : "Not stable" ) << '\n';
    return 0;
}



Measured memory_bytes: 3168
#include<stdio.h>
int main(){
    short n;
    char s[101];
    scanf("%d %s",&n,s);
    if(n&1)printf("No\n");
    else{
        bool b=1;
        n/=2;
        for(int i=0;i<n&&b;i++)b=(s[i]==s[i+n]);
        if(b)printf("Yes\n");
        else printf("No\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
int main(){
    INT(n, m);
    vlint a(n); line(a); sort(all(a));
    vector<vlint> cb;
    rep(i, m){
        INT(b, c);
        cb.pb({c, b});
    }
    sort(all(cb)); reverse(all(cb));
    lint i = 0;
    for (auto&& p : cb){
        while (p[1] && i < n){
            chmax(a[i], p[0]); i++; p[1] --;
        }
    }
    print(sum(a));
    
}


Measured memory_bytes: 10372