akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#
#include<cmath>

using namespace std;

int main()
{
	long int n;
	scanf("%ld", &n);

	long int* memo;
	memo = (long int*)malloc(n/3 * sizeof(long int));

	double ceilodd = sqrt(n*1.0);

	bool divisable = false;

	printf("%ld:", n);


	memo[0] = 2;
	while (n % 2 == 0)
	{
		printf(" 2");
		n /= 2;
	}

	memo[1] = 3;
	while (n % 3 == 0)
	{
		printf(" 3");
		n /= 3;
	}

	long int cnt = 2;

	for (long int i = 5; i <= ceilodd; i += 2)
	{
		divisable = false;

		for (long int j = 3; j < sqrt(i*1.0); j += 2)
		{
			if (i%j == 0)
			{
				divisable = true;
				break;
			}
		}

		if (divisable == false)
		{
			memo[cnt] = i;
			while (n%memo[cnt] == 0)
			{
				printf(" %ld", memo[cnt]);
				n /= memo[cnt];
				if (n == 1)break;
			}
			if (n == 1)break;
			cnt++;
		}

	}
	
	if (n != 1)
		printf(" %ld", n);


		printf("\n");

		free(memo);

	
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int n,k;
    cin>>k>>n;
    int a[n];
    rep(i,0,n)
    cin>>a[i];
    int mx=k-a[n-1]+a[0];
    rep(i,1,n)
    mx=max(mx,a[i]-a[i-1]);
    cout<<k-mx<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
    
int main(){
	int n,k;
	cin>>n>>k;
	double ans=0;
	for(int p=1;p<=n;p++){
		if(p>=k){
			ans+=1;
		}else{
		int r=(int) log2((double)(k/p))+1;
		while(k<=p*pow(2,r-1)){
			r--;
		}
			ans+= pow(0.5,r);
		}
	}
	ans/=n;
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int h;
  cin >> h;
  while(h!=0){
    vector <int> lines[5];
    int b[10][5];
    int i,j,k;
    for(i=0;i<h;i++){
      for(j=0;j<5;j++){
	cin >> b[i][j];
      }
    }
    for(i=h-1;i>=0;i--){
      for(j=0;j<5;j++){
        lines[j].push_back(b[i][j]);
      }
    }
    
    int o=0;
    int f=0,ba,l;
    while(f==0){
      
      k=0;
      
      for(i=0;i<5;i++) k+=lines[i].size();
      
      for(i=h-1;i>=0;i--){
	l=0;
	ba=0;
	for(j=0;j<5;j++){
	  if(lines[j].size()>i){
	    if(ba==0){
	      ba=lines[j][i];
	      l=1;
	    }else if(ba==lines[j][i]){
	      l++;
	    }else{
	      if(l>=3){
		o+=ba*l;
		for(int a=1;a<=l;a++) lines[j-a].erase(lines[j-a].begin()+i);
	      }
	      ba=lines[j][i];
	      l=1;
	    }
	  }else{
	    ba=0;
	    l=0;
	  }
	}
	
	if(l>=3){
	  o+=ba*l;
	  for(int a=0;a<l;a++) lines[4-a].erase(lines[4-a].begin()+i);
	}	
	
      }
      for(i=0;i<5;i++) k-=lines[i].size();
      if(k==0) f=1;
    }
    
    cout << o << endl;
    cin >> h;
  }
  return 0;
}

Measured memory_bytes: 1216
def resolve():
    n = int(input())
    S = [0]*(n+1)
    MOD = (10 ** 9) + 7

    for i in range(1, n+1):
        n_i = i
        p = 2
        while n_i > 1:
            while n_i % p == 0:
                n_i //= p
                S[p] += 1
            p += 1

    ans = 1
    for s in S:
        ans *= s+1
    print(ans % MOD)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
for tc in [0]*1:

    n=int(input())
    l=list(map(int,input().split()))
    tot=sum(l)
    f=0
    ans=0
    for i in range(n):
        ans+=l[i]
        f=0
        if ans*2==tot:
            f=1
            break
    if f:
        print(0)
    else:
        ans=0
        tr=10**9+7+2020202020
        for i in range(n):
            ans+=l[i]
            #print(ans,tr)
            tr=min(tr,abs(ans-abs(tot-ans)))
        print(tr)

Measured memory_bytes: 26024
def func(n):
    if n % 2 == 1:
        a = n + 1
    else:
        a = n 
    if a % 4 == 0:
        between = 1
    else:
        between = 0
    if n % 2 == 0:
        ans = between ^ n
    else:
        ans = between
    return ans

n, m = map(int, input().split())
ans = func(n - 1) ^ func(m)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum,k,a,v1;
  int key,pi[MAX],v[MAX],u,c[MAX],M[MAX][MAX];
  
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v1, &a);
      M[u][v1] = a;
    }
  }
  for(i=0;i<n;i++){
    c[i]=INFTY;
    pi[i]=-1;
    v[i]=0;
  }
  c[0]=0;

  while(1){
    key=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(key>c[i] && !v[i]){
	u=i;
	key=c[i];
      }
    }
    if(u==-1)break;
    v[u]=1;
    for(j=0;j<n;j++){
      if(M[u][j]+c[u]<c[j] && !v[j]){
	pi[j]=u;
	c[j]=c[u]+M[u][j];
      }
    }
  }
  
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (c[i]==INFTY?-1:c[i]));
  }
  
  return 0;
}

Measured memory_bytes: 804
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdlib>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=200000+5;
const int INF=0x7fffffff;
const int inf=100000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
int main()
{
    int n;
    cin>>n;
    ll sum=0;
    int l,r;
    int i;
    for(i=1;i<=n;i++)
    {
        sum+=(ll)i*(n-i+1);
    }
    for(i=1;i<n;i++)
    {
        scanf("%d%d",&l,&r);
        if(l>r)
            swap(l,r);
        sum-=(ll)l*(n-r+1);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3764
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
int n;
int main() {
	while (cin >> n, n) {
		vector<int> a(n), b(n);
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < n; i++) cin >> b[i];
		vector<vector<int> > G(2 * n);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= 2 && i + j < n; j++) {
				int pos = i + j;
				if (b[pos] == 1) {
					while (pos < n - 1 && b[pos + 1] == 1) pos++;
				}
				else if (b[pos] == 2) {
					while (pos > 0 && b[pos] == 2) pos--;
				}
				G[i].push_back(pos + n);
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= 2 && i + j < n; j++) {
				int pos = i + j;
				if (a[pos] == 1) {
					while (pos < n - 1 && a[pos + 1] == 1) pos++;
				}
				else if (a[pos] == 2) {
					while (pos > 0 && a[pos] == 2) pos--;
				}
				G[i + n].push_back(pos);
			}
		}
		int aspos = 0, bspos = 0;
		if (a[aspos] == 1) {
			while (aspos < n - 1 && a[aspos + 1] == 1) aspos++;
		}
		if (b[bspos] == 1) {
			while (bspos < n - 1 && b[bspos + 1] == 1) bspos++;
		}
		queue<int> que;
		vector<int> dist(2 * n, 999999999);
		que.push(aspos); dist[aspos] = 0;
		que.push(bspos + n); dist[bspos + n] = 0;
		while (!que.empty()) {
			int u = que.front(); que.pop();
			for (int i : G[u]) {
				if (dist[i] == 999999999) {
					dist[i] = dist[u] + 1;
					que.push(i);
				}
			}
		}
		int ret = min(dist[n - 1], dist[2 * n - 1]);
		if (ret == 999999999) cout << "NA" << endl;
		else cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    ll ans = 0;
    map<int, int> mp;
    mp[0] = 1;
    int jj = 0;
    rep(i, n) {
        map<int, int> mp_ = mp;
        map<int, int> mmp;
        for(P g:mp_) {
            mp.erase(g.first);
            if(!(g.first & a[i])) {
                ans += g.second;
                mmp[g.first + a[i]] = g.second; 
            }
        }
        mp = mmp;
        mp[0]++;
    }

    cout << ans << endl;
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  int H, W;
  cin >> H >> W;
  int h, w;
  cin >> h >> w;
  int ans = (H - h) * (W - w);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   string s,t;
   cin>>s>>t;
   reverse(s.begin(),s.end());
   if(s==t){cout<<"YES"<<endl;}
   else{cout<<"NO"<<endl;}
return 0;}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
int dp[1000010][5];

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    S += '0';
    int n = S.size();

    rep(i, n + 1) rep(j, 2) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 2) {
            int x = S[i] - '0';
            x += j;
            rep(a, 10) {
                int ni = i + 1, nj = 0;
                int b = a - x;
                if (b < 0) {
                    nj = 1;
                    b += 10;
                }
                chmin(dp[ni][nj], dp[i][j] + a + b);
            }
        }
    }

    cout << dp[n][0] << endl;
}

Measured memory_bytes: 20868
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

int main() {
    string S; cin >> S;
    int a = S[S.size()-1] - '0';

    if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
        cout << "hon" << endl;
    } else if (a == 0 || a == 1 || a == 6 || a == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <fstream>

#include <cmath>

using namespace std;


int bubbleSort(int *a, int N);
void pp_sorting(int *a,int N);
int main(){

    int n, a[100];
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    int counter = bubbleSort(a,n);
    pp_sorting(a,n);
    cout << counter << endl;

    return 0;
}

int bubbleSort(int *a, int N){
    int counter = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1-i;j++){
            if(a[j] > a[j+1]){
                int temp=a[j];
                a[j]=a[j+1];
                a[j+1] = temp;
                counter++;
            }
        }
    }
    return counter;
}

void pp_sorting(int *a,int N){
    for(int i=0;i<N-1;i++) cout << a[i] << " ";
    cout << a[N-1] << endl;
}




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

class UnionFindTree {
   public:
    vector<int> parent;

    UnionFindTree(int n) {
        parent.resize(n);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
    }

    int root(int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        int rx = root(x); int ry = root(y);
        if (rx == ry) return;
        parent[rx] = ry;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    int N, K, L; cin >> N >> K >> L;
    UnionFindTree *road = new UnionFindTree(N);
    UnionFindTree *train = new UnionFindTree(N);

    REP(i, 0, K) {
        int a, b; cin >> a >> b;
        a--; b--;
        road->unite(a, b);
    }
    REP(i, 0, L) {
        int a, b; cin >> a >> b;
        a--; b--;
        train->unite(a, b);
    }

    map<pair<int, int>, int> m;
    REP(i, 0, N) {
        m[make_pair(road->root(i), train->root(i))]++;
    }
    REP(i, 0, N) {
        if (i != N - 1) cout << m[make_pair(road->root(i), train->root(i))] << " ";
        else cout << m[make_pair(road->root(i), train->root(i))] << endl;
    }

    return 0;
}

Measured memory_bytes: 13568
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define P pair<ll, ll>

typedef vector<int> vec;
typedef vector<vec> mat;

bool f(P x, P y){
    if (x.first != y.first) return x.second > y.second;
    else return x.first > y.first;
    
}

int main(){
    ll n, m;
    cin >> n >> m;
    ll a[n];
    rep(i, n) cin >> a[i];
    P b[m];
    rep(i, m) cin >> b[i].second >> b[i].first;
    sort(a, a + n);
    sort(b, b + m, greater<P>());
    ll ans = 0;
    ll idx = 0;
    rep(i, n){
        if(idx < m){
            if(a[i] < b[idx].first) {
                ans += b[idx].first;
                b[idx].second--;
            }else{
                ans += a[i];
                idx = m;
            }
        }else{
            ans += a[i];
        }
        if(b[idx].second == 0) idx++;
    }
    // rep(i, m){
    //     cout << b[i].first << " " << b[i].second << endl;
    // }
    cout << ans << endl;
}

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

int main() {
  string str, T;
  cin >> str >> T;

  for (int i = 1; i <= str.size(); i++) {
    str = str[str.size() - 1] + str;
    str.pop_back();
    if (str == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int max(int [],int ,int ,int );
int main(void){
    int a[1000],n,q,b,e,k;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d %d %d",&b,&e,&k);
        max(a,b,e,k);
    }
    return 0;
}

int max(int a[],int b,int e,int k){
    int i,count=0;
    for(i=b;i<e;i++){
        if(a[i]==k) count++;
    }
    printf("%d\n",count);
    return 0;
}



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

int main() {
  int n, k; cin >> n >> k;
  double cs[n+1] = {};
  cs[0] = 0;
  for (int i = 0; i < n; i++) {
    int p; cin >> p;
    cs[i+1] = cs[i] + (p + 1) / 2.0;
  }

  double ans = 0;
  for (int i = 0; i <= n-k; i++) {
    ans = max(ans, cs[i+k] - cs[i]);
  }
  cout << fixed << setprecision(6) << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <bits/stdc++.h>
#include <cmath>
#include <stdio.h>
#include <utility>
using namespace std;
#define ll long long

int main()
{
   ll n;cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++){
       cin>>a[i];
   }
   ll sum=0;
   for(ll i=0;i<n;i++){
       for(ll j=(i+1);j<n;j++){
           sum+=(a[i]*a[j]);
       }
   }
   cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 11) * 2;
    x %= 11;
    if (x == 0) cout << ans << endl;
    else if (x <= 6) cout << ans+1 << endl;
    else cout << ans+2 << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    REP(i,5){
        int a;
        cin >> a;
        if(0 == a){
            cout << (i+1) << endl;
            return 0;
        }
    }
}

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

int main(){
	int n;
	cin >> n;
	string s, o;
	cin >> s;

	for(int i=0; i< s.length(); i++){
		o.push_back( char( 'A' + (s[i] - 'A' + n)%26) );
	}
	cout << o << endl;
}


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

int num[2];
int main() {
    int k;
    scanf("%d%d%d", &num[0], &num[1], &k);
    for(int i = 0;i < k;i++) {
        int j = i % 2;
        if(num[j] % 2) num[j]--;
        num[j] /= 2, num[(j + 1) % 2] += num[j];
    }
    printf("%d %d\n", num[0], num[1]);
    return 0;
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 998244353

long binary_square(long x, long n);
long factorial(long n);
void rfactorial(long n);

vector<long> fact;
vector<long> rfact;

int main(){
    long n, m, k;
    cin >> n >> m >> k;
    rep(i, n){
        fact.push_back(-1);
    }
    factorial(n);
    rfactorial(n);
    // rep(i, n){
    //     cout << fact[i] << endl;
    // }
    long ans=0;
    rep(i, k+1){
        long x;
        long c = (fact[n-1] * rfact[i] % MOD) * rfact[n-1-i] % MOD;
        //cout << c << endl;
        //cout << (long)MOD * (long)MOD << endl;
        x = (m * (c * binary_square(m-1, n-i-1) % MOD)) % MOD;
        //cout << x << endl;
        ans = (ans + x) % MOD;
    }
    cout << ans << endl;
    return 0;
}

long binary_square(long x, long n){
    long m = MOD;
    long ans = 1;
    while(n){
        if(n%2==1){
            ans = ans * x % m;
        }
        x = x * x % m;
        n >>= 1;
    }
    return ans % m;
}

long factorial(long n){
    if(n==0){
        return 1;
    }else{
        if(fact[n-1]==-1){
            fact[n-1] = factorial(n-1);
        }
        fact[n] = n * fact[n-1] % MOD;
        return fact[n];
    }
}

void rfactorial(long n){
    rep(i, n){
        rfact.push_back(binary_square(fact[i], MOD-2));
    }
}

Measured memory_bytes: 13992
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        for(int i = 1; ; i++){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) break;
            for(int j = 0; j<H; j++){
                for(int k = 0; k<W; k++){
                    if((j+k)%2 == 0){
                        System.out.printf("#");
                    }else{
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


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

int main(){
	set<char> s ;
	char c ;
	while(cin >> c){
		if(s.count(c)){
			cout << "no" << endl ;
			return 0 ;
		}else{
			s.insert(c) ;
		}
	}
	cout << "yes" << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 5001;
// const ll m = 1e9 + 7;
const ll inf= 1ll<<62;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
const ll mod = 1e9+7;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }


int main()
{    
     #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
     #endif     
     ll t = 1;
     // cin>>t;
     while(t--){
          ll x;cin>>x;
          ll amt = 100;
          ll yr=0;
          while(amt<x){
               amt+=amt/100;
               yr++;
          }
          cout<<yr<<'\n';

     }     
     return 0;
}

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

int main() {
int H, W;
while (true) {
cin >> H >> W;
if (H == 0 && W == 0) break;
for (int u = 0; u < H; u++) {
for (int i = 0; i < W; i++) {
cout << "#";
}
cout << endl;
}
cout << "\n";
}
return 0;
}

Measured memory_bytes: 3060
using System;

public class AtCoderA
{
    static void Main()
    {
        int p;
        int q;
        int r;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            p = int.Parse(words[0]);
            q = int.Parse(words[1]);
            r = int.Parse(words[2]);
        }

        Console.WriteLine(p + q + r - Math.Max(Math.Max(p, q), r));
    }
}

Measured memory_bytes: 11092
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    q,r=map(int,input().split())
    weight.append(q)
    value.append(r)

dp=[[0 for i in range(100111)] for j in range(111)]

for i in range(0,n):
    for sum_w in range(0,w+1):
        if sum_w-weight[i]>=0:
            dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i])
        dp[i+1][sum_w]=max(dp[i][sum_w],dp[i+1][sum_w])

print(dp[n][w])

Measured memory_bytes: 185992
a, b = map(int, input().split())
L = list(map(int, input().split()))
x = [0]
y = 0
z = 0
for i in range(a):
  y = y + L[i]
  x.append(y)
for j in range(len(x)):
  if x[j] <= b:
    z = z+1
print(z)

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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int S=0;
	int k;
	int comp;
	for(int i=1; i<=N; ++i)
	{
	    comp=0;
	    k=i;
	    while(k != 0)
	    {
	        comp = comp + (k % 10);
	        k = k / 10;
	    }
	    if(A<=comp && comp<=B) S=S+i;
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
def solve(K, S):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            z = S - x - y
            if K >= z >= 0:
                count = count + 1
    return count


if __name__ == '__main__':
    K, S = map(int, input().split())
    print(solve(K, S))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, n - k) {
        if(a[i] < a[i+k]) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int m=0;
  ll sum=0;
  for(int i=0;i<n;i++){
    m=max(m,a[i]);
    sum+=m-a[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 4032
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io

	ll n,m;
	cin>>n>>m;
	cout<<(n*(n-1))/2+(m*(m-1))/2;
	
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> H(N); rep(i, N) cin >> H[i];
    vector<bool> ans(N, true);
    rep(i, M) {
        int u, v; cin >> u >> v; u--; v--;
        if (H[u] <= H[v]) {
            ans[u] = false;
        }
        if (H[v] <= H[u]) {
            ans[v] = false;
        }
    }
    cout << count(range(ans), true) << endl;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n)cin>>a[i];
  rep(i,n){
    if(a[i]>i){
      COUT(-1);
      return 0;
    }
  }
  rep(i,n-1){
    if(a[i+1]-a[i]>1){
      COUT(-1);
      return 0;
    }
  }
  ll ans=0;
  for(int i=n-1;i>0;i--){
    if(a[i]==a[i-1]+1) ans++;
    else ans+=a[i];
  }
  COUT(ans);
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(200002)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
x = [None] * N

def fail():
    print("No")
    exit()

def dfs(s):
    global x, G
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            dfs(t)
        else:
            if x[t] != x[s] + d:
                fail()

for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1].append([R-1,  D])
    G[R-1].append([L-1, -D])

for i in range(N):
    if x[i] is None:
        x[i] = 0
        dfs(i)

print("Yes")

Measured memory_bytes: 135212
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	long long int  N, M, H, W, A, B, **ans, flag = 0, i, j, ans_0 = 0, ans_W = 0, len, AB, sum, res, count;

//	int count[1000000000] = { 0 };

	scanf("%lld %lld", &N, &M);

	count = N*(N - 1) / 2 + M*(M - 1) / 2;

	printf("%d\n", count);

	return 0;

}
    


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

int d,g;
int *p,*c,*num;
bool* flag;


int test(){
	int i,itemp;
	int iscore,icount;
	int imin=100000;
	for(i=1;i<=d;i++){
	if(flag[i]){
		flag[i]=false;
		icount = (g /100-1)/i+1;
		iscore = icount * i * 100;
		if(icount>=p[i]){
			icount = p[i];
			iscore = p[i]*i*100+c[i];
		}
		if(iscore>=g){
		}else{
			g -= iscore;
			icount = icount + test();
			g += iscore;
		}
		if(imin > icount){
			imin=icount;
		}
		
		flag[i]=true;
	}}
	return imin;
}

int main(){
	
	int count=0;
	int i,itemp,max_index,icount,iscore;
	double dtemp,dmax;
	
	cin >> d >> g;
	
	p = new int[d+1];
	c = new int[d+1];
	num = new int[d+1];
	flag = new bool[d+1];
	

	for(i=1;i<=d;i++){
		cin >> p[i] >> c[i];
		dtemp = p[i]*i*100+c[i];
		dtemp /= p[i]; 
		flag[i] = true;
	}
	// cout << "start"<<endl;
	
	count = test();

	
	cout << count <<endl;
	return 0;
	
}


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

bool check(std::map<char, int> m, int h, int w) {
  int cnt2 = 0, cnt1 = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    if (itr->second % 4 == 3) {
      ++cnt2;
      ++cnt1;
    } else if (itr->second % 4 == 2)
      ++cnt2;
    else if (itr->second % 4 == 1)
      ++cnt1;
  }
  if (h % 2 == 0 && w % 2 == 0) {
    if (cnt2 == 0 && cnt1 == 0)
      return true;
    else
      return false;
  }
  if (h % 2 == 0 && w % 2 != 0) {
    if (cnt2 <= h/2 && cnt1 == 0)
      return true;
    else
      return false;
  }
  if (h % 2 != 0 && w % 2 ==0) {
    if (cnt2 <= w/2&& cnt1 == 0)
      return true;
    else
      return false;
  }
  else {
    if (cnt2 <= (w-1)/2 + (h-1)/2 && cnt1 == 1)
      return true;
    else
      return false;
  }
}

int main() {
  int h, w;
  std::cin >> h >> w;
  std::map<char, int> m;
  std::vector<std::string> tmp;
  for (int i = 0; i < h; ++i) {
    std::string str;
    std::cin >> str;
    tmp.push_back(str);
  }

  for (auto str : tmp) {
    for (auto c : str) {
      if (m.count(c) == 0)
        m[c] = 1;
      else
        m[c] += 1;
    }
  }
  std::cout << (check(m, h, w) ? "Yes" : "No") << std::endl;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


set<int> E[202020]; //自己ループの可能性があるのとbfsで辺を消していきたいのでset
int A[202020], B[202020];

int main() {
    
    int N, M; cin >> N >> M;
    string S; cin >> S;

    rep(i, M) {
        int x,y; cin >> x >> y;
        E[x - 1].insert(y - 1);
        E[y - 1].insert(x - 1);
    }
    

    set<int> Q;
    rep(i, N) {
        for (auto e : E[i]) {
            if (S[e] == 'A') A[i]++;
            if (S[e] == 'B') B[i]++;
        }
        if (A[i] == 0 || B[i] == 0) Q.insert(i);
    }


    int lef = N;
    while (Q.size()) {
        int x = *Q.begin();
        Q.erase(Q.begin());
        lef--;
        for(auto e : E[x]) if (e != x) {
            E[e].erase(x);
            if (S[x] == 'A') A[e]--;
            if (S[x] == 'B') B[e]--;
            if (A[e] == 0 || B[e] == 0) Q.insert(e);
        }
    }

    if (lef) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 34512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int a[n+1] = {};
    rep(i,n-1){
        int b;
        cin >> b;
        a[b]++;
    }

    srep(i,1,n+1)cout << a[i] << endl;
    return 0;
}
 
 


Measured memory_bytes: 4404
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll a[117];
void solve(){
	ll n,i,j,k,tot;
	tot=0;
	cin>>n;
	take(a,n);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			for(k=j+1;k<n;k++){
				if(a[i]!=a[j] and a[i]!=a[k] and a[j]!=a[k] and (max(max(a[i],a[j]),a[k]))*2 < (a[i]+a[j]+a[k])){
					tot++;
				}
			}
		}
	}
	cout<<tot;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include <stdlib.h>
#include <string.h>
int main()
{
    char s[11];
    char t[12];
    scanf("%s",s);
    scanf("%s",t);
    int i=0;
    int flag=0;
    for(i=0;i<strlen(s);i++)
    {
        if(t[i]!=s[i])
            flag=1;
    }
    int len=0;
    len=strlen(t)-strlen(s);
    if(flag==0 && len==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using itn = int;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()


int main(){
    int n,k;
    cin >>n >>k;
    string s;
    cin >>s;

    if(s[k-1] == 'A') s[k-1] = 'a';
    if(s[k-1] == 'B') s[k-1] = 'b';
    if(s[k-1] == 'C') s[k-1] = 'c';

    cout <<s <<endl;

}


Measured memory_bytes: 256
S=input()
count=0
Ans=True
for i in range(len(S)):
    if i%2==1 and S[i]=="R":
        Ans=False
    elif i%2==0 and S[i]=="L": 
        Ans=False
if Ans==True:
    print("Yes")
else:
    print("No")

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> res(N+1, LLONG_MAX);
  queue<pair<ll, ll>> que;
  que.emplace(0, 0);
  while (true) {
    pair<ll, ll> p = que.front(); que.pop();
    ll n = p.first; ll cnt = p.second;
    if (n == N) {
      cout << cnt << endl;
      return 0;
    }
    if (res.at(n) < cnt) continue;
    auto put = [&] (ll m) -> void {
      if (res.at(m) <= cnt + 1) return;
      res.at(m) = cnt + 1;
      que.emplace(m, cnt + 1);
    };
    put(n+1);
    for (ll k = 6; n + k <= N; k *= 6) put(n+k);
    for (ll k = 9; n + k <= N; k *= 9) put(n+k);
  }

  return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,H,W;
	int a[100001],b[100001];
	map<pint,int> blackkosu;
	scan(H);scan(W);scan(N);
	ll ans[10]={};
	ans[0]=(ll)(H-2)*(W-2);
	rep(i,N){
		scan(a[i]);scan(b[i]);
		for(int h=max(2,a[i]-1);h<=min(H-1,a[i]+1);h++){
			for(int w=max(2,b[i]-1);w<=min(W-1,b[i]+1);w++){
				blackkosu[mp(h,w)]++;
				ans[blackkosu[mp(h,w)]-1]--;
				ans[blackkosu[mp(h,w)]]++;
			}
		}
	}
	rep(i,10) prin(ans[i]);
	return 0;
}


Measured memory_bytes: 57216
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		double ans=0;
		String money;
		String[] tmp;
		double amount;
		for(int i=0; i<n; i++) {
			tmp=sc.nextLine().split(" ");
			amount=Double.parseDouble(tmp[0]);
			money=tmp[1];
			if(money.equals("JPY"))
				ans+=amount;
			else
				ans+=amount*380000;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

int main() {
	string S;cin>>S;
	if(count(S.begin(), S.end(), 'o') + (15 - (int)S.size()) >= 8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
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));
    String[] str = in.readLine().split(" ");
    long n = Long.parseLong(str[0]);
    long a = Long.parseLong(str[1]);
    long b = Long.parseLong(str[2]);
    long quo = n/(a+b);
    long rem = n%(a+b);
    //System.out.println(quo + " " + rem);
    if(rem>a)
      System.out.println(quo*a + a);
    else
      System.out.println(quo*a + rem);
  }
}

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

int main(){
  int N, A, B;
  int num, dig, sum = 0;  //各数字の和を求めるのに使用
  int ans = 0;  //最終結果

  cin >> N >> A >> B;

  for(int i = 1; i <= N; i++){
    num = i;
    sum = 0;
    while(num>0){
      sum += num % 10;
      num = num / 10;
    }
    if(sum >= A && sum <= B){
      ans+=i;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,maxs=0;
string s;
map<string,int> m;
map<string,int>::iterator it;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		m[s]++;
	}
	for(it=m.begin();it!=m.end();it++){
		maxs=max(maxs,it->second);
	}
	for(it=m.begin();it!=m.end();it++){
		if(it->second==maxs){
			cout<<it->first<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 25216
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function carry(x::Array{Int,1},n)
	k = length(x)
	for i in 1:k-1
		if x[k-i+1] > n-1
			x[k-i] += div(x[k-i+1],n)
			x[k-i+1] = x[k-i+1]%n
		end
	end
	if x[1] > n-1
		0
	else
		x
	end
end

function main()
	n = readline() |> parseInt
	d = readline() |> split |> parseMap
	if n>23 || minimum(d)==0
		println(0)
	else
		c = zeros(Int,24)
		c[24] = 1
		for i in 1:n
			c[d[i]] += 1
			c[24-d[i]] += 1
		end
		if maximum(c)>=3
			println(0)
		elseif n>11
			println(1)
		else
			e = zeros(Int,n)
			m = 0
			while e!=0
				lm = 24
				x = zeros(Int,n)
				for i in 1:n
					if e[i]==0
						x[i] = d[i]
					else
						x[i]=24-d[i]
					end
				end
				for i in 1:n-1
					for j in i+1:n
						lm = min(lm,abs(x[i]-x[j]))
					end
				end
				lm = min(lm,minimum(d))
				m = max(m,lm)
				e[n] += 1
				e = carry(e,2)
			end
			println(m)
		end
	end
end
main()

Measured memory_bytes: 115212
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = np.array([A1, A2, A3])

N = int(input())
for i in range(N):
    B = int(input())
    A[A==B] = 0
    
result = 'No'
for i in range(3):
    if A[i].sum()==0:
        result = 'Yes'
        break
    elif A[:, i].sum()==0:
        result = 'Yes'
    else:
        pass
if np.diag(A).sum()==0:
    result = 'Yes'
elif (A[0, 2]+A[1, 1]+A[2, 0])==0:
    result = 'Yes'

print(result)

Measured memory_bytes: 12492
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	long long min=1e10,i,len;
	getline(cin,s);
	len=s.size();
	for(i=0;i<len-2;i++){
		int ans=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
		if(abs(ans-753)<min){
			min=abs(ans-753);
		}
	}
	cout<<min<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef vector<int64_t> vi;
typedef pair< int64_t,int64_t> ii;
typedef vector<pair<int64_t, int64_t> > vp;
typedef vector<pair<int64_t, ii> > vpp;
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int int64_t
void solve();
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    solve();
    return 0;
}
void solve()
{
    int n,k;
    cin>>n>>k;
    vi ar(n+1);
    vi br(n+1);
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        br[i]=1e10;
    }
    br[0]=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j<n)
            {
                br[i+j]=min(br[i+j],br[i]+abs(ar[i+j]-ar[i]));
            }
        }
    }
    cout<<br[n-1]<<"\n";
}




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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S; 
    for(int i = 0; i < S.size(); i++){
        char c;
        int s = (int)S[i] + N;
        if( s > 90){
            c = (char)(64 + s - 90);
        }else{
            c = (char)s;
        }
        cout << c;
    }
    cout << endl;
    return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  if ( (T==S+'a'||T==S+'b'||T==S+'c'||T==S+'d'||T==S+'e'||T==S+'f'||T==S+'g'||T==S+'h'||T==S+'i'||T==S+'j'||T==S+'k'||T==S+'l'||T==S+'m'||T==S+'n'||T==S+'o'||T==S+'p'||T==S+'q'||T==S+'r'||T==S+'s'||T==S+'t'||T==S+'u'||T==S+'v'||T==S+'w'||T==S+'x'||T==S+'y'||T==S+'z')
      && S.size()>=1 && S.size()<=10){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}



Measured memory_bytes: 3644
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a=Counter(a)
m=int(input())
b=list(map(int,input().split()))
b=Counter(b)
for d,e in b.items():
    if a[d]<e:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 55264
n = int(input().rstrip("\n"))
cells = [0] + [int(x) for x in input().rstrip("\n").split(" ")]

dp = [0]

for i in range(1,n+1):
  if cells[i-1] >= cells[i]:
    dp.append(dp[-1] + 1)
  else:
    dp.append(0)

print(max(dp))

Measured memory_bytes: 14252
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int d, t, s;
    cin >> d >> t >> s;

    if (s * t >= d) print("Yes");
    else print("No");


}


Measured memory_bytes: 3640