akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  string s; int k;
  cin >> s >> k;
  for (auto &i : s) {
    if (i != 'a' && 'z' - i + 1 <= k) {
      k -= 'z' - i + 1;
      i = 'a';
    }
  }
  if (k) {
    k %= 26;
    s.back() += k;
    if (s.back() > 'z') s.back() -= 26;
  }
  cout << s << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "- ---- -- ----- <3\n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    ll n,ans=0;
    cin>>n;
    vector<ll> l(n);
    for (int i = 0; i < n; i++)
    {
        cin>>l[i];
    }
    sort(all(l));
    //a<=b kakutei
    //b-a<c
    //c<a+b
    for (ll bi = 0; bi < n; bi++)
    {
        for (ll ai = 0; ai < bi; ai++)
        {
            ll a=l[ai];
            ll b=l[bi];
            auto cimax = lower_bound(all(l),a+b);
            //cout<<a<<"\t"<<b<<"\t"<<cimax-(l.begin())<<endl;
            //cout<<cimax-(l.begin())-bi-1<<endl;;
            //cout<<a<<"\t"<<b<<"\t"<<chmax<<"\t"<<chmin<<endl;
            ans+=cimax-(l.begin())-bi-1;            
        }
        
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
key = []
for _ in range(M):
  a, b = map(int, input().split())
  s = 0
  C = list(map(lambda x:int(x)-1, input().split()))
  for c in C:
    s |= 1<<c
  key += [(s, a)]
  
dp = [float('inf')]*(1<<N)
dp[0] = 0
for s in range(1<<N):
  for i in range(M):
    t = s | key[i][0] # 遷移先
    cost = dp[s] + key[i][1]
    dp[t] = min(dp[t], cost)
if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1])






Measured memory_bytes: 46936
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    
    double a, b, x;
    cin >> a >> b >> x;
    double s = x/a;
    double rad;
    if(s >= a*b/2){
        double h = (a*b-s)*2/a;
        rad = atan2(h, a);
    } else {
        double w = s*2/b;
        rad = atan2(b,w);
    }
    double PI = acos(-1);
    double deg = rad/(2*PI)*360;
    printf("%.10f\n", deg);
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int par[100005],sz[100005],_ans;
int find(int x){return x==par[x]?x:par[x]=find(par[x]);}
void unite(int x,int y){
	int nx=find(x),ny=find(y);
	if(nx==ny)return;
	_ans-=sz[nx]*sz[ny];
	sz[nx]+=sz[ny];
	par[ny]=nx;
}
vector<pair<int,int> >edge;
int n,m,ans[100005];
signed main(){
	cin>>n>>m;_ans=n*(n-1)/2;
	for(int i=1;i<=n;i++)par[i]=i,sz[i]=1;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		edge.push_back(make_pair(x,y));
	}
	for(int i=edge.size()-1;i>=0;i--){
		ans[i]=_ans;
		unite(edge[i].first,edge[i].second);
	}
	for(int i=0;i<m;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 5360
#include<stdio.h>
int main(void)
{
	int a,i;
	long X=0;


	scanf("%d",&a);
	for(i=1;i<=a;i++){
		if((i%3!=0)&&(i%5!=0)){
			X=X+i;
		}
	}
	printf("%ld",X);
	return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

vector<bool> visited(200005, false);

int main(){
    ll n, q2;
    cin >> n >> q2;

    vector<vector<ll>> tree(n);
    for(int i = 0; i < n-1; i++){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<ll> ans(n,0);
    for(int i = 0; i < q2; i++){
        ll p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    queue<ll> q;
    q.push(0);
    visited[0] = true;
    while(!q.empty()){
        ll now = q.front();
        q.pop();
        for(int i = 0; i < tree[now].size(); i++){
            if(visited[tree[now][i]] == false){
                q.push(tree[now][i]);
                ans[tree[now][i]] += ans[now];
                visited[tree[now][i]] = true;
            }
        }


    }

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

}


Measured memory_bytes: 17904
// AOJ 1190: Anchored Balloon
// 2017.12.8 bal4u@uu

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

#define N 50
int n;
int x[10], y[10], l[10];

double sach(double xx, double yy)
{
	int i;
    double t, ans = 1e10;

    for (i = 0; i < n; i++) {
        t = l[i]*l[i] - (xx-x[i])*(xx-x[i]) - (yy-y[i])*(yy-y[i]);
        if (t < ans) ans = t;
    }
    return ans;
}

double ysach(double xx)
{
	int i;
    double l = -100.0, r = 100.0, m1, m2;

    i = N; while(i--) {
        m1 = (2*l + r) / 3;
        m2 = (l + 2*r) / 3;
        if (sach(xx, m1) > sach(xx, m2)) r = m2; else l = m1;
    }
    return sach(xx, l);
}

double xysach()
{
	int i;
    double l = -100.0, r = 100.0, m1, m2;

    i = N; while (i--) {
        m1 = (2*l + r) / 3;
        m2 = (l + 2*r) / 3;
        if (ysach(m1) > ysach(m2)) r = m2; else l = m1;
    }
    return sqrt(ysach(l));
}

int main()
{
	int i;

    while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d%d%d", x+i, y+i, l+i);
        printf("%.07f\n", xysach());
    }
}

Measured memory_bytes: 1800
#include<stdio.h>
#define MAX 2000001

//typedef unsigned long long llong;
int H;//dataの数stackのlastを示す値のように使っている
int S[MAX];

void swap(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}


void increaseKey(int i,int k){
  if(k < S[i])return;
  S[i] = k;
  while(i>1 && S[i/2] < S[i]){
    swap(&S[i],&S[i/2]);
    i = i/2;
  }
}

void maxheap(int i){
  int left,right,largest;
  left = 2 * i;
  right = 2 * i + 1;
  if(left <= H && S[left] > S[i])largest = left;
  else largest = i;
  if(right <= H && S[right] > S[largest])largest = right;
  if(largest != i){
    swap(&S[i],&S[largest]);
    maxheap(largest);
  }
}



void insert(int k){
H++;
 S[H] = -1;
 increaseKey(H,k);
}

int extractMax(){
  int max;
  if(H < 1)return -1;
  max = S[1];//root
  S[1] = S[H--];
  maxheap(1);
  return max;
}

int main(){
  int key,temp;
  int datanum,i;
  char command[11];
  while(1){
    scanf("%s",command);
if(command[0] == 'e' && command[1] == 'n')break;
    if(command[0] == 'i'){
scanf("%d",&key);
insert(key);
}else if(command[0] == 'e' && command[1] == 'x'){
temp = extractMax();
 printf("%d\n",temp);
}
    else{
printf("command error\n");
}
  }
  return 0;
}



Measured memory_bytes: 5608
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <string>
#include <complex>
using namespace std;

#define INT_max 2147483647


typedef long long ll;
typedef long double ld;


char change(char x){
	if(x == '9') return '1';
	return x+1;
}


int main(){
	int N,x,y;
	cin>>N>>x>>y;
	vector<int> ans(N,0);
	for(int i = 1;i < N;i++){
		for(int j = i+1;j <= N;j++){
			if(j >= x){
				int t = min(abs(i-x)+1+abs(j-y),abs(j-i));
				ans[t]++;
			}
			else{
				ans[j-i]++;
			}
		}
	}
	for(int i = 1;i < N;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) +
      (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) +
      (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) +
      (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) +
      (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) +
      (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) +
      (x & 0x00000000ffffffffUL);
  return x;
}

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

struct div_moebius {
  long long n, m;
  map<long long, long long> res;
  vector<long long> primes;
  div_moebius() {
    n = m = 0;
    res.clear();
    primes.clear();
  }
  div_moebius(long long newn) {
    div_moebius();
    n = newn;
    for(long long i = 2; i * i <= newn; ++i)
      if(newn % i == 0) {
        primes.push_back(i);
        while(newn % i == 0) newn /= i;
      }
    if(newn != 1) primes.push_back(newn);
    m = primes.size();
    for(long long i = 0; i < (1 << m); ++i) {
      long long mu = 1, d = 1;
      for(long long j = 0; j < m; ++j)
        if(i >> j & 1) {
          mu *= -1;
          d *= primes[j];
        }
      res[d] = mu;
    }
  }
};

long long n, m;
vector<long long> p;
div_moebius dm;

long double solve();

int main() {
  cout << fixed << setprecision(10);
  while(1) {
    cin >> n >> m;
    if(n + m == 0) break;
    p.resize(m);
    for(int i = 0; i < m; ++i) cin >> p[i];
    cout << solve() << endl;
  }
  return 0;
}

long double solve() {
  long double res = (n + 1) * n / 2, cnt = n;
  for(int i = 1; i < (1 << m); ++i) {
    long long now = 1, nowcnt = 0;
    for(int j = 0; j < m; ++j)
      if(i >> j & 1) now = LCM(now, p[j]);
    nowcnt = n / now;
    now *= nowcnt * (nowcnt + 1) / 2;
    if(popcount(i) % 2) {
      cnt -= nowcnt;
      res -= now;
    }
    else {
      cnt += nowcnt;
      res += now;
    }
  }
  if(cnt == 0) return 0;
  return res / cnt;
}


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

int main() {
  int n, x;
  cin >> n >> x;
  int mc = 1005;

  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    mc = min(mc, t);
    x -= t;
  }

  n += x / mc;
  cout << n << endl;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
mod = 10 ** 9 + 7

def mod_inverse(a, p):
    mod = 1
    p_bin = bin(p-2)
    for i in range(len(p_bin) - 1, 1, -1):
        if i == len(p_bin) - 1:
            mul = a
            mul %= p
            mod *= (mul ** int(p_bin[i]))
            mod %= p
        else:
            mul = mul ** 2
            mul %= p
            mod *= (mul ** int(p_bin[i]))
            mod %= p
    return mod

def combination(n, k, p):
    a = 1
    for i in range(n, n - k, -1):
        a *= i
        a %= p
    b = 1
    for i in range(k):
        b *= (i + 1)
        b %= p
    return (a * mod_inverse(b, p)) % p

if (x + y) % 3 != 0:
    print(0)
elif x > y * 2 or y > x * 2:
    print(0)
else:
    total = (x + y) // 3
    a = x - total
    b = total - a
    c = min(a, b)
    print(combination(total, c, mod))

Measured memory_bytes: 3064
#include "stdio.h"

int main() {
    int k,c=0;
    char s[100];
    scanf("%d",&k);
    scanf("%s",&s);
    for (int i=0;i<k+1;++i) {
        if (s[i] == '\0') {
            printf("\n");
            return 0;
        }
        if (i == k && s[i] != '\0') {
           break;
        }
        printf("%c",s[i]);
    }
    printf("...\n");
    return 0;
}

Measured memory_bytes: 1648
#include <algorithm>
#include <cstdio>
#include <limits>
#include <vector>

using namespace std;
using VectorInt = vector<int>;

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

int main()
{
    int n;
    scanf("%d", &n);
    VectorInt v;
    for (int i = 0; i < n; ++i) {
        int t;
        scanf("%d", &t);
        v.push_back(t);
    }
    int mi = v[0];
    int c = numeric_limits<int>::min();
    for (size_t i = 1; i < v.size(); ++i) {
        c = max(v[i] - mi, c);
        mi = min(v[i], mi);
    }
    pi(c);
}

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

int main() {
  int n; string s;
  cin >> n >> s;
  int ans = 1;
  rep(i,0,n-1) {
    if (s[i] != s[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,x; cin >> n >> x;
	vi L(n); rep(i,n) cin >> L[i];
	vi p(n+2,0); p[n+1]=INF;
	rep(i,n) p[i+1]=p[i]+L[i];
	int l=0,r=n+1;
	while(l+1<r){
		int mid = (l+r)/2;
		if(p[mid]<=x) l=mid; else r=mid;
	}
	cout << r << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N-1) {
        int a;
        cin >> a;
        a--;
        mp[a]++;
    }

    rep(i, N) {
        cout << mp[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 16096
#include<bits/stdc++.h>
#define re register
using namespace std;
int n,m,dis[22][22],ans;
char mp[22][22];
inline bool check(re int x,re int y){
	if(x<1||x>n||y<1||y>m)return 0;
	if(mp[x][y]=='#')return 0;
	if(dis[x][y])return 0;
	return 1;
}
queue <int> q;
inline void bfs(re int x,re int y){
	q.push(x);
	q.push(y);
	while(!q.empty()){
		x=q.front();q.pop();
		y=q.front();q.pop();
		if(check(x+1,y))dis[x+1][y]=dis[x][y]+1,q.push(x+1),q.push(y);
		if(check(x-1,y))dis[x-1][y]=dis[x][y]+1,q.push(x-1),q.push(y);
		if(check(x,y+1))dis[x][y+1]=dis[x][y]+1,q.push(x),q.push(y+1);
		if(check(x,y-1))dis[x][y-1]=dis[x][y]+1,q.push(x),q.push(y-1);
	}
}
signed main(){
scanf("%d%d",&n,&m);
for(re int i=1;i<=n;++i)scanf("%s",mp[i]+1);
for(re int i=1;i<=n;++i){
	for(re int j=1;j<=m;++j){
		if(mp[i][j]=='.'){
	
		memset(dis,0,sizeof(dis));
		dis[i][j]=1;
		bfs(i,j);
		for(re int ii=1;ii<=n;++ii){
			for(re int jj=1;jj<=m;++jj){
				ans=max(ans,dis[ii][jj]);
			}
		}	}
	}
}
cout<<ans-1;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
ll mpow(ll a, ll n) {
  ll ans = a;
  for (ll i = 1; i < n; i++) {
    ans *= a;
    ans %= MOD;
  }
  return ans;
}
ll kai(ll n) {
  ll ans = 1;
  for (ll i = 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
map<ll, ll> m;

ll solve(ll n) { return (m[n - 1] * 9 * n) % MOD; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  // if (n == 1) {
  //   cout << 0 << endl;
  //   return 0;
  // }
  // if (n == 2) {
  //   cout << 2 << endl;
  //   return 0;
  // }
  ll ans =
      mpow(10, n) % MOD - (mpow(8, n) + 2 * (mpow(9, n) - mpow(8, n)) % MOD);
  if (ans < 0) {
    cout << ans + MOD << endl;
    return 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll MOD(ll val, ll m) {
    ll res = val % m;
    if (res < 0) res += m;
    return res;
}

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

ll nCr(ll n, ll r){
    ll ans=1;
    REP(i, 0, r){
        ans=(ans*(n-i))%mod;
        ans=(ans*modpow(i+1, mod-2))%mod;
    }
    return ans;
}

int main() {
    ll n, a, b;
    cin>>n>>a>>b;

    if(n==2){
        cout<<0<<endl;
        return 0;
    }

    ll ans=modpow(2, n)-1;
    ans=MOD((ans%mod) - (nCr(n, a)%mod), mod);
    ans=MOD((ans%mod) - (nCr(n, b)%mod), mod);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * @brief AtCoder Beginner Contest 116<br>
 * A - Right Triangle
 *
 * @see https://atcoder.jp/contests/abc116/tasks/abc116_a
 */
#include <iostream>
using namespace std;

int main() {
  int hen[3];
  for (int i{}; i < 3; ++i)
    scanf("%d", &hen[i]);
  sort(hen, hen+3);

  printf("%d\n", hen[0] * hen[1] / 2);
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define roop(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    roop(i, K){
        int r, c, v;
        cin >> r >> c >> v;
        a[r - 1][c - 1] = v;
    }
    roop(i, R){
        roop(j, C){
            for(int k = 2; k >= 0; k--){
                chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
            }
            roop(k, 4){
                chmax(dp[i + 1][j][0], dp[i][j][k]);
                chmax(dp[i][j + 1][k], dp[i][j][k]);
            }
        }
    }
    ll ans = 0;
    roop(k, 4){
        chmax(ans, dp[R - 1][C - 1][k]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 320436
#include <iostream>
#include <vector>
using namespace std;
#define MOD 998244353LL

long long int modpow(long long x, long long y){
  	if(y == 0) return 1;
  if(y < 0) return 0;
	if(y % 2) return (modpow(x, y-1) * x) % MOD;
	else{
      long long buf = modpow(x, y/2);
      return (buf * buf) % MOD;
    }
}

long long fac[300000] = {};
long long factorial(long long x){
  if(x <= 0) return 1;
  if(fac[x] != 0) return fac[x];
  return fac[x] = (x * factorial(x-1))%MOD;
}

long long ncr(long long n, long long r){
  return (factorial(n) * modpow((factorial(n-r) * factorial(r) % MOD), MOD-2)) % MOD;
}

int main(){
  long long n,m,k;
  cin >> n >> m >> k;
  long long ans = 0;
  for(int i = 0; k >= i; i++){
	ans += (((modpow(m-1, n-i - 1) * m )%MOD) * ncr(n-1, i)) % MOD;
    ans %= MOD;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7824
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

		String b = sc.next();

		String answer = "";

		switch(b){
			case "A":
				answer = "T";
				break;
			case "T":
				answer = "A";
				break;
			case "C":
				answer = "G";
				break;
			case "G":
				answer = "C";
				break;
			default:
				break;
		}

        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

class Main {

    public static void print_ans(int n, int m) {
	for (int i = 0; i < m; i++) {
	    System.out.print(n);
	}
	System.out.println();
    }
    
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	int a = sc.nextInt();
	int b = sc.nextInt();

	if (a < b)
	    print_ans(a, b);
	else
	    print_ans(b, a);
    }

}

Measured memory_bytes: 21844
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
all = Array.new(n,0)
m.times do 
    a, b = gets.split.map(&:to_i)
    if h[a-1] > h[b-1]
        all[b-1] += 1
    elsif h[a-1] == h[b-1]
        all[a-1] += 1
        all[b-1] += 1
    else 
        all[a-1] += 1
    end
end
  goukei = 0
all.each do |i|
    if i == 0
          goukei += 1
    end
end

puts goukei
     



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

int main(void){
 vector<int> a(3);
 cin >> a[0] >> a[1] >> a[2];
 sort(a.begin(), a.end());
 if (a[0]==5 && a[1]==5 && a[2]==7) cout << "YES" << endl;
 else cout << "NO" << endl;
 
 return 0;
}

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

using namespace std;

const int MAXN = 1e6 + 7;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n / 2; ++i)
    {
        if (s[i] != s[n - i - 1])
        {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

template
<
    typename TYPE,
    std::size_t SIZE
>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;

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



int main()
{
    int n;
    cin >> n;
    bool ok = true;

    int nx(0),ny(0);
    int nt(0);
    REP(i,n){
        int t1,a,b;
        cin >> t1;
        cin >> a >> b;
        int t = t1 - nt;
        int d = abs(a-nx)+abs(b-ny);
        if(d>t || (t-d)%2){
            ok = false;
            break;
        }
        nx = a;
        ny = b;
        nt = t1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int D,G;
  cin >> D >> G;
  vp sc(D);
  vp com(D);
  rep(i,D) {
    int p,c;
    cin >> p >> c;
    sc[i] = P(p,c);
    com[i] = P(p*i*100+c,i);
  }
  sort(rng(com));
  reverse(rng(com));
  int ans = INF;
  rep(i,1<<D) {
    int cnt = 0;
    int sum = 0;
    rep(j,D) {
      if(i>>j&1) {
        sum += sc[j].first * (j+1) * 100 + sc[j].second;
        cnt += sc[j].first;
      }
    }
    if(sum >= G) {
      ans = min(ans,cnt);
      continue;
    }
    drep(j,D) {
      if(!(i>>j&1)) {
        int cnt2 = cnt;
        int sum2 = sum;
        if((j+1) * 100 * (sc[j].first - 1) >= G - sum) {
          while(sum2 < G) {
            cnt2++;
            sum2 += (j+1) * 100;
          }
          ans = min(ans,cnt2);
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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()
{
  ll n,m,x;
  cin>>n>>m>>x;
  ll arr[n][m+1];
  rep(i,0,n)
  {
    cin>>arr[i][0];
    repA(j,1,m)
    cin>>arr[i][j];
  }
  ll res=LLONG_MAX;
  rep(i,0,(1<<n))
  {
    ll cost=0;
    ll sum[m+1]={0};
    int flag=1;
    rep(j,0,n)
    {
      if(i&(1<<j))
      {
        cost+=arr[j][0];
        repA(k,1,m)
        sum[k]+=arr[j][k];
      }
    }
    repA(k,1,m)
    {
      if(sum[k]<x)
      {
        flag=0;
        break;
      }
    }
    if(flag==1)
    {
      res=min(res,cost);
    }
  }
  if(res==LLONG_MAX)
    cout<<-1<<endl;
  else
  cout<<res<<endl;
}

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

typedef pair<int,int> P;

int dp[4000][4000];

bool pairCompare(const P& Fir, const P& Sec)
{
    return Fir.first < Sec.first; // 1番目について昇順
}

int main(){
    int N,T;
    cin >> N >> T;

    vector<P> v;

    for(int i=0;i<N;i++) {
        int a,b;
        cin >> a >> b;
        v.push_back(P(a,b));
    }
    sort(v.begin(), v.end(), pairCompare);

    for (int i=1;i<=N;i++) {
        for (int j=0;j<T;j++) {
            if (j>=v[i-1].first) dp[i][j] = max(dp[i-1][j-v[i-1].first]+v[i-1].second, dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    int ans = 0;
    for (int i=0;i<N;i++) {
        ans = max(ans, dp[i][T-1] + v[i].second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 47360
#include <bits/stdc++.h>
#define N 306
#define mo 1000000007
using namespace std;
struct arr{int l,r,v;}Q[N];
int n,m,ans;
int f[N][N][N],r[N][N],b[N][N],g[N][N];
inline int read()
{
	int x=0,c=getchar(),f=1LL;while(c<'0'||c>'9')f=(c=='-'?-f:f),c=getchar();
	while(c>='0'&&c<='9')x=(x<<1LL)+(x<<3)+c-48,c=getchar();return f>0?x:-x;
}
void print(long long x)
{
	if(x>9)print(x/10);putchar(x%10+48);
}
inline bool cmp(arr x,arr y)
{
	return x.r<y.r;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)
		Q[i].l=read(),Q[i].r=read(),Q[i].v=read();
	sort(Q+1,Q+m+1,cmp);
	f[0][0][0]=r[0][0]=b[0][0]=g[0][0]=1;
	for(int i=1,h=1;i<=n;i++){
		for(int j=0;j<i;j++)
			for(int k=0;k<i;k++){
				f[i][j][k]=r[j][k];
				f[j][i][k]=b[j][k];
				f[j][k][i]=g[j][k];
			}
		while(Q[h].r==i){
			if(Q[h].v==1){
				for(int j=Q[h].l;j<i;j++)
					for(int k=0;k<i;k++)f[i][j][k]=f[j][i][k]=f[j][k][i]=0;
				for(int k=Q[h].l;k<i;k++)
					for(int j=0;j<i;j++)f[i][j][k]=f[j][i][k]=f[j][k][i]=0;
			}
			if(Q[h].v==2){
				for(int j=Q[h].l;j<i;j++)
					for(int k=Q[h].l;k<i;k++)f[i][j][k]=f[j][i][k]=f[j][k][i]=0;
				for(int k=0;k<Q[h].l;k++)
					for(int j=0;j<Q[h].l;j++)f[i][j][k]=f[j][i][k]=f[j][k][i]=0;
			}
			if(Q[h].v==3){
				for(int j=0;j<Q[h].l;j++)
					for(int k=0;k<i;k++)f[i][j][k]=f[j][i][k]=f[j][k][i]=0;
				for(int k=0;k<Q[h].l;k++)
					for(int j=0;j<i;j++)f[i][j][k]=f[j][i][k]=f[j][k][i]=0;
			}
			h++;
		}
		memset(r,0,sizeof r);memset(g,0,sizeof g);memset(b,0,sizeof b);
		for(int j=0;j<i;j++)
			for(int k=0;k<i;k++){
				r[j][k]=(r[j][k]+f[i][j][k])%mo;
				r[i][k]=(r[i][k]+f[j][i][k])%mo;
				r[k][i]=(r[k][i]+f[j][k][i])%mo;
				b[j][k]=(b[j][k]+f[j][i][k])%mo;
				b[i][k]=(b[i][k]+f[i][j][k])%mo;
				b[j][i]=(b[j][i]+f[j][k][i])%mo;
				g[j][k]=(g[j][k]+f[j][k][i])%mo;
				g[j][i]=(g[j][i]+f[j][i][k])%mo;
				g[i][j]=(g[i][j]+f[i][j][k])%mo;
			}
	}
	for(int j=0;j<n;j++)
		for(int k=0;k<n;k++)
			ans=(1LL*ans+f[n][j][k]+f[j][n][k]+f[n][j][k])%mo;
	print(ans);
}

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






int main(){
  string s;
  while(getline(cin,s)){
    if(s=="."){break;}
  int k=0,m=0;
  int count=0;
  stack<int>  a;
  a.push(0);
  bool j=true;
  for(int i=0;i<s.size();i++){
    if(s[i]=='('){k++; a.push(1);}
    if(s[i]==')'){k--; if(a.top()!=1){j=false; break;} a.pop();}
    if(s[i]=='['){m++; a.push(2);}
    if(s[i]==']'){m--; if(a.top()!=2){j=false; break;} a.pop();}
  }
  if(k!=0 || m!=0){j=false;}
  if(j){cout<<"yes"<<endl;}
  else{cout<<"no"<<endl;}
  
  }
  
  return 0;
}



Measured memory_bytes: 3140
n = int(input())
a = [int(i) for i in input().split()]

ball = [0]*(n+1)

for i in range(n):
    ball[a[i]] += 1

zenbu = 0
    
for i in range(n+1):
    tmp = ball[i]
    if tmp > 1:
        zenbu += (tmp*(tmp-1))//2
        
for i in range(n):
    tmp = ball[a[i]]
    if tmp > 1:
        #sabun = (tmp*(tmp-1))//2 - ((tmp-1)*(tmp-2))//2
        print(zenbu-(tmp-1))
    else:
        print(zenbu)

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

int main() {
    float n;
    cin >> n;
    float answer;
    int cnt = 0;
    for (int i=1; i<=n; i++) {
        if (i % 2 == 1) {
            cnt++;
        }
    }
    cout << cnt / n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <deque>
#include <string>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	deque<int> d;
	char temp_char[10];
	
	while(scanf("%s", &temp_char) != -1){
		
		if(temp_char[0] != '+' && temp_char[0] != '-' && temp_char[0] != '*')
			d.push_back(atoi(temp_char));
		else{
			int num1, num2;
			num1 = d.back();
			d.pop_back();
			num2 = d.back();
			d.pop_back();
			switch(temp_char[0]){
				case '+':
					d.push_back(num1 + num2);
					break;
				case '-':
					d.push_back(num2 - num1);
					break;
				case '*':
					d.push_back(num1 * num2);
					break;
			}
		}
		
		
	}
	
	printf("%d\n", d.back());
	
	

	return 0;
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    ld a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f){
        ld x, y;
        x = (c * e - b * f) / (a * e - b * d);
        y = (c * d - a * f) / (b * d - a * e);
      	if(abs(x) < 1e-10) x = 0;
        if(abs(y) < 1e-10) y = 0;
        cout << fixed << setprecision(3) << x << " " << y << "\n";
    }
}


Measured memory_bytes: 3132
#include "bits/stdc++.h"
using namespace std;

int main()
{
    int K;
    string S;
    cin >> K >> S;

    int cnt = S.size();

    if (K < cnt) {
        cout << S.substr(0, K) << "..." << endl;
    }
    else {
        cout << S << endl;
    }
}


Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct Edge{
  int src, dst, cost;
  Edge(int u, int v, int c) : 
    src(u), dst(v), cost(c) {}
};
typedef vector<Edge> Node;
typedef vector<Node> Graph;
struct State{
  int room, S, cost;
  State(int r, int S, int c) :
    room(r), S(S), cost(c) {}
  bool operator < (const State& s) const {
    if(cost != s.cost) return cost > s.cost;
    if(room != s.room) return room > s.room;
    return S > s.S;
  }
};

int main(){
  int N, M, L, K;
  while(cin >> N >> M >> L >> K && N){
    Graph G(N);
    REP(i, M){
      int u, v, c;
      cin >> u >> v >> c;
      u--; v--;
      G[u].push_back(Edge(u, v, c));
      G[v].push_back(Edge(v, u, c));
    }
    int Start, Goal;
    cin >> Start >> Goal;
    Start--; Goal--;
    vector<int> B(N, -1);
    REP(i, L){
      int t; cin >> t;
      B[t - 1] = i;
    }
    vector<int> dist[50][1 << 7];
    priority_queue<State> que;
    State init(Start, (B[Start] != -1) ? 1 << B[Start] : 0, 0);
    que.push(init);
    while(!que.empty()){
      State s = que.top(); que.pop();
      if(dist[s.room][s.S].size() >= K) continue;
      dist[s.room][s.S].push_back(s.cost);
      FORIT(e, G[s.room]){
        State next = s;
        next.room = e->dst;
        next.cost += e->cost;
        if(B[next.room] != -1){
          next.S |= 1 << B[next.room];
        }
        if(dist[next.room][next.S].size() < K){
          que.push(next);
        }
      }
    }
    if(dist[Goal][(1 << L) - 1].size() == K){
      cout << dist[Goal][(1 << L) - 1].back() << endl;
    }else{
      cout << "NA" << endl;
    }
  }
  return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n],cnt=0LL,mi=1000000000000LL,ans=0LL,f=0LL;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		if (a[i]==0LL)
		{
			f=1LL;
		}
		else if (a[i]<0LL)
		{
			a[i]*=-1LL;
			++cnt;
		}
		ans+=a[i];
		mi=min(mi,a[i]);
	}
	if (f==1LL||cnt%2LL==0LL)
	{
		cout<<ans<<endl;
	}
	else
	{
		cout<<ans-2LL*mi<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits> 
using namespace std;

int main() {
	int n;
	cin>>n;
	
	int arr[n];
	int memo[n];
	for(int i=0; i<n; i++) {
		cin>>arr[i];
		memo[i] = INT_MAX;
	}
	
	memo[0] = 0;
	memo[1] = abs(arr[1]-arr[0]);
	for(int i=2; i<n; i++) {
		memo[i] = min(abs(arr[i]-arr[i-2]) + memo[i-2], abs(arr[i]-arr[i-1]) + memo[i-1]);
	}
	
	cout<<memo[n-1];
	return 0;
}

Measured memory_bytes: 4328
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll n, k;
    cin >> n >> k;
    vi vec(n);
    for(ll &x : vec)
        cin >> x;
    sort(all(vec));
    ll ans = 0;
    for(ll i=0; i<k; i++)
        ans += vec[i];
    cout << ans << endl;
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


Measured memory_bytes: 3668
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int a = sc.nextInt();

        long sum = 0;
        for(int i = 1; i < n; i++){
            int b = a;
            a = sc.nextInt();
            if(b - a > 0){
                sum += b - a;
                a += b - a;
            }
        }

        System.out.println(sum);

    }
}


Measured memory_bytes: 58204
#pragma GCC optimize("O3,no-stack-protector")
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> rgb(3);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            rgb[0].push_back(i);
        } else if (s[i] == 'G') {
            rgb[1].push_back(i);
        } else {
            rgb[2].push_back(i);
        }
    }

    Int ans = 0;
    vector<int> t{0, 1, 2};
    do {
        for (auto e : rgb[t[0]]) {
            auto gitr = upper_bound(rgb[t[1]].begin(), rgb[t[1]].end(), e);
            for (; gitr != rgb[t[1]].end(); ++gitr) {
                auto bitr = upper_bound(rgb[t[2]].begin(), rgb[t[2]].end(), *gitr);
                while (bitr != rgb[t[2]].end()) {
                    if (*gitr - e != *bitr - *gitr) {
                        ans++;
                    }

                    ++bitr;
                }
            }

            auto gitr2 = upper_bound(rgb[t[1]].begin(), rgb[t[1]].end(), e);
            for (; gitr2 != rgb[t[1]].end(); ++gitr2) {
                auto bitr2 = upper_bound(rgb[t[2]].begin(), rgb[t[2]].end(), *gitr2);
                while (bitr2 != rgb[t[2]].end()) {
                    if (*gitr2 - e != *bitr2 - *gitr2) {
                        ans++;
                    }

                    ++bitr2;
                }
            }
        }

    } while (next_permutation(t.begin(), t.end()));

    cout << ans / 2 << '\n';

    return 0;
}


Measured memory_bytes: 3660
(let ((r (read))
      (d (read))
      (x2000 (read)))
  (declare (type fixnum r)
           (type fixnum d)
           (type fixnum x2000))
  (do ((i 2001 (1+ i))
       (xi (- (* r x2000) d) (- (* r xi) d)))
      ((>= i 2011) nil)
      (format t "~&~d" xi)))


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

int main(){
  int N;
  cin >> N;
  
  int T, A;
  cin >> T >> A;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++){
  	cin >> vec.at(i);
  }
  float tmp;
  int num;
  float best_point = FLT_MAX;
  for (int p=0; p<N; p++){
  	tmp = abs((T - vec.at(p) * 0.006) - A);
    if(tmp < best_point){
    	best_point = tmp;
      	num = p;
    }
  }
  cout << num+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//int a[1000000];
long long a[30][30];
long long b[30];
int main()
{long long ans=-1;
 string s;
	cin>>s;
	string t;
	cin>>t;
	int a,b;
	map<string ,int>m;
	cin>>a>>b;
	m[s]=a;
	m[t]=b;
	string u;
	cin>>u;
	m[u]--;
	cout<<m[s]<<" "<<m[t];
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a <= 0&&b >= 0)cout << "Zero\n";
    else if(a > 0)cout << "Positive\n";
    else cout << ((b-a)%2==0?"Negative":"Positive") << endl;
    return 0;
}


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

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int lines = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < lines; i++) {
			String nico = sc.nextLine();
			
			int[] numbers = new int[nico.length()];
			for (int j = 0; j < nico.length(); j++) {
				numbers[j] = nico.charAt(j) - '0';
			}

			Arrays.sort(numbers);

			int min = 0;
			int max = 0;
			
			for (int j = 0; j < nico.length(); j++) {
				min = min * 10 + numbers[j];
				max = max * 10 + numbers[nico.length() - j - 1];
			}

			System.out.println(max - min);
		}
	}
}

Measured memory_bytes: 25840
#include<bits/stdc++.h>
#define INF (1e9)
#define N 305
using namespace std;
int n,p[N][N],d[N][N],ans=-INF;

int sum(int y1,int x1,int y2,int x2){
  return d[y2][x2]-d[y2][x1-1]-d[y1-1][x2]+d[y1-1][x1-1];
}

int cal(int s,int g){
  int mx,res;
  res=mx=sum(s,1,g,1);
  for(int i=2;i<=n;i++){
    int t=sum(s,i,g,i);
    res=max(res,max(mx+t,t));
    if(s!=g)mx=max(t,mx+sum(s,i,s,i)+sum(g,i,g,i));
    else mx=max(t,mx+sum(g,i,g,i));
  }
  return res;
}

int main(){
  cin>>n;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++){
      cin>>p[i][j];
      d[i][j]=p[i][j];
    }
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)d[i][j]+=d[i][j-1];
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)d[j][i]+=d[j-1][i];
  for(int i=1;i<=n;i++)
    for(int j=i;j<=n;j++)ans=max(ans,cal(i,j));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1880
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long; 
const ull MOD{(1ull<<61)-1};

long long modpow(long long a, long long b){
	long long c = 1;
	while(b > 0){
		if(b & 1) c = c * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return c;
}

struct RollingHash{
	const ull m30{(1ull<<30)-1};
	const ull m31{(1ull<<31)-1};
	const ull MOD{(1ull<<61)-1};
	const ull pos{MOD*7};
	ull base;
	vector<ull> powmemo;
	vector<ull> hash;
	
	RollingHash(string s, ull b) : base(b), powmemo(s.size()+1), hash(s.size()+1){
		powmemo.at(0) = 1;
		for(int i=1; i<powmemo.size(); i++){
			powmemo.at(i) = calmod(mul(powmemo.at(i-1),base));
		}
		for(int i=0; i<s.size(); i++){
			hash.at(i+1) = calmod(mul(hash.at(i),base)+s.at(i));
		}
	}
	ull slice(int begin, int length){
		return calmod( hash.at(begin+length) + pos - mul( hash.at(begin),powmemo.at(length) ) );
	}
	ull mul(ull l, ull r){
		ull lu{l>>31};
		ull ld{l&m31};
		ull ru{r>>31};
		ull rd{r&m31};
		ull mid{ld*ru + lu*rd};
		return ( ((lu*ru)<<1) + ld*rd + ((mid&m30)<<31) + (mid>>30) );
	}
	ull calmod(ull val){
		val = (val&MOD) + (val>>61);
		if(val>=MOD) val -= MOD;
		return val;
	}
};

int main(){
	string t,p; cin>>t>>p;
	ull base{};
	RollingHash rht(t,257);
	RollingHash rhp(p,257);
	for(int i=0; i+p.size()<=t.size(); i++){
		if(rht.slice(i,p.size())==rhp.hash.back()) cout << i << endl;
	}
	
}


Measured memory_bytes: 20580
#include <iostream>
#include <vector>
using namespace std;
int main(){
  //n=number of objects
  int n, count=0;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  for (int i=0; i<n; i++){
    bool ans;
    ans = true;
    //divide each smaller number
    for(int j=2; j*j<=vec.at(i); j++){
      if (vec.at(i)%j == 0){
        ans = false;
        break;
      }
    }
    if (ans == true){
      count++;
    }
  }
  cout << count << endl; 
}


Measured memory_bytes: 3108
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// #define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

// const int MAX_F = 3000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int A, B, C, D, E, F;
int MXX, MXY;
set<Pi> PAIRS;

int cmp_conc(int x, int y, int a, int b) {
  if (x + y + a + b == 0) return 0;
  if (x + y == 0) return -1;
  if (a + b == 0) return 1;
  return y * (a + b) - b * (x + y);
}

void dfs(int x, int y) {
  if (cmp_conc(MXX, MXY, 100, E) == 0) return;

  if (x + y > F) return;
  if (cmp_conc(x, y, 100, E) > 0) return;
  if (PAIRS.find(Pi(x, y)) != PAIRS.end()) return;

  debug_printf("%d %d\n", x, y);

  PAIRS.insert(Pi(x, y));
  if (cmp_conc(x, y, MXX, MXY) > 0) {
    MXX = x; MXY = y;
  }

  dfs(x, y + C);
  dfs(x, y + D);
  dfs(x + 100 * A, y);
  dfs(x + 100 * B, y);
}

void solve() {
  if (A < B) swap(A, B);
  if (C < D) swap(C, D);
  MXX = MXY = 0;

  dfs(0, 0);

  cout << MXX + MXY << " " << MXY << endl;
}

int main() {
  cin >> A >> B >> C >> D >> E >> F;

  solve();

  return 0;
}


Measured memory_bytes: 256
tate,yoko=map(int,input().split())
#ト字型に折る
def byodo(H,W):
    bigH=H//2+H%2
    smallH=H-bigH
    todif=10**10
    for i in range(W//2+1):
        Smin=min(H*i,smallH*(W-i))
        Smax=max(H*i,bigH*(W-i))
        todif=min(todif,Smax-Smin)
    for i in range(W//2+1,W):
        Smax=H*i
        Smin=smallH*(W-i)
        todif=min(todif,Smax-Smin)
    return(todif)
def france(H,W):#III
    if W%3:
        return(H)
    else:return(0)
print(min(byodo(tate,yoko),byodo(yoko,tate),france(yoko,tate),france(tate,yoko)))

Measured memory_bytes: 39440
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}



fn main(){
    input!{
        n: usize,
        a: [usize;n - 1],
    }
    
    let mut ans: Vec<usize> = vec![0;n];
    for i in a.iter(){
        ans[*i - 1] += 1;
    }

    for i in ans.iter(){
        println!("{}",i);
    }
}



Measured memory_bytes: 6340