akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

/* mint、表示は変数名.x */
struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

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

  map<ll, ll> prime;
  repp(i, 1, N) {
    map<ll, ll> m = prime_factor(i);
    for (auto p = m.begin(); p != m.end(); p++) {
      prime[p->fi] += p->se;
    }
  }

  mint ans = 1;
  repp(i, 1, N) {
    if (prime.find(i) == prime.end())
      continue;
    ans *= prime[i] + 1;
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 256
def msol19_d():
    n = int(input())
    graph = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(lambda x: int(x)-1, input().split())
        graph[a].append(b)
        graph[b].append(a)
    C = sorted(map(int, input().split()), reverse=True)

    score = sum(C[1:])
    label = [-1]*n
    from collections import deque
    que = deque([0])
    idx = 0
    while que:
        u = que.popleft()
        label[u] = C[idx]
        idx += 1
        for v in graph[u]:
            if label[v] != -1: continue
            que.append(v)
    print(score)
    print(*label, sep=' ')

if __name__ == '__main__':
    msol19_d()

Measured memory_bytes: 11788
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

ll n, p;
ll ans = 1, e = 0, q = 0;

vector<ll> prime_factor(ll n){
	vector<ll> res;
	for (ll i = 2; i * i <= n; i++){
		while (n % i == 0){
			res.push_back(i);
			n /= i;
		}
	}
	if (n != 1) res.push_back(n); 
	return res;
}

int main(){
	cin >> n >> p;
	vector<ll> v = prime_factor(p);
	for (int i = 0; i < v.size(); ++i){
		if (q != v[i]) q = v[i], e = 0;
		e++;
		if (e % n == 0) ans *= v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

template <int MOD>
struct ModInt {
    using lint = long long;
    using mint = ModInt<MOD>;

    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const {
        // non-recursive extended euclidean algorithm
        int s = val, t = MOD;
        mint sx = 1, sy = 0, tx = 0, ty = 1;
        while (s % t != 0) {
            int div = s / t;
            s -= t * div;
            sx -= tx * div;
            sy -= ty * div;

            std::swap(s, t);
            std::swap(sx, tx);
            std::swap(sy, ty);
        }
        return mint(tx);
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

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

    mint ans = 1;
    std::vector<int> num(3, 0);
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;

        int cnt = 0;
        for (int k = 0; k < 3; ++k) {
            if (num[k] == a) ++cnt;
        }

        ans *= cnt;
        for (int k = 0; k < 3; ++k) {
            if (num[k] == a) {
                ++num[k];
                break;
            }
        }
    }

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c,k;
  scanf("%d %d %d %d", &a,&b,&c,&k);
  if(a >= k)
    printf("%d", k);
  else if(a+b >= k)
    printf("%d", a);
  else
    printf("%d", a - k + a + b);
  return 0;
}

Measured memory_bytes: 1728
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const k: number = +this.args[0][0];
            const s: string = this.args[1][0];

            if (s.length <= k) {
                console.log(s);
            } else {
                console.log(s.substr(0, k)+ '...');
            }
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



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

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define len(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long ll;
typedef double db;
typedef pair<int, int> pi;
typedef pair<int, pi> ti;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ti> vti;
typedef vector<vpi> vvpi;

const int inf = (int)0x3f3f3f3f3f3f3f3f;
const int ninf = (int)0xc0c0c0c0c0c0c0c0;
const ll M = (ll)1e9 + 7;
const int N = 2e5 + 10;

int bit[N];

void upd(int i, int v) {
    for (++i; i < N; i += i & -i) bit[i] += v;
}

int get(int i) {
    int res = 0;
    for (++i; i; i -= i & -i) res += bit[i];
    return res;
}

main() {
    int n, d, a; scanf("%lld%lld%lld", &n, &d, &a);
    d *= 2;
    vpi v(n); for (pi& x : v) scanf("%lld%lld", &x.fi, &x.se);
    sort(all(v));
    fore(i, 0, n) upd(i, v[i].se), upd(i + 1, -v[i].se);
    int j = 0, ans = 0;
    fore(i, 0, n) if (get(i) > 0) {
        int tmp = get(i);
        while (j + 1 < n && v[j + 1].fi - v[i].fi <= d) ++j;
        int res = (tmp + a - 1) / a;
        upd(i, -(res * a));
        upd(j + 1, (res * a));
        ans += res;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
	long long n,k,i,ans=0;
	scanf("%lld %lld",&n,&k);
	if(k==0)printf("%lld",n*n);
	else
	{
		for(i=k+1;i<=n;i++)
		{
			ans+=((n/i)*(i-k));
			if((n%i)>=k)ans+=((n%i)-k+1);
		}
		printf("%lld",ans);
	}
}

Measured memory_bytes: 128
#include <stdio.h>
 
void leapyear(int start, int end);
 
int main(void)
{
    int start, end;
    while (1){
        scanf("%d %d", &start, &end);
        if (start == 0 && end == 0){
            break;
        } else {
            // 2回目の出力からは前回の出力とのあいだに空行をおく
            static int first_output = 1;
            if (first_output != 1){
                printf("\n");
            }
            first_output = 0;
 
            leapyear(start, end);
        }
    }
 
    return 0;
}
 
void leapyear(int start, int end)
{
    int cnt = 0;
    for (int year = start; year <= end; year++){
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)){
            printf("%d\n", year);
            cnt++;
        }
    }
    if (cnt == 0){
        printf("NA\n");
    }
}

Measured memory_bytes: 1048
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,m,ev,ov,idx=0,c;
  cin >> n >> m;
  ov = n/2;
  ev = n-ov;
  if(ev%2==1&&ov==0){
    swap(ev,ov);
  }
  ll pre_ev= ev;
  ev /= 2;
  c = ev;
  for(int i=0;i<m;i++){
    if(ev==0){
      idx=0;
      if(ov%2==1){
        c = pre_ev+ov/2+1;
      }else{
        c = pre_ev+ov/2;
      }
    }
    if(ev>0){
      cout << c-idx<<" "<<c+1+idx<<endl;
    }else{
      cout << c-1-idx<<" "<<c+1+idx<<endl;
    }
    idx++;
    ev--;
  }
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main
{
    
    public static void main(String[] args) throws IOException
    {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
        String s = r.readLine();
        String[] sl = s.split("[\\s]+");
        int n = Integer.parseInt(sl[0]);
        int x = Integer.parseInt(sl[1]);
        
        int min = 999999;
        int sum = 0;
        
        for(int i = 0; i < n; i++)
        {
          int z = Integer.parseInt(r.readLine());
          sum += z;
          min = Math.min(min, z);
        }
        
        System.out.println(n + (x - sum) / min);
        
    }
    
}


Measured memory_bytes: 21456
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define MAX 200009
#define int long long
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		int a[6];
		FOR1(i, 5) cin >> a[i];
		FOR1(i, 5){
			if(a[i] == 0) {
				cout << i;
				break;
			}
		}
		cout<<'\n';
	}
	return 0;
}


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

typedef  long long ll;

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

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
   int n,i;
   cin >> n >> i;
   cout << n-i+1 <<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin >> v.at(i);
    }

    sort(v.begin(),v.end(),greater<int>());
    int ans=0;
    for(int i=0;i<K;i++){
        ans += v.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-7)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define reo(i,n) for(int (i) = 1 ; (i) <= (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(n,i) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem0(x) memset(x,0,sizeof(x))
#define vec vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'a')
#define itoc(c) (char)(c+'a')
#define itn int
#define pri_que priority_queue
#define pp(x,y) pb(H{x,y})
#define ppp(x,y,z) pb(Q(x,y,z))
#define cyes cout<<"Yes\n"
#define cno cout<<"No\n"
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
const vec<int>dx{ 0,0,-1,1 }, dy{ 1,-1,0,0 };
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; }
ll read() { ll u, k = scanf("%lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 600000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------------------
int n, d, x;
H a[300000];
int b[300000];
signed main() {
	cin >> n >> d >> x;
	rep(i, n) {
		cin >> a[i].fs >> a[i].sc;
	}
	sort(a, a + n);
	int l = 0;
	int sum = 0, ans = 0;
	rep(i, n) {
		while (l < i && a[i].fs - a[l].fs > 2 * d) {
			sum -= b[l];
			l++;
		}
		while (sum * x < a[i].sc) {
			int t = ceil((a[i].sc - sum * x) * 1. / x);
			b[i] += t;
			sum += t;
			ans += t;
		}
	}
	cout << ans << endl;
}

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

int main(void) {
    int a, b;
    cin >> a >> b;
    if(a <= 0 && b>= 0) cout << "Zero" << endl;
    else if(a < 0 && (a-b)%2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
}

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

int main() {
    int n;
    int ans=30;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a, power_of_two=0;
        cin >> a;
        for (int j = 1; j < 31; j++) {
            if (a % (int)pow(2, j) == 0) power_of_two += 1;
        }
        ans = min(ans, power_of_two);
    }
    cout << ans << endl;
}

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

int main(){
    ll N;
    cin >> N;
    ll sum=0;
    ll A[N], B[N], C[N-1];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];
    ll prev = -100;
    rep(i,N){
        ll idx = A[i] - 1;
        sum += B[idx];
        if(prev+1==idx){
            sum += C[idx-1];
        }
        prev = idx;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int main() {
	int N, K;
	cin >> N >> K;
	int ans = K;
	rep(i, N - 1) ans *= K - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;


char t[200000];
char d[200000];
string s;

int move(char c){
    if(c == 'R'){
        return 1;
    } else {
        return - 1;
    }
}

bool disappear_from_left(int pos, int Q){
    int cur = pos;
    for(int i = 0; i < Q; i++){
        if(s[cur] == t[i]){
            cur += move(d[i]);
        }
        if(cur > (int) s.size() - 1){
            return false;
        }
        if(cur < 0){
            return true;
        }
    }
    return false;
}

bool disappear_from_right(int pos, int Q){
    int cur = pos;
    for(int i = 0; i < Q; i++){
        if(s[cur] == t[i]){
            cur += move(d[i]);
        }
        if(cur < 0){
            return false;
        }
        if(cur > (int) s.size() - 1){
            return true;
        }
    }
    return false;
}


int main(){
    
    int N;
    int Q;
    cin >> N >> Q;
    cin >> s;

    for(int i = 0; i < Q; i++){
        cin >> t[i] >> d[i];
    }

    int left = 0;
    int right = N - 1;
    int right_most_disappear_left;
    if(disappear_from_left(right, Q)){
        cout << 0 << endl;
        return 0;
    } else if(!disappear_from_left(left, Q)){
        right_most_disappear_left = -1;
    } else {
        while(left + 1 < right){
            int mid = (left + right) / 2;
            if(disappear_from_left(mid, Q)){
                left = mid;
            } else {
                right = mid;
            }
        }
        right_most_disappear_left = left;
    }

    left = 0;
    right = N - 1;
    int left_most_disappear_right;
    if(disappear_from_right(left, Q)){
        cout << 0 << endl;
        return 0;
    } else if(!disappear_from_right(right, Q)){
        left_most_disappear_right = N;
    } else {
        while(left + 1 < right){
            int mid = (left + right) / 2;
            if(disappear_from_right(mid, Q)){
                right = mid;
            } else {
                left = mid;
            }
        }
        left_most_disappear_right = right;
    }

    //cout << right_most_disappear_left << " " << left_most_disappear_right << endl;
    cout << max(0, N - (N - left_most_disappear_right) - (right_most_disappear_left + 1)) << endl; 
    return 0;
}

Measured memory_bytes: 900
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int k;
	cin>>k;
	queue<int> q;
	for(int i=1;i<=9;i++)
		q.push(i);
	while(--k)
	{
		int x=q.front();
		q.pop();
		if(x%10)
			q.push(x*10+x%10-1);
		q.push(x*10+x%10);
		if(x%10<9)
			q.push(x*10+x%10+1);
	}
	cout<<q.front()<<endl;
	return 0;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll H,W,K;

int main(){
    cin >> H >> W >> K;
    ll hh=(H*H)%MOD, ww=(W*W)%MOD;
    ll res = 0;
    COMinit();
    for(int d=1;d<=H;d++){
        res += ((d * (H-d) * ww)%MOD)%MOD * COM(H*W-2,K-2);
        res %= MOD;
    }
    for(int d=1;d<=W;d++){
        res += ((d * (W-d))%MOD * hh)%MOD * COM(H*W-2,K-2);
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 15516
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

int main()
{
    std::string S, T;
    std::cin >> S >> T;
    int64_t m = 0;
    for (size_t i = 0; i < S.length() - T.length() + 1; ++i)
    {
        int64_t c = 0;
        for (size_t j = 0; j < T.length(); ++j)
        {
            if (S[i+j] == T[j]) {
                ++c;
            }
        }
        m = std::max(m, c);
    }
    std::cout << T.length() - m << std::endl;

    return 0;
}



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


int main() {

    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.rbegin(), a.rend());
    cout << a[0] - a[2] << endl;
    return 0;
}

Measured memory_bytes: 256
module Main where
--import Debug.Trace
import Data.List
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
import qualified Data.Map as M
import Data.Ord
import Control.Monad

data Symbol = Operand Int | Plus | Minus | Product deriving (Show)

solve :: [Symbol] -> Int
solve = iter [] where
    iter [Operand n] [] = n
    iter st ((Operand n):xs) = iter (push (Operand n) st) xs
    iter st (x:xs) = iter (op x) xs where
        op Plus    = push (Operand (n'' + n')) st''
        op Minus   = push (Operand (n'' - n')) st''
        op Product = push (Operand (n'' * n')) st''
        (Operand n' , st')  = pop st
        (Operand n'', st'') = pop st'

push :: Symbol -> [Symbol] -> [Symbol]
push s st = s:st

pop :: [Symbol] -> (Symbol, [Symbol])
pop (s:st) = (s, st) 

main :: IO() 
main = do
    l <- fmap words getLine
    let el = map f l where
            f "+" = Plus 
            f "-" = Minus 
            f "*" = Product 
            f  x  = Operand (read x)  
    print $ solve el



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

signed main(void)
{
	int k, a, b;
	cin >> k >> a >> b;
	for(int i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

template <class T>
class EdgeBase
{
public:
    int to;
    T cost;
    EdgeBase(){};
    EdgeBase(int to0, T cost0){to = to0; cost = cost0;}
};
typedef EdgeBase<int> Edge;

template<class T>
void shortestPath(const vector<vector<EdgeBase<T> > >& edges, int start, vector<T>& dist)
{
    const T INF = numeric_limits<T>::max();
    const T EPS = static_cast<T>(1.0e-10);

    dist.assign(edges.size(), INF);
    dist[start] = 0;
    priority_queue<pair<T,int>, vector<pair<T,int> >, greater<pair<T,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<T, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first - EPS)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            EdgeBase<T> e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to] - EPS){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

template <class T>
void shortestPath(const vector<vector<EdgeBase<T> > >& edges, vector<vector<int> >& dist)
{
    dist.resize(edges.size());
    for(unsigned i=0; i<edges.size(); ++i)
        shortestPath(edges, i, dist[i]);
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> p(n+11);
        for(int i=2; i<=n; ++i)
            cin >> p[i];

        vector<vector<Edge> > edges(n+1);
        int ret = 0;
        for(int i=2; i<=n; ++i){
            int d;
            cin >> d;
            ret += d * 3;
            edges[i].push_back(Edge(p[i], d));
            edges[p[i]].push_back(Edge(i, d));
        }

        for(int i=1; i<=n; ++i){
            if(edges[i].size() == 1)
                ret -= edges[i][0].cost * 2;
        }

        vector<vector<int> > dist;
        shortestPath(edges, dist);
        int maxDist = 0;
        for(int i=1; i<=n; ++i){
            for(int j=i+1; j<=n; ++j){
                if(edges[i].size() != 1 && edges[j].size() != 1)
                    maxDist = max(maxDist, dist[i][j]);
            }
        }
        ret -= maxDist;
        cout << ret << endl;
    }
}

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

int main(){
	long long a, b;
	cin >> a >> b;
	if(a == 1 || b == 1){
		cout << 1 << endl;
		return 0;
	} 
	long long area = a*b;
	cout << (area+1) / 2 << endl; 
	return 0;
}

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

// Digit Number(0002)
int main()
{
	int a, b;
	while (cin >> a >> b) {
		stringstream ss;
		ss << a + b;

		cout << ss.str().length() << endl;
	}

	return 0;
}

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

#define N 10

void regression(int n, int i, int *s){
  int max_ascii=0;
  if(i==n){
    for(int j=0; j<n; j++)
      printf("%c",s[j]);
    printf("\n");
  }
  else if(i==0){
    s[i] = 'a';
    regression(n, i+1, s);
  }
  else{
    for(int j=0; j<i; j++)
      if(max_ascii<s[j])
        max_ascii = s[j];
    for(int w='a'; w<=max_ascii+1; w++){
      s[i] = w;
      regression(n, i+1, s);
    }    
  }
}

int main(){
  int n,s[N];
  scanf("%d",&n);
  
  regression(n, 0, s);
 
  return 0;
}

Measured memory_bytes: 1408
// Aizu Vol-5 0592: Average Score
// 2017.8.30 bal4u@uu

#include <stdio.h>

int main()
{
	int i, s, a;

	for (s = i = 0; i < 5; i++) {
		scanf("%d", &a);
		if (a < 40) a = 40;
		s += a;
	}
	printf("%d\n", s / 5);
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 2;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        bitset<16> initial, final;
        for(int i=0; i<n; ++i){
            char c;
            cin >> c;
            initial[i] = (c == 'B');
        }
        for(int i=0; i<n; ++i){
            char c;
            cin >> c;
            final[i] = (c == 'B');
        }

        vector<vector<int> > memo(1<<n, vector<int>(n, INF));
        multimap<int, pair<bitset<16>, int> > mm;
        for(int i=0; i<n; ++i){
            memo[initial.to_ulong()][i] = 0;
            mm.insert(make_pair(0, make_pair(initial, i)));
        }

        for(;;){
            int cost = mm.begin()->first;
            bitset<16> bs = mm.begin()->second.first;
            int pos = mm.begin()->second.second;
            mm.erase(mm.begin());
            if(cost > memo[bs.to_ulong()][pos])
                continue;

            if(bs == final){
                cout << cost << endl;
                break;
            }

            for(int i=0; i<n; ++i){
                if(!(bs[i] ^ final[i]))
                    continue;
                for(int j=0; j<n; ++j){
                    if(!(bs[j] ^ final[j]))
                        continue;
                    if(!(bs[i] ^ bs[j]))
                        continue;

                    int cost2 = cost + abs(pos - i) + abs(i - j);
                    bitset<16> bs2 = bs;
                    bs2[i] = !bs2[i];
                    bs2[j] = !bs2[j];
                    if(cost2 < memo[bs2.to_ulong()][j]){
                        memo[bs2.to_ulong()][j] = cost2;
                        mm.insert(make_pair(cost2, make_pair(bs2, j)));
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 15788
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	int count[10][10];
	memset(count,0,sizeof(count));
	inp(n)
	for(int i=1;i<=n;i++)
	{
		int l=i;
		while(l/10>0)
			l/=10;
		count[i%10][l]++;
	}
	int ans=0;
	fo(i,10)
	{
		fo(j,10)
		{
			ans+=count[i][j]*count[j][i];
		}
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

map<ll,ll> primef(ll num){
    map<ll,ll> res;
    for(ll i = 2; i * i <= num; i++){
        if(num % i != 0) continue;
        int cnt = 0;
        while(num % i == 0){
            cnt++;
            num /= i;
        }
        if(cnt > 0){
            res[i] = cnt;
        }
    }
    if(num != 1){
        res[num] = 1;
    }
    return res;
}


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

    map<ll,ll> total;
    for(int i = 2; i <= n; i++){
        map<ll,ll> tmp = primef(i);
        for(auto &i : tmp){
            total[i.first] += i.second;
        }
    }

    ll ans = 0;
    for(auto &i : total){
        if(i.second >= 74){
            ans++;
        }
    }

    for(auto &i : total){
        for(auto &j : total){
            if(i.first == j.first) continue;
            if(i.second >= 14 && j.second >= 4){
                ans++;
            }
        }
    }

    for(auto &i : total){
        for(auto &j : total){
            if(i.first == j.first) continue;
            if(i.second >= 24 && j.second >= 2){
                ans++;
            }
        }
    }

    for(auto &i : total){
        for(auto &j : total){
            for(auto &k : total){
                if(i.first == j.first)continue;
                if(j.first >= k.first)continue;
                if(i.first == k.first)continue;
                if(i.second >= 2 && j.second >= 4 && k.second >= 4){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ar = new int[n];
		for (int i=0; i<n; i++) {
			ar[i] = sc.nextInt();
		}
		boolean F = true;
		int j = 0;
		int times = 0;
		while (F==true) {
			F = false;
			for (int i=n-1; i>=j+1; i--) {
				if (ar[i] < ar[i-1]) {
					int temp = ar[i];
					ar[i] = ar[i-1];
					ar[i-1] = temp;
					times++;
					F = true;
				}
				
			}
			j++;
		}
		for (int x=0; x<n; x++) {
			out.print((x==0?"":" ")+ar[x]);
		}
		out.println();
		out.println(times);
	}
}



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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

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

const int maxn = 1000+1;
const ll mod = 1000000000+7;
char A[maxn][maxn];
ll dp[maxn][maxn];
int N,M;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M;
	forn(i,0,N)forn(j,0,M)cin >> A[i][j];
	dp[0][0] = 1;
	forn(i,0,N){
		forn(j,0,M){
			if(!i && !j)continue;
			if(A[i][j] == '#')continue;
			if(i-1 >= 0 && A[i-1][j] != '#'){
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= mod;
			}
			if(j-1 >= 0 && A[i][j-1] != '#'){
				dp[i][j] += dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	ll res = dp[N-1][M-1];
	if(res < 0)res += mod;
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 9088
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
import re
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

n, q = Is()
s = S()
LR = TIR(q)
acc = [0]*(n+1)
tmp = 0
for i in range(1, n):
    if s[i-1] == "A" and s[i] == "C":
        tmp += 1
    acc[i] = tmp
for l, r in LR:
    l -= 1
    r -= 1
    print(acc[r]-acc[l])

Measured memory_bytes: 22060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int rating[] = {1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801};
	int range[9];
	int N, a;
	scanf("%d", &N);
	for(int i = 0; i < 9; i++) range[i] = 0;
	for(int i = 0; i < N; i++){
		scanf("%d", &a);
		for(int j = 0; j < 9; j++){
			if(a >= rating[j] && a < rating[j + 1]){
				range[j]++;
				break;
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < 8; i++){
		if(range[i] != 0) ans++;
	}
	printf("%d %d\n", max(ans, 1), ans + range[8]);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static List<int>[] Sub;
    static int[] Salary;
    
    
    static void Main(string[] args) {
        var NX  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        var N = NX[0];
        var X = NX[1];
        var A  = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        
        var ans = 0L;
        //一個前の箱と合計してX以下になるように設定
        for(int i = 1; i < N;i++){
            //2つの箱の合計
            var sum = A[i]+A[i-1];
            if(sum <= X){
                //何もしないで次の操作
            }else{
                //食べなければならない数
                var eat = sum-X;
                ans += eat;
                //i番目の箱を食べたあとの値
                A[i] -= Math.Min(eat,A[i]);
            }
            
        }
        //答えを出力する
        Console.WriteLine(ans);
     }
     
    
}


Measured memory_bytes: 31452
using System;
using System.IO;

public class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        bool isHardToType = false;

        if (s[0] == s[1]) isHardToType = true;
        if (s[1] == s[2]) isHardToType = true;
        if (s[2] == s[3]) isHardToType = true;

        if (isHardToType) Console.WriteLine("Bad");
        else Console.WriteLine("Good");
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
#define maxx 1000001
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main() {
    FASTIO
    ll n,sum=0;
    cin>>n;
    string s=to_string(n);
    for(auto c:s) sum+=c-'0';
    if(n%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3712
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int[] a = new int[4];
			int[] b = new int[4];
			for(int i = 0; i < 4; ++i)
			{
				a[i] = stdIn.nextInt();
			}
			for(int i = 0; i < 4; ++i)
			{
				b[i] = stdIn.nextInt();
			}
			int Hit = 0;
			int Blow = 0;
			for(int i = 0; i < 4; ++i)
			{
				for(int j = 0; j < 4; ++j)
				{
					if(a[i] == b[j])
					{
						if(i == j)
						{
							++Hit;
						}
						else
						{
							++Blow;
						}
					}
				}
			}
			System.out.printf("%d %d\n", Hit, Blow);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

#include <functional>
template<typename T>
class SegmentTreeAllOne {
    using Func = function<T(T, T)>;

public:
    vector<T> data;
    int n;
    T init;
    Func update_func;
    SegmentTreeAllOne(int _n, T _init, Func up) {
        init = _init;
        update_func = up;
        for (n = 1; n < _n; n *= 2)
            ;
        data.resize(2 * n - 1, init);
    }
    void update(int l, int r, T val) {
        for (l += n - 1, r += n - 1; l < r; l = l / 2, r = (r - 1) / 2) {
            if (!(l & 1)) {
                data[l] = update_func(data[l], val);
            }
            if (!(r & 1)) {
                data[r - 1] = update_func(data[r - 1], val);
            }
        }
    }
    T query(int pos) {
        pos += n - 1;
        T res = data[pos];
        while (pos > 0) {
            pos = (pos - 1) / 2;
            res = update_func(res, data[pos]);
        }
        return res;
    }
};

#include <utility>
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    using P = pair<int, ll>;
    auto MAX = [](P a, P b) { return max(a, b); };
    int n, q;
    cin >> n >> q;
    SegmentTreeAllOne<P> segtree(n, P(-1, (1LL << 31) - 1), MAX);
    REP(i, 0, q) {
        int com;
        cin >> com;
        if (com) {
            int x;
            cin >> x;
            cout << segtree.query(x).second << endl;

        } else {
            int s, t, x;
            cin >> s >> t >> x;
            segtree.update(s, t + 1, P(i, x));
        }
    }

    return 0;
}



Measured memory_bytes: 6968
#include <stdio.h>
#include <string.h>
int main(void) {
	// your code goes here
	int n;
	scanf("%d",&n);
	char a[n+1],b[n+1];
	scanf("%s%s",a,b);
	
	int i;
	
	for(i=0;i<n;i++)
	    printf("%c%c",a[i],b[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n,m;
  cin >> n >> m;
  priority_queue<ll> que;
  rep(i, n){
    ll a;
    cin>>a;
    que.push(a);
  }
  while(m>0){
    ll num = que.top();
    num /= 2;
    que.pop();
    que.push(num);
    m--;
  }
  ll total = 0;
  while(!que.empty()){
    total += que.top();
    que.pop();
  }
  print(total);
}

Measured memory_bytes: 4256