akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline void setin(string s) {
	freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
	freopen(s.c_str(), "w", stdout);
}

template <typename T> inline T range(T l, T r) {
	return uniform_int_distribution <T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

#define int long long

const int inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 15;
int n, m, a[N];
vector <pii> g[N];
int s, t;

int d[N], ways[N];

inline int add(int a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
	return a;
}

inline void add_t(int &a, int b) {
	a = add(a, b);
}

set <pii> q;

inline int mt(int a, int b) {
	return 1ll * a * b % mod;
}

inline void dxtra(int s, vector <int> &d, vector <int> &ways) {
	d[s] = 0;
	ways[s] = 1;
	q.insert({0, s});
	while(!q.empty()) {
		int v = q.begin()->se;
		q.erase(q.begin());
		for(pii to : g[v]){
			if(d[to.f] > d[v] + to.se) {
				q.erase({d[to.f], to.f});
				ways[to.f] = ways[v];
				d[to.f] = d[v] + to.se;
				q.insert({d[to.f], to.f});
			}
			else if(d[to.f] == d[v] + to.se)
				add_t(ways[to.f], ways[v]);
		}
	}
}

vector <pair <pii, int>> e;

inline int sq(int x) {
	return mt(x, x);
}

main() {
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	// setin("input.txt");
	cin >> n >> m >> s >> t;
	for(int i = 1; i <= m; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		g[u].pb({v, w});
		g[v].pb({u, w});
		e.pb({{u, v}, w});
	}
	vector <int> d1(N, inf), d2(N, inf), ways1(N, 0), ways2(N, 0);
	dxtra(s, d1, ways1);
	dxtra(t, d2, ways2);
	int ans = sq(ways1[t]);

	int d = d1[t];
	for(int i = 1; i <= n; ++i)
		if(d1[i] == d2[i] && d1[i] + d2[i] == d)
			add_t(ans, -sq(mt(ways1[i], ways2[i])));

	for(int i = 0; i < e.size(); ++i) {
		int u = e[i].f.f, v = e[i].f.se, w = e[i].se;
		if(d1[u] + w + d2[v] == d && (d1[u] < d / 2 && d2[v] < d / 2))
			add_t(ans, -sq(mt(ways1[u], ways2[v])));
		swap(u, v);
		if(d1[u] + w + d2[v] == d && (d1[u] < d / 2 && d2[v] < d / 2))
			add_t(ans, -sq(mt(ways1[u], ways2[v])));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34212
#include<bits/stdc++.h>
#include<string>
using namespace std;
main(){
  int n,d;
  string a,b;
  cin>>n>>a>>d;
  for(int i=0;i<n;i++){
    b[i]=a[i];
    if(a[i]=='0'&&d){b[i]='1';d--;}
  }
  if(d)for(int i=n-1;i>=0;i--)if(a[i]=='1'&&d){b[i]='0';d--;}
  for(int i=0;i<n;i++)cout<<b[i];
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3196
import sys
N,T = [int(n) for n in input().split()]
t = [int(n) for n in input().split()]
ans = 0
for i in range(N-1):
    if(t[i+1]-t[i] < T):
        ans+=t[i+1]-t[i]
    else:
        ans+=T

ans+=T
print(ans)


Measured memory_bytes: 25200
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

typedef vector<vector<pair<int,int> > >  Mat;

string str;
int n,pointer;

Mat calMat(Mat a,Mat b);
Mat readSequence();
int readNum();
Mat init();

int ans[101][101];

Mat init()
{
	Mat ret;
	REP(i,n)
	{
		vector<pair<int,int> > tmp;
		REP(j,n)
		{
			tmp.PB(MP(i,j));
		}
		ret.PB(tmp);
	}
	return ret;
}

int readNum()
{
	int ret = 0;
	while(isdigit(str[pointer]))
	{
		ret *= 10;
		ret += str[pointer] - '0';
		pointer++;
	}
	return ret;
}

Mat makeShift(char c,int q)
{
	Mat ret = init();
	q--;
	pair<int,int> tmp;
	if(c == 'U')
	{
		tmp = ret[n-1][q];
		for(int i = n-1;i > 0;i--)ret[i][q] = ret[i-1][q];
		ret[0][q] = tmp;
	}
	else if(c == 'D')
	{
		tmp = ret[0][q];
		for(int i = 0;i < n-1;i++)ret[i][q] = ret[i+1][q];
		ret[n-1][q] = tmp;
	}
	else if(c == 'R')
	{
		tmp = ret[q][0];
		for(int i = 0;i < n-1;i++)ret[q][i] = ret[q][i+1];
		ret[q][n-1] = tmp;
	}
	else
	{
		tmp = ret[q][n-1];
		for(int i = n-1;i > 0;i--)ret[q][i] = ret[q][i-1];
		ret[q][0] = tmp;
	}
	return ret;
}

Mat power(Mat m,int n)
{
	Mat tmp = m;
	Mat ret = init();
	while(n)
	{
		if(n & 1)
		{
			ret = calMat(ret,tmp);
		}
		tmp = calMat(tmp,tmp);
		n >>= 1;
	}
	return ret;
}

Mat readSequence()
{
	Mat ret = init();
	
	while(pointer < str.size())
	{
		if(str[pointer] == '(')
		{
			pointer++;
			ret = calMat(ret,readSequence());
		}
		else if(str[pointer] == ')')
		{
			pointer++;
			int num = readNum();
			ret = power(ret,num);
			return ret;
		}
		else
		{
			char c = str[pointer];
			pointer++;
			int num = readNum();
			Mat mat = makeShift(c,num);
			ret = calMat(ret,mat);
		}
	}
	return ret;
}

Mat calMat(Mat a,Mat b)
{
	Mat ret = a;
	REP(i,n)
	{
		REP(j,n)
		{
			ret[i][j] = b[a[i][j].FI][a[i][j].SE];
		}
	}
	return ret;
}


int main()
{
	int l;
	cin >> n >> l;
	cin >> str;
	
	Mat mat = readSequence();
	int num = 1;
	REP(i,n)
	{
		REP(j,n)
		{
			ans[mat[i][j].FI][mat[i][j].SE] = num;
			num++;
		}
	}
	
	REP(i,n)
	{
		REP(j,n-1)
		{
			cout << ans[i][j] << ' ';
		}
		cout << ans[i][n-1] << endl;
	}
	
	return 0;
}

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

int M[10];

int main(){
	int k;
	for(int i = 0; i <10; ++i){
		cin >> M[i];
	}

	for(int j = 0; j < 9; ++j){
	for(int i = 0; i <9-j; ++i){
		if(M[i] <= M[i+1]){
			k = M[i];
			M[i] = M[i+1];
			M[i+1] = k;
		}
	}
	}

	for(int i = 0; i <3; ++i){
		cout << M[i] << '\n';
	}
	

}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int gcd(int a,int b){
	while(1){
		if(a<b) swap(a,b);
		if(!b) break;
		a %= b;
	}
	return a;
}


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,X;
	cin >> n >> X;
	vector<int> x(n);
	rep(i,0,n){
		cin >> x[i];
		x[i] = abs(X - x[i]);
	}
	int ans = x[0];
	rep(i,1,n){
		ans = gcd(ans,x[i]);
	}
	cout << ans << endl;

}


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

int p=0;

int cat(string &s){
  if(p==s.size()) return p;
  if(s[p]!='m'){
    return p;
  }
  int prep=p;
  p++;
  cat(s);
  if(p==s.size() || s[p]!='e') return p=prep;
  p++;
  cat(s);
  if(p==s.size() || s[p]!='w') return p=prep;
  p++;
  return p;
}

int main(){
  string s;
  cin>>s;
  cout<<(cat(s)==s.size() ? "Cat" : "Rabbit")<<endl;
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005


int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        ll x;
        cin>>x;
        ll y=100;
        for(i=1;i<=100000;i++)
        {
            y=y+y/100;
            if(y>=x)
            {
                cout<<i;return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3612
N=list(input())
A=int(''.join(N[0:2]))
B=int(''.join(N[2:4]))

FLG_A = (A>12) or A==0
FLG_B = (B>12) or B==0


if FLG_A & FLG_B:
    ans='NA'
elif FLG_A & ~FLG_B:
    ans='YYMM'
elif ~FLG_A & FLG_B:
    ans='MMYY'
elif ~FLG_A & ~FLG_B:
    ans='AMBIGUOUS'

print(ans)

Measured memory_bytes: 3188
#include "bits/stdc++.h"

using namespace std;

#define all(v)          v.begin(), v.end()
#define pb              push_back
#define sz(x)          (int) (x.size())
#define endl            "\n"
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))
#define EPS 1e-7

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

int dc(long double x, long double y){
    if(fabs(x-y)<=EPS) return 0;

    if(x<y) return -1;

    return 1;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, d; cin >> n >> d;
    int c  = 0;
    while(n--){
        ll x, y; cin >> x >> y;
        ld di = sqrt(x * x + y * y);
        if(dc(di, d) != 1) c++;
    }
    cout << c;
    return 0;
}


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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int t;cin>>t;rep(i,t)



void solve() {

    ll n, k;
    cin >> n >> k;

    ll arr[n];
    rep(i, n) cin >> arr[i];

    sort(arr, arr + n);

    if (arr[n - 1] == 0 && (k & 1) == 1){
        cout << "0\n";
        return;
    }
    if (arr[n - 1] < 0 && (k & 1) == 1) {
        ll product = 1;
        int i = n - 1;
        while (k > 0) {

            product = (product * arr[i]) % Mod;
            i--;
            k--;
        }
        cout << (product + (ll)Mod) % Mod << "\n";
        return;
    }
    ll product = 1;
    int i = 0, j = n - 1;
    if ((k & 1) == 1) {
        product *= arr[j];
        j--;
        k--;
    }
    
    k >>= 1;
    for (int index = 0; index < k; index++) {
        ll left = (arr[i] * arr[i + 1]);
        ll right = (arr[j] * arr[j - 1]);
        if (left > right) {
            product = (product * (left % Mod)) % Mod;
            i += 2;
        }
        else {
            product = (product * (right % Mod)) % Mod;
            j -= 2;
        }
    }
    cout << (product % Mod + (ll)Mod) % Mod << "\n";
 }

int main()
{
    fastio;
    
    solve();
    //code
    return 0;
}


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

using namespace std;

const int N = 1e5 + 5;
int nxt[26][N];

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

    string s , t;
    cin >> s >> t;

    for (char &c : s) c -= 'a';
    for (char &c : t) c -= 'a';

    memset(nxt , -1 , sizeof nxt);
    for (int i = s.size() - 1 ;i >= 0 ;i--) {
        for (int j = 0 ;j < 26 ;j++)
            nxt[j][i] = nxt[j][i + 1];
        nxt[s[i]][i] = i;
    }

    for (char &c : t) {
        if (nxt[c][0] == -1) {
            cout << -1;
            return 0;
        }
    }

    int p = s.size() - 1;
    long long len = 0;
    for (char &c : t) {
        if (nxt[c][p + 1] != -1) {
            len += nxt[c][p + 1] - p;
            p = nxt[c][p + 1];
        } else {
            len += s.size() - p - 1;
            p = nxt[c][0];
            len += p + 1;
        }
    }

    cout << len;
}


Measured memory_bytes: 13916
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
   int n;
   cin>>n;
   cout<<n*n<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> vec(3);
    for(int i =0;i<N;++i){   
        cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
        sort(vec.begin(), vec.end() );
        if( vec.at(0)*vec.at(0) + vec.at(1)*vec.at(1) ==vec.at(2)*vec.at(2) ){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" <<endl;
        }
    }

}


Measured memory_bytes: 3092
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		int tmp = 0;
		int[] H = new int[N];
		Arrays.setAll(H, i->sc.nextInt());
		
		for (int i=0; i<N-1; i++) {
			if (H[i] >= H[i+1]) {
				tmp++;
				ans = Math.max(ans, tmp);
			} else {
				tmp = 0;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 51092
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 3003, M = 998244353;

int dp[N][N];

signed main()
{
	IO_OP;
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = a; i <= c; i++) {
		for(int j = b; j <= d; j++) {
			if(i == a && j == b) {
				dp[i][j] = 1;
			} else {
				dp[i][j] = ((ll) dp[i-1][j] * j % M + (ll) dp[i][j-1] * i % M - (ll) (i - 1) * (j - 1) % M * dp[i - 1][j - 1] % M + M) % M;
			}
		}
	}
	cout << dp[c][d] << endl;
}





Measured memory_bytes: 38716
X = int(input())
if 400 <=X and X<=599:
    print("8")
if 600 <=X and X<=799:
    print("7")
if 800 <=X and X<=999:
    print("6")
if 1000 <=X and X<=1199:
    print("5")
if 1200 <=X and X<=1399:
    print("4")
if 1400 <=X and X<=1599:
    print("3")
if 1600 <=X and X<=1799:
    print("2")
if 1800 <=X and X<=1999:
    print("1")
    

Measured memory_bytes: 9184
#include <stdio.h>
int n, m;
int main(){
    scanf("%d%d", &n, &m);
    if (n > m){
        int t = n;
        n = m;
        m = t;
    }
    if (n == 1 && m == 1){
        printf("1");
    }
    else if (n== 1 && m > 1){
        printf("%d", m- 2);
    }
    else printf("%lld", 1ll*(n-2) * (m-2));
    putchar('\n');
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  int ans=1;
  for(int i=1;i<=sqrt(m);i++){
    if(m%i==0){
      if(i<=m/n)ans=max(ans,i);
      if(m/i<=m/n)ans=max(ans,m/i);
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll a[200007];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    ll sum = 0;
    ll count = 0;
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        while((a[i] + sum) > (a[i] ^ sum)){
            sum -= a[i - count];
            count--;
        }
        sum += a[i];
        count++;
        ans += count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int x;
    cin >> x;
    cout << !x << "\n";
    return 0;
}


Measured memory_bytes: 3636
use std::io;

fn main() {
    let n = parse_line::<i64>();
    println!("{}", double_fact_digit(n));
}

fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn double_fact_digit(n: i64) -> i64 {
    if n % 2 != 0 {
        return 0;
    }
    let mut i = 1;
    let mut result: i64 = 0;
    loop {
        let law = 5_i64.pow(i) * 2;
        let adder = n / law;
        if adder == 0 {
            break;
        } else {
            result += adder;
        }
        i += 1;
    }
    result
}

Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

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

    void run() {
        int N = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        int[] T = new int[N];
        for (int i = 0; i < N; i++) T[i] = sc.nextInt();
        Arrays.sort(T);
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            int now = T[i];
            int cap = 1;
            int to = i + 1;
            cnt++;
            while (cap < C && to < N && T[to] - now <= K) {
                to++;
                cap++;
            }
            i = to - 1;
        }
        System.out.println(cnt);
    }

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

Measured memory_bytes: 50120
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(len(cds(gcd(a, b))) + 1)
}

func cds(n int) map[int]int {
	r := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			r[i]++
			n /= i
		}
	}
	if n > 1 {
		r[n]++
	}
	return r
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 512
import itertools
import math
import copy

N,M=map(int, raw_input().split())

M2=copy.deepcopy(M)

A={}

a=int( math.sqrt(M) )+2

for i in range(2,a):
	while M%i==0:
		if i not in A:
			A[i]=1
		else:
			A[i]+=1
		M/=i
else:
	A[M]=1



B=[]

for x in A.values():
	B.append( range(x+1) )


L=list(itertools.product(*B))


Y=[]	#Yakusu
for x in L:
	t=1
	for i,j in zip(A,x):
		t*=i**j
	Y.append(t)


ans=0
for cd in Y:	#cd: Common Divivor(yakusu)
	if M2/cd>=N:
		ans=max(ans,cd)

print ans



Measured memory_bytes: 32876
import sys
sys.setrecursionlimit(500*500)

N, M = map(int, input().split())
UF = [-1] * (N+1)
def find(x):
    global UF
    if UF[x] == -1:
        return x
    else:
        UF[x] = find(UF[x])
        return UF[x]
def union(x,y):
    global UF
    xx = find(x)
    yy = find(y)
    if UF[x] == UF[y] == -1:
        UF[y] = xx
        return
    elif xx == yy:
        return 
    else:
        UF[yy] = xx
        return 
    
for _ in range(M):
    x, y = map(int, input().split())
    union(x,y)
    
cnt = [0] * (N+1)
for i in range(1,N+1):
    z = find(i)
    cnt[z] += 1

print(max(cnt))



Measured memory_bytes: 36784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
ll dp[1000005],ret;
int main(){
	int n; cin >> n;
	for(int i=0;i<=n;i++) dp[i] = 1LL;
	ll add = 0LL,sum = 0LL;
	for(int i=3;i<=n;i++){
		add+=sum;
		add+=dp[i-3];
		add%=mod;
		sum+=dp[i-3];
		sum%=mod;
		dp[i]=(dp[i]+add)%mod;
	}
	ret = dp[n]+dp[n-1]*1LL*(n-1)%mod;
	for(int i=0;i<n-1;i++){
		ret += dp[i]*1LL*(n-1)%mod*(n-1)%mod;
		ret += dp[i]*1LL*(i+1)%mod;
	}
	cout << ret%mod << endl;
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int a = 0; a < n; a++){
        for(int b = a+1; b < n; b++){
            for(int c = b+1; c < n; c++){
                if(l[a] + l[b] > l[c]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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


using namespace std;



int main() {

	string S;
	int countA = 0, countB = 0;

	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 0) {
			if (S[i] != '0') { countA++; }
			else { countB++; }
		}
		else {
			if (S[i] != '1') { countA++; }
			else { countB++; }
		}
	}
	if (countA >= countB) {
		cout << countB;
	}
	else {
		cout << countA;
	}

	return 0;

}

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

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

int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        int id = (s[i] - 'A' + n) % 26;   
        s[i] = char(id + 'A');
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int x, t;
  cin >> x >> t;
  int res = x - t;
  if (res >= 0) cout << x - t << endl;
  else cout << 0 << endl;
  return 0;
}


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

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

  for(int i=0;i<n;++i){
    if (ans[i] <= 0LL) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
/*C - Slimes*/

#include <bits/stdc++.h>

using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int ans = 1;
	string cad;
	int tam;

	cin >> tam >> cad;
	
	for (int i = 1; i < tam; ++i)
		if(cad[i-1] != cad[i])
			ans++;	
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
P ball[55];
int f(ll dx,ll dy){
    int cnt = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if((ball[i].fi-ball[j].fi==dx)&&(ball[i].sec-ball[j].sec==dy))cnt++;
        }
    }
    return N-cnt;
}
int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> ball[i].fi >> ball[i].sec;
    }
    int ans = INF;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j)continue;
            ll dx = ball[i].fi - ball[j].fi;
            ll dy = ball[i].sec - ball[j].sec;
            ans = min(ans,f(dx,dy));
        }
    }
    if(N==1)ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
	string s = "";
	getline(cin, s);
	for (int i = 0; i < s.length(); i++)
		if ('A' <= s[i] && s[i] <= 'Z')
			s[i] += 32;
		else  if ('a' <= s[i] && s[i] <= 'z')
			s[i] -= 32;
		
	cout << s << "\n"; 
}


Measured memory_bytes: 3216
import math
def g(n):
  x = [int(raw_input()) for _ in [0]*n]
  x += [360-sum(x)]
  f = lambda x: math.sin(x*math.pi/180)
  return sum(map(f, x))
  
while 1:
  n = input()
  if n==0: break
  s1 = g(n-1)
  s2 = g(input()-1)
  if abs(s1-s2)<1e-6: print 0
  elif s1>s2: print 1
  elif s1<s2: print 2

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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

const int MAXNUM = 300001;

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<int> c(MAXNUM);

    rep(i, N) 
    {
        int input;
        cin >> input;
        c[input] = input;
    }

    rep(i, MAXNUM - 1) c[i + 1] = max(c[i + 1], c[i]);

    rep(i, Q)
    {
        int q, r = 0;
        cin >> q;
        for(int i = q - 1; i < MAXNUM; i += q)
        {
            r = max(r, c[i] % q);
        }

        cout << r << endl;
    }

    return 0;
}


Measured memory_bytes: 3880
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

a,b,c,x,y = readInts()

ans = 1000000000000000000


for i in range(0,max(x,y)*2+1,2):
	A = max(x - i//2,0)
	B = max(y - i//2,0)
	money = A*a+B*b+i*c
	ans = min(ans,money)

print(ans)



Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string o, e; cin >> o >> e;
  for (int i = 0; i < (int)o.size(); ++i) {
    cout << o[i];
    if (e[i]) cout << e[i];
  }
  cout << '\n';
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split(" "))
    R, S, P = map(int, input().split(" "))
    strings = input()
    T = []
    for s in strings:
        T.append(s)
    score = {'r': P, 's': R, 'p': S}
    total = 0

    for i in range(K):
        total += score[T[i]]

    for j in range(K, N):
        if T[j] != T[j - K]:
            total += score[T[j]]
        else:
            T[j] = ' '
            continue

    print(total)

   
if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
using Graph = vector<vector<int>>;
const Int INF = 1e18;
Graph G;
vector<int> A;
vector<Int> B;
vector<vector<Int>> C;
Int neg(const vector<Int> &A) {
    for (int i = 0; i < A.size(); i++) {
        if (A[i] < 0) return i;
    }
    return INF;
}
vector<Int> f(const vector<Int> &A, const vector<Int> &B) {
    vector<Int> ans(A.size() + B.size() - 1, INF);
    for (int i = 0; i < A.size(); i++) {
        for (int j = 0; j < B.size(); j++) {
            ans[i + j] = min(ans[i + j], A[i] + B[j]);
        }
    }
    return ans;
}
void recur(int node, int prev) {
    for (auto next : G[node]) if (next != prev) {
        recur(next, node);
    }
    if (A[node] > 0) {
        B[node] = 0;
        for (auto next : G[node]) if (next != prev) {
            if (A[next] > 0) {
                B[node] += min(neg(C[next]) + 1, B[next]);
            } else {
                B[node] += neg(C[next]) + 1;
            }
        }
    }
    vector<Int> X = {A[node]};
    for (auto next : G[node]) if (next != prev) {
        X = f(X, C[next]);
    }
    if (A[node] > 0) {
        X.resize(max((Int)X.size(), B[node] + 1 + 1), INF);
        X[B[node] + 1] = min(X[B[node] + 1], 0LL);
    }
    C[node] = X;
}
int main() {
    int N; cin >> N;
    G.resize(N);
    A.resize(N); for (auto &a : A) cin >> a;
    B.resize(N, INF);
    C.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v; cin >> u >> v; u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    recur(0, -1);
    cout << min(B[0], neg(C[0])) << '\n';
    return 0;
}


Measured memory_bytes: 77056
#include <stdio.h>

int main(){
	int a, b;

	scanf("%d%d", &a, &b);
	if (a < b)
	{
		printf("a < b\n");
	}
	if (a > b)
	{
		printf("a > b\n");
	}
	if (a == b)
	{
		printf("a == b\n");
	}

	return 0;
}

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

int a[110], b[110];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", b + i);
	}
	for (int i = n; i; --i) {
		bool is = false;
		for (int j = i; j; --j) {
			if (b[j] > j) break;
			if (b[j] == j) {
				a[i] = j;
				for (int k = j; k < i; ++k) {
					b[k] = b[k + 1];
				}
				is = true;
				break;
			}
		}
		if (!is) {
			puts("-1");
			return 0;
		}
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d\n", a[i]);
	}
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define range(a,b)		substr(a,b-a+1)
#define w(x)            int x; cin>>x; while(x--)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int a, b, c, d; cin >> a >> b >> c >> d;

	int ans = max({a * c, a * d, b * c, b * d});

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

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n , m ;
long long pref[2*MAX] , prefcnt[2*MAX] , Ans[2*MAX] ; 

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>arr[i] ;
		arr[i]-- ;
	}
	long long ans = 0ll ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		int dist = (arr[i+1] - arr[i] + m) % m ;
		ans += dist ;
		prefcnt[arr[i]+1]++ ;
		pref[arr[i]+dist+1] -= dist ;
		prefcnt[arr[i]+dist+1]-- ;
	}
	long long sum = 0 , cnt = 0 ;
	for(int i = 0 ; i < m*2 ; ++i)
	{
		cnt += prefcnt[i] ;
		sum += cnt ;
		sum += pref[i] ;
		Ans[i%m] -= max(0ll , sum-cnt) ;
	}
	long long x = *min_element(Ans , Ans + m) ;
	return cout<<ans+x<<"\n" , 0 ;
}		

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define size_of(a) (int)a.size()

typedef long long lint;

const lint lINF = 1LL << 60;

struct Edge {
	int v; lint t;
	Edge(int _v, lint _t) : v(_v), t(_t) {}
};

struct State {
	int v; lint h, c;
	State(int _v, lint _h, lint _c) : v(_v), h(_h), c(_c) {}
	bool operator > (const State& a) const { return c > a.c; }
};

int N, M, X;
vector< vector< Edge > > edges;
lint H[100010];

lint cost[100010];

void solve() {
	priority_queue< State, vector< State >, greater< State > > q;
	q.push(State(0, X, 0));
	fill(cost, cost + N, lINF);
	cost[0] = 0;
	
	while (!q.empty()) {
		State s = q.top(); q.pop();
		if (cost[s.v] < s.c) continue;
		
		int e_size = size_of(edges[s.v]);
		for_(i,0,e_size) {
			Edge e = edges[s.v][i];
			lint nxc = s.c + e.t, nxh = s.h - e.t;
			
			if (H[s.v] - e.t < 0) continue;
			
			if (e.v == N - 1) {
				if (nxh > H[e.v]) nxc += nxh - H[e.v];
				if (nxh < H[e.v]) nxc += H[e.v] - nxh;
				if (cost[e.v] > nxc) cost[e.v] = nxc;
			} else {	
				if (nxh < 0) {
					nxc -= nxh;
					nxh = 0;
				}
				
				if (nxh > H[e.v]) {
					nxc += (nxh - H[e.v]);
					nxh = H[e.v];
				}
				
				if (cost[e.v] > nxc) {
					cost[e.v] = nxc;
					q.push(State(e.v, nxh, nxc));
				}
			}
		}
	}
	
	if (cost[N - 1] == lINF) cout << -1 << endl;
	else cout << cost[N - 1] << endl;
}

int main() {
	cin >> N >> M >> X;
	
	for_(i,0,N) cin >> H[i];
	
	edges.assign(N, vector< Edge >());
	
	for_(i,0,M) {
		int a, b, t; cin >> a >> b >> t;
		--a; --b;
		edges[a].push_back(Edge(b, t));
		edges[b].push_back(Edge(a, t));
	}
	
	solve();
	
	return 0;
}

Measured memory_bytes: 22004
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <stack>
#include <string>
#include <iomanip>
#include <queue>
#include <deque>
#include<cstring>
#include<limits>
#include <sstream>
#include <stdio.h>
#include<unordered_map>
using namespace std;
#define sz(x) (x).size()
#define all(v) (v).begin(),(v).end()
#define m_p make_pair
void run()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int main()
{

	fast();
	string x;
	cin >> x;
	x[3] = '8';
	cout << x << endl;
return 0;

}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a*b<=c*d){
        printf("%d\n",c*d);
    } else{
        printf("%d\n",a*b);
    }
    return  0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <vector>
#include <complex>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2005;
long long ksm(const long long &a, const long long &k)
{
	long long ans = 1;
	for(long long x = a % mod, asd = k; asd; asd >>= 1, (x *= x) %= mod)
		if(asd & 1)
			(ans *= x) %= mod;
	return ans;
}
long long fac[maxn * maxn], invfac[maxn * maxn];
long long calc(const int &n, const int &k)
{
	if(k < 0 || n < k)
		return 0;
	return fac[n] * invfac[k] % mod * invfac[n - k] % mod;
}
long long dp[maxn][maxn];
int main()
{
	std::ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	if(n * k < n + k)
	{
		cout << 1 << endl;
		return 0;
	}
	fac[0] = 1;
	for(int i = 1; i <= n * k; i ++)
		fac[i] = fac[i - 1] * i % mod;
	invfac[n * k] = ksm(fac[n * k], mod - 2);
	for(int i = n * k - 1; i >= 0; i --)
		invfac[i] = invfac[i + 1] * (i + 1) % mod;
	dp[0][0] = 1;
	for(int i = 1; i <= n; i ++)
		dp[0][i] = dp[0][i - 1] * calc(i * (k - 1) - 1, k - 2) % mod;
	for(int i = 1; i <= n; i ++)
		for(int j = i; j <= n; j ++)
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] * calc(j * (k - 1) + i - 1, k - 2)) % mod;
	cout << dp[n][n] * fac[n] % mod << endl;
	
	return 0;
}

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

int main() {
	int n,k; cin >> n >> k;
	int ans=1;
	rep(i,n) {
		if(ans*2<=ans+k) ans*=2;
		else ans+=k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 305;
const ll INF = 2e18;

struct node{
    int x, y;
    bool operator < (const node& a){
        return x < a.x || (x == a.x && y < a.y);
    }
};
int a, b, k, tot, mx, ans[maxn][maxn];
char s[maxn];
struct cmp{
    bool operator ()(node a, node b)const{
        return a.x < b.x || (a.x == b.x && a.y < b.y);
    }
};
set<node, cmp> S;
void work(int x, int y){
    tot++;
    int l = y, r = y, xx = x;
    while(l - 1 > 0 && ans[x][l-1] == 0 && S.find({x, l-1}) == S.end())l--;
    while(r + 1 <= b && ans[x][r+1] == 0 && S.find({x, r+1}) == S.end())r++;
    while(xx > 0 && ans[xx][y] == 0){
        for(int i = l;i <= r;i++)ans[xx][i] = tot;
        xx--;
    }
    if(x == mx){
        xx = x + 1;
        while(xx <= a && ans[xx][y] == 0){
            for(int i = l;i <= r;i++)ans[xx][i] = tot;
            xx++;
        }
    }
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    //ios_base::sync_with_stdio(false);

    vector<node> v;
    scanf("%d%d%d", &a, &b, &k);
    for(int i = 1;i <= a;i++){
        scanf("%s", s + 1);
        for(int j = 1;j <= b;j++)
            if(s[j] == '#')
                v.push_back({i, j}), mx = i, S.insert({i, j});
    }
    sort(v.begin(), v.end());
    int x, y;
    for(auto p : v){
        x = p.x, y = p.y;
        work(x, y);
    }
    for(int i = 1;i <= a;i++)
        for(int j = 1;j <= b;j++)
            printf("%d%c", ans[i][j], " \n"[j == b]);
}


Measured memory_bytes: 6004
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	int ans=a;
	
	if(a<0 && b>0) ans=-1;
	else if(a>0) ans=0;
	else if((-(a+b))%2==0) ans=1;
	else ans=0;

	if(ans==0) cout<<"Positive"<<endl;
	else if(ans==1) cout<<"Negative"<<endl;
	else cout<<"Zero"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
	int h,w;
	int i,j;
	int flag = 1;
	char s[52][52];
	scanf("%d %d",&h,&w);

	for(i = 0; i <= h+1;i++){
		for(j = 0;j <= w+1;j++){
			s[i][j] = '0';
		}
	}

	for(i = 1; i <= h;i++){
		for(j = 1;j <= w;j++){
			scanf(" %c",&s[i][j]);
		}
	}

	for(i = 1; i <= h;i++){
		for(j = 1;j <= w;j++){
			if(s[i][j] == '#'){
				if(s[i-1][j] != '#'&&s[i][j-1] != '#'&&s[i+1][j] != '#'&&s[i][j+1] != '#'){
					flag = 0;
				}
			}
		}
	}	

	if(flag){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const Sd = nextCharArray()
    const T = nextCharArray()
    const q = "?"
    let arr = []
    let pos = 0
    while (pos < Sd.length) {
        let tmp = [...Sd]
        for (let i = pos, j = 0; i < pos + T.length; i++, j++) {
            tmp[i] = T[j]
        }
        if (tmp.length == Sd.length) {
            let isValid = true
            for (let i = 0; i < Sd.length; i++) {
                if (Sd[i] !== q && tmp[i] !== Sd[i]) {
                    isValid = false
                    break
                }
            }
            if (isValid){
                arr.push(tmp)
            }
        }
        pos++
    }
    if(arr.length == 0){
        console.log("UNRESTORABLE")
        return
    }
    for(let str of arr){
        for(let i = 0; i<str.length;i++){
            if(str[i] == q) str[i] = "a"
        }
    }
    arr.sort()
    console.log(arr[0].join(""))
}
Main()

Measured memory_bytes: 29628
#include <stdio.h>

void selectionSort(int a[],int N);
int main(void){
	int i,N;
	scanf("%d",&N);
	int a[N];
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	selectionSort(a,N);
	return 0;
}

void selectionSort(int a[],int N){
	int i,min,j,count=0,tmp;
	for(i=0;i<=N-1;i++){
		min=i;
		for(j=i;j<=N-1;j++){
			if(a[j]<a[min]){
				min=j;
			}
		}
		tmp=a[i];
		a[i]=a[min];
		a[min]=tmp;
		if(i!=min) count++;
	}
	
	for(i=0;i<N;i++){
	if(i>0)	printf(" ");
	printf("%d",a[i]);
	}
	printf("\n");
	printf("%d\n",count);
}


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

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

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdint(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	char s[4];
	scanf("%s", s);
	int i;
	int yy = 0, mm = 0;
	if (s[0] == '0' && s[1] != '0') {
		mm = 1;
	}
	if (s[0] == '1') {
		if (s[1] == '0' || s[1] == '1' || s[1] == '2') {
			mm = 1;
		}
	}
	if (s[2] == '0' && s[3] != '0') {
		yy = 1;
	}
	if (s[2] == '1') {
		if (s[3] == '0' || s[3] == '1' || s[3] == '2') {
			yy = 1;
		}
	}

	if (mm == 1 && yy == 1) {
		showstring("AMBIGUOUS");
	} else if (mm == 1 && yy == 0) {
		showstring("MMYY");
	} else if (mm == 0 && yy == 1) {
		showstring("YYMM");
	} else {
		showstring("NA");
	}
	return 0;
}

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

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

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

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

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

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

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

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

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

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


Measured memory_bytes: 128
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    S = INPUT()

    cnt = 0
    for i in range(N-2):
        if S[i:i+3] == 'ABC': cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>

using namespace std;


int main(){
 int N;
 cin >> N;
 int a[N];
 int i;
 for(i=0;i<N;++i){
     cin >> a[i];
   }
  int tmp = 0;
  int best = 0;
 for(i=0;i<N-1;++i){
   if(a[i]>=a[i+1])tmp++;
    else{
        best = max(best,tmp);
        tmp = 0;
    }
 }
  best = max(tmp,best);
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 640
def resolve():
    import math

    a, b, h, m = list(map(int, input().split()))

    theta = abs(((h + m/60)/12 - m/60) * math.pi * 2)
    if theta == 0:
        print(abs(a - b))
        return
    elif theta == math.pi:
        print(a + b)
        return
    theta = min(theta, 2 * math.pi - theta)
    cos_theta = math.cos(theta)
    c = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * cos_theta))
    print(c)
resolve()

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

int main() {
  int h,a,ans=0;
  cin >> h >> a;
  while(h>0) {
    h-=a;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256