akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll a[500];
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;
		while(n>1000)n-=1000;
		cout<<1000-n<<endl;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 6004
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int num[35], sum[35];

signed main() {
	int N, K;
	cin >> N >> K;

	vector<int> A(N), B(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	rep(i, 31) {
		int tmp = 0;
		rep(j, i + 1) {
			tmp <<= 1;
			tmp++;
		}
		tmp |= K;
		tmp &= ~(1ll << (i + 1));
		num[i] = tmp;
	}
	num[31] = K;

	rep(i, N) rep(j, 32) {
		sum[j] += (num[j] | A[i]) == num[j] ? B[i] : 0;
	}

	int ret = 0;
	rep(i, 32) {
		if (num[i] > K) continue;
		ret = max(ret, sum[i]);
	}

	cout << ret << endl;

    return 0;
}


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

using namespace std;

const int MAX = 1000100;
bool prime[MAX];

void sieve(){
	fill(prime, prime+MAX, true);
	prime[0] = prime[1] = false;

	for(int i=2; i*i < MAX; i++){
		if(!prime[i]) continue;
		for(int j=i*i; j < MAX; j += i) prime[j] = false;
	}
}


int main(){
	sieve();
	int n;
	while(cin >> n){
		int ret = 0;
		for(int i=0; i<= n; i++){
			if(prime[i]) ret++;
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 2136
/**
 * auther: moririn_cocoa
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second

int main (void) {
  
  int a;
  int b;
  int h;
  
  cin >> a;
  cin >> b;
  cin >> h;
  
  cout << ( a + b ) * h * 1 / 2 << endl;
  
  return 0;
}




Measured memory_bytes: 3584
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize, q: usize,
    }

    let mut dsu = DSU::new(n);
    for _ in 0..q {
        input! {
            t: u8, u: usize, v: usize,
        }
        match t {
            0 => {
                dsu.merge(u, v);
            }
            1 => {
                let res = dsu.same(u, v) as u8;
                println!("{}", res);
            }
            _ => unreachable!()
        }
    }
}
#[allow(dead_code)]
pub struct DSU {
    parent_or_size: Vec<i32>,
}

#[allow(dead_code)]
impl DSU {
    pub fn new(n: usize) -> Self {
        assert!(n <= std::i32::MAX as usize);
        Self {
            parent_or_size: vec![-1; n],
        }
    }

    pub fn merge(&mut self, a: usize, b: usize) -> usize {
        let mut x = self.leader(a);
        let mut y = self.leader(b);
        if x == y {
            return x;
        }
        if self.parent_or_size[x] > self.parent_or_size[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.parent_or_size[x] += self.parent_or_size[y];
        self.parent_or_size[y] = x as i32;
        x
    }

    pub fn same(&mut self, a: usize, b: usize) -> bool {
        self.leader(a) == self.leader(b)
    }

    pub fn leader(&mut self, mut a: usize) -> usize {
        while self.parent_or_size[a] >= 0 {
            a = self.parent_or_size[a] as usize;
        }
        a
    }

    pub fn size(&mut self, a: usize) -> usize {
        let leader = self.leader(a);
        -self.parent_or_size[leader] as usize
    }

    pub fn groups(&mut self) -> Vec<Vec<usize>> {
        let mut leader_buf = vec![0usize; self.parent_or_size.len()];
        let mut group_size = vec![0usize; self.parent_or_size.len()];
        for i in 0..self.parent_or_size.len() {
            leader_buf[i] = self.leader(i);
            group_size[leader_buf[i]] += 1;
        }
        let mut result = vec![Vec::new(); self.parent_or_size.len()];
        for i in 0..self.parent_or_size.len() {
            result[i].reserve(group_size[i]);
        }
        for i in 0..self.parent_or_size.len() {
            result[leader_buf[i]].push(i);
        }
        result.retain(|v| !v.is_empty());
        result
    }
}

Measured memory_bytes: 5044
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


s = data()
if s == "ABC":
    out("ARC")
    exit()
out("ABC")


Measured memory_bytes: 72804
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int th[15]={0,1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int f[100005],t;
int main()
{
	memset(f,0x3f,sizeof(f));
	scanf("%d",&n);
	for(int i=1;i<=12;i++)
		if(th[i]<=n)
			++t;
	f[0]=0;
	for(int i=1;i<=t;i++)
		for(int j=th[i];j<=n;j++)
			f[j]=min(f[j],f[j-th[i]]+1);
	printf("%d",f[n]);
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] line = S.Split(' ');

            int N = int.Parse(line[0]);
            int M = int.Parse(line[1]);

            if(N == M)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
       



        }
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int N, M; cin >> N >> M;
  vector<int> a(N), b(N); REP(i, N) cin >> a[i] >> b[i];
  vector<int> res(N + 1, 0);
  REP(i, N) {
    res[a[i]]++; res[b[i]]--;
  }
  REP(i, N) {
    res[i + 1] += res[i];
  }
  string ans = "YES";
  REP(i, N + 1) {
    if(res[i] % 2 == 1) ans = "NO";
  }
  cout << ans << endl;
}

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

int main(){
	int n,x,fin=0;cin>>n>>x;
	while(n--){
		double ans=0,x1,y1;
		cin>>x1>>y1;
		ans = sqrt(x1*x1 + y1*y1);
		if(ans<=x){
			fin++;
		}

	}
	cout<<fin<<endl;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
// #define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5+5;
int a[N];
vector<int> g[N];
int d[N];
void dfs1(int v,int z=0){
    d[v]=z;
    for(int to:g[v])dfs1(to,z+1);
}
int u[N];
void dfs2(int v){
    u[v]=1;
    for(int to:g[v])if(!u[to])dfs2(to);
}
int32_t main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    int ans=0;
    if(a[1]!=1)ans++,a[1]=1;
    for(int i=2;i<=n;++i)g[a[i]].pb(i);
    dfs1(1);
    vector<pii> bad;
    for(int i=1;i<=n;++i)if(d[i]>k)bad.pb(d[i],i);
    sort(bad.begin(), bad.end());
    reverse(bad.begin(), bad.end());
    for(pii p:bad){
        int v=p.s;
        if(!u[v]){
            forn(i,k-1)v=a[v];
            dfs2(v);
            ans++;
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 14728
// Your day breaks, your mind aches
// You find that all the words of kindness linger on
// When she no longer needs you
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define debug(x) cout << #x << " = " << x << endl
#define For(i,a,b) for (int i = a; i < b; i++)
#define roF(i,a,b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

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

const int N = 1e6;
const ll INF = 1e18;
const ld EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll a, ll b) { return uniform_int_distribution<ll> (a, b) (rng); }

int count(int n) {
	int p[n], q[n];
	For(i,0,n) cin >> p[i];
	For(i,0,n) q[i] = p[i];
	sort(q, q + n);
	int ans = 1;
	do {
		bool ok = true;
		For(i,0,n) {
			if (p[i] == q[i]) continue;
			ok = false;
			break;
		}
		if (ok) break;
		ans++;
	} while (next_permutation(q, q + n));
	return ans;
}

void solve() {
	int n;
	cin >> n;
	int a = count(n);
	int b = count(n);
	int ans = abs(a - b);
	cout << ans << endl;
}

int main() {
	fastio;
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[51][200];
char s[51];
int main()
{
	int len;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
	  scanf("%s",s);
	  len=strlen(s);
	  for (int j=0;j<len;j++)
	    a[i][s[j]]++;
    }
    int min1;
    for (int i='a';i<='z';i++)
    {
    	min1=5005;
    	for (int j=1;j<=n;j++)
    	  min1=min(min1,a[j][i]);
    	for (int j=1;j<=min1;j++)
    	  printf("%c",i);
	}
	return 0;
}

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

using namespace std;

string sub(const string& a, const string& b){
	string s = "";
	char c = 0;
	int l = a.length();
	for(int i = 1;i <= l;++i){
		char res = a[l - i] - b[l - i] - c;
		if(res < 0){
			res += 10;
			c = 1;
		}
		else{
			c = 0;
		}
		res += '0';
		s.insert(0, 1, res);
	}
	return s;
}

int main(){
	int n, c;
	string s;
	while(cin >> s >> n, n){
		c = 0;
		map<string, int> m;
		if(s.length() != n){
			int d = n - s.length();
			for(int i = 0;i < d;++i){
				s.insert(0, "0");
			}
		}
		string r = s, b, l;
		while(m.find(r) == m.end()){
			m[r] = c;
			b = r; l = r;
			sort(b.begin(), b.end(), greater<char>());
			sort(l.begin(), l.end());
			r = sub(b, l);
			++c;
		}
		cout << m[r] << " " << stoi(r) << " " << c - m[r] << endl;
	}
}

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

int main() {
    int N, K; cin >> N >> K;
    vector<int> C(N);
    for(int i=0; i < N; i++) {
        cin >> C[i];
    }

    int ans = abs(C[0]) + abs(C[0+K-1] - C[0]);
    for(int i=0; i+K-1 < N; i++) {
        ans = min(ans, (abs(C[i]) + abs(C[i+K-1] - C[i])));
        ans = min(ans, (abs(C[i+K-1]) + abs(C[i+K-1] - C[i])));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int N,D;
    cin >> N >> D;
    int sum=0;
    rep(i,N){
        int x,y;
        cin >> x >> y;
        if(sqrt(pow(x,2)+pow(y,2))<=D) sum+=1;
    }
    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 3228
#include <stdio.h>

#define N 2000
#define BLACK 0
#define WHITE 1
#define GRAY 2
#define inf 200000

int Map[N][N];
int n;
int color[N];
int d[N];
int p[N];


void init(){
	int i;
	for(i=0;i<n;i++){
		color[i]=WHITE;
		d[i] = inf;
	}
}

void prim(){
	init();
	int mincost;
	d[0] = 0;
	p[0] = -1;
	int i;
	int u;
	int v;
	while(1){
		mincost = inf;
		for(i=0;i<n;i++){
			if(color[i]!=BLACK && d[i] < mincost){
				mincost = d[i];
				u = i;
			}
		}

		if(mincost == inf){
			break;
		}
		color[u]=BLACK;
		for(v=0;v<n;v++){
			if(color[v] != BLACK && Map[u][v]!= -1){
				if(Map[u][v] < d[v]){
					d[v] = Map[u][v];
					color[v] = GRAY;
					p[v] = u;
				}
			}
		}
	}
}

int main(){
	scanf("%d",&n);
	int i,j;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&Map[i][j]);
		}
	}
	prim();
	int total = 0;
	for(i=0;i<n;i++){
		total += d[i];
	}
	printf("%d\n",total);
	return 0;
}

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(min(B, D) - max(A, C), 0) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner (System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if ( a < b && b < c)
            System.out.println ("Yes");
        else 
            System.out.println ("No");
        
    }
}


Measured memory_bytes: 26348
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>A;
    vec a(N);
    rep(i,N) cin>>a[i], a[i] -= A;
    mat dp(N + 1, vec(5000, 0));
    rep(i, N){
        ++dp[i+1][2500 + a[i]];
        rep(j, 5000){
            dp[i+1][j] += dp[i][j];
            if(j + a[i] >= 0 && j + a[i] < 5000) dp[i+1][j + a[i]] += dp[i][j];
        }
    }
    cout<<dp[N][2500]<<endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;

int N, M;
vector<vector<int>> graph;
vector<bool> seen;
int cnt = 0;
void dfs(int v)
{
	if (seen[v]) return;
	seen[v] = 1;
	for (int nv : graph[v]) {
		if (seen[nv]) continue;
		dfs(nv);
	}
	bool flag = 1;
	for (int i = 0; i < N; ++i) {
		flag &= seen[i];
	}
	if (flag) {
		++cnt;
	}
	seen[v] = 0;

}
int main()
{
	cin >> N >> M;
	graph.resize(N);
	seen.resize(N, 0);
	for (int i = 0; i < M; ++i) {
		int from, to; cin >> from >> to; --from; --to;
		graph[from].push_back(to);
		graph[to].push_back(from);
	}
	dfs(0);
	cout << cnt << endl;
}


Measured memory_bytes: 3204
local MOD=1000000007
local function add(a,b)return (a+b)%MOD end
local function sub(a,b)return (a-b)%MOD end
local function mul_(a,b)
	local ret=0
	while(b>0)do
		if(b%2==1)then ret=(ret+a)%MOD end
		a=(a+a)%MOD
		b=math.floor(b*.5)
	end
	return ret
end
local function mul(a,b)
	return a<b and mul_(b,a)or mul_(a,b)
end
local function pow(a,b)
	local ret=1
	while(b>0)do
		if(b%2==1)then ret=mul(ret,a)end
		a=mul(a,a)
		b=math.floor(b*.5)
	end
	return ret
end
local function inv(x)
	local a=x
	local b,u,v=MOD,1,0
	repeat
		local t=math.floor(a/b)
		a,b=b,a-t*b
		u,v=v,u-t*v
	until(b==0)
	return u%MOD
end
local function div(a,b)return mul(a,inv(b))end

N=io.read"*n"
r=1
for i=1,N do
	r=mul(r,i)
end
print(r)

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

using namespace std;

int main(){

    int N;
    cin >> N;
    double ans;

    if (N % 2 == 1){
        ans = ((double)N + 1) / (2 * N);
    } else {
        ans = 0.5;
    }

    cout << fixed << setprecision(7);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp::min;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let n = buf.trim().parse::<u32>().ok().unwrap();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut p = Vec::new();
	for i in iter {
		p.push(i.parse::<u32>().ok().unwrap());
	}
	let mut cnt = 0;
	for i in 1..(n-1) as usize {
		if min(p[i], p[i-1]) == p[i] && min(p[i], p[i+1]) == p[i+1] {
			cnt += 1;
		}else if min(p[i], p[i-1]) == p[i-1] && min(p[i], p[i+1]) == p[i] {
			cnt += 1;
		}
	}
	println!("{}", cnt);
}

Measured memory_bytes: 4352
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

// typedef pair<int, int> BC;
// bool pairCompare(const BC& firstElof, const BC& secondElof)
// {
//     return firstElof.second > secondElof.second;
// }

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    // vector<int> B(M), C(M);
    // int iter_max_C;
    // int max_C=1;
    // vector<pair<int, int>> BC;
    priority_queue<pair<int, int>> q;
    // vector<BC> v;
    REP(i, M)
    {
        int B, C;
        cin >> B >> C;
        //v.emplace_back(make_pair(B, C));
        q.emplace(make_pair(C, B));
    }
    //sort(v.begin(), v.end(), pairCompare);

    sort(A.begin(), A.end());
    int iter = 0;
    while (1)
    {
        if (q.empty())
            break;
        pair<int, int> temp = q.top();
        q.pop();
        //v.pop_back();
        int C = temp.first, B = temp.second;
        if (A[iter] >= C)
            break;
        for (int i = 0; i < B; i++)
        {
            if (A[iter] < C)
            {
                A[iter] = C;
                iter++;
            }
        }
    }

    ll sum = 0;
    for (int i = 0; i < A.size(); i++)
        sum += A[i];
    
    cout << sum << endl;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

template<typename T>
struct Doubling{
	const int LOG_X;
	bool flag1, flag2;
	vector<vector<T>> dp;

	Doubling(int n,ll x):LOG_X(log2(x)+1){//n:配列のサイズ,x:遷移する回数
		flag1 = false;
		flag2 = false;
		dp.assign(LOG_X, vector<ll>(n, -1));
	}

	void init(vector<T> &a){//適宜変える
		int n = a.size();
		flag1 = true;
		rep(i, n)
		{
			dp[0][i] = a[i];
		}
	}

	void build(){
		assert(flag1);
		flag2 = true;
		for (int k = 0; k + 1 < LOG_X; ++k)
		{
			for (int i = 0; i < dp[0].size();++i){
				if(dp[k][i]==-1){//2^k先の要素がないなら2^(k+1)先の要素もない
					dp[k + 1][i] = -1;
				}
				else{//2^k*2^k=2^(k+1)
					dp[k + 1][i] = dp[k][dp[k][i]];
				}
			}
		}
	}

	T query(int s,ll x){//s:スタート地点,x:遷移回数
		assert(flag2);
		for (int i = LOG_X - 1; i >= 0; i--)
		{
			if(x&(1LL<<i)){
				s = dp[i][s];
			}
		}
		return s;
	}
};

#define int ll

void solve()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i], a[i]--;
	Doubling<ll>ans(n,k);
	ans.init(a);
	ans.build();
	cout << ans.query(0, k) + 1;
}
#undef int

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}

Measured memory_bytes: 100240
#include "iostream"
#include "algorithm"
#include "string"
#include "set"
#include "vector"
#include "climits"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W;

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

	cin >> N >> M >> K >> H >> W;
	int box = min(H, W);
	long long int ans = min(N*box + M * box, K*box * 2);
	H -= box;
	W -= box;
	if (H) {
		ans += min(N*H, K*H * 2);
	}
	else {
		ans += min(M*W, K*W * 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

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

    if(b - a < 2){
        cout << k + 1 << endl;
        return 0;
    }

    ll ans = 1;
    ans += min(a-1, k);
    if(k < a - 1){
        cout << ans << endl;
        return 0;
    }

    k -= a - 1;

    ans += (b - a) * (k / 2);
    ans += k % 2;

    cout << ans << endl;

    return 0;
}

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

int main(void) {
	int N; cin >> N;
	int i, j, sum = 0, count = 0;

	if (N <= 104) {
		cout << "0" << endl;
		return 0;
	}
	else {
		for (i = 105; i <= N; i++) {
			for (j = 1; j <= N; j += 2) {
				if (i%j == 0) {
					sum += 1;
				}
			}
			if (sum == 8) {
				count += 1;
			}
			sum = 0;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <bitset>
#include <map>
#include <utility>
#include <cmath>
#include <list>
#include <set>
#include <map>

# define INF 0x3f3f3f3f 

using namespace std;

struct Overflow {
    int first = 0;
    unsigned long long int second = 1;
    int third = 0;
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    if(n == 0) {
        cout<<0<<endl;
    }
    struct Overflow *prod = (struct Overflow*)malloc(sizeof(struct Overflow));
    prod->second = 1;
    bool print = true, zero = false;
    for(int i = 0; i < n; i++) {
        long long int t;
        cin>>t;
        zero = zero || (t == 0);
        if(zero) break;
        if(print) {
            unsigned long long int prev = prod->second;
            prod->second = prod->second * t;
            if(prod->second > 1000000000000000000LL || prod->first != 0 || prod->third != 0 || prod->second/prev != t) print = false;
        }
    }
    
    if(zero) {
        cout<<0<<endl;
    }
    else if(print) {
        cout<<prod->second<<endl;
    } else {
        cout<<-1<<endl;
    }
    return 0;
}



Measured memory_bytes: 3648
#include <stdio.h>
struct binary_tree{
    int n;
    int l;
    int r;
};
binary_tree bt[1000000];
int now=0;
void push(int n,int t){
    if(now==0){
        bt[0].n=n;
        now++;
        return;
    }
    if(bt[t].n<n){
        if(bt[t].r==0){
            bt[t].r=now;
            bt[bt[t].r].n=n;
            now++;
        }
        else push(n,bt[t].r);
    }
    if(bt[t].n>n){
        if(bt[t].l==0){
            bt[t].l=now;
            bt[bt[t].l].n=n;
            now++;
        }
        else push(n,bt[t].l);
    }
}
void dfs(int n){
    printf(" %d",bt[n].n);
    if(bt[n].l!=0){
        dfs(bt[n].l);
    }
    if(bt[n].r!=0){
        dfs(bt[n].r);
    }
}
void print_sorted(int n){
    if(bt[n].l!=0){
        print_sorted(bt[n].l);
    }
    printf(" %d",bt[n].n);
    if(bt[n].r!=0){
        print_sorted(bt[n].r);
    }
}
int main(){
    int n,temp;
    char a[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        bt[i].n=bt[i].l=bt[i].r=0;
        scanf("%s",a);
        if(a[0]=='i'){
            scanf("%d",&temp);
            push(temp,0);
        }
        if(a[0]=='p'){
            print_sorted(0);
            printf("\n");
            dfs(0);
            printf("\n");
        }
    }
}

Measured memory_bytes: 8560
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 20:54:35
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

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

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

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

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

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

    int yes = 0;
    while (n > 0) {
        if (n % 10 == 7) {
            yes = 1;
            break;
        } else {
            n /= 10;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll h, w, ans;
string s[30];
ll v1[4] = { 0,0,1,-1 }, v2[4] = { 1,-1,0,0 };
int main() {
	cin >> h >> w;
	REP(i, h)cin >> s[i];
	REP(i, h) {
		REP(j, w) {
			if (s[i][j] != '.')continue;
			queue<P> q;
			ll ma = 0;
			ll d[30][30] = {};
			bool used[30][30] = {};
			q.push(P(i, j));
			used[i][j] = true;
			while (!q.empty()) {
				P now = q.front();
				q.pop();
				REP(nxt, 4) {
					ll x = now.first + v1[nxt], y = now.second + v2[nxt];
					if (0 <= x and x < h and 0 <= y and y < w and !used[x][y]) {
						if (s[x][y] == '.') {
							used[x][y] = true;
							d[x][y] = d[now.first][now.second] + 1;
							q.push(P(x, y));
							ma = max(ma, d[x][y]);
						}
					}
				}
			}
			ans = max(ans, ma);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W,D;
    cin >> H >> W >> D;
    vector<vector<int>> a(H*W,vector<int>(2));
    int A;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cin >> A;
            --A;
            a[A][0] = i;
            a[A][1] = j;
        }
    }
    int cost[H*W];
    for(int i = 0;i < D;i++){
        cost[i] = 0;
    }
    for(int i = D;i < H*W;i++){
        cost[i] = abs(a[i][0] - a[i-D][0]) + abs(a[i][1] - a[i-D][1]) + cost[i-D];
    }
    int Q;
    cin >> Q;
    int R,L;
    int ans;
    for(int i = 0;i < Q;i++){
        cin >> R >> L;
        ans = 0;
        --R;
        --L;
        ans += cost[L]-cost[R];
        cout << ans << endl;
    }
}

Measured memory_bytes: 6400
#include <iostream>

using namespace std;

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

    if ((a%3 == 0) || (b%3 == 0) || ((a+b)%3 == 0)) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

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

const ll MOD = 1000000007;

ll mod_add(ll a, ll b){
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll mod_sub(ll a, ll b){
    return ((a + MOD) - b) % MOD;
}
 
ll mod_mul(ll a, ll b){
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll mod_pow(ll x, ll r){
    if (r == 0) return 1;

    else if (r == 1) return x % MOD;

    else if (r % 2 == 0){
        ll t = mod_pow(x, r/2) % MOD;
        return mod_mul(t, t);
    }

    else{
        ll t = mod_pow(x, r/2) % MOD;
        ll k = mod_mul(t, t);
        return ((k % MOD) * (x % MOD)) % MOD;
    }
}

ll mod_div(ll a, ll b){
    return mod_mul(a, mod_pow(b, MOD - 2));
}

ll mod_fac(ll n){
    ll ret = 1;
    for(ll i = 1; i <= n; ++i){
        ret = (ret*i) % MOD;
    }
    return ret;
}

ll mod_comb(ll n, ll k){
    ll numerator = 1;
    for(ll i = 0; i < k; ++i){
        numerator = numerator*(n-i) % MOD;
    }
    ll denominator = mod_fac(k);
    return mod_div(numerator, denominator);
}

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

    ll n, k;
    cin >> n >> k;

    ll red = n-k;
    for(ll i = 1; i <= k; ++i){
        ll res = 0;
        ll space = red + 1;
        ll var = mod_comb(k-1, i-1);

        res = mod_mul(mod_comb(space, i), var);
        cout << res << endl;
    }


    return 0;
}

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

int main(){
    string T;  cin >> T;
    int N = 0, W = 0, S = 0, E = 0;
    for(char c : T){
        if(c=='N') N++;
        if(c=='W') W++;
        if(c=='S') S++;
        if(c=='E') E++;
    }

    if((N == 0 && S != 0) || (N != 0 && S == 0)){
        cout << "No" << endl;
    }else if((W == 0 && E != 0) || (W != 0 && E == 0)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var X = new int[N + 1];
        var start = 0;
        for (int i = 1; i <= N; i++)
        {
            X[i] = X[i - 1] + i;
            if (X[i] >= N)
            {
                start = i;
                break;
            }
        }
        var res = new List<int>();
        var sum = 0;
        for (int i = start; i >= 1; i--)
        {
            if (sum == N) break;
            if (sum + i <= N)
            {
                sum += i;
                res.Add(i);
            }
        }
        foreach (var item in res)
        {
            Console.WriteLine(item);
        }
    }

    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 13292
import sys
S = input()
while S:
    if (S[-5:] == 'dream') or (S[-5:] == 'erase'):
        S = S[:-5]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-7:] == 'dreamer':
        S = S[:-7]
    else:
        print('NO')
        sys.exit()
print('YES')

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll N;
    cin >> N;
    vector<string> names(N);
    ll M,A,R,C,H;
    M = 0;
    A = 0;
    R = 0;
    C = 0;
    H = 0;
    ll ans = 0;
    vector<ll> a(5,0);
    sort(names.begin() , names.end());
    for(int i = 0; i < N; i++){
        cin >> names[i];
        if(names[i][0] == 'M') a[0]++;
        if(names[i][0] == 'A') a[1]++;
        if(names[i][0] == 'R') a[2]++;
        if(names[i][0] == 'C') a[3]++;
        if(names[i][0] == 'H') a[4]++;
    }
    
    for(int i = 0; i < 3; i++){
        for(int j = i + 1; j < 4; j++){
            for(int k = j + 1; k < 5; k++){
                ans += a[i] * a[j] * a[k];
            }
        }
    }


    cout << ans << endl;

    
    
}


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

int main(){
  string a, b, c; cin >> a >> b >> c;
  cout << char(a[0]+'A'-'a') 
    << char(b[0]+'A'-'a') 
    << char(c[0]+'A'-'a')
    << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 100000
long long H,W,A[10],q;
int p[M];
struct{int a,b,n,q;}d[900001];

void f(int a,int b){
	int h,t,i;
	if(1<a&&a<H&&1<b&&b<W){
		i=p[h=(a/M+a+b/M+b)%M];
		if(i){
			for(;;){
				if(d[i].a==a&&d[i].b==b){
					break;
				}else if(d[i].q){
					i=d[i].q;
				}else{
					d[i=d[i].q=++q].a=a;
					d[i].b=b;
					break;
				}
			}
		}else{
			d[i=p[h]=++q].a=a;
			d[i].b=b;
		}
		--A[t=d[i].n++];
		++A[t+1];
	}
}
int main(){
	int a,b,i,j;
	scanf("%lld%lld%d",&H,&W,&i);
	A[0]=(H-2)*(W-2);
	for(;~scanf("%d%d",&a,&b);)
		for(i=-1;i<=1;++i)
			for(j=-1;j<=1;++j)
				f(a+i,b+j);
	for(i=0;i<=9;++i)printf("%lld\n",A[i]);
	return 0;
}


Measured memory_bytes: 14592
#!/usr/bin/env python3
import sys


def solve(N: int):
    l = []
    for i in range(1, N+1):
        if i % 3 == 0 or i % 5 ==0:
            pass
        else:
            l.append(i)
    print(sum(l))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 29948
#include<bits/stdc++.h>
#define ll unsigned long long 
using namespace std;
const ll N=405;
const ll mod=1e9+7;
ll a[N];
ll dp[N][N];
ll n;
ll sum(ll i,ll j)
{
	ll sum=0;
	for(ll k=i;k<=j;k++)
	sum+=a[k];
	
	return sum;
}
ll cost(ll i,ll j)
{
	if(i==j)
	return 0;
	if(dp[i][j]!=-1)
	return dp[i][j];
	ll res=1e18;
	for(int k=i;k<j;k++)
	{
		ll ans=(cost(i,k)+cost(k+1,j)+sum(i,j));
		if(ans<res)
		res=ans;
	}
	return dp[i][j]=res;
}
int main()
{
	   memset(dp,-1,sizeof(dp));
	   cin>>n;
	   for(int i=0;i<n;i++)
	   cin>>a[i];
	   cout<<cost(0,n-1)<<endl;
	   return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <map>
using namespace std;
int N;
string S;

int main(){
	cin >> N >> S;
	map<char,int> m1,m2;
	int ans = 0;
	for(int i=0;i<N-1;i++){
		int now = 0;
		for(int j=0;j<=i;j++){
			m1[S[j]]++;
		}
		for(int j=i+1;j<N;j++){
			m2[S[j]]++;
		}
		for(auto x:m1){
			if(m2.count(x.first)) now++;
		}
		ans = max(ans,now);
		m1.clear();
		m2.clear();
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5+1;
const long inf=1e14;
int main(){
	int N; long L; cin>>N>>L;
	long A[N];
	rep(i,0,N) cin>>A[i];
	rep(i,0,N-1){
		if(A[i] + A[i+1] >= L){
			cout<<"Possible"<<endl;
			for(int j = N-2; j > i; j--) cout<<j+1<<endl;
            rep(j,0,i+1) cout<<j+1<<endl;
			return 0;
		}
	}cout<<"Impossible"<<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[10001],b[10001];
int main(void){
	scanf("%d",&n);
	ll di=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		di-=a[i];
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&b[i]);
		di+=b[i];
	}
	if(di<0LL){
		puts("No");
		return 0;
	}
	ll ct1=0,ct2=0;
	for(int i=0;i<n;i++){
		while(a[i]<b[i]){
			a[i]+=2LL;
			ct1++;
		}
		ll dif=b[i]-a[i];
		if(dif>0LL){
			a[i]+=((dif+1LL)/2LL)*2LL;
			ct1+=(dif+1LL)/2LL;
		}
		dif=a[i]-b[i];
		if(dif>0LL){
			b[i]=a[i];
			ct2+=dif;
		}
	}
	if(ct1>di || ct2>di){
		puts("No");
	}else{
		ll re=di-ct1;
		ll re2=di-ct2;
		if(re*2LL==re2){
			puts("Yes");
		}else{
			puts("No");
		}
	}
	return 0;
}

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

int main() {
	long long K, X[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cin >> K;
	cout << X[K - 1] << endl;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;

    cin >> n;
    ans = 1;
    FOR(i, 1, n)
    {
        ans = ans * i;
        ans %= MOD;
    }
    pr(ans);
    return 0;
}


Measured memory_bytes: 3652