akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i <= n; i++)

int main()
{
    ll n, m, k;
    cin >> n >> m;
    rep(i, n)
    {
        rep(j, n - i)
        {
            k = n - i - j;
            if (m == i * 10000 + j * 5000 + k * 1000)
            {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }

int main(){
    string s;
    cin >> s;
    if(s == "Sunny") s = "Cloudy";
    else if(s == "Cloudy") s = "Rainy";
    else s = "Sunny";
    cout << s << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
int n,a[N],bc[N];ll ans,t;
ll cl(ll x) {return x>1?x*(x-1)>>1:0;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]),++bc[a[i]];
	for(int i=1;i<=n;++i) ans+=cl(bc[i]);
	for(int i=1;i<=n;++i) printf("%lld\n",ans-cl(bc[a[i]])+cl(bc[a[i]]-1));
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

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

    int a[n];
    int ma = 0;
    rep(i,n){
        cin >> a[i];
        ma = max(ma,a[i]);
    }
    if(ma==0){
        cout << "Yes" << endl;
        return 0;
    }

    if(n%3!=0){
        cout << "No" << endl;
        return 0;
    }

    sort(a,a+n);

    int c[40] = {};
    rep(i,n){
        int aa = a[i];
        rep(j,40){
            c[j] += aa%2;
            aa /= 2;
        }
    }

    rep(j,40){
        if(c[j] != (n/3)*2 && c[j] > 0){
            cout << "No" << endl;
            return 0;
        }
    }

    rep(i,n-1){
        if(i == (n/3)-1 || i == (n/3)*2 - 1)continue;
        if(a[i]!=a[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}
 
 


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int N,W;
long long dp[10001];
long long v[100], w[100];

int main() {
    cin >> N >> W;
    for(int i=0;i<N;i++) cin >> v[i] >> w[i];
    
    for(int i=0;i<N;i++) {
        for(int wi=w[i];wi<=W;wi++) {
            dp[wi] = max(dp[wi], dp[wi-w[i]]+v[i]);
        }
    }

    long long ans = 0LL;
    for(int wi=0;wi<=W;wi++) {
        ans = max(dp[wi], ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3180
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(len(a)-1):
    #左倒す
    left=min(a[i],b[i])
    ans+=left
    a[i]-=left
    b[i]-=left

    #
    right =min(a[i+1],b[i])
    ans+=right
    a[i+1]-=right
    b[i]-=right
print(ans)

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (d  > t*s)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 3632
N = int(input())
S = ""
#素因数分解
while N:
    if N%(-2) == 0:
        S = "0"+S
    else:
        S = "1"+S
        #余りとなった部分を引く
        N -= 1
    N = N/(-2)

if S=="":
    S="0"

print(S)

Measured memory_bytes: 2940
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
#include <stack>
#include <utility>
#include <math.h>
using namespace std;

int main()
{
	int K, S;
	cin >> K >> S;
	int ans = 0;

	for (int X = 0; X <= K; X++)
	{
		if (S < X + 0 + 0) break;
		for (int Y = 0; Y <= K; Y++)
		{
			if (S < X + Y + 0) break;
			if (S - (X + Y) <= K) ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
A = LI()
for i in range(N):
    A[i] -= i+1
A.sort()


def f(x):
    return sum(abs(A[i]-x) for i in range(N))


print(f((A[(N-1)//2]+A[N//2])//2))


Measured memory_bytes: 104684
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize);

    let mut ans = 0;

    for i in 1..(n + 1) {
        let a = n / i;
        ans += (((2 * i) + (a - 1) * i) * a) / 2;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2200
N,K = map(int,input().split())
h = list(map(int,input().split()))
# dp[i] 足場iに辿り着くまでに支払うコストの総和の最小値
# dp[0] = 0, dp[1] = 0, dp[2] = abs(h[1] - h[0])
dp = [float("inf") for i in range(N+1)]
dp[0] = 0; dp[1] = 0
dp[2] = abs(h[1] - h[0])
for i in range(3,N+1):
    for j in range(1,min(i,K+1)):
        if dp[i-j] + abs(h[i-1] - h[i-j-1]) < dp[i]:
            dp[i] = dp[i-j] + abs(h[i-1] - h[i-j-1])
print(dp[N])

Measured memory_bytes: 56928
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt

  val ls = (1 to 2 * n).map(_ => sc.nextInt)
    .sorted

  val ans = (0 to (n - 1)).foldLeft(0){
    case (acc, idx) => acc + ls(idx * 2)
  }

  println(ans)

}


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

int n, l, s, mn = 1e9, m;

int abs(int p) {return p > 0 ? p : -p;}

int main()
{
	int i, t;
	cin >> n >> l;
	for (i = 1; i <= n; i++) {
		t = i + l - 1;
		s += t;
		if (abs(t) < mn) {
			mn = abs(t);
			m = t;
		}
	}
    cout << s - m << endl;
    return 0;
}

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

#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("READ.txt", "r", stdin)
#define Write          freopen("OUTPUT.txt", "w", stdout)
#define INF            99999
#define Co(x)          cout<<x<<endl;
#define Cos(x)         cout<<x<<" ";

typedef vector<long long>vii;
typedef pair<long long,long long>Pair;
typedef map<long long,long long>Map;

int dr[]={1,0,-1, 0 };
int dc[]={0,1, 0,-1 };

//int dr[]={1,1,0,-1,-1,-1, 0, 1};
//int dc[]={0,1,1, 1, 0,-1,-1,-1};

/*while(1) {
    if(!getline(cin,s)||s.empty()) break;
}*/

const int RT = 1000000;
vector<int>prime;
bitset<1000003> status;

void sieve()
{
    int rt = sqrt(RT);
    //for(int i = 4; i <= rt; i+=2) status[i]=true;
    for(int i = 3; i <= rt; i+=2)
        if(!status[i])
            for(int j = i*i; j < RT; j+=(i<<1))
                status[j] = true;
    prime.push_back(2);
    for(int i = 3; i <= RT; i+=2)
        if(!status[i])
            prime.push_back(i);
}

void Binary_Con(int n)
{
    int binaryNum[70];
    int i = 0;
    while (n > 0) {
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }
    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}

lll countDivisors(lll n)
{
   lll pf_idx=0,PF=prime[pf_idx],ans=1;
   while(PF*PF<=n)
   {
       lll power=0;
       while(n%PF==0) {n/=PF; power++; }
       ans*=(power+1);
       PF=prime[++pf_idx];
   }
   if(n!=1) ans*=2;
   return ans;
}

void solve()
{
    sieve();
    int n;
    cin>>n;
    long long ans=0;
    for(int i=1;i<n;i++)
    {
        int num=n-i;
        ans+=countDivisors(num);
    }
    cout<<ans<<endl;
}

void kick_ass()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    solve();
}

int main()
{
   kick_ass();
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int n=s.size(),flag=0;
    for(int i=0;i<n;i++){
        for(int j=0;i+j-1<n;j++){
            string t = s;
            t.erase(i,j);
            if(t=="keyence") flag  = 1;
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,min=INT_MAX;
cin>>n>>k;
vector<int> v(n);
for(int i=0;i<n;i++)
{
cin>>v[i];//if(v[i]<min)min=v[i];
}
sort(v.begin(),v.end());
for(int i=0;i<n-k+1;i++)
{
   if((v[i+k-1]-v[i])<min)min=v[i+k-1]-v[i];
}
cout<<min<<endl;
return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

typedef long long ll;

int main(){
   ll N;
   std::cin >> N;

   ll n = sqrt(static_cast<double>(N));
   ll ans = N;
   ll tmp;
   for(ll i=1; i<=n; ++i){
      if(N%i==0) {
	 tmp = (i-1) + (N/i-1);
	 ans = std::min(ans,tmp);
      }
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] arg) {
        Main m = new Main();
        m.run();
        m.close();
    }

    private Scanner sc;

    private Main() {
        sc = new Scanner(System.in);
    }
    private void close() {
        sc.close();
    }

    private void run() {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] v = IntStream.range(0, n).mapToDouble(i -> sc.nextDouble()).sorted().toArray();
        double d = v[0];
        for (int i = 1; i < n; i++) {
            d = (d + v[i]) / 2;
        }

        System.out.println(d);
    }
}


Measured memory_bytes: 27220
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var N = LnInt();
        var dict =new Dictionary<string, int>();
        for(var i = 0; i < N; i++)
        {
            var S = LnStr();
            if (dict.ContainsKey(S))
            {
                dict[S]++;
            }
            else
            {
                dict[S] = 1;
            }
        }
        var max = dict.Max(x => x.Value);
        var l = new List<string>();
        foreach(var i in dict)
        {
            if (i.Value == max) l.Add(i.Key);
        }
        var array = l.OrderBy(x => x, StringComparer.Ordinal);
        StringBuilder result = new StringBuilder();
        foreach(var i in array)
        {
            result.AppendLine(i);
        }
        print(result.ToString());
    }

public static long PowLite(long n, long p, int mod = (int)1e9 + 7){long ans = 1;long now = n;for (; p > 0; p >>= 1){if ((p & 1) == 1){ans *= now;ans %= mod;}now *= now;now %= mod;}return ans;}
public static void print(object obj) { Console.WriteLine(obj); }
public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable{var a = new List<T>(array).ToArray();var res = new List<T[]>();res.Add(new List<T>(a).ToArray());var n = a.Length;var next = true;while (next){next = false;int i;for (i = n - 2; i >= 0; i--){if (a[i].CompareTo(a[i + 1]) < 0) break;}if (i < 0) break;var j = n;do{j--;} while (a[i].CompareTo(a[j]) > 0);if (a[i].CompareTo(a[j]) < 0){var tmp = a[i];a[i] = a[j];a[j] = tmp;Array.Reverse(a, i + 1, n - i - 1);res.Add(new List<T>(a).ToArray());next = true;}}return res;}}



Measured memory_bytes: 55032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define pb push_back
int main()
{
    ios;
    ll n , a , b , c;
    cin >> n ;
    vector<ll> v[n+1];
    for(ll i=1;i<=n;++i){
        cin >> a >> b >> c;
        v[i].pb(a);v[i].pb(b);v[i].pb(c);
    }
    ll dp[n+1][5];
    for(ll i=1;i<=n;++i){
        dp[i][1] = 0;
        dp[i][2] = 0;
        dp[i][3] = 0;
    }
    dp[1][1] = v[1][0];
    dp[1][2] = v[1][1];
    dp[1][3] = v[1][2];
    for(ll i=2;i<=n;++i){
        /// if chose swim
        dp[i][1] = v[i][0] + dp[i-1][2];
        dp[i][1] = max(dp[i][1] , v[i][0]+dp[i-1][3]);
        dp[i][2] = v[i][1] + dp[i-1][1];
        dp[i][2] = max(dp[i][2] , v[i][1]+dp[i-1][3]);
        dp[i][3] = v[i][2] + dp[i-1][1];
        dp[i][3] = max(dp[i][3] , v[i][2]+dp[i-1][2]);
    }
    cout << max(dp[n][1] , max(dp[n][2] , dp[n][3])) << endl ;
}


Measured memory_bytes: 11264
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long Y = sc.nextLong();
        int ans = 0;
        while (X <= Y){
            ans++;
            Y/=2;
        }
        System.out.println(ans);
	}
}

Measured memory_bytes: 27008
//In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define mod 1000000007


string s,t;


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>s>>t;
	cout<<t<<s<<"\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
 
const ll MOD = 1000000007;
const ll INF = 10000000;
 
 
 
 
int main(void){
    
    vector<int> v;
    ll n,m,sum[100005];
    map<int,ll> count;
    map<ll,bool> used;
    
    count[0]++;
    
    cin >> n >> m;
    for(int i=0;i<n;i++){
        int s;
        cin >> s;
        sum[i] = s;
        if(i != 0) sum[i] += sum[i-1];
        count[sum[i]%m]++;
        v.push_back(sum[i]%m);
    }
    
    ll ans = 0;
    for(int i=0;i<v.size();i++){
        if(used[v[i]]) continue;
        ans += count[v[i]]*(count[v[i]] - 1) / 2;
        used[v[i]] = true;
    }
    
    cout << ans << endl;
    
    
    
 
}

Measured memory_bytes: 9336
import java.util.*;

class Block {
  int count;
  boolean reverse;
  
  Block(int count, boolean reverse) {
    this.count = count;
    this.reverse = reverse;
  }
}

public class Main {
  private static int solve(ArrayList<Block> blocks, int k) {
    int sum = blocks.get(0).count;
    int maxSum = sum;
    for (int i = 1; i+1 < blocks.size(); i+=2) {
      sum += blocks.get(i).count;    // flipped
      sum += blocks.get(i+1).count;  // originally reversed
      if (i - 2 * k - 1 >= 0) {
        sum -= blocks.get(i - 2 * k).count;
        sum -= blocks.get(i - 2 * k - 1).count;
      }
      maxSum = Math.max(sum, maxSum);
    }
    return maxSum;
  }
  
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    int n = s.nextInt();
    int k = s.nextInt();
    String line = s.next();
    ArrayList<Block> blocks = new ArrayList<Block>();
    
    
    
    int count = 0;
    char[] cs = line.toCharArray();
    count = 1;
    boolean lastReverse = cs[0] == '1';
    if (!lastReverse) {
      blocks.add(new Block(0, true));
    }
    
    for (int i = 1; i < cs.length; i++) {
      boolean currentReverse = cs[i] == '1';
      if (lastReverse == currentReverse) {
        count++;
      } else {
        blocks.add(new Block(count, lastReverse));
        count = 1;
        lastReverse = currentReverse;
      }
    }
    blocks.add(new Block(count, lastReverse));
    if (!lastReverse) {
      blocks.add(new Block(0, true));
    }
    blocks.add(new Block(0, false));
    blocks.add(new Block(0, true));
    
    System.out.println(solve(blocks, k));
  }
}


Measured memory_bytes: 28596
#include <stdio.h>
#include <stdlib.h>

int main(){
    int i;
    
    int q;
    scanf("%d\n",&q);
    
    int a[q];
    int head=0,tail=1;
    
    int com,d,x;
    for(i=0;i<q;i++){
        scanf("%d \n",&com);
        switch(com){
            case 0:
                scanf("%d %d\n",&d,&x);
                if(d==0){
                    a[head]=x;
                    if(--head<0)head=q-1;
                }else if(d==1){
                    a[tail]=x;
                    if(++tail>=q)tail=0;
                }
                break;
            case 1:
                scanf("%d\n",&x);
                if(head+x+1<q)printf("%d\n",a[head+x+1]);
                else printf("%d\n",a[head+x+1-q]);
                break;
            case 2:
                scanf("%d\n",&d);
                if(d==0){
                    a[head]=-1;
                    if(++head>=q)head=0;
                }else if(d==1){
                    a[tail]=-1;
                    if(--tail<0)tail=q-1;
                }
                break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3392
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    ld num[n];
    rep(i,n){
        cin >> num[i];
    }
    sort(num,num+n);
    rep1(i,n-1){
        num[i] = (num[i]+num[i-1])/2;
    }
    cout << num[n-1] << endl;
}

Measured memory_bytes: 3796
import sys
W = input()
word = []
counter = 0
while 1:
    line = input()
    
    if line == "END_OF_TEXT" :
        for i in  word:
            counter += i.count( W )
        print(counter)
        sys.exit()
    line = line .lower()
    word.append( line.split() )



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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> A(m+10);
  vector<int> B(m+10);
  vector<int> k(n+10);
  rep(i,n){
    cin >> k[i];
    rep(j,k[i]){
      cin >> A[j];
      B[A[j]] += 1;
    }
  }
  int count = 0;
  rep(i,m){
    if(B[i] == n) ++count;
  }
  cout << count << endl;
  return 0;
}


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

int main()
{
	string str;
	int h=0,N=0;
	cin >> str >> N;

	for(int i=0;i<N;i++){
	string a;
	cin >> a;
	a = a+a;

	string::size_type index=a.find(str);
		if(index!=string::npos){
			h++;
		}
	}

	cout << h << endl;
	return 0;
}	

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;

    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N-1);

    REP(i,N){ cin >> A[i]; }
    REP(i,N){ cin >> B[i]; }
    REP(i,N-1){ cin >> C[i]; }

    ll total = 0;
    REP(j, N){
        int i = A[j]-1;
        total += B[i];
        if( j > 0 && (A[j-1]+1) == A[j] ){
            total += C[A[j-1]-1];
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        s:String,
    }

    let mut len = s.len();
    if s.len() % 2 == 0 {
        len -= 2;
    } else {
        len -= 1;
    }
    while len > 0{
        if s[0..len / 2] == s[(len / 2) .. len] {
            println!("{}",len);
            return;
        }else{
            len -= 2;
        }
    }
}    


Measured memory_bytes: 4352
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product

# input = sys.stdin.readline
S = input()
total = 0
for p in (product((0, 1), repeat=len(S)-1)):
    ns = S[0]
    for i, pp in enumerate(p, 1):
        if pp == 0:
            ns += S[i]
        else:
            total += int(ns)
            ns = S[i]
    total += int(ns)
print(total)





Measured memory_bytes: 27092
import heapq
Q,s = [],[]
flag = 0
while(flag==0):
  c = input()
  if c == "end":
    break
  elif c == "extract":
    print(heapq.heappop(Q) * (-1))
  else:
    s = c.split()
    heapq.heappush(Q, int(s[1])*(-1))


Measured memory_bytes: 45304
# Acceptance of input
import sys

file_input = sys.stdin

n = file_input.readline()

EP = []
l = -1000000001
u = 1000000001
vs_x = set()

for line in file_input:
    x1, y1, x2, y2 = (map(int, line.split()))
    if x1 == x2:
        if y1 < y2:
            EP.append((y1, l, x1))
            EP.append((y2, u, x1))
        else:
            EP.append((y1, u, x1))
            EP.append((y2, l, x1))
        vs_x.add(x1)
    else:
        if x1 < x2:
            EP.append((y1, x1, x2))
        else:
            EP.append((y1, x2, x1))

# Binary Indexed Tree
class BinaryIndexedTree:
    def __init__(self, n):
        self.data = [0] * (n + 1)
        self.num = n

    def switch(self, i, d):
        while  i <= self.num:
            self.data[i] += d
            i += i & -i

    def _sum(self, i):
        s = 0
        while i:
            s += self.data[i]
            i -= i & -i
        return s

    def seg_sum(self, a, b):
        return self._sum(b) - self._sum(a - 1)

# Sweep
import bisect

EP.sort()
BIT = BinaryIndexedTree(len(vs_x))
vs_x = [l] + sorted(vs_x)
d_vs_x = {e: i for i, e in enumerate(vs_x)}
cnt = 0

for p in EP:
    e = p[1]
    if e == l:
        BIT.switch(d_vs_x[p[2]], 1)
    elif e == u:
        BIT.switch(d_vs_x[p[2]], -1)
    else:
        l_x = bisect.bisect_left(vs_x, e)
        r_x = bisect.bisect(vs_x, p[2]) - 1
        cnt += BIT.seg_sum(l_x, r_x)

# Output
print(cnt)

Measured memory_bytes: 35336
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAXN = 2E5 + 10;

int n;
vi fo[MAXN];

int max_v, max_dist;

void Dfs(int vr, int dist, int par = -1){
  if(dist > max_dist){
    max_dist = dist;
    max_v = vr;
  }

  for(int to : fo[vr])
    if(to != par)
      Dfs(to, dist + 1, vr);
}

int MaxDist(int vr){
  max_v = vr;
  max_dist = 1;
  Dfs(vr, 1);
  return max_v;
}

int type[MAXN];

bool IsWin(int l){
  if(l == 0) return false;
  if(l == 1) return true;
  if(l == 2) return false;

  if(type[l] >= 0) return type[l];
  type[l] = (!IsWin(l - 1) || !IsWin(l - 2));
  return type[l];
}

int main(){
  memset(type, -1, sizeof type);

  scanf("%d", &n);
  for(int i = 1;i < n;++i){
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    fo[a].pb(b);
    fo[b].pb(a);
  }

  MaxDist(MaxDist(0));
  int d = max_dist;

  if(IsWin(d)) printf("First\n");
  else printf("Second\n");

  return 0;
}


Measured memory_bytes: 21376
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n+1) cin >> a[i];
    ll ans = 0;
    rep(i,n){
        int b;
        cin >> b;
        if(b <= a[i]){
            ans += b;
            a[i] -= b;
            b = 0;
        }
        else{
            ans += a[i];
            b -= a[i];
            a[i] = 0;
        }
        if(b <= a[i+1]){
            ans += b;
            a[i+1] -= b;
            b = 0;
        }
        else{
            ans += a[i+1];
            b -= a[i+1];
            a[i+1] = 0;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
fun main(args :Array<String>) {
    val s = readLine()!!
    val ss = s.map { it.toInt() - '0'.toInt() }.toIntArray()
    var ans = Int.MAX_VALUE
    for (i in 0 until (ss.size - 2)) {
        val tmp = ss[i] * 100 + ss[i + 1] * 10 + ss[i + 2]
        ans = Math.min(ans, Math.abs(753 - tmp))
    }

    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    ans = max(ans, a+a-1);
    ans = max(ans, a+b);
    ans = max(ans, b+b-1);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << c;
  }
  else if (a == c) {
    cout << b;
  }
  else {
    cout << a;
  }
  cout << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;
    import java.util.Arrays;
    class Main {
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
      int n = sc.nextInt();
      int a[] = new int[n];
      
      for(int i = 0; i < n; i++) {
          a[i] = sc.nextInt();
      }

      Arrays.sort(a);
 
      System.out.println(a[n-1] - a[0]);
  }
}

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

//in
// 2 11 4
//out
// 4
const main = (inp: string) => {
    const [a, b, c]: number[] = inp.split(' ').map(Number);
    if (b / a > c) {
        console.log(c);
    } else {
        console.log(Math.floor(b / a));
    }
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7500
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		A_AntiAdjacency solver = new A_AntiAdjacency();
		solver.solve(1, in, out);
		out.close();
	}

	static class A_AntiAdjacency {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int k = in.nextInt();
			out.println(k <= (n + 1) / 2 ? "YES" : "NO");
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 22868
#include<stdio.h>
long long n;
int cnt = 0;
void f(long long k, bool r3, bool r5, bool r7)
{
	if (k > n)
		return;
	if (r3&&r5&&r7) cnt++;
	f(k * 10 + 3, true, r5, r7); f(k * 10 + 5, r3, true, r7); f(k * 10 + 7, r3, r5, true);
}

int main()
{
	//n =999999999;
	scanf("%lld", &n);
	f(0, false, false, false);
	printf("%d", cnt);
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
vll a;

// <------------- Implement Functions Here ----------> //

long long exponentiation(long long base, 
                        long long exp) 
{ 
    if (exp == 0) 
        return 1; 
  
    if (exp == 1) 
        return base % MOD; 
  
    long long t = exponentiation(base, exp / 2); 
    t = (t * t) % MOD; 
  
    // if exponent is even value 
    if (exp % 2 == 0) 
        return t; 
  
    // if exponent is odd value 
    else
        return ((base % MOD) * t) % MOD; 
} 

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	ll val1 = exponentiation(10,n);
	ll val2 = exponentiation(9,n);
	ll val3 = exponentiation(8,n);

	ll ans = ((val1 + val3)%MOD - (2 * val2)%MOD + MOD)%MOD;
	cout<<ans;
}
int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3656
n,W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
inf = float('INF')
bag = [inf for _ in range(10**5+1)]
bag[0] = 0

ans = 0
for w,v in a:
  for i in range(min(v,10**5+1), 10**5+1)[::-1]:
    if bag[i-v] + w < min(bag[i],W+1):
        bag[i] = bag[i-v] + w
        ans = max(ans, i)
print(ans)


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

using namespace std;
typedef long long ll;
#define sz size()
#define pb push_back 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;
	
vector<ll> Next[200001];
vector<ll> point(200001,0);
bool check[200001];

void dfs(ll x){
    check[x]=false;

    rep(i,Next[x].sz){
        if(check[Next[x][i]]==true){
            point[Next[x][i]]+=point[x];
			dfs(Next[x][i]);
        }
    }
}

int main(){
	ll N,Q; cin>>N>>Q;
    memset(check,true,sizeof(check));
	rep(i,N-1){
		ll A,B; cin>>A>>B;
		Next[A].pb(B);
        Next[B].pb(A);
	}
	rep(i,Q){
		ll p,x; cin>>p>>x;
		point[p]+=x;
	}
	dfs(1ll);
	rep1(i,N){
		cout<<point[i]<<" ";
	}
}


Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a=0;
	string s,ss;
	cin>>s>>ss;
	for(int i=0;i<3;i++)
	{
		if(s[i]==ss[i])a++;
	} 
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	int a, b; cin >> a >> b;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	int cnt[3] = {};
	for (int i = 0; i < n; i++) {
		if (p[i] <= a) cnt[0]++;
		else if (p[i] >= b + 1) cnt[2]++;
		else cnt[1]++;
	}
	cout << min({ cnt[0], cnt[1], cnt[2] }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = 1;
    for (int i = 0;i < s.size();i++){
        if (i%2 == 0 && s[i] == 'L'){
            ans = 0;
            break;
        }
        else if (i%2 == 1 && s[i] == 'R'){
            ans = 0;
            break;
        }
        else {
            ;
        }
    }
    if (ans == 1){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import bisect

class SegmentTree:
    def __init__(self, a):
        # Operator
        self.op = lambda a, b : max(a, b)
        # Identity element
        self.e = 0 

        self.n = len(a)
        self.lv = (self.n - 1).bit_length()
        self.size = 2**self.lv
        self.data = [self.e] * (2*self.size - 1)
        # Bisect checking function 
        self._check = lambda x, acc : acc >= x
        self._acc = self.e

        self.initialize(a)

    # Initialize data
    def initialize(self, a):
        for i in range(self.n):
            self.data[self.size + i - 1] = a[i]
        for i in range(self.size-2, -1, -1):
            self.data[i] = self.op(self.data[i*2 + 1], self.data[i*2 + 2])

    # Update ak as x (0-indexed)
    def update(self, k, x):
        k += self.size - 1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = self.op(self.data[2*k+1], self.data[2*k+2])

    # Min value in [l, r) (0-indexed)
    def fold(self, l, r):
        L = l + self.size; R = r + self.size
        s = self.e
        while L < R:
            if R & 1:
                R -= 1
                s = self.op(s, self.data[R-1])
            if L & 1:
                s = self.op(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

n, k = map(int, input().split())
aa = []
aa_sorted = []
for i in range(n):
    a = int(input())
    aa_sorted.append((a, i))
    aa.append(a)

aa_sorted.sort()
aas = sorted(aa)

place_list = [-1] * n
for place, (val, index) in enumerate(aa_sorted):
    place_list[index] = place

len_list = [0] * n
ST = SegmentTree(len_list)

ans = 0
for i, a in enumerate(aa):
    l = bisect.bisect_left(aas, a - k)
    r = bisect.bisect_right(aas, a + k)
    max_score = ST.fold(l, r)
    ST.update(place_list[i], max_score + 1)
    ans = max(ans, max_score + 1)
print(ans)

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

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

using namespace std;
typedef long long ll;

int main(void)
{
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int sm = h1 * 60 + m1;
  int em = h2 * 60 + m2;
  int last = em - k;
  cout << last-sm << endl;
}

Measured memory_bytes: 3636
from collections import Counter

n, m = list(map(int, input().split()))

if m == 1:
    print(1)
else:

    MOD = pow(10, 9) + 7

    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    def make_fact_list(n, MOD):
        # make factorial list from 0 to n
        fact = [0] * (n+1)
        inv = [0] * (n+1)
        factinv = [0] * (n+1)

        fact[0]=fact[1]=1
        inv[1]=1
        factinv[0]=factinv[1]=1

        for i in range(2,n+1):
            fact[i] = fact[i-1] * i % MOD
            inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
            factinv[i] = factinv[i-1] * inv[i] % MOD
        
        return fact, factinv

    def cbn(n, k, MOD, fact = [], factinv = []):
        if len(fact) == 0 and len(factinv) == 0:
            fact, factinv = make_fact_list(n, MOD)
        return fact[n] * factinv[n-k] * factinv[k] % MOD


    d = Counter(prime_factorize(m)).most_common()

    l = d[0][1] + n 

    fact, factinv = make_fact_list(l, MOD)

    a = 1

    for k, v in d:
        a *= cbn(v + n - 1, v, MOD, fact = fact, factinv = factinv) % MOD

    print(a % MOD)

Measured memory_bytes: 21132
#include <stdio.h>
#include <stdlib.h>
typedef long long LL;
#define rep(i,n)for(int i=0;i<(int)(n);i++)

int acsLL(const LL*a,const LL*b){
	LL*A=(LL*)a;
	LL*B=(LL*)b;
	if(*A>*B)return 1;
	if(*A<*B)return -1;
	return 0;
}

LL gcd(LL a,LL b){
	if(!b)return a;
	return gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a/gcd(a,b)*b;
}

int main(){
	LL n,t[101],ans=1;
	scanf("%lld",&n);
	rep(i,n)scanf("%lld",t+i);
	qsort(t,n,sizeof(LL),acsLL);
	rep(i,n)ans=lcm(ans,t[i]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;
	ll ans = 0;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 1; i < n; i++)
	{
		ans += max(0, a[i - 1] - a[i]);
		a[i] = max(a[i], a[i - 1]);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3992
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b,c,k;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(k>a)
	sum+=a;
	else
	{
	    cout<<sum+k;
	    return 0;
	}
	k-=a;
	if(k<=b)
	{
	    cout<<sum;
	    return 0;
	}
	k-=b;
	sum-=k;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
ll ans,tot;
int main(){
	n=read();
	ans=-1;
	for(int i=1;i<=n;++i){
		ll d=read(),c=read();
		tot+=d*c;
		ans+=c;
	}
	ans+=(tot-1)/9;
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 3544
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = 0;
  for (int i = A; i <= B; i++) {
    string str = to_string(i);
    bool flag = true;
    for (int j = 0; j < str.size() / 2; j++) {
      if (str[j] != str[str.size() - 1 - j]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3724
// Marcin Knapik
#include<bits/stdc++.h>
// #pragma GCC optimize("O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// #define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;

#define boost                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1000000000000000000;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll Hope = 1000000123;

ll n, m, k, q;	

ll dp[4000][4000];
ll dp2[4000][4000];

ll ans = 0;

int main(){
	boost;

	cin >> n >> k;

	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= k; j++)
			dp[i][j] = dp[i - 1][j];
		ll x;
		cin >> x;

		dp[i][x] = (i + dp[i][x]) % mod;
		dp2[i][x] = i;

		for(int j = x + 1; j <= k; j++){
			dp[i][j] = (dp[i][j] + dp[i - 1][j - x]) % mod;
			dp2[i][j] = (dp2[i][j] + dp[i - 1][j - x]) % mod;
		}
		ans += dp2[i][k] * (n - i + 1);
		ans %= mod;
	}
	cout << ans << '\n';
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto& e : a) {
    cin >> e;
  }
  // int x = find(begin(a), end(a), 1) - begin(a);
  cout << (n - 2) / (k - 1) + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  ll a,b,k;
  cin>>a>>b>>k;
  if(a<=k){
    k-=a;
    a=0;
  }
  else{
    a-=k;
    k=0;
  }
  if(b<=k){
    b=0;
  }
  else b-=k;
  cout<<a<<" "<<b<<endl;

  
  return 0;
}


Measured memory_bytes: 256