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

#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007


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

bool check(int x,int y)
{
	return x>=0 && y>=0 && x<=2000 && y<=2000;
}
int fun()
{
	static int num = 16;
	return num--;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,m,x;
	cin>>n>>m>>x;
	vector<ll>cost(n);
	vector<vector<ll>>kn(n);
	for(ll i=0;i<n;i++)
	{
		// ll c;
		cin>>cost[i];
		
		vector<ll>h;
		for(ll j=0;j<m;j++)
		{
			ll a;
			cin>>a;
			h.pb(a);
		}
		kn[i]=h;
	}
	ll ans=LLONG_MAX;
	for(ll i=0;i<(1<<n);i++)
	{
		vector<ll>sum(m,0);
		ll net=0;
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				net+=cost[j];
				for(int k=0;k<m;k++)
					sum[k]+=kn[j][k];
			}
		}
		int f=0;
		for(auto j:sum)
			if(j<x)
				f++;
		if(f==0)
			ans=min(ans,net);
	}
	if(ans==LLONG_MAX)
		cout<<-1<<endl;
	else
	cout<<ans<<endl;

}



Measured memory_bytes: 3576
# include <iostream>
# include <string>
# include <vector>


using namespace std;

bool is_okay(int t_diff, int x_diff, int y_diff) {
    int rest = t_diff - (abs(x_diff) + abs(y_diff));
    if (rest >= 0) {
        if (rest % 2 == 0) {
            return true;
        }
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    vector<int> t(n+2);
    vector<int> x(n+2);
    vector<int> y(n+2);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i=1; i<n+1; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i=0; i<n; i++) {
        int t_diff = t[i+1] - t[i];
        int x_diff = x[i+1] - x[i];
        int y_diff = y[i+1] - y[i];
        if (is_okay(t_diff, x_diff, y_diff) == false) {
            // cout << "i= " << i << endl;
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n, w;
    cin >> n >> w;
    vector<int> wei(n), val(n);
    REP(i, n) cin >> wei[i] >> val[i];

    vector<vector<LL>> dp(n+1, vector<LL>(w+1, 0));
    REP(i, n){
        REP(j, w+1){
            dp[i+1][j] = max(dp[i][j], (wei[i] <= j ? dp[i][j-wei[i]] + val[i] : 0));
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    double N, K; cin >> N >> K;
    vector<double> p(N);

    cout << fixed << setprecision(10);
    for(auto &it : p){
        cin >> it;
    }
    
    double sum = 0;
    for(int i=0; i<K; i++){
        sum += (p.at(i)+1)/2;
    }

    double ans = sum;
    for(int i=1; i<N-K+1; i++){
        sum -= (p.at(i-1)+1)/2;
        sum += (p.at(i+K-1)+1)/2;
        ans = max(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <map>
#include <cstdlib>
#include <algorithm>

#define fin stdin
#define fout stdout

#define x first
#define y second

#define ll long long

#define LIM (10LL * 1000 * 1000 * 1000)
#define MAXR 100000
#define MAXC 3200
#define MAX0 452

#define MAXN 100000

struct myc{
    int x;
    ll y;
};

std::map <ll, int> p2;
std::map <ll, myc> mp;

int pr[MAX0 + 1];
bool c[MAXR + 1];

ll t[MAXN + 1];
int k;

inline void add(ll a, ll b){
    if(a > LIM)
        exit(1);
    if(b > LIM)
        exit(2);
    if(b < 0)
        exit(3);

    auto &u = mp[a];
    u.x ++;
    u.y = b;

    if(u.x == 1)
        t[++ k] = a;
}

inline void inmult(ll &a, ll b){
    if(a > 0){
        a *= b;
        if(a > LIM)
            a = -1;
    }
}

int main(){
    for(int i = 2; i * i <= MAXR; i ++)
        if(c[i] == 0)
            for(int j = i * i; j <= MAXR; j += i)
                c[j] = 1;

    for(int i = 2;  i <= MAXC; i ++)
        if(c[i] == 0)
            pr[++ pr[0]] = i;

    //printf("%d", pr[0]);

    for(int i = MAXC + 1; i <= MAXR; i ++)
        if(c[i] == 0)
            p2[1LL * i * i] = i;

    int n;
    fscanf(fin, "%d", &n);

    int ans = 0;
    bool cub = 0;
    for(int i = 1; i <= n; i ++){
        ll x, imag = 1, rev = 1;
        fscanf(fin, "%lld", &x);

        int q = 1;
        while(q <= pr[0] && x != 1){
            int s = 0;
            while(x % pr[q] == 0)
                s ++, x /= pr[q];
            s %= 3;
            if(s > 0){
                for(int j = 0; j < s; j ++)
                    imag *= pr[q];
                for(int j = 0; j < 3 - s; j ++)
                    inmult(rev, pr[q]);
            }
            q ++;
        }

        if(x == 1){
            if(rev == -1) ans ++;
            else if(rev == 1) cub = 1;
            else add(imag, rev);
        }else{
            int u = p2[x];
            if(u == 0){
                if(x <= MAXR){
                    inmult(rev, x);
                    inmult(rev, x);
                    if(rev == -1) ans ++;
                    else add(imag * x, rev);
                }else ans ++;
            }else{
                inmult(rev, u);
                if(rev == -1) ans ++;
                else add(imag * x, rev);
            }
        }
    }

    ans += cub;

    for(int i = 1; i <= k; i ++){
        auto &u = mp[t[i]];
        if(u.x){
            if(t[i] == 1)
                return 4;
            auto &v = mp[u.y];
            ans += std::max(u.x, v.x);
            v.x = 0;
            u.x=0;
        }
    }

    fprintf(fout, "%lld\n", ans);

    return 0;
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

string s;
string ser[4] = {"dream", "dreamer", "erase", "eraser"};
int main() {
    cin >> s;
    reverse(s.begin(),s.end());
    rep(i,0,4) reverse(ser[i].begin(),ser[i].end());

    for(int i = 0; i < s.size(); ){
        bool a = false;
        rep(j,0,4){
            if(s.substr(i, ser[j].size()) == ser[j]){
                i += ser[j].size();
                a = true;
            }
        }
        if(a != true){
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    while(true){
        vector<tuple<ll, ll, string>> v;
        ll n, q; cin >> n >> q;
        if(n==0 && q==0) break;
        map<string, ll> era_begin;
        rep(i, n){
            string eraname;
            ll erayear, westernyear;
            cin >> eraname >> erayear >> westernyear;
            v.push_back(make_tuple(westernyear - erayear, westernyear, eraname));
        }
        sort(v.begin(), v.end());
        rep(i, q){
            ll que; cin >> que;
            bool ifdetermined = false;
            rep(i, v.size()){
                if(get<0>(v[i]) < que && que <= get<1>(v[i])){
                    cout << get<2>(v[i]) << ' ' << que - get<0>(v[i]) << endl;
                    ifdetermined = true;
                }
            }
            if(!ifdetermined) cout << "Unknown" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>

int main(void)
{
    int n, m, l, r;
    int max = 100001, min = 0;

    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d", &l, &r);
        if (l > min)
            min = l;
        if (r < max)
            max = r;
    }

    int ans = max - min + 1;
    if (ans < 0)
        ans = 0;
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fin         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("in", "r", stdin),freopen("out", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int occ[105];
int main(){
    //FL;
    fin;
    int x, n;
    cin >> x >> n;
    vi v;
    fore(i, 0, n){
        int y;
        cin >> y;
        occ[y] = 1;
    }
    fore(i, 0, 105)
        if(occ[i] == 0)
            v.pb(i);
    int a = 0, b = sz(v), mid;

    while(b - a > 1){
        mid = (a + b) >> 1;
        if(v[mid] <= x)
            a = mid;
        else
            b = mid;
    }
    int val1 = v[a];
    a = -1;
    b = sz(v) - 1;
    while(b - a > 1){
        mid = (a + b) >> 1;
        if(v[mid] >= x)
            b = mid;
        else
            a = mid;
    }
    int val2 = v[b];
    if(abs(val1 - x) == abs(val2 - x))
        cout << min(val1, val2) << '\n';
    else{
        if(abs(val1 - x) < abs(val2 - x))
            cout << val1 << '\n';
        else
            cout << val2 << '\n';
    }
    EjecuteTime;
    return 0;
}       



Measured memory_bytes: 3792
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end
$jt = na(200001,0)
(-100000..100000).each do |d|
  $jt[d] = d**5
end
def b_serf(l_ok,r_ng,x,s)
  m = (l_ok+r_ng)/2
  if(m == l_ok)
    return (($jt[s]-$jt[m])==x)? m : false
  end
  if(($jt[s]-$jt[m])==x)
    return m
  else
    if((($jt[s]-$jt[m])<x))
      return b_serf(m,r_ng,x,s)
    else
      return b_serf(l_ok,m,x,s)
    end
  end
end
def b_sers(l_ok,r_ng,x,s)
  m = (l_ok+r_ng)/2
  if(m == l_ok)
    return (($jt[s]-$jt[m])==x)? m : false
  end
  if(($jt[s]-$jt[m])==x)
    return m
  else
    if((($jt[s]-$jt[m])>x))
      return b_sers(m,r_ng,x,s)
    else
      return b_sers(l_ok,m,x,s)
    end
  end
end
x = inp[0]
(-100000..100000).each do |i|
  if(j = b_serf(0,100000,x,i))
    puts "#{i} #{j}"
    exit
  end
  if(j = b_sers(-100000,0,x,i))
    puts "#{i} #{j}"
    exit
  end
end


Measured memory_bytes: 27132
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
l = Counter(s)
l_common = list(l.most_common())
max_n = l.most_common()[0][1]
l_common = sorted(l_common,key=lambda x:(x[1],x[0]))
for i,j in l_common:
  if j == max_n:
    print(i)

Measured memory_bytes: 62764
fun main(args : Array<String>) {
    val numberSize = readLine()!!.toInt()
    val numberList = readLine()!!.split(" ").map { it.toInt() }
    var doubleCount = 0
    for (i in 0 until numberSize){
        if (numberList[i] % 2 == 0){
            doubleCount ++
            if (numberList[i] % 3 == 0 || numberList[i] % 5 == 0){
                doubleCount --
            }
        }
    }
    if (doubleCount == 0){
        println("APPROVED")
    }else{
        println("DENIED")
    }
}

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

int main(){
  int i,N,M;
  cin >> N;
  vector<string> Blue(N);
  for(i=0;i<N;++i)
    cin >> Blue.at(i);
  cin >> M;
  vector<string> Red(M);
  for(i=0;i<M;++i)
    cin >> Red.at(i);
  int money,lastmoney=0;
  while(N--){
    money = 0;
    for(i=N;i>=0;--i)
      money += (Blue.at(i)==Blue.at(N));
    for(i=0;i<M;++i)
      money -= (Red.at(i)==Blue.at(N));
    if(money > lastmoney)
      lastmoney = money;
  }
  cout << lastmoney << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    ll tmp = 0, ans = 0;
    for(int i=0; i<N; i++){
        if(v[i] < tmp)  ans += (tmp - v[i]);
        else    tmp = v[i];
    }
    print(ans);
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
//bool cmp(int x,int y);
int main(){
    int a[100000];
	int n,m,flag=1;
	long long price=0; //这年头出题人真的是用心险恶，这个卡爆int的条件隐藏的可以啊 
	cin>>n>>m;
	priority_queue<int>q;
	for(int i=1,a;i<=n;i++){
		cin>>a;
		q.push(a);
	}

	for(int i =1;i<m+1;i++){
		int t;
		t=q.top();
		t/=2;
		q.pop();//一定要记得pop啊QAQ，不然直接白给 
		q.push(t);
		
	}
	while(q.size()>0){//也可以是 !q.empty()； q.top()>0不行的，因为 q.top()一调程序就崩溃了啊啊啊啊啊啊 
		int temp=q.top();
		price+=temp;
		q.pop();
		
	}
	cout<<price;
	return 0;
}

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

int main(void){
    int c[3][3];
    int tr[3][3]={};
    int a[3]={};
    bool ans=false;
    int con=0;
    for(int i=0;i<3;i++){
        cin >> c[i][0]>>c[i][1]>>c[i][2];
    }
    for(a[0]=0;a[0]<=100;a[0]++){
        for (a[1] = 0; a[1] <= 100; a[1]++){
            for (a[2] = 0; a[2] <= 100; a[2]++){
                con=0;
                for(int i=0;i<3;i++){
                    
                    for(int j=0;j<3;j++){
                        tr[i][j]=c[i][j]-a[j];
                    }
                    if(tr[i][0]==tr[i][1] and tr[i][1]==tr[i][2]){
                        con++;
                    }
                }
                
                if(con==3){
                    ans=true;
                    goto fin;
                }
                
            }
        }
    }
    fin:
    if(ans){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  int ans = 0;

  for(int h_bit = 0; h_bit < 1<<h; ++h_bit) {
    for(int w_bit = 0; w_bit < 1<<w; ++w_bit) {
      int c = 0;
      rep(i, h) rep(j, w) {
        if(h_bit & 1<<i) continue;
        if(w_bit & 1<<j) continue;

        if(s[i][j] == '#') ++c;
      }
      if(c == k) ++ans;
    }
  }
  cout << ans << endl;
}

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


int main() {
    long long N; cin >> N;
    vector<long long> capacities(5); for (int i = 0; i < 5; i++) cin >> capacities[i];
    sort(capacities.begin(), capacities.end());

    long long ans = 5;
    ans += N / capacities[0];
    if (N % capacities[0] == 0) {
        ans -= 1;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <stack>
#include <map>

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> da(n);
    for(int i=0;i<n;i++){
        cin >> da[i];
    }
    vector<bool> dp(200001,false);
    for(int i=1;i<k+1;i++){
        for(int j=0;j<n;j++){
            if(i>=da[j]){
                if(!dp[i-da[j]]){
                    dp[i]=true;
                    break;
                }
            }
        }
    }
    if(dp[k]){
        cout << "First" << endl;
    }
    else{
        cout << "Second" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(){
    int N;
    std::cin >> N;
    std::vector<long long> h(N);
    long long dp[N];
    for(int i = 0; i < N; i++){
        std::cin >> h[i];
        dp[i] = 0;
    }
    dp[1] = std::abs(h[0] - h[1]);
    for(int i = 2; i < N; i++){
        dp[i] = std::min(dp[i - 1] + std::abs(h[i] - h[i - 1]), dp[i - 2] + std::abs(h[i] - h[i - 2]));
    }
    std::cout << dp[N - 1] << std::endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int a,f,s;
  cin>>a;
  f=a/100;
  s=a%100;
 if((1<=f&&f<=12)&&(s>=1&&s<=12)){
   cout<<"AMBIGUOUS"<<endl;
 }else if(1<=s&&s<=12){
   cout<<"YYMM"<<endl;
 }else if(1<=f&&f<=12){
   cout<<"MMYY"<<endl;
 }else{
   cout<<"NA"<<endl;
 }
   return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
E = [[] for _ in range(N)]

for _ in range(M):
	ta, tb = map(int, input().split())
	E[ta-1].append(tb-1)
	E[tb-1].append(ta-1)


def next_permutation(out, cnt, flg):
	if cnt == N:
		for i in range(N-1):
			if out[i+1] not in E[out[i]]:
				return 0
		return 1

	ans = 0

	for i in range(N):
		if flg[i] == 0:
			out.append(i)
			flg[i] = 1

			ans += next_permutation(out, cnt+1, flg)

			out.pop()
			flg[i] = 0

	return ans

perm = [0]
cnt = 1
flg = [0 for _ in range(N)]
flg[0] = 1

answer = next_permutation(perm, cnt, flg)

print(answer)

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    auto S = readln.chomp.to!(char[]);

    long[] NS;
    long n;
    char last;
    foreach (c; S) {
        if (c == last) {
            ++n;
        } else {
            if (n) NS ~= n;
            n = 1;
            last = c;
        }
    }
    NS ~= n;
    
    while (NS.length > 1 && K) {
        --K;
        if (NS.length == 2) {
            NS[0] += NS[1];
            NS = NS[0..1];
        } else if (NS.length == 3) {
            NS[0] += NS[1] + NS[2];
            NS = NS[0..1];
        } else {
            NS[1] += NS[0];
            NS[$-2] += NS[$-1];
            NS = NS[1..$-1];
        }
    }

    long r;
    foreach (x; NS) r += x-1;
    writeln(r);
}

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a,b,c;
int x,y,z;
int main()
{
	cin>>a>>b>>c;
	x=min(a,min(b,c));
	z=max(a,max(b,c));
	y=a+b+c-x-z;
	cout<<x*y/2;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

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

int main() {
    int N;
    scanf("%d", &N);
    set<int> pos, neg;
    vector<pii> V;
    for (int i = 0; i < N; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        V.push_back(make_pair(a, b));
    }
    int ans = 0;
    sort(V.begin(), V.end());
    for (int i = 0; i < N; i++) {
        int x = V[i].first, y = V[i].second;
        if (i) {
            int tmp1 = -y + *prev(pos.end());
            int tmp2 = y + *prev(neg.end());
            ans = max(ans, max(tmp1, tmp2) + x);
        }
        pos.insert(-x + y);
        neg.insert(-x - y);
    }
    printf("%d\n", ans);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 23532
# 度からラジアンを求める
def radian(degree)
  degree * Math::PI / 180
end

x = gets.to_i

c = Complex(0, 0)
10000000.times do |i|
  tmp = Complex(0, 1)
  tmp = tmp * Complex.polar(1.0, radian(i * x))
  c = c + tmp
  if c.abs < 0.0001
    puts i + 1
    exit
  end
end


Measured memory_bytes: 14512
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/


int N;
vector<pair<int,int>> W;

signed main(){

    in(N);
    W.resize(N);
    rep(i,N){
        in(W[i].second,W[i].first);
    }

    sort(all(W));
    int t=0;
    rep(i,N){
        t+=W[i].second;
        if(t>W[i].first){
            No;
            return 0;
        }
    }

    Yes;

    return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);++i)
#define FORR(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)
#define MAXIMIZE(a, b) (a) = max((a),(b))
#define MINIMIZE(a, b) (a) = min((a),(b))

using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<int, Pii> iPii;
int main(int argc, char **argv, char **envp) {
  int N;
  cin >> N;
  int a[110];
  REP(i, N) {
    cin >> a[i];
  };
  int ans = 0;
  REP(i, N-1) {
    if (a[i] == a[i+1]) {
      ans++;
      ++i;
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define all(a) (a).begin(),(a).end()
#define pair<int,int> P
#define PB push_back
#define F first
#define S second

int main(){
    int n;
    cin>>n;
    ll a[n];
    map<ll,ll>m;
    FOR(i,n)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    ll ans=0;
    FOR(i,n)
    {
        ans=ans+ (m[i+1]*(m[i+1]-1))/2;
    }
    FOR(i,n)
    {
        cout<<(ans-m[a[i]]+1)<<endl;
    }
    return 0;
}


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

#define lli	long long int
#define MOD 1000000007

int main(void) {
	int h, w; cin >> h >> w;
	vector<string> a(h); for (int i = 0; i < h; i++) cin >> a[i];
	
	vector< vector<lli> > dp(h, vector<lli>(w, 1));
	
	for (int i = 1, v = 1; i < h; i++) {
		if (a[i][0] == '#') v = 0;
		dp[i][0] = v;
	}
	
	for (int i = 1, v = 1; i < w; i++) {
		if (a[0][i] == '#') v = 0;
		dp[0][i] = v;
	}
	
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (a[i][j] == '#') dp[i][j] = 0;
			else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
		}
	}

	cout << dp[h-1][w-1];

	return 0;
}

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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main()
{
    string L[] = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    rep(i, 3)
    {
        if(L[i] == s && i<2){
            cout << L[i+1] << endl;
        }
        else if(L[i] == s){
            cout << L[0] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N, K;
    cin >> N >> K;
    int ans = (N - 1) / (K - 1) + ((N - 1) % (K - 1) != 0);
    cout << ans << endl;

    return 0;
}


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

const int INF = 1e9 ;
const int maxN = 2e5 + 5;
int n;

int main()
{
	scanf("%d",&n);
	if(n == 22)
	{
		puts("Christmas Eve Eve Eve");
	}
	else if(n == 23)
	{
		puts("Christmas Eve Eve");
	}
	else if(n == 24)
	{
		puts("Christmas Eve");
	}
	else if(n == 25)
	{
		puts("Christmas");
	}
    return 0;
} 

Measured memory_bytes: 256
from heapq import heappush, heappop
import queue
import re
import math
import functools

def s_raw():
    return input().rstrip("\r")

def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return list(map(int, ss_raw()))


INF = 1 << 29


def make1d_arr(n, val=INF):
    return [val for i in range(n)]


def make2d_arr(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)


def BFord(n,es):
    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[:]
    v_cost = [-INF if prev[idx]!=v_cost[idx] else v_cost[idx] for idx in range(n)]
    return v_cost
    

def main():
    N,K,Q = ints_raw()
    As = [int_raw() for _ in range(Q)]
    Ps = [0]*N
    for a in As:
        Ps[a-1]+=1
    
    for p in Ps:
        if K-(Q-p)>0:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


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

int main(void){
    int N,M,K;
    cin >> N >> M >> K;
    vector<vector<int>> graph(N,vector<int>());
    vector<int> group(N,-1);   //各人物の所属グループ
    vector<int> bucket(N,0); //各グループの所属人数
    vector<vector<int>> hate(N,vector<int>());
    for(int i=0;i<M;i++){
        int A,B;
        cin >> A >> B;
        graph[A-1].push_back(B-1);
        graph[B-1].push_back(A-1);
    }
    for(int i=0;i<K;i++){
        int C,D;
        cin >> C >> D;
        hate[C-1].push_back(D-1);
        hate[D-1].push_back(C-1);
    }

    int groupnum = 0;
    for(int i=0;i<N;i++){
        if(group[i]!=-1) continue;
        queue<int> q;   //これから探査する人
        q.push(i);

        while(!q.empty()){
            int member = q.front(); q.pop();
            if(group[member]!=-1) continue;
            bucket[groupnum]++;
            group[member] = groupnum;

            for(int x: graph[member]){
                if(group[x]==-1) q.push(x);
            }
        }
        groupnum++;
    }



    for(int i=0;i<N;i++){
        int ans=0;
        for(int x: hate[i]){
            if(group[i]==group[x]) ans--;
        }
        //cout << "i = " << i << endl;
        //cout << "hatenum: " << -1*ans << ", groupnum: " << bucket[group[i]] << ", friend: " << graph[i].size() << endl;
        ans += bucket[group[i]] - graph[i].size() - 1;

        if(i!=N-1) cout << ans << " ";
        else cout << ans << endl;
    }

    return 0;

}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  set<int> s;
  rep(i,n) s.insert(a[i]);
  if(s.size() == n) cout << "YES";
  else cout << "NO";
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 998244353
#define N 200005
ll pro(ll a,ll b)
{
    ll temp=a;
    temp*=b;
    return temp;
}
int main()
{
    int n,i,j,a,b,x,y,l,r;
    in(n);
    vii vp(n);
    rep(i,n)
    {
        in2(a,b);
        if(a>b)
            swap(a,b);
        vp[i]={a,b};
    }
    sort(all(vp));
    vi Min(n);
    vi Max(n);
    vector<int> diff(n);
    Min[0]=vp[0].S,Max[0]=Min[0];
    lp(i,1,n)
        Min[i]=min(Min[i-1],vp[i].S),Max[i]=max(Max[i-1],vp[i].S);
    ii temp;
    rep(i,n)
    {
        tie(l,r)=vp[i];
        diff[i]=(1e9);
        if(Min[i]>=l)
        {
            y=vp[n-1].F;
            if(i>0)
                y=max(y,Max[i-1]);
            temp={r,r};
            j=lower(vp,temp);
            if(j>0 && Min[j-1]>=r)
                diff[i]=max(y,Max[j-1])-r;
            diff[i]=min(diff[i],y-l);
        }
    }
    //dbg(diff,i,n);
    ll ans=(1e18);
    ans=min(ans,pro(vp[n-1].F-vp[0].F,Max[n-1]-Min[n-1]));
    rep(i,n)
        ans=min(ans,pro(Max[n-1]-vp[0].F,diff[i]));
    llout(ans);
}






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

namespace ABC089C {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            long mNum = 0;
            long aNum = 0;
            long rNum = 0;
            long cNum = 0;
            long hNum = 0;
            for(int i = 0; i < N; i++) {
                string input = Console.ReadLine();
                string inputChar = input.Substring(0, 1);
                switch(inputChar){
                    case "M":
                        mNum++;
                        break;
                    case "A":
                        aNum++;
                        break;
                    case "R":
                        rNum++;
                        break;
                    case "C":
                        cNum++;
                        break;
                    case "H":
                        hNum++;
                        break;
                    default:
                        break;
                }
            }
            long ans = mNum * aNum * rNum + mNum * aNum * cNum + mNum * aNum * hNum
                + mNum * rNum * cNum + mNum * rNum * hNum + mNum * cNum * hNum
                + aNum * rNum * cNum + aNum * rNum * hNum + aNum * cNum * hNum
                + rNum * cNum * hNum;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 15312
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main() {
    ll h,w,m;
    cin >> h >> w >> m;
    ll row[h+1] = {};
    ll col[w+1] = {};
    set<pair<ll,ll>> targets;
    for(ll i = 1; i <= m; i++) {
        ll x,y;
        cin >> x >> y;
        row[x]++;
        col[y]++;
        targets.insert({x,y});
    }
    ll mx = 0,mx1 = 0;
    for(ll i = 1; i <= h; i++){
        mx = max(mx,row[i]);
    }
    for(ll i = 1; i <= w; i++) {
        mx1 = max(mx1,col[i]);
    }
    ll ans = mx + mx1;

    map<ll,ll> first,second; 
    
    for(ll i = 1; i <= h; i++) {
        first[row[i]]++;
    }
    for(ll i = 1; i <= w; i++) {
        second[col[i]]++;
    }
    ll how = 0;
    for(auto i : first) {
        ll curr = i.first;
        how = how + (first[curr]*second[ans-curr]);
    }

    for(auto i : targets) {
        if(row[i.first] + col[i.second] == ans) {
            how--;
        }
    }

    if(how > 0) {
        cout << ans << endl;
    }
    else {
        cout << ans-1 << endl;
    }

}

Measured memory_bytes: 27012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    int d, t, s;
    cin >> d >> t >> s;
    int temp = s * t;
    if(d <= temp){
    	show("Yes");
    }
    else{
    	show("No");
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
#define MOD 1000000007
using namespace std;
int n,m,pri[1024];
long long res;
long long Facto(int x){
	m=n;
	int cnt=0;
	while(m)
		cnt+=(m/x),m/=x;
	return cnt;
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	res=1LL;
	pri[2]=1;
	for(int i=3;i<=n;i+=2) pri[i]=1;
	for(int i=3;i<=n;i+=2)
		if(pri[i])
			for(int j=i*3;j<=n;j+=i*2)
				pri[j]=0;
	for(int i=1;i<=n;i++){
		if(pri[i]){
			res=(res*(Facto(i)+1LL))%MOD; 
		}
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
dic = {}

for i in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1

C = sorted(dic.items())
max_dic = max(dic.values())

for name,i in C:
    if i == max_dic:
        print(name)

Measured memory_bytes: 46632
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a+b < 24) {
			System.out.println(a+b);
		}else {
			System.out.println(a+b-24);
		}
		
	}

}


Measured memory_bytes: 21204
INF = 55555
P = [1 for _ in range(55556)]
P[0]=0
P[1]=0
for i in range(2,int(55556**0.5)+1):
    for j in range(i*i,55556,i):
        P[j] = 0
N = int(input())
A = []
for i in range(11,55556,10):
    if P[i]==1:
        A.append(i)
    if len(A)==N:
        break
print(*A)

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

int main()
{
    int A_h[2];
    int A_m[2];
    int A_s[2];
    int A_sum;
    int A_sum1 = 0;
    int A_sum2 = 0;

    int B_h[2];
    int B_m[2];
    int B_s[2];
    int B_sum;
    int B_sum1 = 0;
    int B_sum2 = 0;

    int C_h[2];
    int C_m[2];
    int C_s[2];
    int C_sum;
    int C_sum1 = 0;
    int C_sum2 = 0;

    int Ah = 0;
    int Am = 0;
    int As = 0;
    int Bh = 0;
    int Bm = 0;
    int Bs = 0;
    int Ch = 0;
    int Cm = 0;
    int Cs = 0;

    cin >> A_h[0];
    cin >> A_m[0];
    cin >> A_s[0];
    cin >> A_h[1];
    cin >> A_m[1];
    cin >> A_s[1];

    cin >> B_h[0];
    cin >> B_m[0];
    cin >> B_s[0];
    cin >> B_h[1];
    cin >> B_m[1];
    cin >> B_s[1];

    cin >> C_h[0];
    cin >> C_m[0];
    cin >> C_s[0];
    cin >> C_h[1];
    cin >> C_m[1];
    cin >> C_s[1];

    if (A_s[0] > A_s[1]){
        A_m[1]--;
        A_s[1] += 60;
        As = A_s[1] - A_s[0];
    }
    else {
        As = A_s[1] - A_s[0];
    }

    if (A_m[0] > A_m[1]){
        A_h[1]--;
        A_m[1] += 60;
        Am = A_m[1] - A_m[0];
    }
    else {
        Am = A_m[1] - A_m[0];
    }

        Ah = A_h[1] - A_h[0];

    if (B_s[0] > B_s[1]){
        B_m[1]--;
        B_s[1] += 60;
        Bs = B_s[1] - B_s[0];
    }
    else {
        Bs = B_s[1] - B_s[0];
    }

    if (B_m[0] > B_m[1]){
        B_h[1]--;
        B_m[1] += 60;
        Bm = B_m[1] - B_m[0];
    }
    else {
        Bm = B_m[1] - B_m[0];
    }

        Bh = B_h[1] - B_h[0];

    if (C_s[0] > C_s[1]){
        C_m[1]--;
        C_s[1] += 60;
        Cs = C_s[1] - C_s[0];
    }
    else {
        Cs = C_s[1] - C_s[0];
    }

    if (C_m[0] > C_m[1]){
        C_h[1]--;
        C_m[1] += 60;
        Cm = C_m[1] - C_m[0];
    }
    else {
        Cm = C_m[1] - C_m[0];
    }

   Ch = C_h[1] - C_h[0];

   cout << Ah << " " << Am << " " << As << endl;
   cout << Bh << " " << Bm << " " << Bs << endl;
   cout << Ch << " " << Cm << " " << Cs << endl;
    
   return (0);
}



Measured memory_bytes: 3080
n = input()
a = [int(i) for i in input().split()]
q = int(input())
bb = []
cc = []
for i in range(q):
    btmp, ctmp = [int(j) for j in input().split()]
    bb.append(btmp)
    cc.append(ctmp)


amap = {}
for i in a :
    if i not in amap :
        amap[i] = 1
    else:
        amap[i] += 1

atol = sum(a)

for b,c in zip(bb,cc):
    
    if b in amap:
        atol +=  (c - b) * amap[b]
    
        if c in amap :
            amap[c] += amap[b]
        else:
            amap[c] = amap[b]
        
        amap.pop(b)
        
    print(atol)


Measured memory_bytes: 96364
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int n; cin >> n;
  vector<string> a;
  a.push_back("a");

  auto f = [] (vector<string> v) {
    vector<string> res;
    for (auto e : v) {
      int cmax = 0;
      rep(j, e.size()) {
        int x = e[j] - 'a';
        chmax(cmax, x);
      }
      rep(i, cmax+2) {
        res.push_back(e + char('a' + i));
      }
    }
    return res;
  };

  rep(i, n-1) a = f(a);

  for (auto e : a) {
    cout << e << endl;
  }
  return 0;
}


Measured memory_bytes: 10916
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
// 素集合データ構造(0-indexed)
class UnionFind
{
public:
	//par[i]：データiが属する木の親の番号．i==par[i]のとき、データiは木の根ノードである
	vector<int> par;
	//sizes[i]：根ノードiの木に含まれるデータの数．iが根ノードでない場合は無意味な値となる
	vector<int> sizes;

	UnionFind(int n): par(n), sizes(n, 1){
		//最初は全てのデータiがグループiに存在するものとして初期化
		rep(i, n) par[i]=i;
	}

	//データxが属する木の根を得る
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
	}

	//2つのデータx, yが属する木をマージする
	void unite(int x, int y){
		//データの根ノードを得る
		x=find(x);
		y=find(y);

		//既に同じ木に属しているならマージしない
		if(x==y) return;

		//xの木がyの木より大きくなるようにする
		if(sizes[x] < sizes[y]) swap(x, y);

		//xがyの親になるように連結する
		par[y]=x;
		sizes[x]+=sizes[y];
		//sizes[y]=0;  //sizes[y]は無意味な値となるので0を入れておいてもよい
	}

	//2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y){
		return find(x)==find(y);
	}

	//データxが含まれる木の大きさを返す
	int size(int x){
		return sizes[find(x)];
	}
};
int main(void)
{
	int n, m;

	cin>>n>>m;

	vi p(n);
	rep(i, n){
		cin>>p[i];
		p[i]--;
	}

	UnionFind tree(n);

	vi x(m), y(m);

	rep(i, m){
		cin>>x[i]>>y[i];
		x[i]--; y[i]--;
		tree.unite(p[x[i]], p[y[i]]);
	}

	int ans=0;
	rep(i, n){
		if(tree.same(i, p[i])) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2176