akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll n = 1LL << N;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<Pll> dp(n, {0,0});
    rep(i,n){
        dp[i] = {a[i], 0};
    }
    auto merge = [&](Pll &a, Pll &b) -> Pll{
        Pll ret;
        Pll temp = {a.first, b.first};
        ret.first = max(temp.first, temp.second);
        if(temp.first > temp.second)temp.first = a.second;
        else temp.second = b.second;
        ret.second = max(temp.first, temp.second);
        return ret;
    };

    rep(j, N){
        rep(i, n){
            if((i >> j) & 1){
                dp[i] = merge(dp[i], dp[i & ~(1LL << j)]);
            }
        }
    }

    vector<ll> ans(n);
    reps(i,n-1){
        chmax(ans[i], ans[i-1]);
        chmax(ans[i], dp[i].first + dp[i].second);
    }

    reps(i,n-1){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 11264
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x2 = 0
    for i in range(N):
        if i % 2:
            x2 -= A[i]
        else:
            x2 += A[i]
    ans = [0] * N
    ans[0] = x2//2
    for i in range(N-1):
        ans[i+1] = A[i] - ans[i]

    for i in range(N):
        ans[i] *= 2
    
    print(*ans)


main()

Measured memory_bytes: 64612
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

a,b=map(int, input().split())

if (a*b % 2 == 0):
    print("No")
else:
    print("Yes")



Measured memory_bytes: 8952
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

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

	ll ans1 = N / 500;
	ans1 *= 1000;
	N %= 500;
	ll ans2 = N / 5;
	ans2 *= 5;
	ll ans = ans1 + ans2;


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

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){

  int N, M; ll P; cin >> N >> M >> P;

  vector < pair<ll, int> > graph[N];
  vector <int> G1[N], G2[N];
  for (int i = 0; i < M; i++){
    int A, B; ll C; cin >> A >> B >> C;
    A--; B--;
    C = -1 * (C - P);
    graph[A].push_back(make_pair(C, B));
    G1[A].push_back(B);
    G2[B].push_back(A);
  }

  vector <bool> C1(N), C2(N);
  queue <int> que1, que2;
  que1.push(0); C1[0] = true;
  while (!que1.empty()){
    int Q = que1.front(); que1.pop();
    for (int i = 0; i < G1[Q].size(); i++){
      int next = G1[Q][i];
      if (C1[next] == false){
        C1[next] = true;
        que1.push(next);
      }
    }
  }

  que2.push(N - 1); C2[N - 1] = true;
  while (!que2.empty()){
    int Q = que2.front(); que2.pop();
    for (int i = 0; i < G2[Q].size(); i++){
      int next = G2[Q][i];
      if (C2[next] == false){
        C2[next] = true;
        que2.push(next);
      }
    }
  }
  
  vector <ll> dist(N);
  fill(dist.begin() + 1, dist.end(), 1e16);

  bool flag = false;

  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      for (int k = 0; k < graph[j].size(); k++){
        ll cost = graph[j][k].first;
        int next = graph[j][k].second;
        if (dist[j] != 1e16 && dist[next] > dist[j] + cost){
          dist[next] = dist[j] + cost;
          if (i == N - 1 && C1[j] == true && C2[next] == true) flag = true;
        }
      }
    }
  }

  if (flag == true){
    cout << -1 << endl;
  }else if(dist[N - 1] >= 0){
    cout << 0 << endl;
  }else{
    cout << -1 * dist[N - 1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int n,k;
int upbit(int x)
{
    for(int i=30;i>=0;i--)
        if(x>>i&1) return i;
    return -1;
}
vector<pair<int,int>>v[55];
long long sum[55];
int main()
{
    //freopen("01.txt","r",stdin);
    scanf("%d%d",&n,&k);
    long long ans=0,res=0;
    int u=upbit(k);
    for(int i=1;i<=n;i++)
    {
        int a,b;scanf("%d%d",&a,&b);
        int k=upbit(a);
        if(k==-1||(a&k)==a) res+=b;
        else v[k].push_back({a,b}),sum[k]+=b;
    }
    for(int i=u;i>=0;i--)
    {
        if(k>>i&1)
        {
            long long s=0;
            for(int j=i-1;j>=0;j--)
                s+=sum[j];
            ans=max(ans,res+s);
            for(int j=0;j<v[i].size();j++)
            {
                pair<int,int>x=v[i][j];
                x.first^=1<<i;
                int k=upbit(x.first);
                if(k==-1) res+=x.second;
                else v[k].push_back(x),sum[k]+=x.second;
            }
        }
        v[i].clear();
    }
    ans=max(ans,res);
    printf("%lld\n",ans);
}


Measured memory_bytes: 16604
arg1,arg2 = map(int, input().split())
data = []
data2 = []
tmp = []
for x in range(0,arg1):
    tmp = input().split()
    data.append([int(tmp[i]) for i in range(arg2)])
    data[x].append(sum(data[x]))
data.append([(sum(data[i][j] for i in range(arg1))) for j in range(arg2)])
data[arg1].append(sum(data[arg1][i] for i in range(arg2)))
for x in range(0,arg1+1):
    for y in range(0,arg2+1):
        if y != arg2:
            print(data[x][y],end=' ')
        else:
            print(data[x][y])


Measured memory_bytes: 8412
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void brute(ll n){
    int ans = 0;
    rep(i, 1, n){
        if(n/i == (n % i)) ans += i;
    }
    cout<<"Brute: "<<ans<<endl;
}

ll find(ll n){
    ll ret = 0;
    for(ll i = 1; i * i < n; i++){
        if(n % i) continue;
        ll to = (n - i)/i;
        if(n % to) ret += to;
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    ll n;
    cin>>n;
   // brute(n);
//    if(n < 3){
//        cout<<"0\n";
//        return 0;
//    }
    cout<<find(n)<<endl;
    return 0;
}

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N, L;
    cin >> N >> L;
    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    bool impossible = true;
    int index ;
    for(int i = 0; i < N-1; i++){
        if(v[i] + v[i+1] >= L ){
            index = i;
            impossible = false;
        }
    }

    if(impossible){
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;
    for(int i = 0; i < N - 1; i++){
        if(i == index) break;
        if(i != index) cout << i + 1 << endl;
    }

    for(int i = N-2; i >= 0; i--){
        if(i == index) break;
        if(i != index) cout << i + 1 << endl;
    }

    cout << index + 1<< endl;


}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int dp[1000000];


int jump(int n, int q[]){
    if(n==1) return 0;
    if(n==2) return abs(q[n] - q[n-1]);
    if(dp[n] != -1) return dp[n];
    dp[n] = min( jump(n-1,q) + abs(q[n]-q[n-1]) , jump(n-2,q) + abs(q[n]-q[n-2]) );
    return dp[n];
}

int main()
{
    int n; cin>>n;
    for(int i=1;i<=n;i++) dp[i] = -1;
    int h[n+1];
    for(int i=1;i<=n;i++) cin>>h[i];
    cout<< jump(n,h);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define PI 3.1415926535897932384
using namespace std;
signed main(){
  int a,b,h,m;
  cin >> a >> b >> h  >> m;
  long double x = 1.0*30*h + 0.5 * m;
  long double y = 6.0 * m;
  long double s = max(x,y) - min(x,y);
  if(s > 180){
    s = 360 - s;
  }
  
  long double res = a*a + b*b - (2*a*b*cos(s*PI/180));
  
  cout << setprecision(20) << sqrt(res) << endl;
  return 0;
}


Measured memory_bytes: 4128
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self,n):
        fact=[1]*(n+1); invfact=[1]*(n+1)
        for i in range(1,n+1): fact[i]=i*fact[i-1]%MOD
        invfact[n]=pow(fact[n],MOD-2,MOD)
        for i in range(n-1,-1,-1): invfact[i]=invfact[i+1]*(i+1)%MOD
        self.__fact=fact; self.__invfact=invfact

    def inv(self,n):
        assert(n>0)
        return self.__fact[n-1]*self.__invfact[n]%MOD

    def fact(self,n):
        return self.__fact[n]

    def invfact(self,n):
        return self.__invfact[n]

    def comb(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[k]*self.__invfact[n-k]%MOD

    def perm(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[n-k]%MOD

def resolve():
    n = int(input())
    mf = modfact(n)
    E = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v = map(int,input().split())
        u -= 1; v -= 1
        E[u].append(v)
        E[v].append(u)

    # dp on Tree
    dp = [1] * n
    size = [1] * n
    stack = [(~0, -1), (0, -1)]
    while stack:
        v, p = stack.pop()
        if v >= 0:
            for nv in E[v]:
                if nv == p:
                    continue
                stack.append((~nv, v))
                stack.append((nv, v))
        else:
            # v を確定させる
            v = ~v
            for nv in E[v]:
                if nv == p:
                    continue
                size[v] += size[nv]
                dp[v] *= dp[nv] * mf.invfact(size[nv])
                dp[v] %= MOD
            dp[v] *= mf.fact(size[v] - 1)
            dp[v] %= MOD


    def rerooting(v, p):
        if p == -1:
            return

        # dp[p] を v-rooted にする
        dp[p] *= mf.fact(size[p] - size[v] - 1) * mf.invfact(size[p] - 1) * mf.fact(size[v]) * pow(dp[v], MOD-2, MOD)
        dp[p] %= MOD
        size[p] -= size[v]

        # dp[v] を v-rooted にする
        size[v] += size[p]
        dp[v] *= mf.fact(size[v] - 1) * mf.invfact(size[v] - size[p] - 1) * dp[p] * mf.invfact(size[p])
        dp[v] %= MOD

    ans = [None] * n
    stack = [(0, -1)]
    while stack:
        v, p = stack.pop()
        if v >= 0:
            rerooting(v, p)
            ans[v] = dp[v]
            for nv in E[v]:
                if nv == p:
                    continue
                stack.append((~nv, v))
                stack.append((nv, v))
        else:
            rerooting(p, ~v)

    print(*ans, sep = '\n')
resolve()

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

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

    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
        a[i]--;
    }
    vector<bool> v(n,false);
    ll now = 0;
    ll c = 0;
    ll x = 0;

    while (true){
        v[now] = true;
        c++;
        now = a[now];
        if (v[now]){
            x = now;
            break;
        }
    }
    //cout << x << endl;
    //cout << c << endl;
    now = 0;
    ll s = 0;
    while(true){
        if (now == x){
            break;
        }
        else{
            s++;
            now = a[now];
        }
    }
    //cout << s << endl;
    ll loop = c-s;
    ll z = (max(k-s,0LL))%loop;
    ll ans = 0;
    now = 0;
    if (k >= s){
        for (ll i = 0; i < s+z; i++){
            now = a[now];
        }
    }
    else{
        for (ll i = 0; i < k; i++){
            now = a[now];
        }
    }
    cout << now+1 << endl;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int x;
    cin >> x;
    string ans;
    if (x == 7 || x == 5 || x == 3) ans = "YES\n";
    else ans = "NO\n";
    cout << ans;  
}

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

    //int t; cin >> t; while (t--)
        solve();
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int L[10],R[10];
ll dp[1010101];
const ll mo=998244353;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,K) cin>>L[i]>>R[i];
	dp[1]=1;
	dp[2]=mo-1;
	for(i=1;i<=N;i++) {
		(dp[i]+=dp[i-1])%=mo;
		FOR(j,K) {
			(dp[i+L[j]]+=dp[i])%=mo;
			(dp[i+R[j]+1]+=mo-dp[i])%=mo;
		}
		
	}
	cout<<dp[N]%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
	int n;
	cin >> n;
	if (n % 10 == 3) {
		cout << "bon" << endl;
	}
	else if(n%10 == 0 || n % 10 == 1|| n % 10 == 6|| n % 10 == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N;
    cin >> N;
    list<int> L;
    list<int>::iterator itr = L.end();
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        if(A == 0) {
            int B;
            cin >> B;
            itr = L.insert(itr,B);
        }
        else if(A == 1) {
            int B;
            cin >> B;
            if(B >= 0) {
                for(int j = 0;j < B;j++) {
                    ++itr;
                }
            }
            else {
                for(int j = 0;j < abs(B);j++) {
                    --itr;
                }
            }
        }
        else if(A == 2) {
            itr = L.erase(itr);
        }
    }
    for(auto x = L.begin();x != L.end();x++) {
        cout << *x << endl;
    }
}


Measured memory_bytes: 18556
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair

const int inf = 1e9;

int n, m, k, xs, ys, xf, yf;

vector<vector<int>> f;
vector<vector<char>> t;
vector<vector<vector<bool>>> vis;

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

bool valid(int x,int y){
	return (x>0 && y>0 && x<=n && y<=m && t[x][y]!='@');
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m >> k >> xs >> ys >> xf >> yf;
	f.assign(n+1,vector<int>(m+1,inf));
	vis.assign(n+1,vector<vector<bool>>(m+1,vector<bool>(4)));
	t.assign(n+1,vector<char>(m+1));
	
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			cin >> t[i][j];
		}
	}
	
	// Dijkstra
	queue<pii> q;
	q.push({xs,ys});
	f[xs][ys] = 0;
	while(!q.empty()){
		auto now = q.front();
		q.pop();
		int x,y;
		tie(x,y) = now;
			// 4 directions
			for(int i=0;i<4;++i){
				for(int j=1;j<=k;++j){
					int nx = x+j*dx[i],ny = y+j*dy[i];
					if(!valid(nx,ny) || f[nx][ny]<=f[x][y]) break;
					else if(f[nx][ny]==inf) f[nx][ny] = f[x][y]+1, q.push({nx,ny});
				}
			}
	}	
	cout << (f[xf][yf]==inf ? -1 : f[xf][yf]);
}

Measured memory_bytes: 222096
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
	int minv;
	int d[MAX], color[MAX];

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

	d[0] = 0;
	color[0] = GRAY;
	while (1) {
		minv = INFTY;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1) break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}

	int k, c, u, v;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}

	dijkstra();

	return 0;
}


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

#define task "C"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Limit

// Struct

// Variables
ll n,ans=1e12;
// Function

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n;
	rep(i,1,trunc(sqrt(n)))
	{
	    if (n%i==0) ans=min(ans,i+n/i-2);
	}
	cout << ans;
}


Measured memory_bytes: 384
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        ll n;
        cin>>n;
        vll v(n);
        rep(i,0,n-1) cin>>v[i];
        sort(all(v));
        if(v[0]==0)
        {
        	cout<<"0";
        	return 0;
        }
        int ans=1,mxx=1e18;
        rep(i,0,n-1)
        {
        	int val=ans*v[i];
        	if(val<ans || val>mxx)
        	{
        		cout<<"-1";
        		return 0;
        	}
        	ans=val;
        }
        if(ans<=mxx)
        cout<<ans;
    	else cout<<"-1";


        cout<<'\n';
    return 0;
}

Measured memory_bytes: 3976
N = int(input())
L = []
for i in range(N):
    L.append([int(i) for i in input().split()])

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

cur = 0
flag = True
for a, b in L:
    cur += a
    if cur > b:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

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


int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for (int i=0; i<n; i++) {
        cin >> v.at(i);
    }
    
    sort(v.begin(), v.end());
    
    cout << v.at(n-1) - v.at(0) << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    map<Pi,int> mp;
    FOR(i,1,n+1){
        string s=to_string(i);
        Pi now=Pi(int(s[0]-'0'),int(s.back()-'0'));
        mp[now]++;
    }
    ll ans=0;
    for(auto x:mp){
        Pi now=x.fi;
        Pi ne=Pi(now.se,now.fi);
        if(mp.count(ne)){
            ans+=mp[now]*mp[ne];
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int m1,d1,m2,d2,d[101];

int main()
{
    scanf("%d %d %d %d",&m1,&d1,&m2,&d2);
    for (int i=1;i<=7;++i)
        if (i%2==1) d[i]=31;
        else d[i]=30;
    for (int i=8;i<=12;++i)
        if (i%2==0) d[i]=31;
        else d[i]=30;
    if (m1!=2)
    {
        if (d[m1]!=d1)
            cout<<0;
        else cout<<1;
    }
    else
    {
        if (d1==28 && d2==1)
            cout<<1;
        else if (d1==29)
            cout<<1;
        else cout<<0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

inline int max(int a,int b) {
	if (a > b) return a;
	return b;
}

inline int min(int a, int b) {
	if (a < b) return a;
	return b;
}

int n, k, q;
int a[100010] = { 0 };


int num[100010] = { 0 };

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

	for (int i = 0; i < q; i++) {
		num[a[i]-1]++;
	}
	for (int i = 0; i < n; i++) {
		if (q-num[i] >= k) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1408
def main():
    S = input()
    Q = int(input())
    count = 0
    A = []
    B = []
    for _ in range(Q):
        U = input()
        if len(U) == 1:
            count += 1
        else:
            _, F, C = U.split()
            F = int(F)
            if F == 1:
                if count % 2 == 0:
                    A.append(C)
                else:
                    B.append(C)
            else:
                if count % 2 == 0:
                    B.append(C)
                else:
                    A.append(C)

    if count % 2 == 0:
        A = A[::-1]
        return "".join(A) + S + "".join(B)
    else:
        B = B[::-1]
        return "".join(B) + S[::-1] + "".join(A)
        
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 71640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    ll n,m,ans = 0;
    cin >> n >> m;
    vector<int> a(n),b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        //a[i]--;
    }
    vector<vector<ll>> ab(m+1);
    for (int i = 0; i < n; ++i) {
        if(m-a[i] < 0) continue;
        ab[m-a[i]].push_back(b[i]);
    }
    priority_queue<ll> pq;
    for (int t = m-1; t >= 0; --t) {
        for (auto x: ab[t]) {
            pq.push(x);
        }
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <iterator>

using namespace std;

struct Dice
{
  int top;
  int bottom;
  int north;
  int east;
  int south;
  int west;
  void toNorth()
  {
    int t = top, b = bottom, n = north, s = south;
    top = s, bottom = n, north = t, south = b;
  }
  void toEast()
  {
    int t = top, b = bottom, e = east, w = west;
    top = w, bottom = e, east = t, west = b;
  }
  void toSouth()
  {
    int t = top, b = bottom, n = north, s = south;
    top = n, bottom = s, north = b, south = t;
  }
  void toWest()
  {
    int t = top, b = bottom, e = east, w = west;
    top = e, bottom = w, west = t, east = b;
  }
  void toTop(int a)
  {
    if (a == north)
      toSouth();
    else if (a == east)
      toWest();
    else if (a == south)
      toNorth();
    else if (a == west)
      toEast();
    else if (a == bottom)
    {
      toNorth();
      toNorth();
    }
  }
  void spin()
  {
    int n = north, e = east, s = south, w = west;
    north = w, east = n, south = e, west = s;
  }
  bool equals(Dice d)
  {
    int n1[6] = {top, bottom, north, west, south, east};
    int n2[6] = {d.top, d.bottom, d.north, d.west, d.south, d.east};
    bool matchNumbers = true;
    for (int i = 0; i < 6 && matchNumbers; i++)
      matchNumbers = find(begin(n2), end(n2), n1[i]) != end(n2);
    if (!matchNumbers)
      return false;

    toTop(d.top);
    int count = 0;
    while (south != d.south && count <= 3)
    {
      spin();
      count++;
    }

    if (top == d.top && bottom == d.bottom &&
        north == d.north && east == d.east &&
        south == d.south && west == d.west)
      return true;
    else
      return false;
  }
};

int main()
{
  int n;
  cin >> n;
  Dice dices[n];
  for (int i = 0; i < n; i++)
  {
    dices[i] = Dice{};
    cin >> dices[i].top >> dices[i].south >> dices[i].east;
    cin >> dices[i].west >> dices[i].north >> dices[i].bottom;
  }

  bool notEqual = true;
  for (int i = 1; i < n && notEqual; i++)
    notEqual = !dices[0].equals(dices[i]);

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

  return 0;
}

Measured memory_bytes: 3104
N = int(input())
A = list(map(int, input().split()))

for i in range(0, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j-=1
    A[j + 1] = v
    print(' '.join(map(str, A)))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

struct UF {
	vi t;
	UF(int n){
		t.resize(n,-1);
	}
	int find(int a){
		return t[a]<0 ? a : t[a] = find(t[a]);
	}
	void uni(int a, int b){
		a = find(a), b = find(b);
		if(a == b) return;
		if(t[a] < t[b]) swap(a,b);
		t[b] += t[a];
		t[a] = b;
	}
};

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, h;
	cin >> n >> h;
	++h;
	vi as(n), bs(n), cs(n), ds(n);
	rep(i,0,n) cin >> as[i] >> bs[i] >> cs[i] >> ds[i];
	vi cnt(2*h);

	UF uf(2*h);
	vector<bool> seen(2*h);
	rep(i,0,n){
		int x = -1,y = -1;
		if(cs[i]==0) ++cnt[as[i]], x = as[i];
		else --cnt[cs[i]+h], x = cs[i]+h;
		if(ds[i]==0) ++cnt[bs[i]+h], y = bs[i]+h;
		else --cnt[ds[i]], y = ds[i];
		uf.uni(x,y);
		seen[x] = seen[y] = 1;
	}
	rep(i,0,2*h) if(seen[i] && i == uf.find(i)){
		rep(j,0,2*h)
			if(i == uf.find(j) && cnt[j] > 0)
				goto fine;
		puts("NO");
		return 0;
		fine: ;
	}
	trav(x, cnt) if(x < 0){
		puts("NO");
		return 0;
	}
	puts("YES");
}

Measured memory_bytes: 1792
#include <stdio.h>

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

typedef struct{
    int y;
    int x;
} pos_t;

typedef struct{
    int fy;
    int fx;
    int ty;
    int tx;
} move_t;

char a[512][512];
move_t out[512*512];

int main(void){
    int h=gl(), w=gl();
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int t = getchar_unlocked() - 48;
            getchar_unlocked();
            a[i][j] = t;
        }
    }
    char haveCoin = 0;
    int pos = 0;
    pos_t now, old;
    for(int i=0; i<h; i++){
        now.y = i;
        for(int j=0; j<w; j++){
            now.x = i%2==0 ? j : w-1-j;
            if(haveCoin){
                out[pos].fy=old.y+1;
                out[pos].fx=old.x+1;
                out[pos].ty=now.y+1;
                out[pos].tx=now.x+1;
                pos++;
            }
            haveCoin ^= a[now.y][now.x]&1;
            old = now;
        }
    }
    printf("%d\n", pos);
    for(int i=0; i<pos; i++){
        printf("%d %d %d %d\n", out[i].fy, out[i].fx, out[i].ty, out[i].tx);
    }
    return 0;
}


Measured memory_bytes: 6144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		System.out.println(n*n*n);
	}

}

Measured memory_bytes: 24172
#include <iostream>

int n, m;
int ans = 0;
bool str[1000000];

int main() {
	while (1) {
		std::cin >> n;
		if (n == 0)
			break;
		std::cin >> m;
		char in;
		for (int i = 0; i < m; ++i) {
			std::cin >> in;
			str[i] = (in == 'I') ? true : false;//I : true , O : false
		}
		int cnt = 0;
		ans = 0;
		for (int i = 0; i < m; ++i) {
			if (!cnt&&str[i])
				++cnt;
			else if (cnt) {
				if (str[i] == !str[i - 1])
					cnt += 1;
				else if (str[i] == str[i - 1]) {
					if (str[i - 1] && cnt >= n * 2 + 1) {
						ans += (cnt - (n * 2 + 1)) / 2 + 1;
					}
					else if (cnt - 1 >= n * 2 + 1) {
						ans += (cnt - (n + 1) * 2) / 2 + 1;
					}
					cnt = 0;
					if (str[i])
						++cnt;
				}
			}
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 4036
# 0028
array = []
while True:
    try:
        a = input()
        array.append(int(a))
    except EOFError:
        break
s = set(array)
mx = max(list(map(lambda a: array.count(a), s)))
for a in sorted(s):
    if array.count(a) == mx:
        print(a)

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

void solve(long long N, std::vector<long long> P) {
	multiset<int> s{0, 0, N+1, N+1};
	vector<pair<int, int>> v;
	rep(i, N) {
		v.emplace_back(-P[i], i + 1);
	}
	sort(all(v));
	int res = 0;
	rep(i, N) {
		auto it = s.lower_bound(v[i].second);
		int r1 = *(it++);
		int r2 = *(it--);
		it--;
		int l1 = *(it--);
		int l2 = *it;
		res -= (r2 - r1) * (v[i].second - l1) * v[i].first;
		res -= (r1 - v[i].second) * (l1 - l2) * v[i].first;
		s.insert(v[i].second);
	}
	cout << res << endl;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	std::vector<long long> P(N);
	for(int i = 0 ; i < N ; i++){
		scanf("%lld",&P[i]);
	}
	solve(N, std::move(P));
	return 0;
}


Measured memory_bytes: 7280
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ld = long double;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

combination table(200000);

signed main() {
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  map<ll, ll> fact;
  for (ll i = 2; i*i<=m; i++) {
    while(m % i == 0) {
      fact[i]++;
      m /= i;
    }
  }
  if(m != 1) {
    fact[m]++;
  }
  ll ans = 1;
  for(const auto & p : fact) {
    ll cnt = p.second;
    ans = ans * table.C(n-1+cnt, cnt) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
N,M=map(int,input().split())
dp=[10**10]*(1<<N)
dp[0]=0
for i in range(M):
  a,b=map(int,input().split()) 
  c=list(map(int, input().split()))
  d=0
  for j in c:
    d|=1<<j-1
  for k in range(1<<N):
    dp[k|d]=min(dp[k|d],dp[k]+a)
if dp[-1]==10**10:
  print(-1)
else:
  print(dp[-1])

Measured memory_bytes: 3188
S = input()
N = len(S)+1
from_left = [0]*N
from_right = [0]*N
ii = [0]*N

for i, s in enumerate(S, 1):
  if s == '>':
    from_left[i] = 0
  else:
    from_left[i] = from_left[i-1]+1
    
for i,s in enumerate(S[::-1]):
  i = N-2-i
  if s == '<':
    from_right[i] = 0
  else:
    from_right[i] = from_right[i+1]+1
    
seq = [max(x,y) for x, y in zip(from_left, from_right)]    
answer = sum(seq)
print(answer)

Measured memory_bytes: 35488
rb = range(4)
rf = range(3)
rr = range(10)
rooms = [[[0 for i in rr] for j in rf]for k in rb]

lx = int(raw_input())
for i in range(lx):
    b,f,r,v = map(int, raw_input().split())
    rooms[b-1][f-1][r-1] += v

for i in rb:
    for j in rf:
        print '',
        for k in rr:
            print rooms[i][j][k],
        print
    if i < len(rb)-1:
        print '#' * 20

Measured memory_bytes: 4248
K, S = map(int, input().split())
cnt = 0
for x in range(S + 1) :
    if x > K :
        continue
    for y in range(S - x + 1) :
        if y > K :
            continue
        z = S - x - y
        if z > K:
            continue
        cnt += 1
print(cnt)

Measured memory_bytes: 2940
#include<stdio.h> 

int main()
{
	int a, b, ans;
	
	char op;
	
	while(scanf("%d %c %d",  &a, &op, &b))
	{
		if(op == '?')
		{
			break;
		}
		else if(op == '+')
		{
			ans = a+b;
			printf("%d\n", ans);
			
		}
		else if(op == '-')
		{
			ans = a-b;
			printf("%d\n", ans);
			
		}
		else if(op == '*')
		{
			ans = a*b;
			printf("%d\n", ans);
		}
		else if(op == '/')
		{
			ans = a/b;
			printf("%d\n", ans);
		}
	}
	
	return 0;
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N=0, Y=0;
  int a=-1,b=-1,c=-1;
  int i,j,k;
  cin >> N >> Y;
  for(i=0;i<=N;i++){
    for(j=0;j<=(N-i);j++){
      for(k=0;k<=(N-(i+j));k++){
        if(i*10000+j*5000+k*1000 == Y && i+j+k == N){
          a=i;
          b=j;
          c=k;
          break;
        }
      }
    }
  }
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 3536
#include<cstdio>

int main()
{
	int l, r, d;
	scanf("%d %d %d", &l, &r, &d);
	
	int ans = (r - l) / d;
	
	if(r % d == 0 or l % d == 0) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 1732
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int ans[4][4];
int p[310000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	ans[0][0]=a;
	ans[0][1]=b;
	ans[1][1]=c;
	ans[0][2]=c*3-a-b;
	ans[2][1]=c*2-b;
	ans[2][2]=c*2-a;
	ans[1][2]=c*3-ans[0][2]-ans[2][2];
	ans[2][0]=c*3-ans[2][1]-ans[2][2];
	ans[1][0]=c*3-ans[0][0]-ans[2][0];
	for(int i=0;i<3;i++){

		for(int j=0;j<3;j++){
			if(j)printf(" ");
			printf("%d",ans[i][j]);
		}
		printf("\n");
	}

}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	/** ケースごとの数値の種類 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			long[] x = new long[n], y = new long[n], z = new long[n];
			IntStream.range(0, n).forEach(i -> {
				x[i] = scanner.nextLong();
				y[i] = scanner.nextLong();
				z[i] = scanner.nextLong();
			});
			System.out.println(IntStream.range(0, 1 << N)
					.mapToLong(i -> IntStream.range(0, n)
							.mapToLong(j -> (((i & 1) > 0) ? -1 : 1) * x[j] + ((((i >> 1) & 1) > 0) ? -1 : 1) * y[j]
									+ ((((i >> 2) & 1) > 0) ? -1 : 1) * z[j])
							.sorted().skip(n - m).sum())
					.max().getAsLong());
		}
	}
}


Measured memory_bytes: 42868
import math
def ccw(p1,p2,p3):
    return (p2[0]-p1[0])*(p3[1]-p2[1])-(p2[1]-p1[1])*(p3[0]-p2[0])
while True:
    n=input()
    if n==0:
        break
    p=[0]*n
    for i in xrange(n):
        p[i]=map(float,raw_input().strip().split(","))
    P=min(p,key=lambda a:(a[1],a[0]))
    p.sort(key=lambda x:math.atan2(x[1]-P[1],x[0]-P[0]))
    M,ans=0,0
    for i in xrange(1,n-1):
        if all([ccw(p[M],p[i],p[j])>=0 for j in xrange(i+1,n)]):
            M=i
        else:
            ans+=1
    print ans

Measured memory_bytes: 4492
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;

int main()
{
	int str[4][4];
	for(int i=1;i<=3;i++)
	 for(int j=1;j<=3;j++)
	  cin>>str[i][j];
	int n;
	cin>>n;
	int b[15];
	for(int i=1;i<=n;i++)
	 cin>>b[i];
	int vis[4][4];
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++)
	{
		int num=b[i];
		for(int j=1;j<=3;j++)
		 {
		 	for(int k=1;k<=3;k++)
		 	 {
		 	 	if(str[j][k]==num)
		 	 	{
		 	 		vis[j][k]=1;
				}
			  }
		 }
	}
	int flag=0;
	for(int i=1;i<=3;i++)
	{
		if(vis[i][1]&&vis[i][2]&&vis[i][3])
		{
			flag=1;
			break;
		}
	}
	if(flag==0)
	{
		for(int i=1;i<=3;i++)
	{
		if(vis[1][i]&&vis[2][i]&&vis[3][i])
		{
			flag=1;
			break;
		}
	}
	}
	if(flag==0)
	{
		if(vis[1][1]&&vis[2][2]&&vis[3][3])
		{
			flag=1;
			//break;
		}
	}
	if(flag==0)
	{
		if(vis[3][1]&&vis[2][2]&&vis[1][3])
		{
			flag=1;
			//break;
		}
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
	}
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
mod = 1000000007

#A
a,b,c = LI()
s = a+b+c
s /= 2
ans = (s*(s-a)*(s-b)*(s-c))**(1/2)
print(int(ans))
#B

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	for(int i = 0; i < n; i++){
		//cout << ('z'-s[i]) + 1 << endl;
		if(('z'-s[i]) + 1 <= k && s[i] != 'a'){
			k -= ('z'-s[i]) + 1;
			s[i] = 'a';
		}

		// cout << s << endl;
		// cout << "k = " << k << endl;
		if(i == n-1){
			k %= 26;
			for(int j = 0; j < k; j++){
				if(s[i] == 'z') s[i] = 'a';
				else s[i]++;
			}
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 512