akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n;
	cin >> n;
	vector<int> p(n + 1);
	int i = 0;
	while (true)
	{
		cin >> p[i] >> p[i + 1];
		i++;
		if (i == n) break;
	}

	vector<vector<int>> m(n, vector<int>(n, INT_MAX));
	for (int i = 0; i < n; i++)
	{
		m[i][i] = 0;
	}

	for (int l = 1; l < n; l++)
	{
		for (int i = 0; i < n - l; i++)
		{
			int j = i + l;
			for (int k = i; k <= j - 1; k++)
			{
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i] * p[k + 1] * p[j + 1]);
			}
		}
	}

	cout << m[0][n - 1] << endl;
}


Measured memory_bytes: 3164
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        if((n-k)%2 == 0) {
          out.println((0L+n+k)/2);

        }
        else out.println("IMPOSSIBLE");
        out.close(); System.exit(0);
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    string s, t;
    cin >> s >> t;

    map<char, int> sm, tm;
    for(int i=0; i<s.length(); i++)
        sm[s[i]]++;

    for(int i=0; i<t.length(); i++)
        tm[t[i]]++;

    if (s.length() != t.length()){
        cout << "No";
        return 0;
    }

    vector<int> aa, bb;
    for(auto it : sm)
        aa.push_back(it.second);
    sort(aa.begin(), aa.end());
    for(auto it : tm)
        bb.push_back(it.second);
    sort(bb.begin(), bb.end());

    for(int i=0; i<aa.size(); i++){
        if (aa[i] != bb[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


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

int main( void ){
    int deg[4] = {0, 0, 0, 0}, x;
    for(int i=0; i<6; i++){
        cin >> x;
        deg[x]++;
    }
    sort(deg, deg+4);
    if( deg[1] == 1 && deg[2] == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

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

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    ll W,H;
    cin>>W>>H;
    vector<ll> p(W),q(H);
    rep(i,W) cin>>p[i];
    rep(i,H) cin>>q[i];
    ll t = H+1LL,s = W+1LL;
    priority_queue<P,vector<P>,greater<P>> A;
    rep(i,W) A.push(make_pair(p[i],0));
    rep(i,H) A.push(make_pair(q[i],1));
    ll ans = 0LL;
    while(!A.empty()){
        P x = A.top();
        A.pop();
        if(x.second == 0){
            ans += x.first*t;
            s--;
        }
        if(x.second == 1){
            ans += x.first*s;
            t--;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

const int mod = (long long) 1e9 + 7;
long long s, dp[3000];
long long sol(int rem) {
  if (rem < 3) {
    return 0;
  }
  long long& ret = dp[rem];
  if (ret != -1) {
    return ret;
  }
  ret = 1;
  for (int i = 3; i <= rem; i++) {
    ret += sol(rem - i);
    if (ret >= mod) {
      ret -= mod;
    }
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, -1, sizeof dp);
  cin >> s;
  cout << sol(s) << '\n';
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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 INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int N;
    double T, A;
    cin >> N >> T >> A;
    double H[N];
    REP(i, N) {
        cin >> H[i];
    }
    double temp = T - H[0] * 0.006;
    double best_dif = temp - A;
    if (best_dif < 0) { best_dif = -best_dif; }
    int best = 1;
    REP(i, N) {
        double tmp = T - H[i] * 0.006;
        double dif = tmp - A;
        if (dif < 0) { dif = -dif; }
        if (dif < best_dif) {
            best_dif = dif;
            best = i + 1;
        }
    }
    printAns(best);

}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(readline())
    for h in range(1, 3501):
        for n in range(1, 3501):
            if 4 * h * n - N * n - N * h != 0:
                w = (N * h * n) / (4 * h * n - N * n - N * h)
                if int(w) == w and w > 0:
                    print(h, n, int(w))
                    exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    c++;
    cout << c << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef unsigned long long ll;
using std::cout ;
using std::endl ;
using std::cin ;
using std::string ;
using std::vector ;
using std::set ;
using std::map ;
using std::pair ;
#define rep(i,n) for(int i=0, i##_end=(n); i<i##_end; i++)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
template<class T>bool updateMax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool updateMin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(c) c.begin(),c.end()
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif



int main() {
    int N;
    ll K;
    cin >> N >> K;
    int A[N];
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }
    
    int PMAX = 60;
    
    int pow[PMAX][N];
    rep(i, PMAX) {
        rep(j, N) {
            pow[i][j] = (i == 0 ? A[j] : pow[i-1][pow[i-1][j]]);
        }
    }
    
    int mati = 0;
    rep(i, PMAX) {
        if((K & (1ULL << i)) != 0ULL) {
            mati = pow[i][mati];
        }
    }
    cout << (mati+1) << endl;
    return 0;
}



Measured memory_bytes: 51268
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("-1");exit(0);}

const int maxn=105;
const int maxm=20005;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
int n,m;
char c[maxn][maxn];

class max_flow{
public:
	int s,t;
	class EDGE{
	public:
		int to,cap,rev;
		EDGE(int _to,int _cap,int _rev){to=_to;cap=_cap;rev=_rev;}
	};
	vector<EDGE>edge[maxm];
	int lvl[maxm],nxt[maxm],q[maxm];
	void add_edge(int from,int to,int cap){
//		cout<<from<<" "<<to<<endl;
		edge[from].pb(EDGE(to,cap,edge[to].size()));
		edge[to].pb(EDGE(from,0,edge[from].size()-1));
	}
	void bfs(){
		int l=0,r=0;
		memset(lvl,-1,sizeof(lvl));
		lvl[s]=0;
		q[r++]=s;
		while(l<r){
			int x=q[l++];
			rep(i,edge[x].size()){
				EDGE &y=edge[x][i];
				if(y.cap&&lvl[y.to]<0){
					lvl[y.to]=lvl[x]+1;
					q[r++]=y.to;
				}
			}
		}
	}
	int dfs(int x,int f){
		if(x==t)return f;
		for(int &i=nxt[x];i<edge[x].size();i++){
			EDGE &y=edge[x][i];
			if(y.cap&&lvl[y.to]==lvl[x]+1){
				int d=dfs(y.to,min(f,y.cap));
				if(d>0){
					y.cap-=d;
					edge[y.to][y.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	int mf(){
		int res=0;
		while(true){
			bfs();
			if(lvl[t]<0)return res;
			memset(nxt,0,sizeof(nxt));
			int f;
			while((f=dfs(s,INF))>0)res+=f;
		}
	}
}M;

int get_id(int i,int j,int tp){
	return (i*m+j)*2+tp;
}

int main(){
	scanf("%d%d",&n,&m);
	rep(i,n)scanf("%s",c[i]);
	M.s=n*m*2,M.t=n*m*2+1;
	rep(i,n)rep(j,m){
		if(c[i][j]=='X'){
			M.add_edge(get_id(i,j,0),get_id(i,j,1),INF);
			M.add_edge(get_id(i,j,1),M.t,INF);
			if(!i||i==n-1||!j||j==m-1){
				puts("-1");
				return 0;
			}
		}
		else{
			M.add_edge(get_id(i,j,0),get_id(i,j,1),1);
			if(!i||i==n-1||!j||j==m-1)M.add_edge(M.s,get_id(i,j,0),INF);
		}
		rep(k,4){
			int ni=i+dx[k],nj=j+dy[k];
			if(ni>=0&&ni<n&&nj>=0&&nj<m){
				M.add_edge(get_id(i,j,1),get_id(ni,nj,0),INF);
			}
		}
	}
	printf("%d\n",M.mf());
	return 0;
}

/*
Input:
5 4
....
..X.
.XX.
..X.
....
-----------------
Output:
*/

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

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

  int prev = 0;
  int a;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a < prev) {
      ans += prev - a;
      a = prev;
    }
    prev = a;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3760
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int n; cin >> n;

    int a[n];

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

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

    if(cntodd % 2 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int choice_list[3] = {1,2,3};
int len = sizeof(choice_list)/sizeof(int);

void delete(int x)
{
	for (int i = 0; i < len; ++i)
	{
		if (x == choice_list[i])
		{
			int tmp;
			tmp = choice_list[i];
			choice_list[i] = choice_list[len-1];
			choice_list[len-1] = tmp;
			len--;
		}
		
	}
	
}

void print()
{
	for (int i = 0; i < len; ++i)
	{
		printf("%d", choice_list[i]);
		printf("\n");
	}
}

int main(int argc, char const *argv[])
{
	int A,B;
	scanf("%d", &A);
	scanf("%d", &B);

	delete(A);
	delete(B);

	printf("%d\n", choice_list[0]);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
	
	int a, b;
	scanf("%d %d", &a, &b);
	int nilai[a];
	for(int i = 0; i<a; i++){	
		scanf("%d", &nilai[i]);
	}
	
	for(int j = 0; j<a-b; j++){
		if(nilai[j] < nilai[j+b]){
		printf("Yes\n");
		}else{
			printf("No\n");
		}
		
	}
	return 0;
}

Measured memory_bytes: 2392
class Graph
  attr_accessor :node
  def initialize(n=nil)
    @node = Array.new(n){Node.new}
  end
  def print
    @node.size.times{|i|
      puts "#{i} #{node[i].cost}"
    }
  end
end

class Node
  attr_accessor :edges_to, :edges_cost, :done, :cost
  def initialize
    @edges_to = []
    @edges_cost = []
    @done = false
    @cost = 1.0 / 0.0
  end
  def >(other)
    return self.cost < other.cost ? true : false
  end
  def <(other)
    return self.cost > other.cost ? false : true
  end
end


class Heep
  def initialize
    @node = []
  end
  def insert(num)
    i = @node.size
    @node[i] = num
    p = (i+1)/2-1
    while i > 0 && @node[p] < @node[i]
      @node[i], @node[p] = @node[p], @node[i]
      i = p
      p = (i+1)/2-1
    end
  end
  def extract
    ret = @node[0]
    if @node.size > 1
      @node[0] = @node.pop()
      maxHeapify(0)
    else
      @node = []
    end
    return ret
  end
  def maxHeapify(i)
    h = @node.size
    largest = i
    l = 2 * i + 1
    largest = l if l < h && @node[l] > @node[largest]
    r = 2 * i + 2
    largest = r if r < h && @node[r] > @node[largest]
    if largest != i then
      @node[i], @node[largest] = @node[largest], @node[i]
      maxHeapify(largest)
    end
  end
  def size
    return @node.size
  end
  def contain(node)
    if @node.index(node) == nil
      return false
    else
      return true
    end
  end
end

n = gets.to_i
graph = Graph.new(n)

n.times{
  u, k, *vc = gets.split.map(&:to_i)
  k.times{|i|
    graph.node[u].edges_to << vc[2*i]
    graph.node[u].edges_cost << vc[2*i+1]
  }
}
q = Heep.new
graph.node[0].cost = 0
q.insert(graph.node[0])

loop do
  break if q.size == 0
  doneNode = q.extract
  doneNode.done = true
  doneNode.edges_to.size.times{|i|
    to = doneNode.edges_to[i]
    cost = doneNode.cost + doneNode.edges_cost[i]
    if cost < graph.node[to].cost then
      graph.node[to].cost = cost
      q.insert(graph.node[to]) unless q.contain(graph.node[to])
    end
  }
end

graph.print

Measured memory_bytes: 8996
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
int n, a, b, c;
vi l;

int rec(int i, int A, int B, int C) {
	if (i == n) {
		if (A == 0 || B == 0 || C == 0)return ll_INF;
		return abs(a - A) + abs(b - B) + abs(c - C);
	}

	int res = rec(i + 1, A, B, C);

	res = min(res, rec(i + 1, A + l[i], B, C) + (A ? 10 : 0));
	res = min(res, rec(i + 1, A, B + l[i], C) + (B ? 10 : 0));
	res = min(res, rec(i + 1, A, B, C + l[i]) + (C ? 10 : 0));

	return res;
}
signed main(void) {
	cin >> n >> a >> b >> c;
	l.resize(n);
	f_vI(l, n);
	cout << rec(0, 0, 0, 0);
	return 0;
}

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

static const int64_t MOD = 1000000007;

int main() {
    int64_t N, K;
    std::cin >> N >> K;

    int64_t sum = 0;
    int64_t min = 0, max = 0;
    for (int64_t k = K; k <= (N + 1); ++k) {
        min = k * (k - 1) / 2;
        max = (2 * N - k + 1) * k / 2;

        sum += (max - min + 1);
        sum %= MOD;
    }

    std::cout << sum << std::endl;

    return 0;
}


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

int main(){
  int n;string s;
  cin >> n >> s;
  for(auto& i :s){
    i = i + n;
    char Z = 'Z';
    if(i>Z)
      i = i-26;
  }
  cout << s << endl;
}

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

int main() {
    int n, ans=0; cin >> n;
    vector<int> c(n), v(n);
    for(int i=0; i < n; ++i){
        cin >> v.at(i);
    }
    for(int i=0; i < n; ++i){
        cin >> c.at(i);
        if(v.at(i)-c.at(i) > 0){
            ans += v.at(i)-c.at(i);
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    ll n, k;
    cin >> n >> k;
    if (n % k == 0)
        cout << 0;
    else if (n < k)
        cout << min(k - n, n);
    else {
        ll p = n / k + 1;
        cout << abs(n - k * p);
    }
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
import copy
ans1 = 10**10
g = []
def v(a,b):
    for i in range(len(a)):
        a[i] += b[i]
    return a
b = [0 for i in range(n)]
for i in range(n):
    a = list(map(int,input().split()))
    g.append(a)
for i in range(len(g)):
    b[i] = g[i][0]
    g[i].pop(0)
for i in range(2**n):
    ans = 0
    ni = [0 for s in range(m)]
    u = copy.deepcopy(i)
    for j in range(n):
        if u &1 == 1:
            ni = v(ni,g[j])
            ans += b[j]
        u = u >> 1
    if min(ni) >= x:
        ans1 = min(ans1,ans)
if ans1 == 10**10:
    print(-1)
else:
    print(ans1)

Measured memory_bytes: 9356
import java.util.PriorityQueue

fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }
    
    val edges = Array(N) { mutableListOf<Pair<Int, Long>>() }

    for (i in N - 1 downTo 1) {
        edges[i].add(Pair(i - 1, 0L))
    }

    for (i in 1..M) {
        val (L, R, C) = readInputLine().split(" ").map { it.toInt() }
        edges[L - 1].add(Pair(R - 1, C.toLong()))
    }
    
    val cost = LongArray(N) { Long.MAX_VALUE }
    cost[0] = 0L
    val queue = PriorityQueue<Pair<Int, Long>>(N) { x, y -> x.second.compareTo(y.second) }
    
    queue.add(Pair(0, 0L))
    
    while (!queue.isEmpty()) {
        val (s, c) = queue.poll()!!
        
        if (cost[s] < c) {
            continue
        }
        
        for ((ed, ec) in edges[s]) {
            if (cost[ed] > cost[s] + ec) {
                cost[ed] = cost[s] + ec
                queue.add(Pair(ed, cost[ed]))
            }
        }
    }

    if (cost[N - 1] == Long.MAX_VALUE) {
        println(-1)
    } else {
        println(cost[N - 1])
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 103420
/*********
深さ優先探索
**********/

#include<iostream>
#include<cstdio>
#include<algorithm>
#define MAX 101

int w,h,n,i,j,ii,count=-1;
int sx,sy,gx,gy;
int c,d,x,y;
int bord[MAX][MAX][MAX]={0};
int num;

//プロトタイプ宣言
int bfs(int x,int y);



int main(){
  
  while(1){

    scanf("%d %d",&w,&h);
    if(w==0 && h==0) break;
    else{
      count++;

    scanf("%d %d",&sx,&sy);
    scanf("%d %d",&gx,&gy);
    scanf("%d",&n);
    
    for(ii=0;ii<n;ii++){
      
      scanf("%d %d %d %d",&c,&d,&x,&y);
      x-=1; y-=1;
      
      if(d==0){
	for(i=0;i<2;i++){
	  for(j=0;j<4;j++){
	    bord[count][y+i][x+j]=c;
	  }
	}
      }
      
      else{
	for(i=0;i<4;i++){
	  for(j=0;j<2;j++){
	    bord[count][y+i][x+j]=c;
	  }
	}
      }
      
    }
    
    //こっからは探索!!
    sx-=1; sy-=1;
    gx-=1; gy-=1;
    num=bord[count][sy][sx];
    
    bfs(sx,sy);
    
    if(bord[count][gy][gx]==-1) printf("OK\n");
    else printf("NG\n");
    }

  }
  return 0;
}



int bfs(int x,int y){
    
  if(x<w && y<h){
    //今いるところを、-1に置き換える
    bord[count][y][x]=-1;
    
    //移動する4方向を調べる
    if(0<=x && x<w && 0<=y-1 && y-1<h && bord[count][y-1][x]==num) bfs(x,y-1);
    if(0<=x-1 && x-1<w && 0<=y && y<h && bord[count][y][x-1]==num) bfs(x-1,y);
    if(0<=x+1 && x+1<w && 0<=y && y<h && bord[count][y][x+1]==num) bfs(x+1,y);
    if(0<=x && x<w && 0<=y+1 && y+1<h && bord[count][y+1][x]==num) bfs(x,y+1);
  }
  
  else return 0;
}

Measured memory_bytes: 1480
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibutan(auto a,auto b);
void print(int a,int b,int c){
    cout << a << " " << b << " " << c << endl;
}


signed main(){
    int n,y;
    cin >> n >> y;
    int yukiti=0,higuti=0,noguti=y/1000;
    if(noguti == n){
        print(yukiti,higuti,noguti);
        return 0;
    }
    else if(noguti < n){
        print(-1,-1,-1);
        return 0;
    }
    while(noguti>4){
        noguti -= 5;
        higuti++;
        if(higuti + noguti == n){
            print(0,higuti,noguti);
            return 0;
        }
        else if(higuti + noguti - n <= higuti/2 && higuti + noguti - n>=0){
            int t = higuti + noguti - n;
            print(t,higuti - 2*t,noguti);
            return 0;
        }
    }
    print(-1,-1,-1);
	
    
    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibutan(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    return x-1;
}

Measured memory_bytes: 256
//////////////////////////
//////////////////////////
////Please give me AC!////
////Please give me AC!////
//////////////////////////
//////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll X,N;
  cin>>X>>N;
  map<ll,ll> mp;
  for(ll i=0;i<N;i++){
    ll a;
    cin>>a;
    mp[a]++;
  }
  if(N==0){cout<<X<<endl;return 0;}
  for(ll i=0;i<1000;i++){
    if(mp[X-i]==0){cout<<X-i<<endl;return 0;}
    if(mp[X+i]==0){cout<<X+i<<endl;return 0;}
  }
}

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

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    int menu[5];
    int sa = 10;
    int j = 0;
    for(int i = 0; i < 5; i++){
        cin >> menu[i];
        if(menu[i] % 10 <= sa){
            if(menu[i] % 10 == 0){
                continue;
            }else{
                sa = menu[i] % 10;
                j = i;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 5; i++){
        if(i == j){
            ans += menu[i];
        }else if(menu[i] % 10 == 0){
            ans += menu[i];
        }else{
            ans = ans + ((menu[i] / 10) + 1) * 10;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import heapq

N = int(input())
A = list(map(int,input().split()))

pos = [-1] * N
for i,a in enumerate(A):
    pos[a-1] = i

q = []
heapq.heapify(q)
right = [N] * N
for i,a in enumerate(A):
    while q and -q[0] > a:
        v = -heapq.heappop(q)
        right[v-1] = i
    heapq.heappush(q,-a)

q = []
heapq.heapify(q)
left = [0] * N
for i,a in reversed(list(enumerate(A))):
    while q and -q[0] > a:
        v = -heapq.heappop(q)
        left[v-1] = i+1
    heapq.heappush(q,-a)

ans = 0
for i,(p,l,r) in enumerate(zip(pos,left,right)):
    ans += (p-l+1) * (r-p) * (i+1)
print(ans)

Measured memory_bytes: 59296
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')[0].split(' ').map(n => Number(n))
  let i = 1
  let tmp = []
  while (input[0] >= i && input[1] >= i) {
    if (input[0] % i == 0 && input[1] % i == 0) {
      tmp.push(i)
    }
    i++
  }
  tmp.reverse()
  console.log(tmp[input[2] - 1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11468
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int MAXN = 105;
int a[MAXN];
int main()
{
    int n;
    scanf("%d", &n);
    int ans=0, odd=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%d", &a[i]);
        if(a[i]&1)
            odd++;
    }
    ans=1;
    for(int i=1;i<=n;++i)
        ans*=3;
    int x=1;
    for(int i=1;i<=n-odd;++i)
        x*=2;
    printf("%d\n", ans-x);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;
typedef long long ll;


int main()
{
   int H,W,h,w;
   scanf("%d%d%d%d",&H,&W,&h,&w);
   cout<<(H-h) * (W-w) <<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
 
 int main(void){
     int n, q;
     scanf("%d", &n);
     int S[n];
     for(int i=0; i<n; i++){
         scanf("%d", &S[i]);
     }
     scanf("%d", &q);
     int T[q];
     for(int i=0; i<q; i++){
         scanf("%d", &T[i]);
     }
    int count = 0;
   
    int mid;
    for(int i=0; i<q; i++){
        int left=0;
        int right=n;
      
        while(left<right){
            mid = (left + right) / 2;
            if(S[mid]==T[i]){
                count++;
               
                break;
            }
            else if(S[mid] > T[i]){
                right = mid;
            }
            else{
                left = mid + 1;
            }
        }
    }

     printf("%d\n",count);

     return 0;
 }

 


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

using namespace std;
#define ll long long

struct info {
    int value, weight;
    char type;
    ll date;
    string name;

    bool operator<(const struct info &arg) const {
        if (value != arg.value) return value < arg.value;
        else if (weight != arg.weight) return weight < arg.weight;
        else if (type != arg.type) return type < arg.type;
        else if (date != arg.date) return date < arg.date;
        else return name < arg.name;
    }
};

int main() {
    int n;
    cin >> n;
    vector<info> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].value >> v[i].weight >> v[i].type >> v[i].date >> v[i].name;
    }
    sort(v.begin(), v.begin()+n);
    for (int i = 0; i < n; i++) {
        cout << v[i].value << " " << v[i].weight << " " << v[i].type << " " << v[i].date << " " << v[i].name << endl;
    }

    return 0;
}


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

long long N;
// iより下の
long long sumi[300000];
long long xori[300000];
long long A[300000];

long long cal(long long left){
	long long s = left;
	long long e = N;

	while(s + 1 < e){
		long long m = (s+e)/2;
		long long sval = sumi[m + 1] - sumi[left];
		long long xval = xori[m + 1] ^ xori[left];
		if(xval < sval){
			e = m;
		} else {
			s = m;
		}
	}
	//cout << "left = " << left << " right = " << s << endl;
	return 1 + ((s - left));
}

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++)
		cin >> A[i];

	for(long long i = 1; i <= N; i++){
		sumi[i] = sumi[i-1] + A[i-1];
		xori[i] = xori[i-1] ^ A[i-1];
		//cout << "sumi[" << i << "]=" << sumi[i] << endl;
		//cout << "xori[" << i << "]=" << xori[i] << endl;
	}

	//cout << "left = " << 0 << " right = " << 1 << endl;
	//cout << sumi[2] - sumi[0] << endl;
	//cout << (xori[2] ^ xori[0]) << endl;

	long long ans = 0;
	for(long long i = 0; i < N; i++){
		ans += cal(i);
		//cout << "curans = ";
		//cout << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6016
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtCoder
{
    class Program2
    {

        static void Main(string[] args)
        {
            //lee una linea con numeros
            string A = Console.ReadLine();

            bool coffeelike = (A[2].Equals(A[3]) && A[4].Equals(A[5]));

            if (coffeelike)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }


    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}


const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    int n;
    cin >> n;
    ll a[n+1];
    rep(i,n+1) cin >> a[i];
    ll b[n];
    rep(i,n) cin >> b[i];

    ll bef = 0;
    rep(i,n+1){
        bef += a[i];
    }

    rep(i,n){
        if (b[i] <= a[i]) {
            a[i] -= b[i];
        }
        else if (b[i] <= a[i] + a[i+1]) {
            b[i] -= a[i];
            a[i] = 0;
            a[i+1] -= b[i];
        }
        else {
            a[i] = 0;
            a[i+1] = 0;
        }
    }

    ll aft = 0;
    rep(i,n+1) aft += a[i];


    cout << bef - aft << endl;



}





//              g++ -std=c++1z


Measured memory_bytes: 1792
#include <iostream>
#define llint long long
#define inf 1e18

using namespace std;

llint n;
llint p[4], t[4];

int main(void)
{
	cin >> n;
	for(int i = 0; i < 4; i++) cin >> p[i];
	for(int i = 0; i < 4; i++) cin >> t[i];
	
	llint ans = inf;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= n; k++){
				llint rem = max(0LL, n - (t[0]*i + t[1]*j + t[2]*k));
				llint l = (rem+t[3]-1) / t[3];
				ans = min(ans, p[0]*i + p[1]*j + p[2]*k + p[3]*l);
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;


map<pair<int,int>, int> mp;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
   // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        int n;
        cin >> n;
        int cnt = 0;
        for(int i = 1; i <= n; i++){
            int x;
            cin >> x;
            mp[{x,i}]++;
            mp[{i,x}]++;
            //cerr << mp[{x,i}] << " "<<mp[{i,x}]<<endl;
            if(mp[{x,i}] == 2) cnt++;
        }
        cout <<cnt << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 12800
n=int(input())
g=[[]for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    g[a-1].append((c,b-1))
    g[b-1].append((c,a-1))

def dijkstra(g,st):
    from heapq import heappush, heappop, heapify
    inf=10**18
    dist=[inf for i in range(len(g))]
    visited=[False for i in range(len(g))]
    dist[st]=0
    que=[]
    heappush(que,(0,st))
    while que:
        c,v=heappop(que)
        if visited[v]:
            continue
        visited[v]=True
        for x in g[v]:
            tmp=x[0]+c
            if tmp<dist[x[1]] and not visited[x[1]]:
                dist[x[1]]=tmp
                heappush(que,(tmp,x[1]))
    return dist

dist=dijkstra(g,0)
for i in range(n):
    print(0 if dist[i]%2==0 else 1)


Measured memory_bytes: 43136
#include <iostream>

using namespace std;

int main()
{
    int x ;
    cin>>x;
    int h=0 , i=0 ;
    while(x>0){
            if(x>=500){
                for(i=0; i<x && x>=500; x=x-500){h=h+1000;}}
            else if (x<500){
                    int r= x%5 ;
            x=x-r;
                for(i=0;i<x;x=x-5){
                    h=h+5;
                }
            }

        }
        cout<<h;
    return 0;
}

Measured memory_bytes: 256
M, D = map(int, input().split())
count = 0
for i in range(1,M+1):
  for j in range(22,D+1):
    #print(j,j//10)
    if j//10>=2:
      if j%10>=2:
        if (j//10)*(j%10)==i:
          count+=1
print(count)

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    string str{"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"};
    int N;
    string S;
    cin >> N >> S;

    rep (i, S.size())
    {
        S[i] = str[S[i] - 'A' + N];
    }
    cout << S << "\n";
    return 0;
}



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

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

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

ll Q, L, R, Sum[100001];
bool Prime[100001];

signed main() {
    Prime[0] = Prime[1] = 1;
    inc(i, 2, sqrt(100000)) {
        if(Prime[i] == 0) {
            for(ll j = 2; i * j <= 100000; j++) {
                 Prime[i * j] = 1;
            }
        }
    }
    for(ll i = 3; i <= 100000; i += 2) {
        if(Prime[i] == 0 && Prime[(i + 1) / 2] == 0) {
             Sum[i]++;
        }
    }
    inc(i, 1, 100000) Sum[i] += Sum[i - 1];
    cin >> Q;
    rep(i, Q) cin >> L >> R, cout << Sum[R] - Sum[L - 1] << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int n, m;
vector<int> to[8];
vector<bool> visited(8);
int cnt = 0;
void dfs(int cur, int dep) {
    //printf("%d %d\n", cur, dep);
    visited[cur] = true;
    if(dep == n-1) {
        cnt++;
        //return;
    }
    for(int v : to[cur]) {
        if(visited[v]) continue;
        dfs(v, dep+1);
    }
    visited[cur] = false;
}
int main() {
    cin >> n >> m;
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0, 0);
    cout << cnt;
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

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

  Int n;
  cin>>n;
  cin.ignore();

  vector<string> vs;
  for(Int i=0;i<n;i++){
    string s;
    getline(cin,s);
    vs.emplace_back(s);
  }

  map<string, Int> idx;
  for(Int i=0;i<n;i++){
    if(count(vs[i].begin(),vs[i].end(),' ')) continue;
    vs[i].pop_back();
    idx[vs[i]]=i;
  }

  using P = pair<Int, Int>;
  vector< vector<P> > G(n+1);
  for(Int i=0;i<n;i++){
    if(count(vs[i].begin(),vs[i].end(),' ')){
      auto pos=vs[i].find(' ');
      string s=vs[i].substr(pos+1);
      s.pop_back();
      G[i].emplace_back(idx[s],0);
      G[i].emplace_back(i+1,1);
    }else{
      G[i].emplace_back(i+1,0);
    }
  }

  const Int INF = 1e5;
  vector<Int> dp(n+1,INF);
  queue<Int> que;
  dp[0]=0;
  que.emplace(0);

  while(!que.empty()){
    Int v=que.front();que.pop();
    //cout<<v<<":"<<dp[v]<<endl;
    for(auto e:G[v]){
      Int u=e.first,c=e.second;
      if(dp[u]<=dp[v]+c) continue;
      dp[u]=dp[v]+c;
      que.emplace(u);
    }
  }

  cout<<dp[n]<<endl;
  return 0;
}



Measured memory_bytes: 3264
class ModInt:
    def __init__(self, num, mod):
        self.num = num
        self.mod = mod

    def __str__(self):
        return str(self.num)

    def __repr__(self):
        return "ModInt(num: {}, mod: {}".format(self.num, self.mod)

    def __add__(self, other):
        ret = self.num + other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __sub__(self, other):
        ret = self.num - other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __mul__(self, other):
        ret = self.num * other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def pow(self, times):
        pw = pow(self.num, times, self.mod)
        return ModInt(pw, self.mod)

    def inverse(self):
        return self.pow(self.mod - 2)

    def __truediv__(self, other):
        num = self * other.inverse()
        return ModInt(num, self.mod)


class Combination:
    def __init__(self, n, mod):
        self.mod = mod
        self.fact = [ModInt(1, mod)]
        self.inverse = [ModInt(1, mod)]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * ModInt(i, mod))
            self.inverse.append(self.inverse[-1] * ModInt(i, mod).inverse())

    def comb(self, n, k):
        if k < 0 or n < k:
            return ModInt(0, self.mod)

        return self.fact[n] * self.inverse[k] * self.inverse[n-k]


n, m, k = map(int, input().split())
mod = 10 ** 9 + 7

cmb = Combination(2 * 10 ** 5, mod)
ans = ModInt(0, mod)
for i in range(n):
    for j in range(m):
        add = ModInt(n - i, mod) * ModInt(m - j, mod) * ModInt(i + j, mod)
        if i != 0 and j != 0:
            add *= ModInt(2, mod)

        ans += add

ans *= cmb.comb(n * m - 2, k - 2)
print(ans)


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

int main(){
    int n; cin >> n;
    vector<int> x(n),y(n);
    rep(i,n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(),y.end());
    rep(i,n){
        int mid = y[n/2];
        if(x[i]<mid) cout << y[n/2] << endl;
        else cout << y[n/2-1] << endl;
    }
    return 0;
}

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



void solve(){
    int h,w;
    cin >> h >> w;
    vector<string> v;
    rep(i,h){
      string tmp;
      cin >> tmp;
      v.emplace_back(tmp);
    }

    bool a[w+5];
    rep(i,h){
      a[i] = true;
      for(int j=0; j<w; j++){
        if(v[i][j]!='.') a[i]=false;
      }
    }

    bool b[h+5];
    rep(i,w){
      b[i]=true;
      for(int j=0; j<h; j++){
        if(v[j][i]!='.') b[i]=false;
      }
    }


    rep(i,h){
      rep(j,w){
        if(!b[j]&&!a[i]) cout << v[i][j];
      }
      if (!a[i]) cout << endl;
    }
    cout << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A=0,B=0;//入力される整数
  int _sum=0; //和
  int _diff=0; //差
  int _pro=0; //積
  int max; //最大の数
  
  scanf("%d %d",&A,&B);
  
  _sum = A + B;
  max = _sum;
  _diff = A - B;
  _pro = A * B;
  if(max < _diff)
    max = _diff;
  if(max < _pro)
    max = _pro;
  
  printf("%d",max);
  return 0;
}

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

using namespace std;

int main() {
  int h, w;
  scanf("%d %d", &h, &w);

  int a[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf("%d", a[i] + j);
    }
  }

  vector<string> result;
  for (int i = 0; i < h-1; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] % 2 == 1) {
        a[i+1][j]++;

        char b[20];
        sprintf(b, "%d %d %d %d", i+1, j+1, i+2, j+1);
        result.push_back(string(b));
      }
    }
  }

  for (int j = 0; j < w-1; j++) {
      if (a[h-1][j] % 2 == 1) {
        a[h-1][j+1]++;

        char b[20];
        sprintf(b, "%d %d %d %d", h, j+1, h, j+2);
        result.push_back(string(b));
      }
  }

  printf("%d\n", result.size());
  for (string r : result) {
    cout << r << endl;
  }

  return 0;
}


Measured memory_bytes: 9972
n,m,x=map(int,input().split())
gate=list(map(int,input().split()))
cnt1=0
cnt2=0
for i in range(1,x):
    if i in gate:
        cnt1+=1
for j in range(x+1,n):
    if j in gate:
        cnt2+=1
print(min(cnt1,cnt2))

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  int m;
  cin >> m;
  vector<ll> b(m);
  rep(i, m) cin >> b[i];
  cout << lexicographical_compare(all(a), all(b)) << endl;
  return 0;
}



Measured memory_bytes: 3220
#include<stdio.h>
#define MAX 100

int bubbleSort(int *,int);

int main()
{
  int a[MAX];
  int i,n,count;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  count = bubbleSort(a,n);

  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[n-1]);
  printf("%d\n",count);

  return 0;
}

int bubbleSort(int *A,int N)
{
  int flag = 1;
  int i,x,count = 0;

  while(flag){
    flag = 0;
    
    for(i=N-1;i>0;i--){
      if(A[i] < A[i-1]){
	x = A[i];
	A[i] = A[i-1];
	A[i-1] = x;
	flag = 1;
	count++;
      }
    }
  }

  return count;
}
  
  



Measured memory_bytes: 2144