akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;


struct Unionfind{
    vector<int> parents;
    int n;
    Unionfind(int n):n(n),parents(n,-1){ }

    int find(int x){
        if(parents[x] < 0) return x;
        else return parents[x] = find(parents[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x==y) return;
        //if(parents[x] > parents[y]) swap(x,y);
        parents[x] += parents[y];
        parents[y] = x;
    }  

   int size(int x){
       return -parents[find(x)];
   }

   bool same(int x,int y){
       return find(x) == find(y);
   }

   vector<int> members(int x){
       int root = find(x);
       vector<int> member;
       for(int i=0;i<n;i++){
           if(find(i)==root){
               member.push_back(i);
           }
       }
      return member;
  }

  int group_cnt(){
      int c = 0;
      rep(i,n){
          if(parents[i] < 0) ++c;
      }
      return c;
  }
};


int main(){
    while(1){
        int n,q;
        cin >> n >> q;
        if(n == 0 && q == 0) break;
        Unionfind uf(n);
        vector<vector<int>> tree(n);
        vector<int> p(n);
        vector<int> mark(n);

        for(int i=1;i<n;i++){
            int a;
            cin >> a;
            --a;
            tree[a].push_back(i);
            tree[i].push_back(a);
            p[i] = a;
        }

        vector<pair<char,int>> query(q);
        rep(i,q){
            cin >> query[i].first >> query[i].second;
            --query[i].second;
            if(query[i].first == 'M') mark[query[i].second] ++;
        }
        stack<int> before;

        function<void(int,int,int)> dfs = [&](int i,int par,int m){

            if(mark[i] > 0){
                before.push(m);
                m = i;
            }else{
                uf.unite(m,i);
            }

            for(int c:tree[i]){
                if(c == par) continue;
                dfs(c,i,m);
            }

            if(mark[i] > 0){
                m = before.top();
                before.pop();
            }
        };

        /*
        rep(i,n) cout << p[i] << " " ;
        cout << endl;
        */

        dfs(0,-1,0);

        ll ans = 0LL;

        for(int i=q-1;i>=0;i--){
            if(query[i].first == 'M'){
                mark[query[i].second] --;
                if(mark[query[i].second]==0) uf.unite(p[query[i].second],query[i].second);
                //cout << query[i].second << " " << p[query[i].second] << endl;
            }else{
                ans += (ll)(uf.find(query[i].second) + 1);
                //cout << uf.find(query[i].second) << endl;
            }
        }

        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;
int ans,N,M;
bool graph[10][10];
void dfs(vector<bool> vis, int current, int visCnt){
  if(visCnt == N){
    ans ++;
    return;
  }
  for(int i = 0; i < N; i++){
    if(graph[current][i] && vis[i] == false){
      vis[i] = true;
      dfs(vis,i,visCnt + 1);
      vis[i] = false;
    }
  }
  return ;
}
int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
      int to,from;
      cin >> to >> from;
      to--; from--;
      graph[to][from] = true;
      graph[from][to] = true;
    }
    vector<bool> vis(N,false);
    vis[0] = true;
    dfs(vis,0,1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def solve(n, id, ln, ar)
  ar[id] = n
  if id == ln-1
    @cnt += 1
    pif = qif = 1
    for i in 0..(ln-1)
      pif = 0 if ar[i] != @p[i]
      qif = 0 if ar[i] != @q[i]
    end
    @pod = @cnt if pif == 1
    @qod = @cnt if qif == 1
    return
  end
  
  for i in 1..ln
    flag = 1
    for j in 0..id
      if ar[j] == i
        flag = 0
        break
      end
    end
    solve(i, id+1, ln, ar) if flag == 1
  end
end

n = gets.to_i
@p = gets.split.map(&:to_i)
@q = gets.split.map(&:to_i)

@cnt = 0
@pod = @qod = -1
for i in 1..n
  ar = Array.new(n)
  solve(i, 0, n, ar)
end
puts (@pod-@qod).abs

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int a[maxn];
int cmp(const int a,const int b){
    return a>b;
}
int n,m,v,p;
int b[maxn];
bool judge(int mid){
    //printf("hello %lld\n",mid);
    if(mid<=p)return true;
    if(a[mid]+m<a[p])return false;
    if(v<=p-1&&a[mid]+m>=a[p])return true;
    for(int i=1;i<=n;i++)b[i]=a[i];
    int temp=0;
    int inx=n,cnt=v-p+1;
    for (int i=n,j=v-p;i>mid&&j;i--,j--){
        temp+=m;
        b[i]+=m;
    }
    temp+=m*p;
    int now=a[mid]+m;
    int res=m*v-temp;
    int ww=a[p];
    for(int i=p;i<mid;i++){
        int add=min(m,max(now-a[i],0ll));
        if(add>res)add=res;
        res-=add;
        b[i]+=add;
        if(i==p){
            ww+=add;
        }
    }
    return now>=ww&&res<=0;
}
signed main(){
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    int low=1,high=n;
    int ans=0;
    while(low<=high){
        int mid=(low+high)>>1;
        if(judge(mid)){
            low=mid+1;
            ans=mid;
        }
        else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	vector<tint> hen;
	int di[30]={1,0};
	for(int i=1;i<30;i++)
		di[i]=di[i-1]*2;
	int L;
	cin>>L;
	L--;
	//必要な点の数
	int poi=0;
	//Lの2進表示で一番右の桁
	for(int i=0;i<25;i++)
		if(L<(1<<i)-1){
			poi=i;
			break;
		}
	//cout<<poi<<endl;
	//基本の辺を張る
	for(int i=1;i<poi;i++){
		hen.eb(i,i+1,di[i-1]);
		hen.eb(i,i+1,0);
	}
	//追加の辺を張る
	//現在の辺で表せる最大の数
	int maxi=(2<<(poi-2))-1;
	//cout<<maxi<<endl;
	int a=0;
	for(int i=25;i>=0;i--){
		if(L>=maxi+di[i]){
			hen.eb(i+1,poi,maxi+1);
			maxi+=di[i];
			//cout<<maxi<<endl;
		}
	}
	cout<<poi<<" "<<hen.size()<<endl;
	for(tint T:hen){
		int a,b,c;
		tie(a,b,c)=T;
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=0; i<=n; i++)
	    f[i] = 0;
	for(int i=1; i<=n; i++)
	{
	    for(int j=i+1; j<=n; j++)
	    {
	        f[min(min(abs(i-x) + abs(j -y)+1,abs(i-j)),abs(i-y) + abs(j-x)+1)]++;
	        //cout<<i<<' '<<j<<' '<<min(min(abs(i-x) + abs(j -y)+1,abs(i-j)),abs(i-y) + abs(j-x)+1)<<endl;
	    }
	}
	for(int i=1; i<n; i++)
	    cout<<f[i]<<'\n';
	return 0;
}


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

public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ')
            .Select(x => Decimal.Parse(x))
            .ToList();

        var ret = input[0] * input[1];
        System.Console.WriteLine(Decimal.Floor(ret));
    }
}


Measured memory_bytes: 28396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

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

    vector<int> nums;
    int cnt = 0;
    int now = 1;
    rep(i,n){
        if (s[i] == '0'+now) cnt++;
        else {
            nums.push_back(cnt);
            now ^= 1;
            cnt = 1;
        }
    }
    nums.push_back(cnt);
    if (nums.size() % 2 == 0) nums.push_back(0);

    vector<int> sums(nums.size()+1);
    rep(i, nums.size()){
        sums[i+1] = sums[i] + nums[i];
    }

    int add = 2 * k + 1;
    int tmp = 0;
    int ans = 0;
    for(int i = 0; i < nums.size(); i+=2){
        int left = i;
        int right = min(i + add, (int)nums.size());
        ans = max(ans, sums[right] - sums[left]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4216
n,k = map(int,input().split())
l = list(map(int,input().split()))
ls = []
for i in range(n-k+1):
  a = l[i]
  b = l[i+k-1]
  ls.append(min(abs(a)+abs(a-b), abs(b)+abs(a-b)))
print(min(ls))

Measured memory_bytes: 20132
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<string.h>
typedef long long int ll;
using namespace std;
ll d[100];
int mod=1e9+7;
int main()
{
	int n,m,i;
	cin>>n>>m;
	if(n<m)
	{
		for(i=0;i<m;i++)
		printf("%d",n);
	}
	else
	{
		for(i=0;i<n;i++)
		printf("%d",m);
	}
}

Measured memory_bytes: 256
/* Selection Sort */

#include <stdio.h>

int main(void) {
  int i, j, swap = 0, n, tmp, mini;
  scanf("%d", &n);
  int a[n];
  for(i = 0; i < n; i++) scanf("%d", &a[i]);
  for(i = 0; i < n; i++) {
    mini = i;
    for(j = i; j < n; j++)
      if(a[j] < a[mini])
        mini = j;
    if(i != mini) swap++;
    tmp = a[i];
    a[i] = a[mini];
    a[mini] = tmp;
  }

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

  return 0;
}

Measured memory_bytes: 604
import sys
input = sys.stdin.readline
def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False
    return True
n = int(input())
ans = 0
for _ in range(n):
    ans += int(is_prime(int(input())))
print(ans)




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

// types - only for stuff used a lot 
using ll = long long;
#define vv vector
#define Pp pair

// IO
#define get(x) scanf("%d",&x)
#define getl(x) scanf("%lld",&x);

// Operations
#define pb push_back
#define pob pop_back
#define sz(a) int(a.size()) 
#define re(a,b) a=max(a,b) // relax
#define ri(a,b) a=min(a,b) // relaxi

// Debugging

#ifndef LOCAL
#define cerr if (0) cerr
#else
#define cerr cout
#endif

#define print(arr,n) {for (int _ = 0; _ < n; _++) cerr<<arr[_]<<" "; cerr << endl; }
#define printv(vec)  {for (int _ : vec) cerr<<_<<" "; cerr<<endl;}

const int mod = 1e9+7, oo = 1e9;
const ll loo = 1e18;

// Functions 
ll modpow(ll a, ll b) {
	ll ans = 1; // faster modpow than recursive
	for (; b; b/=2,a=a*a%mod)
		if (b&1) ans = (ans*a)%mod;
	return ans;
}
ll gcd(ll a, ll b) {
	while (a) b%=a,swap(a,b);
	return b;
}
#define bitcount __builtin_popcountll
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)


/* 

   ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS

 */

const bool DEBUG = 1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n,k; cin>>n>>k;
	int a[n]; 
	f(i,0,n) cin>>a[i];
	deque<int> dqmx, dqmi;
	f(i,0,k-1) {
		while (dqmx.size() && dqmx.back() < a[i])
			dqmx.pop_back();
		while (dqmi.size() && dqmi.back() > a[i])
			dqmi.pop_back();
		dqmx.pb(a[i]);
		dqmi.pb(a[i]);
	}
	int cnt = 0;
	int sorted = dqmi.size() == k;
	f(i,0,n-k+1) {
		cnt++;
		while (dqmx.size() && dqmx.back() < a[i+k-1])
			dqmx.pop_back();
		while (dqmi.size() && dqmi.back() > a[i+k-1])
			dqmi.pop_back();
		dqmx.pb(a[i+k-1]);
		dqmi.pb(a[i+k-1]);
		if (i) {
			if (dqmi.size() == k) sorted++;
			if (dqmx.size() == 1 && dqmi.front() > a[i-1])	{
				cnt--;
			} else if (dqmi.size() == k && sorted != 1) {
				cnt--;
			}
		}	
		if (dqmx.front() == a[i])
			dqmx.pop_front();
		if (dqmi.front() == a[i])
			dqmi.pop_front();
	}
	cout << cnt << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}



Measured memory_bytes: 1920
using System;

namespace Circle_in_a_Rectangle
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int w = int.Parse(str[0]);
            int h = int.Parse(str[1]);

            int x = int.Parse(str[2]);
            int y = int.Parse(str[3]);
            int r = int.Parse(str[4]);

            if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl "\n"
const int MAX = 3e5+5;
const ll MAX2 = 11;
const ll MOD = 1000004119;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

ll n,hs[MAX],hst[MAX],z,le,ri,m1,m2,ans,a,b;// z = key hashing
string s;
set<ll> st;

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    z = 1000003601;
    cin>>s;
    hst[0] = 1;
    for(auto i:s){
    	++n;
    	hs[n] = (hs[n-1]*z+i);
    	hst[n] = (hst[n-1]*z);
	}
    le = 1, ri = n;
    while(ri-le>10){
    	m1 = (le+le+ri)/3;
    	m2 = (le+ri+ri)/3;
    	st.clear();
    	rep(i,m1,n)st.insert(((hs[i]-hs[i-m1]*hst[m1])));
    	a = st.size();
    	st.clear();
    	rep(i,m2,n)st.insert(((hs[i]-hs[i-m2]*hst[m2])));
    	b = st.size();
    	if(a<b)le = m1+1;
    	else ri = m2-1;
    	ans = max(ans,max(a,b));
//    	cout<<m1<<" = "<<a<<endl;
//    	cout<<m2<<" = "<<b<<endl;
	}
//	cout<<hs[1]<<' '<<((hs[2]-hs[1]*z)%MOD+MOD)%MOD<<endl;
	rep(k,le,ri){
    	st.clear();
    	rep(i,k,n)st.insert(((hs[i]-hs[i-k]*hst[k])));
    	ans = max(ans,(ll)st.size());
//    	cout<<k<<" = "<<st.size()<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10072
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements <=num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
//#define int long long int
//Binary_Search->dp->greedy
bool is(string s){
	int n=s.length();
	int l=0,r=n-1;
	while(l<=r){
		if(s[l]!=s[r]) return false;
		l++;r--;
	}
	return true;
}
void solve(){
	string s;
	cin>>s;
	int n=s.length();
	int len=(n-1)/2;
	string s1=s.substr(0,len);
	string s2=s.substr((n/2)+1,len);
	if(is(s1) && is(s2) && is(s)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
 
 
 
 
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
}   

Measured memory_bytes: 256
my $N = <STDIN>;
my $input = <STDIN>;
chomp $input;
my @arr = split(/ /, $input);
my @nsort = [];
for (my $i = 0; $i < (my $j = @arr); $i++)
{
    push @nsort, [@arr[$i], $i + 1];
}
@nsort = sort {$a->[0] <=> $b->[0]} @nsort;
my @ans = map {$_->[1]} @nsort;
print join(" ", @ans) . "\n";

Measured memory_bytes: 49584
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  for (ll i = A; i <= B; i++) {
    if (i < A + K) cout << i << endl;
    else if (i > B - K) cout << i << endl;
  }
}


Measured memory_bytes: 384
val1=input()
s=input()
n=int(val1)
count=0
for i in range(0,1000):
    a=str(i).zfill(3) #ゼロうめ
    p=0
    for j in range(0,n):
        if a[p]==s[j]:
            p+=1
            if p==3:
                count+=1
                break
print(count)

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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int n;
vvl a, dp;

ll solve() {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (k == i || k == j || i == j || dp[i][k] == INF || dp[k][j] == INF) {
					continue;
				}

				if (dp[i][k] + dp[k][j] == a[i][j]) {
					dp[i][j] = INF;
				} else if (dp[i][k] + dp[k][j] < a[i][j]) {
					return -1;
				}
			}
		}
	}

	ll res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			res += dp[i][j] == INF ? 0 : dp[i][j];
		}
	}

	return res / 2LL;
}

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

	cin >> n;

	a.resize(n, vl(n));
	dp.resize(n, vl(n));

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

	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && c==b){
    cout << "No" << endl;
  }else if(a==b || a == c || b==c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[2003][2003],n,m,s[2003],t[2003];
const long long MOD=1000000007;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>s[i+1];
	for(int i=0;i<m;i++)cin>>t[i+1];
	for(int i=0;i<=n;i++)dp[i][0]=1;
	for(int i=0;i<=m;i++)dp[0][i]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%MOD;
			if(s[i]==t[j])dp[i][j]=(dp[i][j]+dp[i-1][j-1])%MOD;
		}
	cout<<(dp[n][m]%MOD+MOD)%MOD;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m,K;
int in[N];
void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&in[i]);
	for(int i=n;i>=2;i--){
		if(in[i-1]>in[i]+1){
			puts("No");
			return;
		}else if(in[i-1]>in[i]){
			in[i-1]--;
		}
	}
	puts("Yes");
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 998244353L;
template<class T> inline void chmin(T& a, T b) { if (a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }

void cinv(lls& llVec, ll n, bool to_0_origin = false) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		if (to_0_origin) val--;
		llVec.push_back(val);
	}
}


int main()
{
	ll N;
	std::string X;
	cin >> N >> X;

	//Nの約数のうち奇数のものを求める
	lls oddVec;
	for (ll i = 1; i <= N; i++) {
		if (i * i > N) break;

		if (N % i != 0) continue;
		if (i % 2 == 1) oddVec.push_back(i);

		if (i != N / i) {
			if ((N / i) % 2 == 1) oddVec.push_back(N / i);
		}
	}
	//降順にソート
	std::sort(oddVec.begin(), oddVec.end(),
		[](ll& a, ll& b) {return a > b; }
	);

	//Xのはじめのn桁の数値を計算 valVec[n-1]
	lls valVec(N);
	{
		ll sum = 0;
		for (ll i = 0; i < N; i++) {
			sum = sum * 2 + (X[i] - '0');
			sum %= MOD;
			valVec[i] = sum;
		}
	}

	//---- 場合の数を計算
	lls baaiNumVec(oddVec.size());

	for (ll i=0;i<oddVec.size();i++){
		ll y = oddVec[i];
		ll bitNum = N / y;

		//X以下か判定
		bool isXika = true;
		for (ll idx = bitNum; idx < N; idx++) {
			if (X[idx - bitNum] != X[idx]) continue;
			if (X[idx] == '1') isXika = true;
			else isXika = false;
			break;
		}
		//場合の数
		ll baaiNumOrg;
		if (isXika) baaiNumOrg = valVec[bitNum-1] + 1;
		else        baaiNumOrg = valVec[bitNum - 1];

		//重複を引く
		for (ll j = 0; j < i; j++) {
			ll big_y = oddVec[j];
			if (big_y % y != 0) continue;

			baaiNumOrg = baaiNumOrg + (MOD - baaiNumVec[j]);
			baaiNumOrg %= MOD;
		}

		baaiNumVec[i] = baaiNumOrg;
	}

	//---- 総和計算
	{
		ll sum = 0;
		for (ll i = 0; i < oddVec.size(); i++) {
			ll y = oddVec[i];
			ll atai = (2 * N) / y;
			sum += (atai * baaiNumVec[i]);
			sum %= MOD;
		}
		cout << sum << '\n';
	}

	return 0;
}



Measured memory_bytes: 2180
#include <stdio.h>

int main(void)
{
	int a,b,i,j;
	int c[100];
	char op;
	
	for(i=0;;i++){
	scanf("%d %c %d",&a,&op,&b);
	
		if(op == '+'){
			c[i] = a+b;
		}else if(op == '-'){
			c[i] = a-b;
		}else if(op == '*'){
			c[i] = a*b;
		}else if(op == '/'){
			c[i] = a/b;
		}else if(op == '?'){
			break;
		}
	}
	for(j=0;j<i;j++){
		printf("%d\n",c[j]);
	}
	return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 2e5+3;
const int INF = 1e9;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    //int ntest; cin >> ntest; while(ntest--)
    {
        int n; 
        LL k;
        cin >> n >> k;

        int b = 0;
        while((1LL<<b) < k) b++;
        vector<vector<int>> dp(n, vector<int>(b+1));

        fori(i,n) {
            cin >> dp[i][0];
            dp[i][0]--;
        }

        fore(j,1,b) {
            fori(i,n) {
                dp[i][j] = dp[dp[i][j-1]][j-1];
            }
        }

        int u = 0;
        fori(j,b) {
            if((k>>j)&1) u = dp[u][j];
        }
        cout << u+1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 57844
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int main()
{
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;

    vector<pii> cost_num;
    cost_num.emplace_back(q*8, 0);
    cost_num.emplace_back(h*4, 1);
    cost_num.emplace_back(s*2, 2);
    cost_num.emplace_back(d, 3);

    sort(cost_num.begin(), cost_num.end());
    
    ll ans;
    if (cost_num[0].second == 3)
    {
        // cout << n << ' ' << cost_num[0].first <<' ' << cost_num[0].second << ' ' << (n / 2) * cost_num[0].first<< endl;
        if (n % 2 == 0)
            ans = n / 2 * cost_num[0].first;
        else
            ans = (n / 2) * cost_num[0].first + cost_num[1].first/2;
    }
    else 
        ans = cost_num[0].first / 2 * n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    AB = []
    for _ in range(M):
        a, b = map(int, input().split())
        AB.append([a, b])

    first = set()
    second = set()

    for a, b in AB:
        if a == 1:
            first.add(b)
        elif b == N:
            second.add(a)

    # print(first, second)
    if first & second:
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')


if __name__ == "__main__":
    main()

Measured memory_bytes: 43360
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int32_t main(){
		IOS;
		string s;
		string t;
		cin>>s>>t;
		if(t.size()==s.size()+1){
			bool f=1;
			for(int i=0;i<s.size();i++){
				if(t[i]==s[i])continue;
				else{
					f=0;break;
				}
			}
			if(f) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
		else cout<<"No"<<endl;
		return 0;
	}


Measured memory_bytes: 3576
N = input()
n = list(N)
p = n.pop()
if int(p) == 2 or int(p) == 4 or int(p) ==5 or int(p) ==7 or int(p) ==9 :
    print("hon")
elif int(p) == 0 or int(p) ==6 or int(p) ==1 or int(p) ==8 :
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9196
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
using namespace std;
ll ans=0;
void add(string s)
{
	ll now=0;
	rep(i,SZ(s))
	{
		if(s[i]>='0'&&s[i]<='9')
		{
			now*=10;
			now+=s[i]-'0';
			if(i==s.size()-1)
			{
				ans+=now;
			}
		}
		else
		{
			ans+=now;
			now=0;
		}
	}
}
void dfs(int now,string s)
{
	if(now==SZ(s))
	{
		//cout<<s<<endl;
		add(s);
		return;
	}
	dfs(now+1,s);
	string t=s.substr(0,now);
	if(t[t.size()-1]=='+') return;
	t+='+';
	t+=s.substr(now,s.size()-now);
	//cout<<t<<"@@@@"<<endl;
	dfs(now+1,t);
}
int main()
{
	ios::sync_with_stdio(0);
	string s;
	cin>>s;
	dfs(1,s);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B_C = [[0,0] for _ in range(Q)]
for i in range(Q):
    B_C[i] = list(map(int,input().split()))

df = {}
original_sum = 0 
for a in A:
    if not a in df.keys():
        df[a] = 1
    else:
        df[a] += 1
    original_sum += a

result = []
now_sum = original_sum

for i in range(Q):
    if (B_C[i][0] in df.keys()):
        if (df[B_C[i][0]] > 0):
            now_sum += (B_C[i][1] -B_C[i][0]) * df[B_C[i][0]]
            if B_C[i][1] in df.keys():
                df[B_C[i][1]] += df[B_C[i][0]]
            else:
                df[B_C[i][1]] = df[B_C[i][0]]
            df[B_C[i][0]] = 0
    result.append(now_sum)

for i in range(Q):
    print(result[i])

Measured memory_bytes: 37112
#幅優先探索
from collections import deque
d=deque()
e=deque()
import sys
sys.setrecursionlimit(1000000000)
n=int(input())
start_node=0
querie=[]
edge={i:[]for i in range(1,n+1)}
for j in range(n-1):
    a,b=map(int,input().split())
    querie.append((a,b))
    edge[a].append(b)
    edge[b].append(a)
    if j==0:
        start_node=a  

d.append((start_node,0))

#はじめにdequeに入れておいて幅優先探索を行うものを決める。そして、塗り分けの結果はans_dictに保存する
#print(edge) 
ans_dict={i:{}for i in range(1,n+1)}
K=0
for some in edge.values():
    K=max(K,len(some))
    
#幅優先探索に使用する すでに訪れたか確認するためのリスト

visited=[False for i in range(n+1)]
visited[start_node]=True

#使う頂点の数を記録した
#nodeをリスト型にしたリストを返す
#start_nodeを記録しておく
def determine_edge_color(node,color):
    new_color=0
    for some in edge[node]:
        if visited[some]==False:
            visited[some]=True
            new_color+=1
            if new_color==color:
                new_color+=1
                ans_dict[node][some]=new_color
                ans_dict[some][node]=new_color
                e.append((some,new_color))
            else:
                ans_dict[node][some]=new_color
                ans_dict[some][node]=new_color
                e.append((some,new_color))
        else:
            pass
            
while d:
    for some in d:
        if visited[some[0]]==True:
            determine_edge_color(some[0],some[1])
        else:
            determine_edge_color(some[1],some[0])
    d=e
    e=deque()
    
#ans_dictの完成
print(K)
#答えの出力
for item in querie:
    a,b=item[0],item[1]
    print(ans_dict[a][b])


Measured memory_bytes: 80664
while True:
    try:
        s=raw_input()
    except EOFError:
	break
    cj,ci=0,0
    for i in range(len(s)):
        if s[i:i+3]=="JOI":
	    cj+=1
        elif s[i:i+3]=="IOI":
	    ci+=1
    print cj
    print ci

Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
long long a,b[100005],ans;
bool now=1;
int main()
{
	cin>>a;
	for(int s=0;s<a;s++)cin>>b[s];
	sort(b,b+a);
	for(int s=0;s<a;s++)
	{
		if(b[s]==b[s+1])now=!now;
		else
		{
			if(now)
			ans++;
			now=1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
 //pair<pair<int,int>,int> p[100001];
signed main() {
 int n,k;
 cin>>n>>k;
 if(2*k>n+1){
   cout<<-1;
   return 0;
 }
 if(n%2==1){
   int t=(n+1)/2 -k;
   int a=n,b=n+(n+1)/2;
   int bo=b;
   for(int i=0;i<n;i++){
     cout<<a-t<<' '<<b-t<<' '<<a+b-t<<endl;
     a++;b++;
     if(a==bo)a-=n;
   }
 }else{
   int t=n/2 -k;
   int a=n,b=n+n/2;
   int bo=b;
   for(int i=0;i<n/2;i++){
     cout<<a-t<<' '<<b-t<<' '<<a+b-t<<endl;
     a++;b++;
     if(a==bo)a-=n;
 }
 for(int i=0;i<n/2;i++){
     cout<<a-t<<' '<<b-t<<' '<<a+b-t+1<<endl;
     a++;b++;
     if(a==bo)a-=n;
 }
 }
return 0;
}


Measured memory_bytes: 2304
n = int(input())
travel_plan = [tuple(map(int, input().split())) for i in range(n)]
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y > t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 18092
s = input()
len_s = len(s)
duplication = False

for i in range(len_s - 1):
    for j in range(i, len_s-1):
        if s[i] == s[j+1]:
            print("no")
            duplication = True
            break
    if duplication:
        break
if not duplication:
    print("yes")


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
#define MOD 1000000007
typedef unsigned long long ull;
typedef long long ll;
using namespace std;


int main(){
	int n,sum = 0,num = 0;
	double ave = 0,memo;
	cin >> n;
	int a[n];
	
	rep(i,0,n){
		cin >> a[i];
		sum += a[i];
	}
	
	ave = (double)sum / (double)n;
	
	rep(i,0,n){
		if(i == 0){
			memo = abs((double)a[i] - ave);
			num = i;
		}
		else if(abs((double)a[i] - ave) < memo){
			memo = abs((double)a[i] - ave);
			num = i;
		}
	}
	
	cout << num << endl;
	
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

char s[100010];
const char ans[2][10] = {"First" , "Second"};

int main(){
	scanf("%s" , s);
	int n = 0;
	while(s[n] != 0) ++n;
	printf("%s\n" , (s[0] == s[n-1]) ^ (n % 2 == 1) ? ans[0] : ans[1]);
	return 0;
}


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

int main()
{
    int a, b;

    cin >> a;
    cin >> b;

    int res, sub, mult;

    res = a + b;
    sub = a- b;
    mult = a * b;

    if(res < sub) {
        res = sub;
    }
    if(res < mult) {
        res = mult;
    }

    cout << res;
    return 0;
}

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

int main(){
    while(1){
    
    int H,W;
    
    cin>>H>>W;
    
    if( H == 0 && W == 0 ) break;
    
    for ( int i = 0; i < H; i++ ){
        for (int j = 0; j < W; j++){
            
            if ( i == 0 || i == H - 1 || j == 0 || j == W - 1 ) cout<<"#";
            
            else cout<<".";
        }
            
            cout<<endl;
            
        }
        
        cout<<endl; 
    }
    
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long K,N;
  cin>>K>>N;
  long long sum=0;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    long long data;
    cin>>data;
    A.at(i)=data-sum;
    sum=sum+A.at(i);
  }
  A.at(0)=A.at(0)+(K-sum);
  sort(A.begin(),A.end());
  cout<<K-A.at(N-1)<<endl;
}
  

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  string s;
  cin >> s;
  ll a;

  if(s=="RRR")a=3;
  else if(s=="RRS" || s=="SRR")a=2;
  else if(s=="SSS")a=0;
  else a=1;
  cout << a << endl;


}

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

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

    ll ans1 = a * c;
    ll ans2 = a * d;
    ll ans3 = b * c;
    ll ans4 = b * d;

    ll ans = max(ans1, ans2);
    ans = max(ans, ans3);
    ans = max(ans, ans4);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
 
int main() {
  int N,M;
  cin >> N >> M;
  Graph G(N);
  for (int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  vector<int> point(N);
  for (int i=0;i<N;i++){
    point[i]=i;
  }
  int ans=0;
  do {
    bool path=true;
    for (int i=0;i<N-1;i++){
      bool path2=true;
      for (int j=0;j<G[point[i]].size();j++){
        if (G[point[i]][j]==point[i+1]){
          path2=false;
        }
      }
      if (path2){
        path=false;
      }
    }
    if (path){
      ans++;
    }
  } while(next_permutation(point.begin()+1,point.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    long k = scanner.nextLong();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = scanner.nextLong();
    }
    scanner.close();
    int count = 0;
    for (; ((long) 1 << (count + 1)) <= k; count++)
      ;
    long x = 0;
    for (; count >= 0; count--) {
      long tmp = x + ((long) 1 << count);
      if (tmp > k)
        continue;
      long t = 0;
      long u = 0;
      for (long l : a) {
        t += l ^ tmp;
        u += l ^ x;
      }
      if (t >= u) {
        x = tmp;
      }
    }
    long ans = 0;
    for (long l : a) {
      ans += l ^ x;
    }
    System.out.println(ans);

  }

}


Measured memory_bytes: 60796
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A,B,C;
        A=sc.nextInt();
        B=sc.nextInt();
        C=sc.nextInt();
        int a;
        for( a=A;a<B*A;a++){
            int num = a%B;
            if(num==C&&a%A==0) {
                System.out.println("YES");
                break;
            }
        }
        if(a==B*A) System.out.println("NO");
         }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=1e5+5;
ll i,j;

/*


*/
ll dp[N];
void solve(){
	in2(n,W);
	for(ll item=1;item<=n;item++){
		in2(w,v);
		for(i=W;i>=w;i--){
			dp[i]=max(dp[i-w]+v,dp[i]);
		}
	}    
	ll best=0;
	for(i=0;i<=W;i++){
		best=max(best,dp[i]);
	}
	ce(best);
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

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

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    for(auto e : s) ans += (e == '+' ? 1 : -1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	string s;
	int n;
	cin >>  n >> s;
	int a;
	int c;
	fi(s.size()) {
		c = s[i] + n;
		if (c > 90) {
			c -= 26;
		}
		printf("%c", c);
	}


	

	
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    mod = 10 ** 9 + 7
    s = list(input())
    n = len(s)
    s.reverse()

    dp = [[0] * 13 for _ in range(n + 1)]
    dp[0][0] = 1

    mul = 1
    for i, c in enumerate(s):
        for j in range(10):
            if (c.isdigit() and int(c) == j) or c == '?':
                m = (j * mul) % 13
                for k in range(13):
                    dp[i + 1][(m + k) % 13] += dp[i][k]
        for k in range(13):
            dp[i + 1][k] = dp[i + 1][k] % mod
        mul *= 10
        mul %= 13
    print(dp[n][5])


if __name__ == '__main__':
    main()


Measured memory_bytes: 65656
import java.util.PriorityQueue;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] V = new int[N];
        for (int i = 0; i < V.length; ++i) {
            V[i] = sc.nextInt();
        }

        System.out.println(solve(V, K));

        sc.close();
    }

    static int solve(int[] V, int K) {
        int result = 0;
        for (int leftLength = 0; leftLength <= V.length; ++leftLength) {
            for (int rightLength = 0; rightLength <= Math.min(V.length, K) - leftLength; ++rightLength) {
                int sum = 0;
                PriorityQueue<Integer> negatives = new PriorityQueue<>();
                for (int i = 0; i < leftLength; ++i) {
                    sum += V[i];
                    if (V[i] < 0) {
                        negatives.offer(V[i]);
                    }
                }
                for (int i = V.length - rightLength; i < V.length; ++i) {
                    sum += V[i];
                    if (V[i] < 0) {
                        negatives.offer(V[i]);
                    }
                }

                for (int i = 0; i < K - leftLength - rightLength; ++i) {
                    if (!negatives.isEmpty()) {
                        sum -= negatives.poll();
                    }
                }

                result = Math.max(result, sum);
            }
        }

        return result;
    }
}

Measured memory_bytes: 38804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  cout << (1 << m) * (1900 * m + (n - m) * 100) << endl;
}

Measured memory_bytes: 3628
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */



#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int>arr(M);
  if (N >= M)
   cout<<0;
  else {
    for (int i = 0; i < M; i++)
     cin>>arr[i];
    sort(arr.begin(), arr.end());
    vector<int>dif(M - 1);
    for (int i = 0; i < M - 1; i++) {
      dif[i] = arr[i + 1] - arr[i];
    }
    sort(dif.begin(), dif.end());
    int ans = 0;
    for (int i=0; i<(M-N); i++)
      ans += dif[i];
    cout<<ans;
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=2e5+10;
int dp[maxn];
int a[maxn];
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF) {
        for(int i=1;i<=n;i++)scanf("%d",&a[i]);
        memset(dp, 0, sizeof(dp));
        for(int i=n;i>=1;i--)
            dp[a[i]]=dp[a[i]+1]+1;
        int ma=0;
        for(int i=1;i<=n;i++)ma=max(ma,dp[a[i]]);
        printf("%d\n",n-ma);
    }
    return 0;
}

Measured memory_bytes: 1792