akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = sc.nextInt();
		int s[] = new int[n];
		int t[] = new int[n];
		int cs[] = new int[n];
		for(int i=0; i<n; i++) {
			s[i] = sc.nextInt();
			t[i] = sc.nextInt();
			cs[i] = sc.nextInt();
		}
		sc.close();
		int len = 0;
		for(int i=0; i<t.length; i++) {
			if(len < t[i]) len = t[i];
		}
		int ary1[] = new int[len*2+2]; //0.5を考慮するため*2
		int ary2[] = new int[len*2+2];
		
		for(int i=1; i<=c; i++) {
			Arrays.fill(ary1, 0);
			for(int j=0; j<n; j++) {
				if(cs[j] == i) {
					ary1[s[j]*2-1]++;
					ary1[t[j]*2]--; // T除く
				}
			}
			for(int j=1; j<ary1.length; j++) {
				ary1[j] += ary1[j-1];
			}
			for(int j=0; j<ary1.length; j++) {
				if(ary1[j] > 0) ary2[j]++;
			}
		}
		
		int ans = 0;
		for(int i=0; i<ary2.length; i++) {
			if(ans < ary2[i]) ans = ary2[i];
		}
		
		System.out.println(ans);
	}

}

Measured memory_bytes: 93456
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int d[] = new int[N];
    for(int i=0;i<N;i++){
      d[i]=sc.nextInt();
    }
    Arrays.sort(d);
    int h = N/2;
    int midu=d[h];
    int midl=d[h-1];
    System.out.println(midu-midl);
  }
  

  
}

Measured memory_bytes: 50252
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    VI v(n);
    VI c(n);

    for(int i=0; i<n ; ++i)cin >> v[i];
    for(int i=0; i<n ; ++i)cin >> c[i];


    for(int i=0; i<n ; ++i){
        if(v[i] - c[i] > 0)ans += v[i] - c[i];
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    int s;
    cin >> s;
    string ans;
    ans = s >= 1000 ? "ABD" : "ABC";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main() {
    ll n;
    cin >> n;
    ll ans = modpow(10, n, MOD) - 2*modpow(9, n, MOD) + modpow(8, n, MOD);
    ans %= MOD;
    if (ans<0) ans += MOD;
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	int K = rei();
	int T = N;
	int need = K;
	double c = 1;
	double ans = 0;
	while(T){
		ans += c * max(0,T-need+1);
		T = min(T,need-1);
		need = (need+1) / 2;
		c *= 0.5;
	}
	ans /= N;
	printf("%1.10lf\n",ans);
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<int> ans;
  method(func,void,int p){
    static int cnt = 0;
    if(p==-1){
      cout << cnt++ << ":";
      for(auto itr=ans.rbegin();itr!=ans.rend();++itr){
        cout << " " << *itr;
      }
      cout << endl;
      return;
    }
    func(p-1);
    ans.emplace_back(p);
    func(p-1);
    ans.pop_back();
  };
  func(n-1);
}



Measured memory_bytes: 3264
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
	int v[3]; cin >> v[0];
	while (cin >> v[0] >> v[1] >> v[2]) {
		sort (v, v + 3);
		cout << (*v**v + *(v + 1)**(v + 1) == *(v + 2)**(v + 2) ? "YES" : "NO") << endl;
	}
}

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

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

  int n, a, b;
  cin >> n >> a >> b;

  string s;
  cin >> s;

  int now = 0, rank = 1;
  for (auto c : s) {
    int d = c - 'a';
    bool ok = true;

    switch (d) {
      case 0:
        if (now < a + b) ++now;
        else ok = false;
        break;
      case 1:
        if (now < a + b && rank <= b) ++rank, ++now;
        else ok = false;
        break;
      case 2:
        ok = false;
        break;
    }

    if (ok) puts("Yes");
    else puts("No");
  }

  return (0);
}

Measured memory_bytes: 3772
MOD=10**9+7
L=input()
K=len(L)
dp=[[0,0] for i in range(K+1)]
dp[0][0]=1
for i in range(K):
    if(L[i]=='0'):
        dp[i+1][0]=dp[i][0]
        dp[i+1][1]=dp[i][1]*3%MOD
    elif(L[i]=='1'):
        dp[i+1][0]=dp[i][0]*2%MOD
        dp[i+1][1]=(dp[i][1]*3%MOD+dp[i][0])%MOD
print(sum(dp[K])%MOD)

Measured memory_bytes: 19640
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

pair<ll,ll> q[100005];

void solve()
{
    IN(n, k, s);
    if (s == 1000000000LL)
    {
        rep(i, k)
        {
            cout << s << " ";
        }
        rep(i, n-k)
        {
            cout << 1 << " ";
        }
        return;
    }
    rep(i, k)
    {
        cout << s << " ";
    }
    rep(i, n-k)
    {
        cout << s+1 << " ";
    }
    cout << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	int n;
	double G;
	Item[] item;
	int[] perm, ans;
	boolean[] used;

	void run() {
		for (;;) {
			n = sc.nextInt();
			if (n == 0) return;
			item = new Item[n];
			ans = new int[n];
			perm = new int[n];
			used = new boolean[n];
			G = Double.MAX_VALUE;

			for (int i = 0; i < n; i++) item[i] = new Item(sc.next(), sc.nextInt(), sc.nextInt());

			permutation(0, 0);

			for (int i = n - 1; i >= 0; i--) System.out.println(item[ans[i]].name);
		}
	}

	void permutation(int pos, int weight) {
		if (pos == n) {
			double tmp = 0;
			for (int i = 0; i < n; i++) tmp += item[perm[i]].w * (n - i);
			if (tmp / weight < G) {
				G = tmp / weight;
				for (int i = 0; i < n; i++) ans[i] = perm[i];
			}
		}
		for (int i = 0; i < n; i++) {
			if (!used[i]) {
				if (weight > item[i].s) {
					return;
				} else {
					perm[pos] = i;
					used[i] = true;
					permutation(pos + 1, weight + item[i].w);
					used[i] = false;
				}
			}
		}
	}
	
	class Item {
		String name;
		int w;
		int s;

		public Item(String name, int w, int s) {
			super();
			this.name = name;
			this.w = w;
			this.s = s;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}

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


int main(){
    string str;
    cin >> str;
    int n = str.size();

    if(str[0] == 'A'){
        int cnt = 0;
        for(int i=2;i<n-1;i++){
            if(str[i] == 'C'){
                cnt++;
            }
        }
        if(cnt == 1){
            cnt = 0;
            for(int i=0;i<n;i++){
                if(islower(str[i])){
                    cnt++;
                }
            }
            if(cnt == n-2){
                cout << "AC" << endl;
                exit(0);
            }
        }
    }
    cout << "WA" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll ans=len(s);
    rep(i,len(s)){
      if(i+1<=len(s) && s[i]!=s[i+1]){
        ans=min(ans,max(i+1,len(s)-i-1));
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long int> num(n + 1, 0);
  vector<long long int> ball;
  int temp;
  for(int i = 0; i < n; ++i){
    cin >> temp;
    ball.push_back(temp);
    num[temp]++;
  }
  long long int ans = 0;
  for(int i = 1; i < n + 1; ++i) ans += num[i] * (num[i] - 1) / 2;
  for(int i = 0; i < n; ++i) cout << ans - (num[ball[i]] - 1) << endl;

}


Measured memory_bytes: 5872
a,b,c=map(int,input().split())

def total(x):
    b=0
    while x > 0:
        a=x%10
        b +=a
        x =x//10
    
    return b    
ans=0
for i in range(1,a+1):
  sum=total(i)
  if sum >= b and sum <= c:
    ans +=i
print(ans)    

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep (i, n) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  P(ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef grief
#define IOS
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) =",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<'\n';}
template<typename I,typename ...T> void _DO(I&&x,T&&...tail){cerr<<x<<'\n';_DO(tail...);}
#else
#define debug(...)
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0);
#endif
typedef long long ll;
ll n;
ll arr[110],brr[110];
ll que(int x){
	ll r=0;
	for(int i=1;i<=x;i++)	r+=arr[i];
	for(int i=x;i<=n;i++)	r+=brr[i];
	return r;
}
int main(){
	IOS
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	for(int i=1;i<=n;i++)
		cin>>brr[i];
	ll ma=0;
	for(int i=1;i<=n;i++)
		ma=max(ma,que(i));
	cout<<ma<< '\n';
}

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

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

  vector<int> X(N), Y(N);
  rep(i,0,N-1) {
    cin >> X[i];
    Y[i] = X[i];
  }

  sort(X.begin(), X.end());
  int L = X[N/2-1], R = X[N/2];

  rep(i,0,N-1) {
    if (Y[i] <= L) cout << R << endl;
    else if (R <= Y[i]) cout << L << endl;
  }

  return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };



int main() {
	int n, i, j;
	cin >> n;
	vl a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	ll pre = 0;
	bool flag = false;
	vl b;
	for (i = 0; i < n; i++) {
		if (flag) {
			pre = a[i];
			flag = false;
		}
		else {
			if (pre == a[i]) {
				b.push_back(a[i]);
				if (b.size() == 2) {
					break;
				}
				flag = true;
				pre = a[i];
			}
			else {
				pre = a[i];
			}
		}
	}
	if (b.size() == 2) {
		cout << b[0] * b[1] << endl;
	}
	else {
		cout << "0" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
int const MAX_N = 41;

int N, ans, cost[MAX_N], f[MAX_N];
map<string,int> h;
vector<int> G[MAX_N];
bool used[MAX_N], edge[MAX_N][MAX_N];

void add_edge(const string& a, const string& b, int& id, int cost_){
	if( !h.count(a) ) h[a] = id++;
	int u = h[a];
	if( !h.count(b) ) h[b] = id++;
	int v = h[b];
	G[u].push_back( v );
	G[v].push_back( u );
	edge[u][v] = edge[v][u] = true;
	cost[u] = cost_;
}

// k := テ、ツサツ甘ィツヲツ凝」ツ?ヲテ」ツ??」ツつ凝ゥツ?づァツつケ, sum := テァツキツ湘・ツ陳?
void solve(int k, int sum){
	if( N == k ){
		ans = max(ans, sum);
	}else{
		// ans テ」ツつ暗」ツつ甘」ツ??」ツ??ィツァツ」テ」ツ?古ィツヲツ凝」ツ?、テ」ツ?凝」ツつ嘉」ツ?ェテ」ツ??」ツ?ィテ」ツ??
		if( sum + f[k] <= ans ) return;
		
		if( G[k].size() == 0 ){ // テヲツャツ。テヲツ閉ー 0 テ」ツ?ョテ」ツ?ィテ」ツ??
			solve(k+1, sum + cost[k]);
			return ;
		}
		
		// is_used := テゥツ?づァツつケ k テ」ツつ津、ツスツソテ」ツ?暗」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ??
		bool is_used = true;
		for(int i=0 ; i < k ; i++ ){
			if( used[i] && edge[i][k] ) is_used = false;
		}
		if( is_used ){
			used[k] = true;
			solve(k+1, sum + cost[k]);
			used[k] = false;
			
			bool flag = true;
			for(int i=k+1 ; i < N ; i++ ){
				if( edge[k][i] ) flag = false;
			}
			if( !flag )
				solve(k+1, sum);
		}else{
			solve(k+1, sum);
		}
	}
}

int main(){
	while( cin >> N , N ){
		h.clear();
		for(int i=0 ; i < MAX_N ; i++ ){
			G[i].clear();
			used[i] = false;
			f[i] = 0;
			for(int j=0 ; j < MAX_N ; j++ ){
				edge[i][j] = false;
			}
		}
		int id = 0;
		
		for(int i=0 ; i < N ; i++ ){
			string A, D;
			int B, C;
			cin >> A >> B >> C;
			
			if( !h.count(A) ) h[A] = id++;
			int u = h[A];
			cost[u] = B;
			for(int j=0 ; j < C ; j++ ){
				cin >> D;
				
				if( !h.count(D) ) h[D] = id++;
				int v = h[D];
				G[u].push_back( v );
				G[v].push_back( u );
				edge[u][v] = edge[v][u] = true;
			}
		}
		for(int i = N-1 ; i >= 0 ; i-- ){
			f[i] += f[i+1] + cost[i];
		}
		
		ans = cost[0];
		used[0] = true;
		solve(1, cost[0]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1276
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#超えない最大の三角数
tmp = 0
ls = [0]
for i in range(1,41):
    tmp += i
    ls += [i]*(i+1)

#print(ls[:10])

N = int(input())
if N == 1:
    print(0)
else:
    fac = factorization(N)
    ans = 0
    for p in fac:
        ans += ls[p[1]]
        #print(p)
    print(ans)


Measured memory_bytes: 63404
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		System.out.println(Math.max(C-(A-B), 0));
	}
}

Measured memory_bytes: 21716
#include <cstdio>

int main(void)
{
  int i,j,H,W;

  for(;;){
    scanf("%d %d", &H, &W);
    if(H==0&&W==0) break;
    for(i=0;i<H;i++){
      if(i==0||i==H-1){
	for(j=0;j<W;j++){
	  if(j!=W-1) printf("#");
	  if(j==W-1) printf("#\n");
	}
	continue;
      }
      for(j=0;j<W;j++){
	if(j==0) printf("#");
	if(j==W-1) printf("#\n");
	if(j!=0&&j!=W-1) printf(".");
      }
    }
    printf("\n");
  }

  return 0;
}


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

int main()
{
    int a, b, c, d;

    cin >> a>>b>>c>> d;

    if((a+b)>(c+d))
    {
        cout << "Left" << endl;
    }
    else if((a+b)<(c+d))
    {
        cout << "Right" << endl;
    }
    else if((a+b)==(c+d))
    {
        cout << "Balanced" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
int a[N], b[N];
priority_queue<pii> que;

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	REP(i, n) scanf("%d", b+i);
	REP(i, n) que.emplace(b[i], i);
	ll ans = 0;
	while(que.size()){
		pii tp = que.top(); que.pop();
		int i = tp.second;
		int dif = b[i] - a[i];
	 	int stp = b[(i+n-1)%n] + b[(i+1)%n];
		if(dif >= stp){
			int cnt = dif / stp;
			DEBUG("[%d] = %d - %d\n", i, b[i], stp * cnt);
			b[i] -= stp * cnt;
			que.emplace(b[i], i);
			ans += cnt;
		} else if (a[i] != b[i]) {
			printf("-1\n");
			return 0;
		}
	}
	bool ok = true;
	REP(i, n) if(a[i] != b[i]) ok = false;
	if(!ok) ans = -1;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3956
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    double r = din();
    printf("%lf %lf\n", r * r * M_PI, 2 * r * M_PI);
    return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n, a, b;
	cin >> n >> a >> b;
	if (!a && !b) {
		cout << 0 << endl;
		return 0;
	}
	ll c1 = n / (a + b);
	n %= (a + b);
	ll c2 = min(n, a);
	ll ans = c1 * a + c2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
A_N = list(map(int, input().split()))
A_N = [i for i in A_N if i % 2 == 0]
# print(A_N)
B_N = [i for i in A_N if i % 3 == 0 or i % 5 == 0]
# print(B_N)
if len(A_N) == len(B_N):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
import sys

N=input()

X=[]
for _ in range(N):
    x,l=map(int, sys.stdin.readline().split())
    X.append((x-l,x+l))

X.sort(key=lambda x:x[1] )

ans=0
end=float("-inf")
for l,r in X:
    if end<=l and end<r:
        ans+=1
        end=r

print ans


Measured memory_bytes: 45212
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

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

limit = sum(A) / (4 * M)

ans = [a for a in A if a >= limit]
if len(ans) >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 65328
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)
int main(void)
{

    int N;
    scanf("%d", &N);
    double *A;
    A = (double *)malloc(sizeof(double) * N);
    rept(i, 0, N)
    {
        scanf("%lf", &A[i]);
    }
    double sumofA = 0.0;
    rept(i, 0, N)
    {
        sumofA += (1.0 / A[i]);
    }
    sumofA = 1.0 / sumofA;

    printf("%lf", sumofA);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

typedef map<int, vector<int> > graph;

int main(){
    int N,Q,a,b;
    graph g;
    cin >> N >> Q;
    for(int i=1;i<N;i++){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int p[N+1];
    for(int i=1;i<=N;i++)
        p[i]=0;
    for(int i=0;i<Q;i++){
        int x,val;
        cin >> x >> val;
        p[x] += val;
    }
    
    int ans[N+1];

    queue< tuple<int,int,int> > que;
    tuple<int,int,int> q = make_tuple(1,0,-1);
    que.push(q);

    while(!que.empty()){
        tuple<int,int,int> q = que.front();
        que.pop();
        int v = get<0>(q);
        ans[v] = get<1>(q) + p[v];
        vector<int> edges = g[get<0>(q)];
        for(auto itr = edges.begin(); itr != edges.end(); itr++){
            if(*itr != get<2>(q)){
                tuple<int,int,int> qq = make_tuple(*itr,ans[v],v);
                que.push(qq);
            }
        }
    }
    for(int i=1;i<=N;i++){
        if(i<N)
            cout << ans[i] << " ";
        else
            cout << ans[i] << endl;
    }
}


Measured memory_bytes: 28900
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
using namespace std;

int main()
{
	int N,p;
	int sum = 0;
	vector<int> P;

	cin >> N;

	for (int i = 0; i <= N - 1; i++) {
		cin >> p;
		P.push_back(p);
	}
	sort(P.rbegin(), P.rend());
	P[0] = P[0] / 2;
	for (int n = 0; n <= N - 1; n++) {
		sum += P[n];
	}
	cout << sum << endl;
		return 0;
}

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

int main()
{
    string a,b,c;
    cin >> a >> b >> c;
    char d='a';
    for(int i=0;i<301;i++){
      if(d=='a'){
        if(a==""){
          break;
        }
        d=a[0];
        a=a.substr(1);
        continue;
      }
    if(d=='b'){
      if(b==""){
        break;
      }
      d=b[0];
      b=b.substr(1);
      continue;
    }
    if(d=='c'){
      if(c==""){
        break;
      }
      d=c[0];
      c=c.substr(1);
      continue;
    }
  }
  cout << char(d+'A'-'a') << endl;

    return 0;
}

Measured memory_bytes: 256
import scala.util.control.Breaks

object Main extends App {
  val abcInput = scala.io.StdIn.readLine()
  val abcArray =  abcInput.split(" ").map(_.toInt).toVector
  var a = abcArray(0)
  var b = abcArray(1)
  var c = abcArray(2)

  val k =  scala.io.StdIn.readInt()

  val br = new Breaks

  var count = 0
  var successFlg = false

  br.breakable {
    while(true) {
      if (count > k) {
        br.break()
      } else if (a < b && b < c) {
        successFlg = true
        br.break()
      } else {
        if(a >= b) {
          b = b * 2
        } else {
          c = c * 2
        }
        count = count + 1
      }
    }
  }

  if (successFlg) {
    println("Yes")
  } else {
    println("No")
  }

}

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

int main() {
  int K;
  cin>>K;
  string S;
  cin>>S;
  if(S.size()<=K){
    cout<<S<<endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
}

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

const int Maxn = 105;
const int Maxd = 10;
const int Inf = 2000000007;

int n;
int F[Maxn][Maxd];
int P[Maxn][Maxd + 1];
int res = -Inf;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < Maxd; j++)
			scanf("%d", &F[i][j]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= Maxd; j++)
			scanf("%d", &P[i][j]);
	for (int i = 1; i < 1 << Maxd; i++) {
		int cand = 0;
		for (int j = 0; j < n; j++) {
			int sam = 0;
			for (int k = 0; k < Maxd; k++)
				sam += bool(i & 1 << k) && F[j][k];
			cand += P[j][sam];
		}
		res = max(res, cand);
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int K;

int main() {
  cin >> K;

  vector<bool> visited(K, false);
  deque<pair<int, int>> que;
  que.push_back(make_pair(1, 1));
  // visited[1] = true;

  while (true) {
    auto p = que.front();
    que.pop_front();

    if (visited[p.first])
      continue;
    visited[p.first] = true;

    if (p.first == 0) {
      cout << p.second << endl;
      break;
    }

    if (!visited[(p.first * 10) % K]) {
      que.push_front(make_pair((p.first * 10) % K, p.second));
    }
    if (!visited[(p.first + 1) % K]) {
      que.push_back(make_pair((p.first + 1) % K, p.second + 1));
    }
  }

  return 0;
}

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

void solve()
{
    string s1, s2;
    cin >> s1 >> s2;
    vector<vector<int>> dp(s1.size() + 1, vector<int>(s2.size() + 1, 0));
    for (int i = 1; i <= s1.size(); i++)
    {
        for (int j = 1; j <= s2.size(); j++)
        {
            if (s1[i - 1] == s2[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string s="";
    int i=s1.size();
    int j=s2.size();
   
    // for(int i=0;i<=s1.size();i++)
    // {
    //     for(int j=0;j<=s2.size();j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }

    while(dp[i][j]!=0)
    {   
        
        if(s1[i-1]==s2[j-1])
        {
            // cout<<"Match:"<<i<<" "<<j<<endl;
            s+=s1[i-1];
            i--;
            j--;
        }
        else
        {
            // cout<<"Match:"<<i<<" "<<j<<endl;
            if(dp[i-1][j]>dp[i][j-1])
            {
                i=i-1;
            }
            else
            {
                j=j-1;
            }
            
        }
            
    }
    // cout<<s;
    reverse(s.begin(),s.end());
    cout<<s;
}

int32_t main()
{
    solve();
}

Measured memory_bytes: 70784
/********   In the name of Allah, the most gracious, the most merciful ********/
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int dp[n + 1][3];
    int a = 0, b = 0, c = 0;
    dp[0][0] = 0, dp[0][1] = 0, dp[0][2] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a >> b >> c;
        dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c + max(dp[i - 1][1], dp[i - 1][0]);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}


Measured memory_bytes: 1408
/**********************************************************
* @Author: 			   Kirito
* @Last Modified by:   Kirito
* @Remark:
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=411111;
//graph
int v[maxn],head[maxn],nxt[maxn],cnt,n,m;
//邻接表
void add(int x,int y){
    v[++cnt]=y;
    nxt[cnt]=head[x];head[x]=cnt;
    return;
}
//ans
int sig[maxn],book[maxn];

void bfs(){
    queue<int> box;
    box.push(1);
    while(!box.empty()){
        int be=box.front();box.pop();
        for(int i=head[be];i!=-1;i=nxt[i]){
            if(book[v[i]]==0){
                book[v[i]]=1;
                sig[v[i]]=be;
                box.push(v[i]);
            }
        }
    }
    return;
}

int main()
{
    FAST;
    cin>>n>>m;
    CSE(head,-1);CSE(nxt,-1);CSE(sig,0);CSE(book,0);
    for(int i=0;i<m;i++){
        int x,y;cin>>x>>y;
        add(x,y);add(y,x);
    }
    bfs();
    bool fl=true;
    for(int i=2;i<=n;i++){
        if(sig[i]==0){
            fl=false;
            break;
        }
    }
    if(fl){
        cout<<"Yes"<<endl;
        for(int i=2;i<=n;i++) cout<<sig[i]<<endl;
    }
    else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 11684
#include<stdio.h>
int main(){
	unsigned int x, sum=0, i, j;
	scanf("%u", &x);
	
	 j = x;
	
	for(; x!=0; ){
		i = x%10;
		x = x/10;
		sum = sum+i;
	}
	
	
	if(j % sum == 0){
		printf("Yes\n");
	}
	
	else{
		printf("No\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int h, w, a, b, i, j;
	
	scanf("%d%d%d%d", &h, &w, &a, &b);
	
	for (i = 0; i < b; i++) {
		for (j = 0; j < a; j++)
			putchar('0');
		for (j = 0; j < w-a; j++)
			putchar('1');
		putchar('\n');
	}
	
	for (i = 0; i < h-b; i++) {
		for (j = 0; j < a; j++)
			putchar('1');
		for (j = 0; j < w-a; j++)
			putchar('0');
		putchar('\n');
	}
	
	return 0;
}

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

//配列出力処理
void output(int a[], int n) {
  rep(i, n) {
    if (i > 0) {
      // cout << " ";
      printf(" ");  //要素間に空白を入れる
    }
    // cout << a[i];
    printf("%d", a[i]);  //フォーマット指定子 %c char %d int10進数
  }
  // cout << endl;
  printf("\n");
}

// Insertion Sort
void selectionSort(int a[], int n) {
  int cnt = 0;
  rep(i, n) {
    int minIndex = i;
    for (int j = i; j < n; j++) {
      if (a[j] < a[minIndex]) {
        minIndex = j;
      }
    }
    swap(a[i], a[minIndex]);
    if (i != minIndex) cnt++;
  }
  output(a, n);
  cout << cnt << endl;
}

// O(n^2)
int main() {
  int n;
  int a[1000];
  cin >> n;
  rep(i, n) cin >> a[i];
  selectionSort(a, n);
  return 0;
}



Measured memory_bytes: 3252
a,b,c= map(int, input().split())
k = int(input())
for i in range(k):
    if a < b < c:
        print("Yes")
        exit()
    if b >= c:
        c *= 2
    elif a >= b:
        b *= 2
if a < b < c:
        print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  string s;
  cin >> s;

  bool f = true;
  bool includeC = false;
  for (int i = 0; i < s.length(); i++) {
    if (i == 0 && s[i] != 'A') {
      f = false;
      break;
    }

    if (2 <= i && i <= s.length() - 2 && s[i] == 'C') {
      if (includeC) {
        f = false;
        break;
      }
      includeC = true;
    }
    if (i != 0 && s[i] != 'C' && !('a' <= s[i] && s[i] <= 'z')) {
      f = false;
      break;
    }
  }
  // cout << f << includeC << endl;
  if (f && includeC) {
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }
  return 0;
}


Measured memory_bytes: 504
A = input()
B = input()
l = max(len(A), len(B))

if len(A) > len(B):
    print('GREATER')
elif len(A) < len(B):
    print('LESS')
elif A > B:
    print('GREATER')
elif A < B:
    print('LESS')
else:
    print('EQUAL')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int cnt=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]%2==0)cnt++;
    }
    if(cnt==n)cout<<"second"<<endl;
    else cout<<"first"<<endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
int num[26];

int main(void){
	string a;
	cin >> a;

	const int n = a.size();
	ll ans = 1LL * n * (n+1) / 2LL +1LL;

	rep(i,n) num[a[i]-'a']++;

 	rep(i,26) ans -= 1LL * num[i] * (num[i] + 1) /2LL;
 	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long int ll;

const ll MAXN = 10;

vector < bool > used(MAXN, false);
vector < vector < ll > > adj(MAXN, vector < ll > ());

ll ans = 0, n, m;

void bfs(ll u){
  used[u] = true;
  for(auto to : adj[u]){
    if(!used[to]){
      bfs(to);
      used[to] = false;
    }
  }
  bool ok = true;
  for(int i = 1; i <= n; i++){
    if(!used[i]) ok = false;
  }
  if(ok) ans++;
}

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

  cin >> n >> m;
  for(int i = 0; i < m; i++){
    ll u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  bfs(1);

  cout << ans << '\n';
}


Measured memory_bytes: 256
N, M = map(int, input().split())

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

arr.sort()

prev = 0
ans = 0
for b, a in arr:
  if prev <= a:
    ans += 1
    prev = b

print(ans)

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=1e5+5;
ll dp[mxn][4];
// 0 'A' 1 'B' 2 'C' 3, read "ABC" from left to right
void add(ll &a, ll b){
	a%=MOD; b%=MOD; a+=b; a%=MOD;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	memset(dp,0LL,sizeof(dp));
	dp[0][0]=1LL;
	int n=s.length();
	for(int i=0; i<n; i++){
		if(s[i]=='A'){
			for(int j=0; j<4; j++)add(dp[i+1][j],dp[i][j]);
			add(dp[i+1][1],dp[i][0]);
		}else if(s[i]=='B'){
			for(int j=0; j<4; j++)add(dp[i+1][j],dp[i][j]);
			add(dp[i+1][2],dp[i][1]);
		}else if(s[i]=='C'){
			for(int j=0; j<4; j++)add(dp[i+1][j],dp[i][j]);
			add(dp[i+1][3],dp[i][2]);
		}else{
			for(int j=0; j<4; j++){
				add(dp[i+1][j],3*dp[i][j]);
				if(j<3)add(dp[i+1][j+1],dp[i][j]);
			}
		}
	}
	cout << dp[n][3] << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  int N,H,i,a,b,c;scanf("%d%d",&N,&H);
  pair<int,bool> K[N<<1];
  for(i=0;i<N;i++){
    scanf("%d%d",&a,&b);
    K[i] = make_pair(b,1);
    K[N+i] = make_pair(a,0); 
  }
  sort(K,K+(N<<1),greater<pair<int,bool>>());
  c = 0;
  for(i=0;i<(N<<1);i++){
    if(K[i].second == 1){
      H -= K[i].first;
      c++;
      if(H <= 0) break;
    }
    else{
      c += (H-1)/K[i].first+1;
      break;
    }
  }
  printf("%d\n",c);
}

Measured memory_bytes: 5360
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int H,W;

int main(){
    cin>>H>>W;
    char c[H][W];
    rep(i,H){
        rep(j,W){
            cin>>c[i][j];
        }
    }
    rep(i,H+2){
        rep(j,W+2){
            if(i==0||i==H+1||j==0||j==W+1){
                cout<<'#';
            }
            else{
                cout<<c[i-1][j-1];
            }
        }
        out("");
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

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

int main(){
	int a, b;

	scanf("%d %d", &a, &b);
	printf("%d\n", a*b - 1*a - 1*b + 1);

	return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int N;
  string s;
  cin >> N;
  cin >> s;
  int x = 0, ans = 0;
  REP(i, N){
    if(s[i] == 'I'){
      x++;
    }
    else{
      x--;
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    ll a,b;
    cin>>a>>b;
    if((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

unsigned long long comb(long long n, long long r) {
  if (r == 0) return 1;
  else if (r == 1) return n;

  int numerator[r];
  int denominator[r];

  for (int k = 0; k < r; k++)
  {
      numerator[k] = n - r + k + 1;
      denominator[k] = k + 1;
  }

  for (int p = 2; p <= r; p++)
  {
      int pivot = denominator[p - 1];
      if (pivot > 1)
      {
          int offset = (n - r) % p;
          for (int k = p - 1; k < r; k += p)
          {
              numerator[k - offset] /= pivot;
              denominator[k] /= pivot;
          }
      }
  }

  unsigned long long result = 1;
  for (int k = 0; k < r; k++)
  {
      if (numerator[k] > 1) result *= numerator[k];
  }

  return result;
}

int main() {
  int n;
  cin >> n;
  int count = n;
  long long temp,a,b;
  std::vector<long long> v;
  for (size_t i = 0; i < count; i++) {
    cin >> temp;
    v.push_back(temp);
  }
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 1; i < count; i++) {
    if (i == count - 1) {
      a = v[0];
      b = v[i];
    } else if (v[i] <= v[0]/2) {
      a = v[0];
      if (v[0]/2 - v[i] < v[i-1] - v[0]/2) b = v[i];
      else b = v[i-1];
      break;
    }
  }
  cout << a << ' ' << b << endl;
}


Measured memory_bytes: 1400
#define loop(i, n) for (int i = 0; i < n; i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
const ll m = 1e9 + 7;

ll exp_mod(ll a, ll n) {
	if (n == 0)
		return 1;
	else {
		ll res = exp_mod(a, n / 2);
		res = (res * res) % m;
		if (n % 2 != 0)
			res = (res * a) % m;
		return res;
	}
}

int main() {


	int n;	ll lcm = 1, final = 0;	cin >> n;
	vector <ll> v(n);		map <ll, ll> p;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		ll temp = v[i];
		for (int i = 2; i * i <= temp; i++) {
			ll cnt = 0;
			while (temp % i == 0) {
				temp /= i;
				cnt++;
			}
			if (cnt)
				p[i] = max(p[i], cnt);
			if (temp == 1)		break;
		}
		if (temp > 1)	p[temp] = max(p[temp], (ll)1);
	}
	for (auto &i : p) {
		lcm = (lcm * exp_mod(i.first, i.second)) % m;
	}
	for (int i = 0; i < n; i++) {
		final += (lcm * exp_mod(v[i], m - 2)) % m;
		final %= m;
	}
	cout << final << endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    if(S == "SAT"){
        cout << 1 << endl;
    } else if(S == "SUN"){
        cout << 7 << endl;
    } else if(S == "MON"){
        cout << 6 << endl;
    } else if(S == "TUE"){
        cout << 5 << endl;
    } else if(S == "WED"){
        cout << 4 << endl;
    } else if(S == "THU"){
        cout << 3 << endl;
    } else if(S == "FRI"){
        cout << 2 << endl;
    }
}


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

int main() {
  char c;

  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256