akhauriyash/Code-Regression huggingface dataset:
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
struct z{
  int x,y,c;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int h,w;cin>>h>>w;
  char mp[h][w];
  queue<z> A;
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      cin>>mp[i][j];
      if(mp[i][j] == '#'){
        A.push({i,j,0});
      }
    }
  }
  int ans = 0;
  while(A.size()){
    z Z = A.front();A.pop();
    for(auto x:ar4){
      if(Z.x+x.first >= 0 && h > Z.x+x.first && Z.y+x.second >= 0 && w > Z.y+x.second && mp[Z.x+x.first][Z.y+x.second] == '.'){
        mp[Z.x+x.first][Z.y+x.second] = '#';
        A.push({Z.x+x.first,Z.y+x.second,Z.c+1});
        ans = max(ans,Z.c+1);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13328
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
const int M = 333;
vector<int> v[N];
LL pre[N][M];
int a[N];
void init()
{
	for (int i = 1; i < N; i++)
	{
		for (int j = i; j < N; j += i)
			v[j].push_back(i);
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	init();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = n - 1; i >= 0; i--)
	{
		for (int j = 1; j < M && i + j < n; j++)
		{
			pre[i][j] = pre[i + j][j] + a[i];
		}
	}
	LL ans = 0;
	for (int i = 1; i < n - 1; i++)
	{
		int rest = n - 1 - i;
		for (auto& delta : v[rest])
		{
			int A = i;
			int B = A - delta;
			if (B <= 0) break;
			int cur1 = A;
			int cur2 = A - B;
			if (B % delta == 0 && A + B < n - 1) continue;
			LL sum = 0;
			if (delta < M)
			{
				sum += pre[cur1][delta] + pre[cur2][delta] - pre[cur2 + rest][delta];
			}
			else
			{
				while (cur1 < n - 1)
				{
					sum += a[cur1] + a[cur2];
					cur1 += delta;
					cur2 += delta;
				}
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 271232
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,i;
    cin >> N >> i;
    
    cout << N-i+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a[120], ans;
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++)
    	for(int j = i + 1; j <= n; j++)
    		for(int k = j + 1; k <= n; k++)
    			if(a[i] + a[j] + a[k] - max(a[i], max(a[j], a[k])) > max(a[i], max(a[j], a[k])))
    			{
					if(a[i] == a[j] or a[i] == a[k] or a[j] == a[k]) continue;
    				ans++;
				}
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,k,a,i;
    cin>>n>>k;
    map<int,int> f;
    vector<pair<int,int>> grp;
    set<int> dist;
    for (i=0;i<n;i++)
    {
        cin>>a;
        dist.insert(a);
        f[a]++;
    }
    if (dist.size()<=k)
        cout<<"0\n";
    else
    {
        for (auto e: f)
            grp.pb(mp(e.ss,e.ff));
        sort(grp.begin(),grp.end());
        int ans=0;
        for (i=0;i<dist.size()-k;i++)
            ans+=grp[i].ff;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 21236
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    if (N == 0) {
        cout << "0" << endl;
        return 0;
    }

    ll base = 1;

    string ans = "";
    while (N != 0) {
        // cout << "base " << base << endl;
        // int modc = abs(N % (base * 2));
        // cout << modc << endl;
        if (abs(N % (base*2)) == base) {
            ans += '1';
            N -= base * pow(-1, int(ans.size()+1));
            // cout << "new N " << N << endl;
        } else {
            ans += '0';
        }
        base *= 2;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}
/*

123456789
11000101011001101110100010101
11000101011001101110100010101
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,q;
const int inf=(1LL<<31)-1;

struct SegmentTree{
 vector<int> data;
 int sz;
 SegmentTree(int n){
  sz=1;
  while(sz<n){
   sz<<=1;
  }
  data.resize(2*sz-1,inf);
 }
 void look(){
  cout<<"===================================="<<"\n";
  int now=1;
  for(int i=0;i<(int)data.size();i++){
   cout<<data[i]<<" ";
   if(i+1==now){
    cout<<"\n";
    now+=now+1;
   }
  }
 }

 void update(int k,int x){
  k+=sz-1;
  data[k]=x;
  while(k>0){
   k=(k-1)/2;
   data[k]=min(data[2*k+1],data[2*k+2]);
  }
  //look();
 }
 int query(int a,int b,int k,int l,int r){
  if(r<=a || b<=l)return inf;
  if(a<=l && r<=b)return data[k];
  return min(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
 }
 int query(int a,int b){
  return query(a,b,0,0,sz);
 }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
 cin>>n>>q;
 SegmentTree rmq(n);
 for(int i=0;i<q;i++){
  char a;
  int x,y;
  cin>>a>>x>>y;
  if(a=='0'){
   rmq.update(x,y);
  }else{
   cout<<rmq.query(x,y+1)<<"\n";
  }
 }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

using namespace std;

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

  vector<int> res;
  int ans = 1;
  res.push_back(s);
  while(true) {
    ans++;

    if(s % 2 == 0){
      s /= 2;
    }
    else {
      s = 3*s + 1;
    }

    if(find(res.begin(), res.end(), s) != res.end())
      break;
    
    res.push_back(s);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;

  int idx = 1, cnt = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a == idx) {
      ++idx;
    } else {
      ++cnt;
    }
  }
  if (idx == 1) {
    cnt = -1;
  }
  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const ll mod = (1e+9) + 7;

int main() {
	int N, tmp = -1, count = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int H;
		cin >> H;
		if (tmp > H) {
			count += tmp - H;
		}
		else if (tmp < H) count = 0;
		tmp = H;
		if (count > 1) break;
	}
	if (count > 1) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readST(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readST(String str) {
		String[] strArr = str.split("\\s+");

		String ans = "";
		for (int i = 0; i < N; i++) {
			ans = ans + strArr[0].charAt(i);
			ans = ans + strArr[1].charAt(i);
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21332
#include<stdio.h>
#define N 110
#define INF 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int n,keep[N][N];
 
void cul(){
  int i,min,u;
  int d[N],color[N];
   

 
  for(i=0;i<n;i++){
    d[i]=INF;
    color[i]=WHITE;
  }
 
  d[0]=0;
   
 
  while(1){
    min=INF;
    for(i=0;i<n;i++){
      if(min>d[i]&&color[i]!=BLACK){
	u=i;
	min=d[i];
      }
    }
     
    if(min==INF) break;
    color[u]=BLACK;
 
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && keep[u][i]!=INF &&d[i]>d[u]+keep[u][i] ){
	d[i]=keep[u][i]+d[u];
      }
    }
  }
 
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
}

int main(){
  int i,j,u,a,b,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      keep[i][j]=INF;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&a);
    for(j=0;j<a;j++){
      scanf("%d",&b);
      scanf("%d",&c);
      keep[u][b]=c;
    }
  }
  
  cul();
  return 0;
}

Measured memory_bytes: 640
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N = I()
L = LI()

L.sort()
l = list(itertools.combinations(L,3))

count = 0
for a in l:
    length = len(collections.Counter(a))
    # print(length)
    if not length==3:
        continue
    # print('OK')
    if a[0]+a[1]>a[2] and a[1]+a[2]>a[0] and a[2]+a[0]>a[1]:
        count += 1
print(count)

Measured memory_bytes: 38512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

vector<int> a;
vector<vector<ll> > dp;
vector<vector<bool> > used;
ll rec (int l, int r) {
    if (l >= r) return 0;
    ll x, y;
    x = a[r - 1] - (used[l][r - 1] ? dp[l][r - 1] : rec(l, r - 1));
    y = a[l] - (used[l + 1][r] ? dp[l + 1][r] : rec(l + 1, r));
    used[l][r] = true;
    return dp[l][r] = max(x, y);
}
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    a.resize(n); rep (i, n) cin >> a[i];
    dp.resize(n + 1); rep (i, dp.size()) dp[i].resize(dp.size());
    used.resize(n + 1); rep (i, used.size()) used[i].resize(used.size());
    cout << rec(0, n) << "\n";
    return 0;
}

Measured memory_bytes: 72192
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,r;
signed main(){
  cin>>n>>r;
  if(n < 10)r += 100*(10-n);
  cout << r << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
  int n,a,b,c;
  cin>>n;
  int y[n],m[n],d[n];
  for(int i=0; i<n;i++){
    cin>>y[i]>>m[i]>>d[i];
    if(y[i]%3==0){
      a=y[i]/3*200+(y[i]-y[i]/3)*195;
      a=a-(11-m[i])*20;
      a=a+d[i];
    }else{
      a=y[i]/3*200+(y[i]-y[i]/3)*195;
      if(m[i]%2==0){
	a=a-(((10-m[i])/2)+1)*19-(((10-m[i])/2)*20);
      }else{
	a=a-(((10-m[i])/2)*20+(10-m[i]-(10-m[i])/2)*19+20);
	  }
    
      a=a+d[i];
    }
      cout<<196471-a<<endl;
  
  }
  return 0;
}

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while( (line = br.readLine()) != null) {
            String[] line2 = line.split(" ");
            Integer i = new Integer(Integer.parseInt(line2[0]) + Integer.parseInt(line2[1]));
            System.out.println(i.toString().length());
        }
    }
}

Measured memory_bytes: 17004
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		sc.nextLine();
		String s=sc.nextLine()+'Z';
		int sum = 0;
		for(int i=0;i<n;i++){
			if(s.charAt(i)!=s.charAt(i+1))
				sum++;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26428
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=500010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
char s[N],t[N];
int res=1e9;
signed main()
{
    scanf("%s%s",s,t);
    int n=strlen(s), m=strlen(t);
    for(ri int i=0;i+m<=n;i++)
    {
        int qwq=0;
        for(ri int j=0;j<m;j++)
        {
            if(s[i+j]!=t[j]) qwq++;
        }
        res=min(res,qwq);
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3840
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> v;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(), v.end());
	int f;
	if ((v[0] & 1) != (v[1] & 1)) {
		f = v[2] + 1;
	} else {
		f = v[2];
	}
	int ret = 3 * f - a - b - c;
	cout << ret / 2 << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;


////////////////////////////////////////
#define MAX_N (ll)2E7///変更！！！！！！！
vector<int>prime;
bool is_prime[MAX_N+1];
void precal(){
    rep(i,0,MAX_N)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,MAX_N){
        if(is_prime[i]){
            prime.pb(i);
            for(int j=2*i;j<=MAX_N;j+=i)is_prime[j]=false;
        }
    }
}
vector<i_i> fact(ll n){//ただし2<=n<=MAX_N^2
    vector<i_i>v;
    for(int p:prime){
        if(p*p>n)break;
        int c=0;
        while(n%p==0){
            n/=p;
            c++;
        }
        if(c)v.pb(i_i(p,c));//pという素因数がc個入っている
    }
    if(n!=1){
        int vsize=v.size();
        if(vsize>=1&&v[vsize-1].first==n)v[vsize-1].second++;
        else v.pb(i_i(n,1));
    }
    return v;
}
#define N 300004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return mod(po(mod(mod(i)*mod(i)),p/2));
    else  return mod(mod(i)*mod(po(i,p-1)));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    for(int i=1;i<N;i++){
        kai[i]=mod(kai[i-1]*i);
        kai2[i]=mod(po(kai[i],i_5));
    }
}
ll comb(ll n,ll k){
    if(n==0){
        if(k==0)return 1;
        else return 0;
    }
    else if(n<k)return 0;
    else return mod(mod(mod(kai[n])*mod(kai2[n-k]))*mod(kai2[k]));
}

/////////////////////////////
int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    
    precal();calc();
    ll n,m;cin>>n>>m;
    if(m==1||n==1){cout<<1;return 0;}
    vector<i_i>v=fact(m);
    ll ans=1;
    for(auto x:v){
        ans=mod(ans*comb(x.second+n-1,x.second));
        //cout<<x.second<<" "<<endl;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 31592
using System;
using System.Linq;
namespace ABC143D
{
    public class EmptyClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] l = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            l = l.OrderBy(e=>e).ToArray();

            int cnt = 0;
            for (int i = 0; i < n - 2; i++)
            {
                for (int j = i + 1; j < n - 1; j++)
                {
                    int a = l[i];
                    int b = l[j];
                    int ab = a + b;
                    var x = LowerBound(l,j, l.Length,ab) -(j+1);
                    cnt += x;
                }
            }
            Console.WriteLine(cnt);
        }

        static int LowerBound(int[] arr, int l, int r, int value)
        {

            int center;
            while (l < r)
            {
                center = ((r - l) >> 1) + l;
                if (arr[center] < value)
                    l = center + 1;
                else
                    r = center;
            }
            return l;
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int a,b;
  cin>>a>>b;
  out(a<b?0:10);
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	fill((T *)array, (T *)(array + N), val);
}

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

ll modpow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	else if (b % 2 == 0) {
		ll d = modpow(a, b / 2, c);
		return (d * d) % c;
	}
	else return (a * modpow(a, b - 1, c)) % c;
}

ll factm(ll n, ll mod) {
	if(n == 0)return 1;
	return ((n * factm(n - 1,mod)) % mod);
}

int main(){
	IOS;
	ll n;
	cin >> n;
	vl a(n + 1),s(n + 1);
	s[0] = 0;
	for(int i = 1;i <= n;i++){	
		s[i] = s[i - 1] + modpow(i, mod - 2, mod); //1/1 + 1/2 + 1/3...
	}
	for(ll i = 1;i <= n;i++)cin >> a[i];
	ll ans = 0;
	for(ll i = i;i <= n;i++) {
		ans += ((s[i] + s[n - i + 1] - 1) % mod * a[i]) % mod; //P(1) + P(2) + ...
		ans %= mod;
	}
	ans *= factm(n,mod);
	ans %= mod;
	dump(ans);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int plusminus(int x, int y, int op) {
    if (op == 0) return x + y;
    else return x - y;
}

char cout_pm(int op) {
    if (op == 0) return '+';
    else return '-';
}

int main(){
    int ABCD, A, B, C, D, ai, bi, ci, ab, abc, abcd;
    cin >> ABCD;
    A = ABCD / 1000; 
    B = (ABCD % 1000) / 100;
    C = (ABCD % 100) / 10;
    D = (ABCD % 10); 

    for (ai=0; ai<2; ai++) {
        for (bi=0; bi<2; bi++) {
            for (ci=0; ci<2; ci++) {
                ab = plusminus(A, B, ai);
                abc = plusminus(ab, C, bi);
                abcd = plusminus(abc, D, ci);
                if (abcd == 7) break;
            }
            if (abcd == 7) break;
        }
        if (abcd == 7) break;
    }

    cout << A << cout_pm(ai) << B << cout_pm(bi) << C << cout_pm(ci) << D;
    cout << "=7" << endl;

    return 0;
}


Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=ja
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

class UnionFind:
    def __init__(self, n):
        # 初期状態は全要素が根なので、親は自分自身
        self.par = [i for i in range(n+1)]
        # 集団の要素数(size)を格納する(初期は全て1)
        self.size = [1] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        # 根までたどったらその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索過程で親を書き換える(圧縮経路)
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def unite(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # サイズを比較し、小さい方を大きい方に繋げる
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    # 同じグループに属するかを判定する関数
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素が属する木のサイズを返す関数
    def get_size(self, x):
        return self.size[self.find(x)]
    
    # グループ数を返す関数
    def group_sum(self):
        c = 0
        for i in range(len(self.par)):
            if self.find(i) == i:
                c += 1
        return c


def main():
    n,q,*query = map(int, read().split())

    uf = UnionFind(n)

    for com, x, y in zip(*[iter(query)]*3):
        if com:
            print(1 if uf.is_same(x, y) else 0)
        else:
            uf.unite(x, y)


if __name__ == "__main__":
    main()


Measured memory_bytes: 28912
N = int(input())
xyh = []
X = 0
Y = 1
H = 2
for i in range(N):
    xyh.append(list(map(int, input().split())))

ng = 0
MAX = 101
estH = -1
newH = -1
for x in range(MAX):
    for y in range(MAX):
        for xyhi in xyh:
            if(xyhi[H] > 0):
                newH = xyhi[H] + abs(x - xyhi[X]) + abs(y - xyhi[Y])
#                print("x={},y={},estH={},newH={}".format(x,y,estH,newH))
                if(estH < 0):
                    estH = newH
                elif(estH != newH):
                    ng = 1
                    break
        if(1 == ng):
#            print("NG1!!!")
            ng = 0
            estH = -1
            continue
        for xyhi in xyh:
            if(xyhi[H] == 0):
                if(estH > abs(x - xyhi[X]) + abs(y - xyhi[Y])):
                    ng = 1
                    break
        if(1 == ng):
#            print("NG2!!!")
            ng = 0
            estH = -1
            continue
        print("{} {} {}".format(x, y, estH))
        exit()


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

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

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string humi[2] = { "RUD", "LUD" };
    string S;
    cin >> S;
    rep(i, S.size()) {
        if(humi[i % 2].find(S[i]) == string::npos) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
 ll h,n;
  cin >> h >> n;
 vll a(n),b(n);
  ll m=0;
  rep(i,0,n) {
    cin >> a[i] >> b[i];
    m=max(m,b[i]);  
  }
 vll dp(30005,inf);
  
  dp[0]=0;
  rep(i,0,n){
    ll x=((h-1)/a[i]);
   rep(j,0,h-x*a[i]+1) dp[j+x*a[i]]=min(dp[j+x*a[i]],dp[j]+x*b[i]);
  }
  rep(i,0,n){
   rep(j,0,h) dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i]);
  }
  
  
  ll res=inf;
  rep(i,h,30005) res=min(dp[i],res);
  
  cout << res << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin >> x1>>y1>>x2>>y2;
  int xx=abs(x1-x2);int yy=abs(y1-y2);
  if(x1<=x2&&y1>=y2){
    cout <<x2+yy<<" "<<y2+xx<<" "<<x1+yy<<" "<<y1+xx<<endl;
    return 0;
  }
  if(x1>=x2&&y1<=y2){
    cout <<x2-yy<<" "<<y2-xx<<" "<<x1-yy<<" "<<y1-xx<<endl;
    return 0;
  }
  if(x1<=x2&&y1<=y2){
    cout << x2-yy<<" "<<y2+xx<<" "<<x1-yy<<" "<<y1+xx<<endl;
    return 0;
  }
  if(x1>=x2&&y1>=y2){
    cout << x2+yy<<" "<<y2-xx<<" "<<x1+yy<<" "<<y1-xx<<endl;
    return 0;
  }
}


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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
ll dp[3010][3010];
ll a,b;
string s,t;
int main(){
	fast;
	string ans="";
	cin>>s>>t;
	a=s.length();
	b=t.length();
	for(ll i=0;i<=a;i++){
		for(ll j=0;j<=b;j++){
			if(i==0||j==0){
				dp[i][j]=0;
			}
			else if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	ll i=a;
	ll j=b;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			ans+=t[j-1];
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

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

#define MAX 45
#define NIL -1

typedef struct {
	int parent;
	int left;
	int right; 
} Tree; 

int index = 0;
vector<int> v;


void rebuild(Tree T[], int pre[], int in[], int left, int right, int n)
{
	int rootIndex;
	
//	if (index+1 > n-1)
//		return;
	if (left >= right)
		return;
	
	for (int i = left; i < right; i++) {
		if (pre[index] == in[i]) {
			rootIndex = i;
			break;
		}
	}
	
	if (rootIndex != left) {
		if (index+1 > n-1)
			return;
		index++;
		T[in[rootIndex]].left = pre[index];
		T[pre[index]].parent = in[rootIndex];
		rebuild(T, pre, in, left, rootIndex, n);
	}
	if (rootIndex+1 != right) {
		if (index+1 > n-1)
			return;
		index++;
		T[in[rootIndex]].right = pre[index];
		T[pre[index]].parent = in[rootIndex];
		rebuild(T, pre, in, rootIndex+1, right, n);
	}
}

void Postorder(Tree T[], int rootId)
{
	if (rootId == NIL)
		return;
		
	Postorder(T, T[rootId].left);
	Postorder(T, T[rootId].right);
	//cout << rootId << " ";
	v.push_back(rootId);
}

int main(void)
{
	Tree T[MAX];
	int pre[MAX];
	int in[MAX];
	int n;
	
	cin >> n;
	for (int i = 0; i <= n; i++) {
		T[i].parent = NIL;
		T[i].left = NIL;
		T[i].right = NIL;
	}
	for (int i = 0; i < n; i++) {
		cin >> pre[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> in[i];
	}
	rebuild(T, pre, in, 0, n, n);
	Postorder(T, pre[0]);
	for (int i = 0; i < v.size(); i++) {
		if (i > 0)
			cout << " ";
		cout << v[i];
	}
	cout << '\n';
	
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
const long long MOD = 998244353;
const int MAX = 2000001;
long long fac[MAX];
long long finv[MAX];
long long inv[MAX];
 
long long power(long long m, long long n){
    long long res = 1;
    while(n > 0){
        if(n & 1) {
            res = (res * m) % MOD;
        }
        m = (m * m) % MOD;
        n >>= 1;
    }
    return res;
}

long long inverse(long long a){
    return power(a, MOD - 2);
}
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  comb_init();

  long long ans = 0;
  for(int i = 0; i <= K; i++){
    long long base = (M * power(M - 1, N - i - 1)) % MOD;
    long long cur_diff = (comb(N - 1, i) * base) % MOD;
    ans = (ans + cur_diff) % MOD;
    //cout << i << " " << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 50528
N,M=map(int,input().split())
L=[[] for _ in range(N)]
visited=[True]+[False]*(N-1)
for _ in range(M):
    a,b=map(int,input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
def dfs(now,cnt):
    ans=0
    if cnt==N:
        return 1
    for nxt in L[now]:
        if visited[nxt]:
            continue
        visited[nxt]=True
        ans+=dfs(nxt,cnt+1)
        visited[nxt]=False
    return ans
print(dfs(0,1))

Measured memory_bytes: 41564
#include<bits/stdc++.h>
#define N 300050
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N
using namespace std;
double l;
double cube(double a){
    return a*a*a;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   cin>>l;
   cout<<fixed<<setprecision(15)<<cube(l/3.0);
        return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int x=max(a,max(b,c));
    cout << a+b+c+x*(pow(2,k)-1) <<endl;
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a > b){
        int t = a;
        a = b;
        b = t;
    }
    if(b > c){
        int t = b;
        b = c;
        c = t;
    }
    if(a > b){
        int t = a;
        a = b;
        b = t;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
long long t[5];
char s[15];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        scanf("%s",s);
        if(s[0]=='M')
            t[0]++;
        if(s[0]=='A')
            t[1]++;
        if(s[0]=='R')
            t[2]++;
        if(s[0]=='C')
            t[3]++;
        if(s[0]=='H')
            t[4]++;
    }
    long long sum=0;
    for(int i=0; i<5; i++)
        for(int j=i+1; j<5; j++)
            for(int k=j+1; k<5; k++) {
                sum+=t[i]*t[j]*t[k];
            }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
import numpy as np
H, W, K = map(int, input().split())
p = 10**9 + 7
r = [1, 1, 2, 3, 5, 8, 13, 21, 34]
dp = np.zeros([H + 1, W], dtype=int)
dp[0, 0] = 1
for h in range(H):
    for w in range(W):
        if w != 0:
            dp[h+1, w] += ((dp[h, w-1] * r[w-1])%p * r[W-1-w])%p
        dp[h+1, w] += ((dp[h, w] * r[w])%p * r[W-1-w])%p
        if w != W-1:
            dp[h+1, w] += ((dp[h, w+1] * r[w])%p * r[W-2-w])%p
        dp[h+1, w] = dp[h+1, w]%p
print(dp[H, K-1])

Measured memory_bytes: 12508
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;in(N);
  vector<int>a(N);ins(a);
  int now=1,cnt=0;
  bool f=true;
  rep(i,N){
    if(a[i]!=now){
      cnt++;
    }else{
      now++;
    }
    if(a[i]==1)f=false;
  }
  if(f)out(-1);
  else out(cnt);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1152
A = [int(input()) for i in range(5)]
amari = A[0] % 10
index = 0

for i in range(1, 5):
    if 0 < A[i] % 10 < amari:
        amari = A[i] % 10
        index = i

for i in range(5):
    if i == index:
        continue
    for j in range(10):
        if A[i] % 10:
            A[i] += 1
        else:
            break

print(sum(A))


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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,m,n) for(int i=m;i>n;i--)

int main(){
  long n,l;
  cin >> n >> l;
  vector<long> a(n);
  rep(i,0,n) cin >> a[i];
  
  bool flag=false;
  long index;
  rep(i,0,n-1) {
    if(a[i]+a[i+1]>=l) {
      flag=true;
      index=i+1;
      break;
    }
  }
  if(!flag) {
    cout << "Impossible" << endl;
  }
  else {
   cout << "Possible" << endl;
   rep(i,1,index) cout << i << endl;
   repr(i,n-1,index-1) cout << i << endl; 
  }
}

Measured memory_bytes: 1664
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int a,b;
	std::cin >> a >> b;
	for(int i=1;i<=10000;i++) {
		if(i*8/100==a && i*10/100==b) {
			print(i);
			return 0;
		}
	}
	print(-1);

	return 0;
}


Measured memory_bytes: 256
///F - Make a Rectangle
#include"bits/stdc++.h"

using namespace std;

int main(){

    vector<int> a;
    map<int,int> m;

    int N;
    scanf("%d",&N);

    for(int i = 0; i < N; i++){

        int k;
        scanf("%d",&k);
        a.push_back(k);

    }

    sort(a.rbegin(),a.rend());

    long long int max1 = 0,max2 = 0,maxsqr = 0;

    for(int i = 0; i < N; i++){

        long long int x;
        x = a[i];
        map<int,int>::iterator itr = m.find(x);

        if(!itr->second)
            m[x] = 1;
        else
            m[x]++;

        if(m[x] < 4)
        {

            if(m[x] > 1)
                max1 = max(max1,x);

            if(m[x] > 1 && x < max1)
                max2 = max(max2,x);

        }else
            maxsqr = max(maxsqr,x);

    }

    if(maxsqr*maxsqr > max1*max2)
        printf("%lld",maxsqr*maxsqr);
    else
        printf("%lld",max1*max2);

    return 0;

}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
//#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char a;
    cin >> a;
    ++a;
    cout << a;
}


Measured memory_bytes: 256
import sys
# sys.stdin = open('input.txt')

from math import gcd


k = int(input())
ans = 0
memory = {}

for i in range(1, k+1):
    for j in range(1, k+1):
        temp = gcd(i, j)
        for k in range(1, k+1):
            ans += gcd(temp, k)

print(ans)

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

int main(){
  int a,i,count=0;
  int bbb,ccc;

  scanf("%d",&a);
  
  for(i=1;i<=a;i++){
    scanf("%d",&bbb);
    scanf("%d",&ccc);
    count=ccc-bbb+1+count;
  }
  printf("%d\n",count);
  return 0;
}

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

using namespace std;
int main() {
  int N; 
  cin >> N;
  int sum=0;
  vector<int> A(N);
  for (int i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  for (int i=1;i<N;i=i+2){
    sum-=2*A[i];
  }
  vector<int> result(N);
  result[0]=sum;
  for(int i=1;i<N;i++){
    result[i]=A[i-1]*2-result[i-1];
  }
  for(int i=0;i<N;i++){
    cout<<result[i]<<" ";
  }
  return 0;
}

Measured memory_bytes: 2048
main = interact $ unlines . map (show' . nnw) . init . lines
 where show' (n,d) = if d==1 then show n else show n ++ "/" ++ show d

nnw "north" = (0,1)
nnw "west" = (90,1)
nnw "northwest" = (45,1)
nnw "westnorth" = (45,1)
nnw xs = (irreducible, 2 ^ ((length sign + 2) - div numerator irreducible))
 where
  irreducible = until odd (`div` 2) numerator
  numerator = (sum $ zipWith ($) sign (iterate (*2) 90)) + 90*(2^(length sign))
  sign = map (\c -> if c=='n' then negate else id) $ init $ init $ filter (flip elem "nw") xs

Measured memory_bytes: 3940