akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pddd(n, m, z) printf("%d %d %d\n", n, m, z)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define plddd(n, m, z) printf("%lld %lld %lld\n", n, m, z)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ce i == n ? '\n' : ' '
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
	int ret = 0, sgn = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-')
			sgn = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		ret = ret * 10 + ch - '0';
		ch = getchar();
	}
	return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
	if (a > 9)
		Out(a / 10);
	putchar(a % 10 + '0');
}

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

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = x * x % mod, n >>= 1;
	}
	return res;
}

int n, m;
int a[110];
int sum, cnt;

int main()
{
	sdd(n, m);
	sum = 0;
	cnt = 0;
	rep(i, 1, n)
	{
		sd(a[i]);
		sum += a[i];
	}
	double res = 1.0 * sum / (4.0 * m);
	sort(a + 1, a + 1 + n);
	per(i, n, 1)
	{
		if (a[i] < res)
			break;
		cnt++;
	}
	if (m <= cnt)
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		int[][] array = new int[3][3];
		for(int i=0;3>i;i++) {
			for(int j=0;3>j;j++) {
				int a = sc.nextInt();
				array[i][j] = a;
			}
		}

		int n = sc.nextInt();
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			for(int j=0;3>j;j++) {
				for(int k=0;3>k;k++) {
					if(array[j][k]==a)
						array[j][k]=0;
				}
			}
		}

		for(int i=0;3>i;i++) {
			if(array[i][1]==array[i][2] && array[i][0]==array[i][1]) {
				System.out.println("Yes");
				System.exit(0);
			}
		}

		for(int i=0;3>i;i++) {
			if(array[1][i]==array[2][i] && array[0][i]==array[1][i]) {
				System.out.println("Yes");
				System.exit(0);
			}
		}

		if(array[0][0]==array[1][1] && array[0][0]==array[2][2]) {
			System.out.println("Yes");
			System.exit(0);
		}

		if(array[2][0]==array[1][1] && array[2][0]==array[0][2]) {
			System.out.println("Yes");
			System.exit(0);
		}

		System.out.println("No");
	}
}

Measured memory_bytes: 22996
#include<stdio.h>
int main()
{
	int i,n,m,b;
	while(~scanf("%d %d", &n, &m))
	{
		int ar[51]={0};
		for(i=0; i<2*m; i++)
		{
			scanf("%d", &b);
			ar[b-1]++;
		}
		for(i=0; i<n; i++)
			printf("%d\n", ar[i]);
	}
	return 0;
}

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

struct StList
{
  int  m_nKey;
  StList* m_poPrev;
  StList* m_poNext;
  
  StList() :
    m_nKey(0), m_poPrev(nullptr), m_poNext(nullptr)
  { }

  StList(int nNum, StList& roHead) :
    m_nKey(nNum), m_poPrev(&roHead), m_poNext(roHead.m_poNext)
  { }

  ~StList() { }
};

void fnLinkedListSet(StList& roHead, StList& roTrail)
{
  string sCmd;
  int nMaxCmd, nNum;

  cin >> nMaxCmd;
  for (int i = 0; i < nMaxCmd; i++)
  {
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      cin >> nNum;
      StList* poList = new StList(nNum, roHead);
      roHead.m_poNext->m_poPrev = poList;
      roHead.m_poNext = poList;
    }
    else if (sCmd[6] == 'F')
    {
      StList* poList = roHead.m_poNext;
      if (poList != &roTrail)
      {
        poList->m_poNext->m_poPrev = poList->m_poPrev;
        roHead.m_poNext = poList->m_poNext;
        delete poList;
      }
    }
    else if (sCmd[6] == 'L')
    {
      StList* poList = roTrail.m_poPrev;
      if (poList != &roHead)
      {
        roTrail.m_poPrev = poList->m_poPrev;
        poList->m_poPrev->m_poNext = poList->m_poNext;
        delete poList;
      }
    }
    else if (sCmd[0] == 'd')
    {
      cin >> nNum;
      StList* poList = roHead.m_poNext;
      while (poList != &roTrail)
      {
        if (poList->m_nKey == nNum)
        {
          poList->m_poNext->m_poPrev = poList->m_poPrev;     
          poList->m_poPrev->m_poNext = poList->m_poNext;
          delete poList;
          break;
        }
        poList = poList->m_poNext;
      }
    }
  }
}

void fnLinkedListGet(StList& roHead, StList& roTrail)
{
  StList* poList = roHead.m_poNext;
  while (poList != &roTrail)
  {
    if (poList != roHead.m_poNext) cout << " ";
    cout << poList->m_nKey;
    poList = poList->m_poNext;
    delete poList->m_poPrev;
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  StList oHead, oTrail;
  oHead.m_poNext  = &oTrail;
  oTrail.m_poPrev = &oHead;
 
  fnLinkedListSet(oHead, oTrail);
  fnLinkedListGet(oHead, oTrail);

  return 0;
}



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

int a[15];

int main()
{
	ios::sync_with_stdio(0);
	string s;
	cin>>s;
	int ans=0;
	for (int i=0; i<s.size(); i++)
	{
		if (s[i]=='0')
		{
			ans++;
			a[ans]=0;
		}
		else if (s[i]=='1')
		{
			ans++;
			a[ans]=1;
		}
		else if (s[i]=='B' && ans>=1)
		  ans--;
	}
	for (int i=1; i<=ans; i++)
	   cout<<a[i];
	return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())

A, B, C = sorted([A, B, C])

diff = (C-A) + (C-B)

# 偶奇で分ける
if diff % 2 == 0:
  print(diff // 2)
else:
  print(diff // 2 + 2)
  

Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var Q = int.Parse(Console.ReadLine());
            var aggP = new int[(int)1e5 + 1];
            var prime = new Prime(2);
            for (var i = 2; i < aggP.Length; i++)
            {
                aggP[i] = aggP[i - 1];
                if (prime.IsPrime(i) && prime.IsPrime((i + 1) / 2)) aggP[i]++;
            }
            for (var i = 0; i < Q; i++)
            {
                var lr = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var answer = aggP[lr[1]] - aggP[lr[0] - 1];
                Console.WriteLine(answer);
            }
        }


        public class Prime
        {
            public Dictionary<long, long> Factors => new Dictionary<long, long>(_factors);
            private Dictionary<long, long> _factors;
            private static HashSet<long> _primes;
            public Prime(long n)
            {
                if (_primes == null) _primes = new HashSet<long>();
                _factors = new Dictionary<long, long>();
                var tmp = n;
                var max = (long)Math.Sqrt(n);
                var p = 2;
                while (p <= max)
                {
                    if (tmp % p == 0)
                    {
                        _factors[p] = 0;
                        _primes.Add(p);
                        while (tmp % p == 0)
                        {
                            tmp /= p;
                            _factors[p]++;
                        }
                    }
                    p++;
                }
                if (tmp > 1)
                {
                    _factors[tmp] = 1;
                    _primes.Add(tmp);
                }
            }
            public bool IsPrime(long n)
            {
                if (_primes.Contains(n)) return true;
                var p = new Prime(n);
                return _primes.Contains(n);
            }
        }
    }
}


Measured memory_bytes: 47660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll x[N],y[N];
  ll h[N];
  int t;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] != 0) {
      t = i;
    }
  }
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      ll tmp = abs(i - x[t]) + abs(j - y[t]) + h[t];
      bool can = true;
      for (int k = 0; k < N; k++) {
        if (h[k] == 0) {
          if (abs(i - x[k]) + abs(j - y[k]) < tmp) {
            can = false;
          }
        } else {
          if (abs(i - x[k]) + abs(j - y[k]) + h[k] != tmp) {
            can = false;
          }
        }
      }
      if (can) {
        cout << i << " " <<  j << " " << tmp << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N+1){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
#define s(a) cout<<a<<endl;

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 100000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=0;
//--------------------------------------//
//
//abc 079 まだ出してないので出しといて
struct E{int to,cost;};
int h,w;
int c[10][10];
vector<E> v[10];
int d[10];

void solve(){
	rep(i,10)rep(j,10){
		if(i!=j)
		v[j].pb({i,c[i][j]});
	}
	priority_queue<P,vector<P>,greater<P>> q;
	q.push(P(0,1));
	fill(d,d+10,INF);
	d[1]=0;
	while(!q.empty()){
		P p=q.top();q.pop();
		int f=p.first;
		int s=p.second;
		if(d[s]<f) continue;
		d[s]=f;
		rep(i,v[s].size()){
			q.push(P(f+v[s][i].cost,v[s][i].to));
		}
	}
	da(d,9);
	int ans=0;
	rep(i,h*w){
		int a;
		cin>>a;
		if(a!=-1) ans+=d[a];
	}
	cout<<ans<<endl;
}

int main(){
	cin>>h>>w;
	rep(i,10) rep(j,10) cin>>c[i][j];
	solve();
	return 0;
}


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

int main() {
  string s; cin >> s;
  if(s=="SUN") cout << 7 << endl;
  if(s=="MON") cout << 6 << endl;
  if(s=="TUE") cout << 5 << endl;
  if(s=="WED") cout << 4 << endl;
  if(s=="THU") cout << 3 << endl;
  if(s=="FRI") cout << 2 << endl;
  if(s=="SAT") cout << 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              10000001
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int D[sz];
bool mark[sz];
vector < int > primes;
void  sieve(){
    memset(mark,0,sizeof(mark));
    for(int i=4; i<sz; i+=2)mark[i]=1;
    for(int i=3; i*i<sz; i+=2){
        if(mark[i]==0){
            for(int j=i*i; j<sz; j+=(i*2))
                mark[j]=1;
        }
    }
    primes.push_back(2);
    for(int i=3; i<sz; i+=2){
        if(mark[i]==0)
            primes.push_back(i);
    }
}

void DivisorGenerate(){
    int i,j,val,N,M,count;
    D[1]=1;
    for(i=2; i<=sz; i++){
        N=M=i;
        val=sqrt(N)+1;
        for(j=0; primes[j]<val; j++){
            if(M%primes[j]==0){
                count=0;
                while(M%primes[j]==0){
                    M/=primes[j];
                    count++;
                }
                D[N]=(count+1)*D[M];
                break;
            }
        }
        if(M==N) //Special Case if N equal prime{
            D[N]=2;
    }
}

int main(){
    Fast;
    sieve();
    DivisorGenerate();

    ll n,tot=0;
    cin>>n;
    for(int i=1; i<=n; i++){
        tot+=(i*1LL*D[i]);
    }
    cout<<tot<<endl;




    return 0;
}



Measured memory_bytes: 54872
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    cout << N * N * N << endl;
}


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

int main()
{
  int n, nticket;
  cin >> n >> nticket;
  priority_queue<int> pq;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    pq.push(val);
  }
  for (int i = 0; i < nticket; i++) {
    int x = pq.top();
    pq.pop();
    pq.push(x / 2);
  }
  long long res = 0;
  while (!pq.empty()) {
    res += pq.top();
    pq.pop();
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;
	int m, h;

	cin >> s;

	while(s != "-") {
		cin >> m;

		for(int i = 0;i < m;i++) {
			cin >> h;
		
			s = s.substr(h, s.size() - h) + s.substr(0, h);
		}

		cout << s << endl;

		cin >> s;
	}

	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K ;
  string  S;
  cin >> K >> S;
  string M;
  if (K >= S.size()){
    cout << S << endl;
  }
  else if(K < S.size()){
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

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



int main(){

  int H, W; 
  while(cin >> H >> W, H|W){
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        cout << '#';
      }
      cout << endl;
    }
  cout << endl;
  }

  return 0;
}

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

int main(){
    double a, b, x;
    cin >> a >> b >>x;
    double ans;
    if (x <= a * a * b / 2) {
        ans = atan((a*b*b) / (2*x)) * (180 / M_PI);
    } else {
        ans = atan((2*a*a*b - 2*x) / (a*a*a)) * (180 / M_PI);
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 640
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()
city = [[] for i in range(N+1)]
for i in range(M):
    P,Y = MI()
    city[P].append((Y,i))

ID = []
for i in range(N+1):
    city[i] = sorted(city[i])
    for j in range(len(city[i])):
        P,Y = city[i][j]
        ID.append((Y,str(i).zfill(6)+str(j+1).zfill(6)))

ID.sort()
for i in range(M):
    print(ID[i][1])


Measured memory_bytes: 109432
#include <iostream>

int main() {
	const int MIN_MAX = 60;
	const int SEC_MAX = 60;
	
	int input, h, m, s;
	std::cin >> input;
	
	h = input / (MIN_MAX*SEC_MAX);
	m = (input / SEC_MAX) % MIN_MAX;
	s = input % SEC_MAX;
	
	std::cout << h << ":" << m << ":" << s << std::endl;
}

Measured memory_bytes: 1164
import sys
sys.setrecursionlimit(10 ** 9)

N = int(input())
T = [[] for i in range(N)]
for i in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    T[u].append([v, w])
    T[v].append([u, w])


visited = [False] * N
visited[0] = True


def dfs(n):
    visited = [False] * N
    stack = [[n, 0]]
    longest = [-1, -1]

    while stack:
        node, weight = stack.pop()
        if visited[node]:
            continue
        visited[node] = True
        if longest[1] < weight:
            longest = [node, weight]

        for n, w in T[node]:
            if not visited[n]:
                stack.append([n, w + weight])

    return longest


start, xw = dfs(0)


color = [None] * N


def dfs(n):
    for to, weight in T[n]:
        if color[to] is None:
            if weight % 2 == 0:
                color[to] = color[n]
                dfs(to)
            else:
                color[to] = color[n] ^ 1
                dfs(to)


color[start] = 0
dfs(start)
print(*color, sep='\n')


Measured memory_bytes: 123744
firstInput=list(map(int,input().split()))
perimeter=firstInput[0]
numHouses=firstInput[1]
housesDistances=list(map(int,input().split()))
maxDistance=0
maxidx=1
totalDistance=0
for idx, house in enumerate(housesDistances[:-1]):
  distance=housesDistances[idx+1]-house
  totalDistance+=distance
  if distance>maxDistance:
      maxDistance= distance
      maxidx=idx+1

lastDistance= perimeter-housesDistances[-1]+housesDistances[0]
totalDistance+=lastDistance
if lastDistance>maxDistance:
  maxDistance=perimeter-housesDistances[-1]+housesDistances[0]
  maxidx=idx+1
print(totalDistance-maxDistance)

Measured memory_bytes: 26444
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<LL> a(3 * N); cin >> a;
  sort(a.rbegin(), a.rend());
  LL sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += a[2 * i + 1];
  }
  cout << sum << endl;
}


Measured memory_bytes: 5584
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    ll res = 0;
    //各桁の0,1の数を調査
    rep(d, 60){
        ll n0 = 0, n1 = 0;
        rep(i, n){
            if((A[i] >> d) & 1) n1++;
            else n0++; 
        }
        ll tmp = (1ll << d) % MOD;
        ll n = n0 * n1 % MOD;
        tmp = tmp * n % MOD;
        res = (res + tmp) % MOD;
    }
    cout << res % MOD << ln;
}


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

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

    pair<pair<int, int>, int> q[50];
    for (int i = 0; i < n; i++) {
        cin >> q[i].first.first >> q[i].first.second;
        q[i].second = i;
    }

    sort(q, q + n);

    int tx[50], ty[50];
    int a = (int)1e+9 + 1, xx = -1;
    for (int i = 0; i < n; i++) {
        if (q[i].first.first != a) {
            a = q[i].first.first;
            xx++;
        }
        tx[xx] = q[i].first.first;
        q[i].first.first = xx;
    }
    xx++;

    for (int i = 0; i < n; i++) {
        swap(q[i].first.first, q[i].first.second);
    }
    sort(q, q + n);

    int b = (int)1e+9 + 1, yy = -1;
    for (int i = 0; i < n; i++) {
        if (q[i].first.first != b) {
            b = q[i].first.first;
            yy++;
        }
        ty[yy] = q[i].first.first;
        q[i].first.first = yy;
    }
    yy++;

    int p[50][50] = {};
    for (int i = 0; i < n; i++) {
        p[q[i].first.second][q[i].first.first] = 1;
    }

    int s[51][51] = {};
    for (int i = 1; i <= 50; i++) {
        for (int j = 1; j <= 50; j++) {
            s[i][j] = s[i][j - 1] + p[i - 1][j - 1];
        }
    }
    for (int j = 1; j <= 50; j++) {
        for (int i = 1; i <= 50; i++) {
            s[i][j] += s[i - 1][j];
        }
    }
    //for (int i = 0; i <= 50; i++) {
    //    for (int j = 0; j <= 50; j++) {
    //        cout << s[i][j] << ' ';
    //    }
    //    cout << endl;
    //}

    //for (int i = 0; i < 50; i++) {
    //    for (int j = 0; j < 50; j++) {
    //        cout << p[i][j] << ' ';
    //    }
    //    cout << endl;
    //}

    int64_t m = -1;
    for (int i = 0; i < xx; i++) {
        for (int j = 0; j < yy; j++) {
            for (int x = i + 1; x < xx; x++) {
                for (int y = j + 1; y < yy; y++) {
                    int l = s[x + 1][y + 1] - s[x + 1][j] - s[i][y + 1] + s[i][j];
                    //if (l > 0) cout << l << ' ';
                    if (l < k) continue;
                    int64_t t = (int64_t)(tx[x] - tx[i]) * (ty[y] - ty[j]);
                    if (m < 0 || t < m) {
                        //cout << tx[x] << ' ' << tx[i] << ' ' << ty[y] << ' ' << ty[j] << endl;
                        m = t;
                    }
                }
            }
        }
    }

    cout << m << endl;

    return 0;
}

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

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define mp          make_pair
#define endl        "\n"
#define m9          1000000009
#define m7          1000000007
#define inf         1e18
#define sz(x)       (ll)x.size()
#define all(s)      (s).begin(),(s).end()
#define rall(s)     (s).rbegin(),(s).rend()
#define __lcm(a,b)  (a*b)/__gcd(a,b)
#define fori(i,p,n) for(i=p;i<n;i++)
#define ford(i,p,n) for(i=p;i>=n;i--)
#define FAST_IO     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

//template<typename... T>void read(T&... args){((cin >> args), ...);}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res =(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve() {
    ll i, j, k;
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}

int main() {
    FAST_IO;
    ll t = 1;
    //cin>>t;
    while (t--) {
        solve();
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=600005;
const int mod=1e9+7;
int n,m,L,R;
int fac[maxn],ifac[maxn];

int C(int a,int b){
	if(a<b||a<0||b<0)return 0;
	return 1LL*fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}

int calc(int R){
	int ans=0;
	rep(i,R+1){
		int cR=R-m*i;
		if(cR<0)break;
		rep(j,n-m+1){
			int ccR=cR-j*i;
			if(ccR<0)break;
			int cur=1LL*C(n-m,j)*(C(ccR+n,n)-C(ccR+n-m,n)+mod)%mod*(j&1?(mod-1):1)%mod;
			ans+=cur;
			if(ans>=mod)ans-=mod;
		}
	}
	return ans;
}

int main(){
	scanf("%d%d%d%d",&n,&m,&L,&R);
	fac[0]=ifac[0]=fac[1]=ifac[1]=1;
	for(int i=2;i<=n+R;i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		ifac[i]=1LL*ifac[mod%i]*(mod-mod/i)%mod; 
	}
	REP(i,n+R)ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
	printf("%d\n",((C(R+n,n)-C(L-1+n,n)+mod)%mod-1LL*(calc(R)-calc(L-1)+mod)*C(n,m)%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 4992
// Author : Chi
// created : Sunday 2020-05-31
// Sawal : https://www.codechef.com/LTIME84B/problems/TREDIFF

//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//namespaces
using    namespace __gnu_pbds;
using    namespace std;
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb(x)       push_back(x)
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         998244353
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define pdp(d,i)    fixed<<setprecision(i)<<d
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define db(...)     __f(#__VA_ARGS__, __VA_ARGS__)                      //for debugging
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define dig(n) floor(log10(n) + 1)
//LOVE ALGO
void solve(){
    ll n;
    cin>>n;
    ll a[n];
    r0n(i,n){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<"\n";
            return;
         }
    }
    ll ans=1;
    r0n(i,n){
        if(a[i]>((ll)1e18/ans)){
            cout<<-1<<"\n";
            return;
                }
        ans*=a[i];
    }
    cout<<ans<<"\n";
}

// Driver Code
int main(){
    CHI
    TEST1
    return 0;
}



Measured memory_bytes: 4444
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt();

        int[][] a = new int[H + 1][W + 1], b = new int[H + 1][W + 1];
        for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) {
            a[i][j] = sc.nextInt();
        }
        for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) {
            b[i][j] = sc.nextInt();
        }

        boolean[][][] dp = new boolean[2][W + 1][160 * 80 + 1];

        dp[0][1][160 * 40] = true;
        int x = 0;
        for (int h = 1; h <= H; h++) {
            x = 1 - x;
            for (int w = 1; w <= W; w++) {
                Arrays.fill(dp[x][w], false);
//                HashSet<Integer> ok = new HashSet<>();
                for (int k = 0; k <= 12800; k++) {
                    if (dp[1 - x][w][k] || dp[x][w - 1][k]) {
//                        debug(dp[1 - x][w][k], dp[x][w - 1][k], x, h, w, k);
                        if (0 <= k + a[h][w] - b[h][w] && k + a[h][w] - b[h][w] <= 12800) {
                            dp[x][w][k + a[h][w] - b[h][w]] = true;
//                            ok.add(k + a[h][w] - b[h][w]);
                        }
                        if (0 <= k - a[h][w] + b[h][w] && k - a[h][w] + b[h][w] <= 12800) {
                            dp[x][w][k + b[h][w] - a[h][w]] = true;
//                            ok.add(k + b[h][w] - a[h][w]);
                        }
                    }
                }
//                debug(h, w, ok);
            }
        }

        int ans = 1 << 30;
        for (int d = 0; d <= 12800; d++) {
//            debug(dp[x][W][d], d);
            if (dp[x][W][d]) ans = Math.min(ans, Math.abs(d - 6400));
        }
        System.out.println(ans);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

}


Measured memory_bytes: 36828
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

ll dp[51][51][2501] = {};
int main() {
  int n;
  ll a;
  cin >> n >> a;
  vl x(n + 1, 0LL);
  REP(i, n) { cin >> x[i + 1]; }

  dp[0][0][0] = 1LL;
  FOR(i, 1, n + 1) {
    REP(j, i + 1) {
      REP(k, 2501) {
        dp[i][j][k] = dp[i - 1][j][k];
        if (k - x[i] >= 0 && j >= 1) {
          dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
        }
      }
    }
  }
  ll ans = 0LL;
  FOR(i, 1, n + 1) { ans += dp[n][i][i * a]; }
  cout << ans << endl;
}


Measured memory_bytes: 49152
from collections import deque

H, W = map(int, input().split())
grid = [list(input()) for i in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append([h, w, 0])

ans = 0
while len(black_cells) > 0:
    one_black_cell = black_cells.popleft()  # キューとして使うのでpop()ではなくpopleft()
    for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
        nh = one_black_cell[0] + dy
        nw = one_black_cell[1] + dx
        d = one_black_cell[2]
        if nh < 0 or H <= nh or nw < 0 or W <= nw:
            continue
        if grid[nh][nw] == '.':
            grid[nh][nw] = '#'
            black_cells.append([nh, nw, d + 1])
        ans = d

print(ans)

Measured memory_bytes: 176092
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1000000007;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll x, a, b;
  std::cin >> x >> a >> b;
  std::cout << x*a/2;
  return 0;
}

Measured memory_bytes: 256
/*


*/
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<set>
#include<cmath>
#define ll long long
#define M
#define mmp make_pair
using namespace std;
int read() {
	int nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}

int note[11][2][2][2];
bool vis[11][2][2][2];
int n, tp, up[11];
int ans = 0;
set<int> st;
void dfs(ll get, int a, int b, int c) {
	if(get <= n && a && b && c) ans++;
	if(get > n) return;
	dfs(get * 10 + 3,1, b,c);
	dfs(get * 10 + 5, a, 1, c);
	dfs(get * 10 + 7, a, b, 1);
}

int main() {
	n = read();
	dfs(0, 0, 0, 0);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();


		Character a = s.charAt(2);
		Character b = s.charAt(3);

		Character c = s.charAt(4);
		Character d = s.charAt(5);

		if(a.equals(b) && c.equals(d)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}
}


Measured memory_bytes: 23764
n, a, b = list(map(int, input().split()))

str = input()

res = a + b
b_num = 1

for i in range(len(str)):
    if(str[i] == 'a'):
        if(res > 0):
            print('Yes')
            res -= 1
        else:
            print('No')
    elif(str[i] == 'b'):
        if(res > 0) and (b_num <= b):
            print('Yes')
            res -= 1
            b_num += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
n = int(input())
a = [int(input()) for _ in range(n)]
if any(a[i] > i for i in range(n)):
    print(-1)
    exit()
a = a[::-1]

cnt = 0
tmp = 0
for i in range(n):
    if a[i] > tmp:
        tmp = a[i]
        cnt += tmp


    elif a[i] < tmp:
        print(-1)
        exit()

    tmp -= 1

print(cnt)

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

using namespace std;

#define ll long long

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll D, T, S;
    cin >> D >> T >> S;

    cout << (((S * T) >= D) ? "Yes" : "No");
    
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N,K,Q;cin>>N>>K>>Q;
	int A[Q];int score[N];
	rep(i,0,N){
		score[i]=K-Q;
	}rep(i,0,Q){
		cin>>A[i];A[i]--;
		score[A[i]]++;
	}rep(i,0,N){
		if(score[i]>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

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

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, x, t;
  cin >> n >> x >> t;

  cout << (n+x-1) / x * t << '\n';
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int MAX = 510000;
const int INF = 1e9 + 7;

using namespace std;

ll 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 % INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

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] % INF) % INF;
}


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

	int h, w, a, b;
	cin >> h >> w >> a >> b;

	COMinit();

	vector<ll> up(w, 0);
	vector<ll> down(w, 0);
	for (int i = b; i < w; i++) {
		up[i] = COM(i + h - (a + 1), h - (a + 1));
		down[i] = COM((i - b) + a - 1, a - 1);
	}

	ll res = 0;
	for (int i = b; i < w; i++) {
		res = res + (up[i] * down[w - 1 - (i - b)] % INF) % INF;
	}

	cout << res % INF << endl;
	return 0;
}


Measured memory_bytes: 13824
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    words = []
    starts_with_B = 0
    end_with_A = 0
    contain_AB = 0
    starts_with_B_and_end_with_A = 0
    for i in range(N):
        word = input()
        words.append(word)
        contain_AB += len(word) - len(word.replace("AB", "_"))

        if word[0] == "B" and word[-1] == "A":
            starts_with_B_and_end_with_A += 1
        elif word[0] == "B":
            starts_with_B += 1
        elif word[-1] == "A":
            end_with_A += 1

    if starts_with_B_and_end_with_A == 0:
        print(contain_AB + min(starts_with_B, end_with_A))
        return
    if starts_with_B + end_with_A == 0:
        print(contain_AB + starts_with_B_and_end_with_A - 1)
        return
    print(contain_AB + starts_with_B_and_end_with_A +
          min(starts_with_B, end_with_A))


main()


Measured memory_bytes: 70388
n,y = map(int,input().split())

for sen in range(n+1):
    for gosen in range(n+1-sen):
        man = n-sen-gosen
        if 1000*sen + 5000*gosen + 10000*man == y:
            print(man,gosen,sen)
            exit()

print(-1,-1,-1)


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

void solve(int A, int B) {
    // white, black
    int ra = (A+49)/50, rb = (B+49)/50;
    --A; --B;

    cout << (ra*2 + rb*2) << " 100" << endl;
    rep(i,ra){
        vector<char> line(100, '#');
        rep(j,50) {
            if (A-- > 0) line[j*2] = '.';
        }
        cout << string(ALL(line)) << endl;

        line.assign(100, '#');
        cout << string(ALL(line)) << endl;
    }
    rep(i,rb){
        vector<char> line(100, '.');
        cout << string(ALL(line)) << endl;
        rep(j,50) {
            if (B-- > 0) line[1+j*2] = '#';
        }
        cout << string(ALL(line)) << endl;
    }
}

int main() {
    int A,B; cin >>A>>B;
    solve(A,B);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, x;
	cin >> N >> x;
	vector<int>a(N);
	rep(i, N)cin >> a[i];

	int ans = 0;
	rep(i, N - 1)if (x < a[i] + a[i + 1]) {
		if (a[i] <= x) {
			ans += a[i] + a[i + 1] - x;
			a[i + 1] -= a[i] + a[i + 1] - x;
		}
		else {
			ans += a[i + 1];
			a[i + 1] = 0;
			ans += a[i] - x;
			a[i] = x;
		}
	}
	if (x < a[N - 2] + a[N - 1]) {
		ans += a[N - 2] + a[N - 1] - x;
	}
	cout << ans << endl;

	return 0;
}


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

const int M = 1000005;

int main() {
  int n, k, ans=0;
  cin >> n >> k;
  vector<int> a(n);  
  rep(i,n) cin >> a[i];
  
  std::sort(a.begin(),a.end());
  rep(i,k) ans += a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
//typedef pair<ll, ll> P;

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

ll gcd(ll p, ll q) {
    while (q != 0) {
        ll r = p % q;
        p = q;
        q = r;
    }
    return p;
}

int main() {
    ll ans = 0;

    // input
    ll K;
    cin >> K;

    // process
    for (ll a = 1; a <= K; ++a) {
        for (ll b = 1; b <= K; ++b) {
            for (ll c = 1; c <= K; ++c) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3220
let _ = read_int ()
let s, ans = read_line (), ref 0
let _ = Char.(for i = 0 to 9 do let a = chr (48 + i) in for j = 0 to 9 do let b = chr (48 + j) in for k = 0 to 9 do let c = chr (48 + k) in
  try String.(index_from s (index_from s (index s a + 1) b + 1) c) |> ignore; incr ans with _ -> () done done done; Printf.printf "%d\n" !ans)

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

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
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...);
}
#else
#define trace(...)
#endif
map<vi,int> m;
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  cin>>n;
  rep(i,1,n+1)
    {
      string s;
      cin>>s;
      vi cnt(26,0);
      for(auto it:s)
	cnt[it-'a']++;
      m[cnt]++;
    }
  ll ans=0;
  for(auto it:m)
    ans+=((ll)it.se*(it.se-1))>>1;
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 19072
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double x;
    cin >> x;
    double n = 100; 
    int i = 0;
    while(n < x){
        n = floor(n*1.01);
        i++;
    }
    cout << i << '\n';
    return 0;
}


Measured memory_bytes: 3740
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */


#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DKeepDistances {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      vector<int> x(n);
      rep(i, n) {
        cin >> x[i];
      }

      vector<vector<int>> next(20, vector<int>(n, n));
      vector<vector<ll>> dp(20, vector<ll>(n, 0));
      int j=1;
      for(int i=0; i<n; i++) {
        while(j < n && x[j] - x[i] < k) {
          j++;
        }
        next[0][i] = j;
        dp[0][i] = j;
      }

      vector<vector<int>> next2(20, vector<int>(n, -1));
      vector<vector<ll>> dp2(20, vector<ll>(n, 0));
      j=n-2;
      for(int i=n-1; i>=0; i--) {
        while(j >= 0 && x[i] - x[j] < k) {
          j--;
        }
        next2[0][i] = j;
        dp2[0][i] = j;
      }

      for(int r=1; r<20; r++) {
        for(int i=0; i<n; i++) {
          if (next[r-1][i] == n) {
            next[r][i] = n;
          } else {
            next[r][i] = next[r-1][next[r-1][i]];
            dp[r][i] = dp[r-1][i] + dp[r-1][next[r-1][i]];
          }
        }
      }

      for(int r=1; r<20; r++) {
        for(int i=0; i<n; i++) {
          if (next2[r-1][i] == -1) {
            next2[r][i] = -1;
          } else {
            next2[r][i] = next2[r-1][next2[r-1][i]];
            dp2[r][i] = dp2[r-1][i] + dp2[r-1][next2[r-1][i]];
          }
        }
      }

      int q; cin >> q;
      rep(_, q) {
        int l, r; cin >> l >> r;
        l--; r--;
        ll lcnt = l;
        int now = l;
        int cnt = 1;
        for(int p=19; p>=0; p--) {
          if (next[p][now] <= r) {
            lcnt += dp[p][now];
            now = next[p][now];
            cnt += (1<<p);
          }
        }
        //debug(_, lcnt);
        now = r;
        ll rcnt = r;
        for(int p=19; p>=0; p--) {
          if (next2[p][now] >= l) {
            rcnt += dp2[p][now];
            now = next2[p][now];
          }
        }
        //debug(_, rcnt);
        cout << rcnt-lcnt+cnt << '\n';
      }
    }
};

signed main() {
  DKeepDistances solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 100268
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

m = int(input())
if m == 1:
  print(0)
  exit()
a = factorization(m)
b = []
ans = 0
for i in a:
    j = 1
    while j *(j+1) //2 <= i[1]:
        j += 1
    ans += j-1
print(ans)


Measured memory_bytes: 9484