akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  string S;
  cin >> S;
  int cnt[3];
  fill(cnt, cnt+3, 0);
  for (auto x : S) {
    cnt[x - 'a']++;
  }
  sort(cnt, cnt+3);
  if (abs(cnt[0] - cnt[2]) < 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;    
  }
}


Measured memory_bytes: 512
N  = int(input())
c = list(map(int,input().split()))

c.sort()
a = c[N-1]
list_c = [0]*(a+1)
for i in c:
  mal = 2
  b = i
  while i<=a:
    list_c[i]+=1
    i = b*mal
    mal+=1
count = 0
for i in c:
  if list_c[i]==1:
    count+=1
print(count)
    
    

Measured memory_bytes: 32376
#include <iostream>
using namespace std;
#include<string>
#define ll long long int

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
const ll N=1e18;



int main(){
    long double a,b,p;
    cin>>a>>b;
    p=a*b;
    p=floor(p);
    cout<<setprecision(17)<<p;
  return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll ans = 1;
  for(ll i=2;i<n;i++){
    ll a = i;
    while(a*i <= n){
      a *= i;
    }
    if(i == a)continue;
    ans = max(ans,a);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 10;
typedef long long ll;
int x,n,k,a[maxn]; 
int main() {
	scanf("%d%d",&k,&n);
	for (int i = 0; i < n; i++)
		scanf("%d",&a[i]);
	int d = 0;
	for (int i = 0; i < n; i++) {
		d = max(d,(a[i] - a[(i - 1 + n) % n] + k) % k);
	}
	printf("%d\n",k - d);
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int Mod = 998244353, r = 3;
const int N = 1 << 15, M = 210;

int Pow(int x, int e) {
	int ret = 1;
	while (e) {
		if (e & 1) ret = 1ll * ret * x % Mod;
		x = 1ll * x * x % Mod;
		e >>= 1;
	}
	return ret;
}

int rev[N];

void DFT(int *A, int n, int f) {
	For(i, 0, n - 1) if (i < rev[i]) swap(A[i], A[rev[i]]);
	static int w[N];
	for (int i = 1; i < n; i <<= 1) {	
		w[0] = 1, w[1] = Pow(r, (Mod - 1) / (i << 1));
		if (f == -1) w[1] = Pow(w[1], Mod - 2);
		for (int j = 2; j < i; ++j) w[j] = 1ll * w[j - 1] * w[1] % Mod;

		for (int j = 0; j < n; j += i << 1)
			for (int k = 0; k < i; ++k) {
				int x = A[j + k], y = 1ll * w[k] * A[i + j + k] % Mod;
				A[j + k] = (x + y) % Mod, A[i + j + k] = (x + Mod - y) % Mod;
			}

	}
}

int dp[M][N];
int fac[N], rfac[N];

int C(int n, int m) {
	return 1ll * fac[n] * rfac[m] % Mod * rfac[n - m] % Mod;
}

int A[N], mul[N];

int main() {

	int n = N - 5, m;
	fac[0] = 1;
	For(i, 1, n) fac[i] = 1ll * fac[i - 1] * i % Mod;
	rfac[n] = Pow(fac[n], Mod - 2);
	Forr(i, n, 1) rfac[i - 1] = 1ll * rfac[i] * i % Mod;

	scanf("%d%d", &n, &m);
	dp[0][0] = 1;

	int l = 1;
	while (l <= n * 2) l <<= 1;
	For(i, 0, l - 1) rev[i] = (rev[i >> 1] >> 1) | (i & 1 ? l / 2 : 0);
	For(i, 1, n) mul[i] = rfac[i + 2];
	DFT(mul, l, 1);
	int inv = Pow(l, Mod - 2);

	For(i, 1, m) {
		For(j, 0, l - 1) A[j] = 1ll * dp[i - 1][j] * rfac[j] % Mod;
		DFT(A, l, 1);
		For(j, 0, l - 1) A[j] = 1ll * A[j] * mul[j] % Mod;
		DFT(A, l, -1);
		For(j, 0, l - 1) A[j] = 1ll * A[j] * inv % Mod * fac[j + 2] % Mod;
		For(j, 0, n) dp[i][j] = (A[j] + 1ll * dp[i - 1][j] * (C(j + 1, 2) + 1)) % Mod;
	}

	int ans = 0;
	For(i, 0, n) ans = (ans + 1ll * dp[m][i] * C(n, i)) % Mod;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 25728
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
result = []
max = -1
for i in 0...n
  if (i == 0)
    result << 0
    max = a[i]
    next
  end
  if (a[i] <= max)
    result << max - a[i]
  else
    result << 0
    max = a[i]
  end
end
puts result.sum

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int x = Integer.parseInt(in.readLine());
    int max = 0;
    for(int i=2; i<=x; i++) {
      for(int j=2; Math.pow(i,j)<=x; j++) {
          max = Math.max((int)Math.pow(i,j),max);
      }
    }
    System.out.println(x==1?1:max);
  }
}

Measured memory_bytes: 32816
#include <cstdio>
#include <cmath>
using namespace std;
const double PI=3.14159265358979323846;
int a, b, x; double t, ans;
int main() {
  scanf("%d %d %d", &a, &b, &x);
  if(a*a*b<2*x) {
    x = a*a*b-x;
    t = 2.0*x/(a*a*a);
  } else {
    t = a*b*b/(2.0*x);
  }
  ans = atan(t)*180.0/PI;
  printf("%lf\n", ans);
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int p=1;
  for(int i=0;i<n-1;i++){
    if(s.at(i)!=s.at(i+1)){
      p++;
    }
  }
  cout<<p<<endl;
}

Measured memory_bytes: 512
import itertools
L=9**9
dp={0:0}
for v in itertools.accumulate(map(lambda c:1<<ord(c)-ord('a'),input()),lambda a,b:a^b):
	dp[v]=min(dp.get(v,L),min(dp.get(v^1<<i, L)for i in range(26))+1)
print(dp[v]+(v==0))

Measured memory_bytes: 32884
x = gets.chomp.to_i
n = (x ** (1/2.0)).floor
max = 1
2.upto(n) do |b|
        p = 2
        while(b ** p <= x)
                p += 1
        end
        n = b ** (p - 1)
        max = (max < n) ? n : max
end
puts max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
#define inf 1000000007
using namespace std;
int cnt[1000];

signed main() {
	int n,ans=1;
	cin>>n;
	for(int i=2;i<=n;i++){
		int x=i,a=2;
		while(a*a<=x){
			if(x%a==0){
				cnt[a]++;
				cnt[a]%=inf;
				//cout<<a<<endl;
				x/=a;
			}
			else{
				a++;
			}
		}
		cnt[x]++;
		cnt[x]%=inf;
		//cout<<x<<endl;
	}
	for(int i=1;i<=1000;i++){
		ans*=(cnt[i]+1)%inf;
		ans%=inf;
		//cout<<cnt[i]<<endl;
	}
	cout<<ans<<endl;
}


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

typedef long long ll;

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    if(k<a){
        cout<<a-k<<" "<<b<<endl;;
    }else if(k>=a&&k<a+b){
        ll c=k-a;
        cout<<0<<" "<<b-c<<endl;
    }else{
      	cout<<0<<" "<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
n,w = map(int,input().split())
v = [0]*n
for i in range(n):
    v[i] = list(map(int,input().split()))

dp = [[0 for j in range(w+1)] for i in range(n+1)]

for i,[W,V] in enumerate(v):
    for j in range(w):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j + W <= w:
            dp[i+1][j+W] = max(dp[i][j]+V, dp[i+1][j+W])

ans = 0
for i in range(1,n+1):
    ans = max(ans, max(dp[i]))
print(ans)



Measured memory_bytes: 217712
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

ll gcd(ll a,ll b){
	if(a%b==0)	return b;
	return gcd(b,a%b);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;	cin>>t;
	while(t--){
		ll a,b,c,d;	cin>>a>>b>>c>>d;
		if(a<b || d<b){
			printf("No\n");	continue;
		}
		if(c>=b-1){
			printf("Yes\n");	continue;
		}
		ll temp=b-(a%b),hcf=gcd(b,d);
		if(temp%hcf==0){
			temp=(temp/hcf)-1;
		}
		else{
			temp/=hcf;
		}
		if((a%b + (temp*hcf))%b > c)	printf("No\n");
		else	printf("Yes\n");
	}
	return 0;
}

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

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];

    ll ans = 0;
    ll mask;
    for (mask = 1; mask < MAX_A; mask <<= 1)
    {
        ll cnt = 0;
        rep(i, 0, n)
        if (mask & a[i]) ++cnt;

        if (cnt * 2 < n)
            ans += mask;
    }

    for (mask; mask > 0; mask >>= 1)
    if ((mask & ans) != (mask & k))
    {
        if (mask & k)
            break;
        else
            ans -= mask;
        // cout << ans << ' ' << k << endl;
    }

    ll res = 0;
    rep(i, 0, n)
        res += a[i] ^ ans;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
int main()
{

    ull N;
    cin >> N;
    int ans = 0;
    for (int i = 2; i <= (int)(1e6); ++i)
    {
        int cur = 0;
        while (N % i == 0)
        {
            cur++;
            N /= i;
        }
        for (int j = 1; j <= cur; ++j)
        {
            if (cur < j)
                break;
            ans++;
            cur -= j;
        }
    }
    if (N > 1)
        ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
	int input[4][4],tc;
	for(int i = 0;i<3;i++)
	{
		for(int j = 0;j<3;j++)
		{
			scanf("%d",&input[i][j]);
		}
	}
	scanf("%d",&tc);
	int testcase;
	for(int i = 0;i<tc;i++)
	{
		scanf("%d",&testcase);
		for(int i = 0;i<3;i++)
		{
			for(int j = 0;j<3;j++)
			{
				if(input[i][j] == testcase)
				{
					input[i][j] = 0;
				}
			}
		}
	}
	if(input[0][0] == 0 && input[1][1] == 0 && input[2][2] == 0)
	{
		puts("Yes");
	}
	else if(input[0][2] == 0 && input[1][1] == 0 && input[2][0] == 0)
	{
		puts("Yes");
	}
	else if(input[0][0] == 0 && input[0][1] == 0 && input[0][2] == 0)
	{
		puts("Yes");
	}
	else if(input[1][0] == 0 && input[1][1] == 0 && input[1][2] == 0)
	{
		puts("Yes");
	}
	else if(input[2][0] == 0 && input[2][1] == 0 && input[2][2] == 0)
	{
		puts("Yes");
	}
	else if(input[0][0] == 0 && input[1][0] == 0 && input[2][0] == 0)
	{
		puts("Yes");
	}
	else if(input[0][1] == 0 && input[1][1] == 0 && input[2][1] == 0)
	{
		puts("Yes");
	}
	else if(input[0][2] == 0 && input[1][2] == 0 && input[2][2] == 0)
	{
		puts("Yes");
	}
	else
	{
		puts("No");	
	}
	return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int A[M];
  REP(i,M){
    cin>>A[i];
    N-=A[i];
  }
  
  if(N>=0) cout<<N<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ




//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m ;
  cin >> n >> m ;
  int cnt = 0 ;
  int pen = 0 ;
  vector<int> vec(n,0) ;
  vector<int> che(n,0) ;
  
  REP(i,m){
    int a ;
    string s ;
    cin >> a >> s ;
    if(s=="WA"){
      vec.at(a-1)++ ;
    }
    else{
      if(che.at(a-1)==0){
        pen += vec.at(a-1) ;
        cnt++ ;
        che.at(a-1)++ ;
      }
    }
  }
  cout << cnt << " " << pen <<endl ;
      

    
    
  
  
  
  return 0 ;
}




Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define MAX 100
#define INFTY (1<<30)
#define rep(i,n) for(int i=0;i<n;i++)
enum{
	white,
	gray,
	black,
};

int n,m[MAX][MAX];

 void dijkstra(){
 	int minv;
 	int d[MAX],color[MAX];
 	rep(i,n){
 		d[i]=INFTY;
 		color[i]=white;
 	}
	d[0]=0;
 	color[0]=gray;
 	while(1){
 		minv=INFTY;
 		int u=-1;
 		rep(i,n){
 			if(minv>d[i]&&color[i]!=black){
 				u=i;
 				minv=d[i];
 			}
 		}
 		if(u==-1)	break;
 		color[u]=black;
 		rep(v,n){
 			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;
 				}
 			}
 		}
 	}
 	rep(i,n){
 		cout<<i<<" ";
 		if(d[i]==INFTY)	cout<<-1<<endl;
 		else	cout<<d[i]<<endl;
 	}
 }

 int main(){
 	cin>>n;
 	rep(i,n){
 		rep(j,n)		m[i][j]=INFTY;
 	}
 	int k,c,u,v;
 	rep(i,n){
 		cin>>u>>k;
 		rep(j,k){
 			cin>>v>>c;
 			m[u][v]=c;
 		}
 	}
 	dijkstra();
 	return 0;
 }

Measured memory_bytes: 1200
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		    total += arr[i];
		}
		Arrays.sort(arr);
		if (total % 10 != 0) {
		    System.out.println(total);
		    return;
		}
		for (int i = 0; i < n; i++) {
		    if (arr[i] % 10 != 0) {
		        System.out.println(total - arr[i]);
		        return;
		    }
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

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

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

int main(){
    int n;
    while(cin>>n, n){
        int sum=0, smin=1000, smax=0;
        for(int i=0; i<n; i++){
            int s; cin>>s;
            sum+=s;
            chmin(smin, s);
            chmax(smax, s);
        }
        sum-=smin;
        sum-=smax;
        
        cout << sum/(n-2) << endl;
    }
}


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

int main(void)
{
  int i, shfnum, pos;
  string cards, ctmp;
  while (1) {
    cin >> cards;
    if (cards == "-") break;
    cin >> shfnum;
    for (i = 0; i < shfnum; i++) {
      cin >> pos;
      ctmp = cards.substr(0, pos);
      cards = cards.erase(0, pos);
      cards += ctmp;
    }
    cout << cards << endl;
  }
  return 0;
}

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

int n, r, p, c;
vector<int> cards(50);

void shuffle(int p, int c) {
	reverse(cards.begin(), cards.begin() + p);
	reverse(cards.begin() + p, cards.begin() + p + c);
	reverse(cards.begin(), cards.begin() + p + c);
}

int main() {
	while (1) {
		cin >> n >> r;
		if ( ! n && ! r) break;

		iota(cards.rend() - n, cards.rend(), 1);
		for (int i=0; i<r; ++i) {
			cin >> p >> c;
			shuffle(p - 1, c);
		}
		cout << cards[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
round' :: (RealFrac a, Integral b) => a -> b
round' x
  | f <= -0.5 = n - 1
  | f >= 0.5  = n + 1
  | otherwise = n
  where (n, f) = properFraction x

solve :: [(Int, Int)] -> (Int, Int)
solve xs = let (tp, tn) = foldl f (0, 0) xs
               f (tp, tn) (p, n) = (tp + p * n, tn + n)
            in (tp, round' (fromIntegral tn / fromIntegral (length xs)))

main :: IO ()
main = getContents >>= printResult . solve . input
  where input = map (tup . words) . lines . map c2s
        c2s c = if c == ',' then ' ' else c
        tup (a:b:_) = (read a, read b)
        printResult (a, b) = print a >> print b

Measured memory_bytes: 3700
#include <iostream>

using namespace std;

int main() {
	int l, n, m, s[100][100][2];
	while (cin >> n >> m, n || m) {
		for (int y = 0; y < 100; ++y)
			for (int x = 0; x < 100; ++x) {
				if (x == y) s[y][x][0] = 0, s[y][x][1] = 0;
				else s[y][x][0] = 100000, s[y][x][1] = 100000;
			}

		for (int i = 0; i < n; ++i) {
			int a, b, cost, time;
			cin >> a >> b >> cost >> time;
			--a, --b;
			s[a][b][0] = cost, s[b][a][0] = cost;
			s[a][b][1] = time, s[b][a][1] = time;
		}

		for (int t = 0; t < 2; ++ t)
			for (int i = 0; i < m; ++i)
				for (int j = 0; j < m; j++)
					for (int k = 0; k < m; k++)
						if (s[j][k][t] > s[j][i][t]+s[i][k][t])
							s[j][k][t] = s[j][i][t]+s[i][k][t], s[k][j][t] = s[j][k][t];

		cin >> l;
		for (int i = 0; i < l; ++ i) {
			int p, q, r;
			cin >> p >> q >> r;
			--p, --q;
			cout << s[p][q][r] << endl;
		}
	}
}

Measured memory_bytes: 940
def dfs(i, total, count, left):
    global ans
    if i == d:
        if total < g:
            target = max(left)
            n = min(pc[target - 1][0], -(-(g - total) // (target * 100)))
            count += n
            total += n * target * 100

        if total >= g:
            ans = min(ans, count)

    else:
        dfs(i+1, total, count, left)
        dfs(i + 1, total + pc[i][0] * (i + 1) * 100 + pc[i][1], \
        count + pc[i][0], left - {i + 1})

d,g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0,0,0,set(range(1,d+1)))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	while (true) {
		int n, w;

		cin >> n >> w;

		if (n == 0 && w == 0) {
			break;
		}

		int graph[100] = { 0 };
		int size = 0;
		int higher = 0;
		double ans = 0;

		rep(i, n) {
			int temp;

			cin >> temp;

			graph[temp / w]++;

			size = max(size, temp / w);
			higher = max(higher, graph[temp / w]);
		}

		rep(i, size + 1) {
			ans += (double)graph[i] / higher*(size - i) / size;
		}

		cout << ans + 0.01 << endl;
	}

	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  string s;
  cin >> s;
  i64 p, l, r;
  l = s.size();
  r = s.size() + 1;
  string n, m;
  for (i64 i = 0; i < s.size(); i++)
    if (s[i] == '.')
      p = i;
    else if (s[i] == '(')
    {
      l = i;
      m = n;
    }
    else if (s[i] == ')')
      r = i;
    else
      n += s[i];
  i64 ans[2];
  if (r - l - 1 == 0)
  {
    ans[0] = stoi(n);
    ans[1] = pow(10, l - p - 1);
  }
  else
  {
    ans[0] = stoi(n) - stoi(m);
    ans[1] = pow(10, l - p - 1 + r - l - 1) - pow(10, l - p - 1);
  }
  i64 g = __gcd(ans[0], ans[1]);
  cout << ans[0] / g << "/" << ans[1] / g << endl;
  return 0;
}



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

#define ll long long
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
pair<ll,ll>A[10000000] = {}, X[1000000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = INFL, b = 0, c = 0, n = 0, sum = 0, max = INF;
str S;
ll ans = 0;

int findDigits(int n) {
	int i = 0;
	while (n > 0) {

		sum += n % 10;
		n /= 10;
		i++;
	}
	return i;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n;
	for (int i = 0; i < n; i++)cin >> A[i].first;
	for (int i = 0; i < n; i++)cin >> A[i].second;
	for (int i = 0; i < n; i++) {
		if (A[i].first - A[i].second >= 1)ans += A[i].first - A[i].second;
	}

	cout << ans << endl;
	cin >> ans;
	//Code Line
	return 0;
}


Measured memory_bytes: 172160
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];
    int ans = 0;
    rep(i, n)
    {
        if (h[i] >= k)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
n, max_w = map(int, input().split())
item = [tuple(int(x) for x in input().split()) for _ in range(n)]

ans = dict()
ans[0] = 0
for w, v in item:
    next = dict()
    for temp_w, temp_v in ans.items():
        if temp_w + w <= max_w:
            if temp_w + w not in next.keys():
                next[temp_w + w] = temp_v + v
            else:
                if temp_v + v > next[temp_w + w]:
                    next[temp_w + w] = temp_v + v
    #print(next)
    for x, y in next.items():
        if x not in ans.keys():
            ans[x] = y
        else:
            if y > ans[x]:
                ans[x] = y

#print(ans)
res = 0
for x, y in ans.items():
    res = max(res, y)

print(res)


Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;


int main(void){
  
  string s;
  cin>>s;
  
  
  long long int t=0;
  
  for(long long int i=0;i<s.size();i++){
  	t+=s[i]-'0';
  }

  if(t%9==0){
  	cout<<"Yes"<<endl;
  }else{
  	cout<<"No"<<endl;
  }
  
    
}

Measured memory_bytes: 3716
X = int(input())
if 0 <= X <= pow(10, 9):
    max500Coins = int(X/500)
    X = X % 500
    max5Coins = int(X/5)
    X = X % 5
    numberOFHappinessCoins = max500Coins*1000 + max5Coins*5
    print(numberOFHappinessCoins)

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M;
vector<int> edge [100001];
bool vis [100001];

bool dfs(int curr,int p,map<int,int>& color)
{
	vis [curr] = true;
	color [curr] = p;
	int res = true;
	for(const auto& it : edge [curr]){
		if(color.count(it) == 0){
			res &= dfs(it,!p,color);
		}
		else{
			res &= color [it] == !p;
		}
	}
	return res;
}

int main()
{
	scanf("%d%d",&N,&M);
	FOR(i,0,M){
		int u,v;
		scanf("%d%d",&u,&v);
		edge [u].push_back(v);
		edge [v].push_back(u);
	}

	ll x = 0,y = 0,z = 0;
	FOR(i,1,N + 1) if(vis [i] == false){
		map<int,int> color;
		if(dfs(i,0,color)){
			if(color.size() == 1){
				x++;
			}
			else{
				y++;
			}
		}
		else{
			z++;
		}
	}
	ll ans = x * N * 2 - x * x + y * y * 2 + y * z * 2 + z * z;

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 17920
using System;

namespace Number
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string[] i = Console.ReadLine().Split(' ');

                if(i[1] == "?") break;

                int a = int.Parse(i[0]);
                int b = int.Parse(i[2]);
                int ans = 0;

                switch(i[1])
                {
                    case "+":
                        ans = a + b;
                        break;
                    case "-":
                        ans = a - b;
                        break;
                    case "*":
                        ans = a * b;
                        break;
                    case "/":
                        ans = a / b;
                        break;
                }

                Console.WriteLine("{0}", ans);
            }
        }
    }
}

Measured memory_bytes: 9264
#include <stdio.h>

int main()
{
    int rect_w, rect_h, x, y, r;

    scanf("%d %d %d %d %d", &rect_w, &rect_h, &x, &y, &r);

    if (x >= r && x + r <= rect_w && y >= r && y + r <= rect_h){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
vector<int> rel[1000000];
bool checked[1000000];

void dfs(int i){
    checked[i] = true;
    for (int j : rel[i])
    {
        if(!checked[j]){
            dfs(j);
        }
    }    
}

int main(){
    int n,m;
    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin>> a >> b >> c;
        rel[a-1].push_back(b-1);
        rel[b-1].push_back(a-1);
    }
    memset(checked,false, sizeof(checked));
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        if(!checked[i]){
            dfs(i);
            sum ++ ;
        }
    }
    cout << sum << endl; 
}


Measured memory_bytes: 34156
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,m,d[100010],a[1000010],b,i,r[100010]={};
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d",&a[R],&b);
    hin(b);
  }
  for(i=0;i<m;i++){
    b=hout();
    d[b-1]=r[a[b]]++;
  }
  for(i=0;i<m;i++)printf("%06d%06d\n",a[i+1],d[i]+1);
  return 0;
}


Measured memory_bytes: 8960
import sys
N,M=map(int,input().split())
table=[]
for i in range(M):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    if x>y:
        x,y=y,x
    table.append((x,y))
L=[0]*N
for x,y in table:
    if x==0:
        L[y]+=1
    else:
        L[x]+=1
        L[y]+=1
for s in L:
    if s%2==1:
        print('NO')
        sys.exit()
print('YES')

Measured memory_bytes: 53720
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a[3];
	REP(i, 3) {
		char e;
		cin >> e;
		a[i] = e - 'a';
	}
	sort(a, a + 3);
	if (a[0] == 0 && a[1] == 1 && a[2] == 2) cout << "Yes" << endl;
	else cout << "No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        int tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

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

    int lgcd[n], rgcd[n];
    lgcd[0] = a[0];
    for (int i = 1; i < n; i++) lgcd[i] = gcd(lgcd[i - 1], a[i]);
    rgcd[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0 ; i--) rgcd[i] = gcd(rgcd[i + 1], a[i]);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0) ans = max(ans, rgcd[1]);
        else if (i == n - 1) ans = max(ans, lgcd[n - 2]);
        else ans = max(ans, gcd(lgcd[i - 1], rgcd[i + 1]));
    }

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


Measured memory_bytes: 1408
require 'time'

n, t = gets.split.map(&:to_i)
output = []

_, _, prev_ar_time, _ = gets.split
while gets
    st_time, st_name, ar_time, ar_name = $_.split
    x = (Time.parse(st_time) - Time.parse(prev_ar_time)).to_i / 60
    output << "#{st_name} #{x}" if x >= t
    prev_ar_time = ar_time
end

puts output.size, output

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

#define ll long long

int main()
{
    ll n, w;
    cin >> n >> w;
    vector<pair<ll, ll>> wv(n + 1);

    for(ll i = 1; i <= n; i++)
    {
        cin >> wv[i].first >> wv[i].second;
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1));

    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= w; j++)
        {
            if(j - wv[i].first >= 0)
            {
                dp[i][j] = max(dp[i - 1][j - wv[i].first] + wv[i].second, dp[i - 1][j]);   
            }
            else
            {
                dp[i][j] = dp[i - 1][j];
            }       
        }
    }

    cout << dp[n][w];

    return 0;
}

Measured memory_bytes: 83136
fn main() {
    let mut nk = String::new();
    std::io::stdin().read_line(&mut nk).unwrap();
    let nk: Vec<usize> = nk.trim().split_whitespace().flat_map(str::parse).collect();
    let n = nk[0];
    let k = nk[1];

    let mut x = String::new();
    std::io::stdin().read_line(&mut x).unwrap();
    let x: Vec<isize> = x.trim().split_whitespace().flat_map(str::parse).collect();

    println!("{}", (0..(n - k+1)).map(|s| {
        let start = x[s];
        let end = x[s + k - 1];
        if start >= 0 {
            end
        } else if end > 0 {
            let a = -start * 2 + end;
            let b = -start + end * 2;
            if a < b { a } else { b }
        } else {
            -start
        }
    }).min().unwrap());
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ll long long
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}

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

int main(){
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
	int N, K; cin >> N >> K;
	ll A[N];
	for(int i=0; i<N; i++){ cin >> A[i]; A[i]--;}
	ll sum[N];
	sum[0] = A[0]%K;
	ll ans = 0;
	map<ll, ll> m;
	m[0]++;
	ans += m[sum[0]];
	m[sum[0]]++;
	for(int i=1; i<N; i++){
		sum[i] = (sum[i-1] + A[i]) % K;
		if(i - K + 1 >= 0){
			if(i-K+1 == 0) m[0]--;
			else m[sum[i-K]]--;
		}
		ans += m[sum[i]];
		m[sum[i]]++;
	}
	if(K==1) cout << 0 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
int main()
{
	char input[10];
	scanf("%s", input);

	char temp;
	temp = input[0];
	bool bGood = true;
	for (int i = 1; i < 4; i++) {
		if (temp == input[i]) {
			bGood = false;
			break;
		}
		temp = input[i];
	}

	if (bGood) {
		printf("Good\n");
	}
	else {
		printf("Bad\n");
	}

	return 0;
}

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

int main() {
  int N, K, ans = 1;
  cin >> N >> K;
  
  do {
    if (N < K) break;
    N = N/K;
    ans += 1;
  } while (N >= K);
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	a, _ := strconv.Atoi(stringLineScan())
	b, _ := strconv.Atoi(stringLineScan())
	x, _ := strconv.Atoi(stringLineScan())
	ans := 0
	for i := 1; i < n; i++ {
		y, _ := strconv.Atoi(stringLineScan())
		ans += smaller(b, a*(y-x))
		x = y
	}
	fmt.Println(ans)
}
func smaller(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int main(){
  int n,p; cin >>n >>p;
  string s; cin >>s;
  if(p==2 or p==5){
    li cnt=0;
    rep(i,n){
      if((s[i]-'0')%p==0) cnt+=i+1;
    }
    print(cnt);
    return 0;
  }
  reverse(s.begin(),s.end());
  
  vector<int> rem(n);
  int r10=1,r=0;
  rep(i,n){
    r+=(s[i]-'0')*r10;
    rem[i]=r%=p;
    (r10*=10)%=p;
  }
  if(df)  print(rem);
  vector<li> memo(p,0);
  li cnt=0;
  rep(i,n){
    cnt+=memo[rem[i]]++;
  }
  print(cnt+memo[0]);
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    string s,t;
    cin>>s>>t;
    
    int n=s.length();
    int m=t.length();
    int dp[n+1][m+1],i,j;
 
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
            else
            {
                if(s[i-1]==t[j-1])
                {
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
    }
   i=n;
   j=m;
   vector<char>v;
   while(i>0 && j>0)
   {
       if(dp[i][j] != max(dp[i-1][j],dp[i][j-1]))
       {
           v.push_back(s[i-1]);
           i--;j--;
       }
       else if(dp[i][j]==dp[i-1][j])
       {
           i--;
       }
       else
       {
           j--;
       }
   }
   for(i=v.size()-1;i>=0;i--)
   {
       cout<<v[i];
   }
   cout<<endl;
}

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

int main() {
	int n, m, x;
	cin >> n >> m >> x;

	int l = 0;
	int r = 0;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		if (a < x) {
			l++;
		} else {
			r++;
		}
	}
	int ans = min(l, r);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::map<ll, ll> prime_factor( ll x )
{
  std::map<ll, ll> ret;

  for( ll i = 2; i*i <= x; ++i )
  {
    while( x%i == 0 )
    {
      ++ret[i];
      x /= i;
    }
  }

  if( x != 1 )
    ++ret[x];

  return ret;
}

const ll mod = 1000000007;

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

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

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N, M;
combination comb( 1000010 );

int main()
{
  std::cin >> N >> M;

  auto mp = prime_factor(M);

  mint ans = 1;

  itr( it, mp )
    ans *= comb( it->second+N-1, N-1 );

  std::cout << ans.x << std::endl;

  return 0;
}

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

int main(){
    using namespace std;
    unsigned long T;
    cin >> T;
    for(unsigned long testcases{0}; testcases < T; ++testcases){
        unsigned long N, A, B, C, D;
        cin >> N >> A >> B >> C >> D;
        priority_queue<pair<unsigned long, unsigned long>, vector<pair<unsigned long, unsigned long>>, greater<>> pq;
        pq.emplace(0, N);
        map<unsigned long, unsigned long> mp;
        mp[N] = 0;
        const auto& try_push = [&pq, &mp](unsigned long x, unsigned long c){
            if(mp.count(x) && mp[x] <= c)return;
            mp[x] = c;
            pq.emplace(c, x);
        };
        unsigned long ans{numeric_limits<unsigned long>::max()};
        while(!pq.empty()){
            auto [c, x] = pq.top();
            pq.pop();
            if(c > ans){
                cout << ans << endl;
                break;
            }
            ans = min(ans, x * D + c);
            if(mp[x] > c) mp[x] = c;
            try_push(x / 2, c + A + (x % 2) * D);
            try_push((x + 1) / 2, c + A + (2 - x % 2) * D);
            try_push(x / 3, c + B + (x % 3) * D);
            try_push((x + 2) / 3, c + B + (3 - x % 3) * D);
            try_push(x / 5, c + C + (x % 5) * D);
            try_push((x + 4) / 5, c + C + (5 - x % 5) * D);
        }
    }
    return 0;
}

Measured memory_bytes: 4272
N, A, B = map(int,input().split())
S = input()
p = 0
c = B
for e in S:
    if e == "a":
        if p < A+B:
            print("Yes")
            p += 1
        else:
            print("No")
    elif e == "b":
        if p < A+B and c > 0:
            print("Yes")
            p += 1
            c -= 1
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 4016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int N = sc.nextInt();
        int arr[] = new int[N];
        int second[] = new int[N];
        for (int i=0; i<N; i++) {
            int S = sc.nextInt();
            arr[i] = S;
            second[i] = S;
        }
        Arrays.sort(second);
        int max = second[N-1];
        int max2 = second[N-2];
        for (int i=0; i<N; i++) {
            if (arr[i]==max) {
                System.out.println(max2);
            } else {
                System.out.println(max);
            }
        }
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 50924
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  int a, b;
  cin >> a >> b;
  int ans = (a-1)*(b-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    int A[N+1];
    int B[N];
    long long int sum_monstor = 0;
    for(int i=0;i<N+1;i++){
        scanf("%d",&A[i]);
        sum_monstor += A[i];
    }
    for(int i=0;i<N;i++){
        scanf("%d",&B[i]);
    }
    
    for(int i=0;i<N;i++){
        if(A[i]<=B[i]){
            B[i] -= A[i];
            A[i] = 0;
            if(A[i+1]<=B[i]){
                A[i+1] = 0;
            }else{
                A[i+1] -= B[i];
            }
        }else{
            sum_monstor -= A[i]-B[i];
        }
        /*
        for(int j=0;j<N+1;j++){
            printf("%d, ",A[j]);
        }
        printf("\n");
        */
    }
    sum_monstor -= A[N];
    printf("%lld",sum_monstor);
    return 0;
}

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

int main() {
  vector<set<int>> G(4);
  for (int i = 0; i < 3; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    G.at(a).insert(b);
    G.at(b).insert(a);
  }
  vector<int> v = { 0, 1, 2, 3 };
  do {
    bool can = true;
    for (int i = 0; i < 3; i++) {
      if (!G.at(v.at(i)).count(v.at(i+1))) can = false;
    }
    if (can) {
      cout << "YES" << endl;
      return 0;
    }
  } while (next_permutation(v.begin(), v.end()));
  cout << "NO" << endl;
}

Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll dp[3002][3002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    std::vector<ll> v(n);
    for(ll& x:v)
    {
    	cin>>x;
    }
    for (int l = n-1; l >=0; --l)
    {
    	for (int r = l; r < n ; ++r)
    	{
    		if(l==r)
    		{
    			dp[l][r]=v[l];
    		}
    		else
    			dp[l][r]=max(v[l]-dp[l+1][r],v[r]-dp[l][r-1]);
    	}
    }
    cout<<dp[0][n-1]<<'\n';
}


Measured memory_bytes: 70016
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


long double Fact(int a){
    long double t = a;
    if(a==0) return 1;
    for(int i=a-1; i>=1; i--){
        t *= i;
    }
    return t;
}

long double Combi(int a, int b){
    return Fact(a) / Fact(a - b) / Fact(b);
}

int main() {
    int N, A, B; cin >> N >> A >> B;
    vector<ll> V(N);
    map<ll, int> M;
    for(ll &v:V){
        cin >> v;
        M[v]++;
    }
    
    sort(V.begin(), V.end(), greater<>());
    double av = 0;
    bool same = true;
    int same_num = M[V[0]];
    long double cnt = 1;
    int mncnt = 0;
    
    for(int i=0; i<A; i++){
        av += V[i];
        if(V[i] == V[A-1]) mncnt++;
        if(V[i] != V[0]) same = false;
    }
    
    cnt = Combi(M[V[A-1]], mncnt);
    av /= A;

    if(same){
        cnt = 0;
        for(int i=A; i<=min(same_num, B); i++){
            cnt += Combi(same_num, i);
        }
    }
    cout << fixed << setprecision(10) << av << endl;
    cout << fixed << setprecision(0) << cnt << endl;
    return 0;
    
}


Measured memory_bytes: 256