akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	string S;
	int count = 0;
	cin >> S;
	vector<int>V;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '0') {
			V.push_back(0);
		}
		else {
			V.push_back(1);
		}
	}
	while (true) {
		bool can = false;
		if (V.size() == 0)break;
		for (int i = 0; i < V.size() - 1; ++i) {
			if (V[i] != V[i + 1]) {
				can = true;
				V.erase( V.begin() + i+1);
				V.erase(V.begin() + i);
				count += 2;
				break;
			}
		}
		if (!can)break;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 1020
#include<stdio.h>

int main(void){
    long long k_target;
    long long k = 100;
    long long year = 0;
    scanf("%lld", &k_target);
    while (k<k_target) {
        k = k *1.01;
        year++;
    }
    
    printf("%lld\n", year);
    return 0;
}


Measured memory_bytes: 1700
#include <stdio.h>
int main(){
  int i,j,k,tmp,A[100],n,count=0;

scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d",&A[i]);
}

for(i=0;i<n-1;i++){
  for(j=n-1;j>i;j--){
    if(A[j]<A[j-1]){
      tmp = A[j];
      A[j] = A[j-1];
      A[j-1] = tmp;
      count++;
    }
    }
  }

  for(k=0;k<n-1;k++){
    printf("%d ",A[k]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2144
m,d = map(int,input().split())
if d <= 9:
  print(0)
  exit()
ans = 0
for i in range(1,m+1):
  for j in range(10,d+1):
    d10 = j//10
    d1 = j % 10
    if d10 * d1 == i and d1 >= 2 and d10 >= 2:
      ans += 1
print(ans)

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

int main() {
    using namespace std;
    string s, t;
    cin >> s >> t;
    while(s.size() < t.size())s += s;
    unsigned long N = s.size(), M = t.size();
    s += s;

    vector<unsigned long> idx(N);
    {
        string Q = t + "_" + s;
        vector<unsigned long> KMP(Q.size() + 1);
        for(unsigned long i = 1, j = 0; i <= Q.size(); ++i){
            while(j > 0 && Q[i - 1] != Q[j - 1])j = KMP[j - 1];
            KMP[i] = ++j;
            if(KMP[i] > M && i >= KMP[i] + M && i < KMP[i] + N + M)idx[i - KMP[i] - M] = ~0UL;
        }
    }
    
    auto f = [rec = [&idx, &M, &N](auto f, unsigned long i, unsigned long t, unsigned long k) -> unsigned long{
        if(!idx[i])return 0;
        if(i == t && k)idx[i] = 2 * N;
        else if(!~idx[i])idx[i] = f(f, (i + M) % N, t, 1) + 1;
        return idx[i];
    }](unsigned long n){rec(rec, n, n, 0);};
    for(unsigned long i = 0; i < N; ++i)f(i);

    unsigned long ans = *max_element(idx.begin(), idx.end());
    if(ans > N)puts("-1");
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42224
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]
    t=[int(readline()) for _ in range(D)]

    kaisai=[0]*26
    manzokudo=0
    for i in range(D):
        manzokudo+=s[i][t[i]-1]
        kaisai[t[i]-1]=i+1
        for j in range(26):
            manzokudo-=c[j]*(i+1-kaisai[j])
        print(manzokudo)

if __name__=="__main__":
    main()

Measured memory_bytes: 9384
#include <iostream>
#define ll long long
#define fr(n) for(int i = 1; i <= n; i++) d[i] = -1;

using namespace std;

const int NMAX = 1e5 + 20;
ll d[NMAX];

ll n, g, p;
ll GMAX;
ll mmax = -1e9;

int main()
{
    cin >> n >> GMAX;
    fr(n + 5);
    d[0] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> g >> p;
        for(int j = GMAX - g; j >= 0; j--) {
            if(d[j] != -1) {
                if(d[j + g] < d[j] + p || d[j + g] == -1) {
                    d[j + g] = d[j] + p;
                }
            }
        }
    }
    for(int i = 1; i <= GMAX; i++) {
        if(d[i] > mmax)
            mmax = d[i];
    }
    cout << "\n\n";
    cout << mmax;
    return 0;
}


Measured memory_bytes: 4372
import sys
S = input()

if S == "SUN":
  print(7)
  sys.exit()
elif S == "MON":
  print(6)
  sys.exit()
elif S == "TUE":
  print(5)
  sys.exit()
elif S == "WED":
  print(4)
  sys.exit()
elif S == "THU":
  print(3)
  sys.exit()
elif S == "FRI":
  print(2)
  sys.exit()
elif S == "SAT":
  print(1)
  sys.exit()
  
  


Measured memory_bytes: 3060
#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 = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); 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;
    int num = n % 10;
    if(num == 3) cout << "bon" << ln;
    else if(num == 1 || num == 0 || num == 6 || num == 8) cout << "pon" << ln;
    else cout << "hon" << ln;
}

Measured memory_bytes: 3636
#include <string>
#include <algorithm>
#include <iostream>
#include <math.h>

using namespace std;

void a_rainy_season(void) {
    string s;
    cin >> s;

    int cnt = 0;
    bool rainy = false;

    for (int i = 0; i < 3; i++) {
        if (s[i] == 'R') {
            if (cnt != 0) {
                if (s[i - 1] == s[i]) cnt++;
            }
            else {
                cnt++;
            }
        }
    }

    cout << cnt << endl;


}

int main()
{
    a_rainy_season();

    return 0;
}

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

int gcd(int a, int b)
{
    if (a > b) swap(a, b);
    if(b % a == 0) return a;
    else return gcd(a, b % a);
}

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

    int ans = a[0];
    rep(i, 0, n) ans = gcd(ans, a[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize(2)
#include<iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
ll dp[55][3500];
int main()
{
    int n,a;
    int x;
    ll o=0;
    dp[0][0]=1;
    scanf("%d %d",&n,&a);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        o+=x;
        for(int j=i;j>=1;j--)
        {
            for(int k=o;k>=x;k--)
            {
                dp[j][k]+=dp[j-1][k-x];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=50;i++)
    {
        ans+=dp[i][i*a];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1408
#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 int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9+7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5 + 5)

void solve()
{
    string s,t;
    cin>>s>>t;

    ll ans = 0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i] != t[i])
            ans++;
    }
    cout<<ans;
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k;
    string s;
    cin >> s >> k;
    n = s.length();
    ll dp[101][101];
    memset(dp, 0, sizeof(dp));
    ll cnt = 0;
    for (ll i = 2; i <= n; ++i) {
        dp[i][0] = 1;
    }
    for (ll i = 1; i <= n; i++) {
        if (s[i - 1] > '0') {
            dp[i][cnt] += 1;
            dp[i][cnt + 1] += (s[i - 1] - '0' - 1);
            cnt++;
        }
        for (ll j = 1; j <= min(i, k); ++j) {
            dp[i][j] += dp[i - 1][j - 1] * 9 + dp[i - 1][j];
        }
    }
    cout << (cnt == k ? dp[n][k] + 1 : dp[n][k]);
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 
int main(){
    int i, j, m, n;
    int a[100][100], b[100];
    long c[100] = {0};
     
    scanf(" %d %d", &m, &n);
     
    for(i=0; i<m; ++i){
        for(j=0; j<n; ++j){
            scanf(" %d", &a[i][j]); 
        }
    }
     
    for(i=0; i<n; ++i){
        scanf(" %d", &b[i]);
    }
     
    for(i=0; i<m; ++i){
        for(j=0; j<n; ++j){
            c[i] += a[i][j]*b[j];
        }   
    }
     
    for(i=0; i<m; ++i)
        printf("%ld\n", c[i]);
     
    return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int32 n = s.size();
  int32 i = 0;
  int32 j = n-1;
  int32 cntf = 0, cntb = 0;
  int32 ans = 0;
  while(i <= j){
    while(i < n && s[i] == 'x'){
      ++i;
      cntf++;
    }
    while(j >= 0 && s[j] == 'x'){
      --j;
      cntb++;
    }
    if(i > j){
      break;
    }
    if(s[i] != s[j]){
      ANS(-1);
      return 0;
    }
    ans += abs(cntf - cntb);
    cntf = cntb = 0;
    ++i;
    --j;
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3768
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Set<String> set = new HashSet();
		int N = sc.nextInt();
		for(int i=0;i<N;i++){
			set.add(sc.next());
		}
		System.out.println(set.size());
	}
}


Measured memory_bytes: 23764
n = int(input())
s = input()
cnt = 0

for N in range(1000):
    tgt = str(N).zfill(3)
    if tgt[0] in s:
        i = s.index(tgt[0])
        if tgt[1] in s[i+1:]:
            j = s[i+1:].index(tgt[1]) + i
            if tgt[2] in s[j+2:]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9224
import java.util.Scanner

object ThreeNumber {
  val sc = new Scanner(System.in)

  def input() :List[Int]  = {
    val a, b, c = sc.nextInt()
    List(a, b, c)
  }

  def run(): Unit ={
    val l1 = input()
    val l2 = l1.sorted
    val s = l2.mkString(" ")
    println(s)
  }
}


object Main extends App {
  ThreeNumber.run()
}

Measured memory_bytes: 45044
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int main() {
	int n,m;
	cin >> n >>m;
	string a= "",b = "";
	for(int i = 0; i <n;i++)
		a+=('0'+m);
	for(int i = 0; i <m;i++)
		b+=('0'+n);
	cout << min(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,M;
int nums[100];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,M){
        int a,b;
        cin>>a>>b;
        nums[a]++;
        nums[b]++;
    }
    
    rep1(i,N){
        cout1(nums[i])
    }
}

Measured memory_bytes: 256
import string


def solve(n):
    digit = 1
    digit_sum = 0
    d = 0

    while n >= digit_sum:
        digit *= 26
        digit_sum += digit
        d += 1

    n -= (digit_sum - digit)

    ans = ''
    for _ in range(d):
        n, m = divmod(n, 26)
        ans += string.ascii_lowercase[m]

    return ans[::-1]


n = int(input())
print(solve(n - 1))


Measured memory_bytes: 9988
# -*- coding: utf-8 -*-

import itertools

N = int(input())
P_list = list(map(str, input().split()))
Q_list = list(map(str, input().split()))

P_tuple = tuple(P_list)
Q_tuple = tuple(Q_list)

P_all = list(itertools.permutations(sorted(P_list)))
Q_all = list(itertools.permutations(sorted(Q_list)))

P_num = P_all.index(P_tuple)
Q_num = P_all.index(Q_tuple)

print(abs(P_num - Q_num))


Measured memory_bytes: 50928
# coding: utf-8

n,m=map(int,input().split())
a_list=list(map(int,input().split()))
popular= []

for a in a_list:
    if a >= sum(a_list)/(4*m):
        popular.append(a)

if len(popular) >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
main = do
  s <- getLine
  if s == "0 0"
    then return ()
    else do print . nCombination . map read . words $ s
            main

nCombination [n, s] = length . filter (`sumEq` s) $ combinations n [0..9]
  where sumEq ls s = sum ls == s

-- all combinations of distinct n elements of list xs.
-- cited from: http://www.geocities.jp/m_hiroi/func/haskell06.html
combinations :: Int -> [a] -> [[a]]
combinations n xs = comb n (length xs) xs
  where
    comb r n (y:ys)
      | r == 0    = [[]]
      | r >= n    = [y : ys]
      | otherwise = map (y:) (comb (r - 1) (n - 1) ys) ++ comb r (n - 1) ys

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n; cin >> n;
	int m = n%10;
	if(m == 3) cout << "bon";
	else if(m == 0 || m == 1 || m ==6 || m == 8) cout << "pon";
	else cout << "hon";
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

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

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

		if(a>b){
			int x=a;
			a=b;
			b=x;
		}
		if(b>c){
			int y=b;
			b=c;
			c=y;
		}
		if(a>b){
			int z=a;
			a=b;
			b=z;
		}

		System.out.println(a+" "+b+" "+c);
			}
}

Measured memory_bytes: 26168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

/**
 * Lesson10A ２点 P1(x1, y1), P2(x2, y2) の距離を求めるプログラム
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		// 1行目を取得
		try {
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			String strLine = insBR.readLine();

			// 分解
			String[] strAryLine1 = strLine.split(" ");

			// intにキャスト
			// 1つ目
			double dbX1 = Double.parseDouble(strAryLine1[0]);

			// 2つ目
			double dbY1 = Double.parseDouble(strAryLine1[1]);

			// 3つ目
			double dbX2 = Double.parseDouble(strAryLine1[2]);

			// 4つ目
			double dbY2 = Double.parseDouble(strAryLine1[3]);

			// 計算
			double dbAnswer = ((dbX2 - dbX1) * (dbX2 - dbX1)) + ((dbY2 - dbY1) * (dbY2 - dbY1));

			dbAnswer = Math.sqrt(dbAnswer);


			 //小数5桁まで
		    DecimalFormat insdf = new DecimalFormat("0.00000000");

			//結果を出力 double型は小数5桁まで表示
			System.out.println(insdf.format(dbAnswer));

		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println("数字で入力して下さい");
		}
	}
}

Measured memory_bytes: 17300
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<bitset>
#include<vector>
#include<queue>
#include<ext/pb_ds/priority_queue.hpp>
#include<set>
#include<map>
#include<math.h>
#include<set>
#define maxn 500005
#define lson (now<<1)
#define rson ((now<<1)|1)
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
ll fac[maxn],inv[maxn];
ll quickpow(ll p,ll k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)
			ans=(ans*p)%mod;
		p=(p*p)%mod;
		k>>=1;
	}
	return ans;
}
ll c(ll n,ll m)
{
	if(n<m) return 0;
	return ((fac[n]*inv[m]%mod)*inv[n-m])%mod;
}
ll a(ll n,ll m)
{
	return (fac[n]*inv[n-m])%mod;
}
ll n,m;
int main()
{
	fac[0]=1;
	for(int i=1;i<=500000;i++)
		fac[i]=(fac[i-1]*i)%mod;
	inv[500000]=quickpow(fac[500000],mod-2);
	for(int i=499999;i>=0;i--)
		inv[i]=(inv[i+1]*(i+1))%mod;
		
	scanf("%lld%lld",&n,&m);
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		ll flag=((i&1)?-1:1);
		ans=(ans+((c(n,i)*flag*a(m-i,n-i))%mod))%mod;
		ans=(ans%mod+mod)%mod;
	}
	printf("%lld\n",(ans*a(m,n))%mod);
}

Measured memory_bytes: 11568
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, q, top;
long long s[MAXN], t[MAXN];
long long cnt[MAXN];
int main() {
	read(n), read(q);
	s[top = 1] = n;
	for (int i = 1; i <= q; i++) {
		long long x; read(x);
		while (top && s[top] >= x) top--;
		s[++top] = x;
	}
	t[top] = 1;
	for (int i = top; i >= 2; i--) {
		long long k = s[i];
		while (k >= s[1]) {
			int l = 1, r = i - 1;
			while (l < r) {
				int mid = (l + r + 1) / 2;
				if (s[mid] <= k) l = mid;
				else r = mid - 1;
			}
			t[l] += k / s[l] * t[i];
			k %= s[l];
		}
		cnt[k] += t[i];
		t[top] = 0;
	}
	cnt[s[1]] += t[1];
	for (int i = n; i >= 1; i--)
		cnt[i] += cnt[i + 1];
	for (int i = 1; i <= n; i++)
		printf("%lld\n", cnt[i]);
	return 0;
}

Measured memory_bytes: 4096
/*
 * count.cpp
 *
 *  Created on: 2019/05/17
 *      Author: MEIP-users
 */

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <ctype.h>
#include <bits/stdc++.h>

using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(){

	int a,b;
	cin>>a>>b;
	if(a>=13){
		cout<<b<<endl;
	}else if(a>=6){
		b=b/2;
		cout<<b<<endl;
	}else{
		cout<<'0'<<endl;
	}

	return 0;

}


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

int main() {
    int n, k, num = 1;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        if (2 * num < num + k) {
            num *= 2;
        } else {
            num += k;
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

t=UnionFind(n)

for _ in range(m):
    a,b=map(int,input().split())
    
    t.union(a-1,b-1)
ans=0
for i in range(n):
    ans=max(ans,t.size(i))

print(ans)

Measured memory_bytes: 76724
import sys
input=sys.stdin.readline
import time
import random
from bisect import bisect_left


def query(p,q,d):
    b=bisect_left(play[p],d)
    bp=play[p][b-1]
    np=play[p][b+1]
    minus=((0+np-d)*(np-d+1)//2*c[p])-((np-bp+d-bp)*(d-np)//2*c[p])
    b=bisect_left(play[q],d)
    bp=play[q][b-1] if b!=0 else 0
    np=play[q][b+1] if b!=len(play[q])-1 else 366
    plus=((np-bp+d-bp)*(d-np)//2*c[q])-((0+np-d)*(np-d+1)//2*c[q])
    if plus-minus>0:
        play[p].remove(d)
        play[q].append(d)
        play[q].sort()
        t[d]=q
start=time.time()
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
t=[random.randrange(26) for i in range(D)]
play=[[-1]*D for i in range(26)]
for i in range(D):
    play[t[i]].append(i)
for i in range(26):
    play[i].append(366)
while(True):
    if time.time()-start>1.70:
        break
    for i in range(D):
        if time.time()-start>1.70:
            break
        q=random.randrange(26)
        p=t[i]
        query(p,q,i)
for i in range(D):
    print(t[i]+1)

Measured memory_bytes: 81632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;

ll n,m,x,y,k,num[110],h,dp[25000],cnt,d2[25000],ans;

int main()
{
	ll i,j;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&num[i]);
	}
	sort(num+1,num+n+1);
	dp[0]=d2[0]=1;
	for(i=1;num[i]<k&&i<=n;i++)
	{
		num[i]=k-num[i];
		for(j=3000;j>=num[i];j--)
		{
			dp[j]+=dp[j-num[i]];
		}
	}
	for(;num[i]==k&&i<=n;i++) cnt++;
	for(;i<=n;i++)
	{
		num[i]-=k;
		for(j=3000;j>=num[i];j--)
		{
			d2[j]+=d2[j-num[i]];
		}
	}
	for(i=0;i<=3000;i++)
	{
		ans+=dp[i]*d2[i]*(1ll << cnt);
	}
	cout<<-1+ans;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;

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

  int res[4][3][10] = {};

  int b,f,r,v;
  for(int i = 0; i < n; i++){
    cin>>b>>f>>r>>v;
    res[b-1][f-1][r-1] += v;
  }

  for(int i = 0; i < 4; i++){
    for(int j=0; j < 3; j++){
      for(int k=0; k<10; k++){
        cout<<' '<<res[i][j][k];
      }
      cout<<endl;
    }
    if(i!=3) cout<<"####################"<<endl;
  }
}

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

int main(){
    string s;
    cin >> s;
    
    int n=s.size(), mod=1000000000+7;

    long long dp[100010][4]={};
    for (int i=n;i>=0; i--){
        for (int j=3; j>=0; j--){
            if (i==n){
                dp[i][j]=(j==3 ? 1:0);
            }
            else {
                dp[i][j]=dp[i+1][j]*(s[i]=='?' ? 3LL : 1LL);
                if (j<3 && (s[i]=='?' || s[i]=="ABC"[j])){
                    dp[i][j]+=dp[i+1][j+1];
                }
                dp[i][j]%=mod;
            }
        }
    }
    cout << dp[0][0] <<endl; 
}

Measured memory_bytes: 3584
#include<stdio.h>
int main(){

  int l,a,b,c,d,kn,sn,an,sn2,sn3;
  scanf("%d\n%d\n%d\n%d\n%d",&l,&a,&b,&c,&d);

  if(a%c==0){
    kn=a/c;
  }
  if(a%c!=0){
    kn=a/c+1;
  }
  if(b%d==0){
    sn=b/d;
  }
  if(b%d!=0){
    sn=b/d+1;
  }
  
  sn2=kn;
  sn3=sn;

  if(kn>=sn){
    printf("%d\n",l-kn);
  }
  if(kn<sn){
    printf("%d\n",l-sn);
  }
  
  return 0;
  
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(ll i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 998244353
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
ll fastPowMod(ll a, ll p,ll mod){ if(p==0) return 1; ll z = fastPowMod(a,p/2,mod); z = (z*z)%mod; if(p%2) z = (z*a)%mod; return z; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}


void solve()
{
    ll n,W;
    cin>>n>>W;
    vll w(n+1,0),v(n+1,0);
    srep(i,1,n) cin>>w[i]>>v[i];
    ll dp[n+1][W+1];
    set0(dp);
    srep(i,1,n)
    {
        srep(j,1,W)
        {
            if(w[i]<=j)
            {
                dp[i][j] = max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            
        }
        
    }
    cout<<dp[n][W];
}

int main()
{
    fastio;
    /*int t;
    cin>>t;
    
    rep(i,t)
    {*/
        solve();
        cout<<"\n";
    //}
    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <limits.h>

using namespace std;

int main(){
  int a,b,x;
  cin>>a>>b>>x;
  int num=INT_MAX;
  for(int i=0;i<21;i++){
    int d = x - i*1000;
    int cst = a*i;
    if(d>0){
      cst += ((d + 499)/500)*b;
    }
    if(num>cst){
      num = cst;
    }else{
      break;
    }
  }
  cout<<num<<endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef vector< pair< ll,ll > > ii;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) (c).begin() , (c).end()
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin >> n >> m;
    ll penalty = 0,ac=0;
    vector<int> v(n+1),mp(n+1);
    for(int i = 0;i<m;i++)
    {
        int x;
        string s;
        cin>>x>>s;
        if(v[x]==0)
        {
            if(s=="WA")
            {
                mp[x]++;
            }
            else
            {
                v[x] = 1;
                ac++;
                penalty += mp[x];
            }
        }
    }
    cout << ac << " " << penalty << endl;
    return 0;
}

Measured memory_bytes: 1024
#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>;

int main(){
    int n, x, t;
    cin >> n >> x >> t;

    int ans = 0;
    int cnt = 0;
    while(cnt<n){
        cnt += x;
        ans += t;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import groupby
from math import factorial

def comb(n,k):
    if(k<0 or n<k): return 0
    return factorial(n)//(factorial(k)*factorial(n-k))

def resolve():
    n,a,b=map(int,input().split())
    V=list(map(int,input().split()))
    V.sort(reverse=1)
    m=sum(V[:a])/a
    print(m)

    cnt=0
    for key,iter in groupby(V):
        k=len(list(iter))
        if(cnt+k>=a): break
        cnt+=k

    ans=0
    K=min(k,b-cnt)
    if(cnt==0):
        for i in range(a-cnt,K+1):
            ans+=comb(k,i)
    else:
        ans=comb(k,a-cnt)
    print(ans)
resolve()

Measured memory_bytes: 38640
n,l=map(int, input().split())
ans = 0
if l > 0:
    for i in range(n-1):
        ans += i+l+1
elif l + n > 0:
    for i in range(n):
        ans += i+l
else:
    for i in range(n-1):
        ans += i+l
print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int aMin = (int) Math.ceil(100 * a / (double) 8);
        int aMax = (int) Math.floor(100 * (a + 1) / (double) 8);
        int bMin = (int) Math.ceil(100 * b / (double) 10);
        int bMax = (int) Math.floor(100 * (b + 1) / (double) 10);
        int ans = -1;
        for (int i = aMin; i < aMax; i++) {
            for (int j = bMin; j < bMax; j++) {
                if (i == j) {
                    ans = i;
                    break;
                }
            }
            if (ans != -1) {
                break;
            }
        }
        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: 24916
#include <iostream>
using namespace std;

int n, a, cnt[100005], q, b, c;
long long ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        cnt[a]++;
        ans += a;
    }
    cin >> q;
    for (int i = 0; i < q; i++){
        cin >> b >> c;
        ans += (c-b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
int main(){
 int h,w;
  cin >> h >> w;
  vector<vector<int>> da(h,vector<int>(w,0));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> da[i][j];
    }
  }
  int co=0;
  vector<vector<int>> ans(250000);
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      if(da[i][j]%2==1){
        da[i][j]--;
        da[i][j+1]++;
        ans[co]={i+1,j+1,i+1,j+2};
        co++;
      }
    }
  }
  for(int i=0;i<h-1;i++){
    if(da[i][w-1]%2==1){
      da[i][w-1]--;
      da[i+1][w-1]++;
      ans[co]={i+1,w,i+2,w};
      co++;
    }
  }
  cout << co << endl;
  for(int i=0;i<co;i++){
    for(int j=0;j<3;j++){
      cout << ans[i][j] << ' ';
    }
    cout << ans[i][3] << endl;
  }
  /*for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cout << da[i][j] << ' ';
    cout << endl;
  }*/
}


Measured memory_bytes: 12928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String string = scanner.next();
		if (string.length() % 2 != 0) {
			System.out.println("No");
			return;
		}
		for (int i = 0; i < string.length(); i++) {
			if (i % 2 == 0) {
				if (string.charAt(i) != 'h') {
					System.out.println("No");
					return;
				}
			} else {
				if (string.charAt(i) != 'i') {
					System.out.println("No");
					return;
				}
			}

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

	}

}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b;
  cin >> a >> b;

  cout << max(0LL,a-2*b) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, D;
    int x, y;
    size_t DD, xx, yy;

    cin >> N >> D;
    DD = static_cast<size_t>(D);

    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        cin >> x >> y;

        if (x >= 0) { xx = static_cast<size_t>(x); }
        else { xx = static_cast<size_t>(-x); }

        if (y >= 0) { yy = static_cast<size_t>(y); }
        else { yy = static_cast<size_t>(-y); }

        if (xx * xx + yy * yy <= DD * DD)
        {
            ++count;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a , b;
	cin >> a;
	cin >> b;
	for(int i = 0;i < a.size();i++){
		if(a.at(i) != b.at(i)){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;		
}
			


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

using namespace std;

const bool IsMonth(const int &month)
{
    return 1 <= month && month <= 12;
}


int main()
{
    int S;
    cin >> S;
    int upper = S / 100;
    int lower = S % 100;
    const bool upperMonth = IsMonth(upper);
    const bool lowerMonth = IsMonth(lower);

    if (upperMonth)
    {
        if (lowerMonth)
        {
            cout << "AMBIGUOUS";
        }
        else
        {
            cout << "MMYY";
        }
    }
    else if (lowerMonth)
    {
        cout << "YYMM";
    }
    else
    {
        cout << "NA";
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
int n, k,sum;
signed main() {
	cin >> n >> k;
	if (k % 2 == 1) {
		cout << (n / k)*(n / k)*(n / k) << endl;
	}
	else {
		sum = k / 2;
		cout << (n / k)*(n/k)*(n/k) + (((n + sum) / k))*(((n + sum) / k))*(((n + sum) / k)) << endl;
	}
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll gcdd(int a, int b) {
  if(a % b == 0) return b;
  else return gcdd(b, a % b);
}

ll lcmm(int a, int b) {
  return a / gcdd(a, b) * b;
}

signed main() {
	ll n, t, result = 1;
  cin >> n;
  rep(i, n) {
    cin >> t;
    result = lcmm(result, t);
  }
  cout << result << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin >> str;
  if(str[0]==str[1] ||str[1]==str[2] ||str[2]==str[3]){
    cout << "Bad" <<endl;
  }
  else{
    cout << "Good" <<endl;
  }
  
 return 0; 
}

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

int main(){
	char N[4];
	int index = 0, yes = 1;
	while(index < 4){
		scanf("%d", &N[index]);
		if(N[index] == 1 || N[index] == 9 || N[index] == 7 || N[index] == 4){
			if(index != 0){
				int index2 = 0;
				while(index2 < index){
					if(N[index2] == N[index]){
						yes = 0;
						break;
					}
					index2++;
				}	
			}
		} else{
			yes = 0;
			break;
		}
		index++;	
	}	
	if(yes == 1){
		printf("YES\n");
	} else{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	ll n; cin >> n;
	map<ll,int> dic;
	for(ll i=2; ; i++){
		if(n == 1) break;
		if(i*i > n){
			dic[n] = 1;
			break;
		}
		if(n%i == 0){
			int c=0;
			while(n%i == 0){
				n /= i;
				c++;
			}
			dic[i] = c;
		}
	}
	int ans = 0;
	for(auto [v,c]: dic){
		int k;
		for(k=1; k*(k+1)/2 <= c; k++);
		
		ans += k-1;
	}
	cout << ans << endl;
}

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

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double E=2.718281828459045;
const double eps=1e-3;
const int INF=0x3f3f3f3f;
const int MOD=1e8+7;
const int N=1e4+5;
const ll maxn=1e6+5;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};
int main()
{
    ll n,k;
    while(cin>>n>>k)
    {
        ll ans=0;
        rep(p,k+1,n+1)
        {
            ans=ans+(n/p)*(p-k);///根据对p取模得到
            ll t=n%p+1-k;
            if(t>0) ans+=t;/// 样例1
            //cout<<"ans="<<ans<<endl;
        }
        if(!k) ans-=n;
        cout<<ans<<endl;
    }
    return 0;
}

/***
5 2
10 0
31415 9265
*/


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

using namespace std;

int main()
{
    int n,m;
    float sum=0;
    cin>>n>>m;
    int vote[100];
    for(int i=0;i<n;i++){
        scanf("%d",&vote[i]);
        sum+=vote[i];
    }
    sort(vote,vote+n);
    int flag=0;
    for(int i=n-1;i>=n-m;i--){
        if(vote[i]<sum/(4*m)){
           flag=1;
           break;
           }
    }
    if(flag==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

previous = -1
score = 0

for i in range(N):
    score += B[A[i]-1]
    if i >= 1 and A[i] == previous + 1:
        score += C[previous-1]
    previous = A[i]

print(score)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
#define mk make_pair
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef double db;
const int N = 100005, mod = 1000000007;
int p[4], a[N][4], n, c[N], mp, mq, mr;
ll ans;
priority_queue< pair<ll, int> > w[4][4];
void add(int i, int j) {
	int i0 = i;
	Rep(k, 1, 3) if (j != k) {
		w[j][k].push( mk((ll)a[i][k] - a[i][j], i0) );
	}
}
int main()
{
	Rep(i, 1, 3) scanf ("%d", &p[i]), n += p[i];
	Rep(i, 1, n) {
		int mx = 0;
		Rep(j, 1, 3) scanf ("%d", &a[i][j]), mx = max(a[i][j], mx);
		Rep(j, 1, 3) if (a[i][j] == mx) {
			c[i] = j;
			p[j] --;
			ans += mx;
			add(i, j);
			break ;
		}
	}
	while (1) {
		// cout << p[1]<<" "<<p[2]<<" "<<p[3]<<" "<<ans<<endl;
		Rep(i, 1, 3) 
			Rep(j, 1, 3) {
				while (!w[j][i].empty() && c[ w[j][i].top().sd ] != j) w[j][i].pop();
			}
		bool fl = 1;
		ll mx = -(1ll << 60);
		Rep(i, 1, 3) if (p[i] > 0) {
			fl = 0;
			Rep(j, 1, 3) if (i != j && !w[j][i].empty()) {
				if (p[j] < 0) {
					if (w[j][i].top().fr > mx) {
						mx = w[j][i].top().fr;
						mp = i, mq = j; mr = 0;
					}
				}
				Rep(k, 1, 3) if (i != j && j != k && p[k] < 0 && !w[k][j].empty()) {
					if (w[j][i].top().fr + w[k][j].top().fr > mx) {
						mx = w[j][i].top().fr + w[k][j].top().fr;
						mp = i, mq = j, mr = k;
					}
				}
			}
			break ;
		}
		if (fl) break ;
		ans += mx;
		if (mr) {
			int x = w[mr][mq].top().sd;
			c[x] = mq; p[mr] ++; p[mq] --;
			add(x, mq);
		}
		int x = w[mq][mp].top().sd;
		c[x] = mp; p[mq] ++; p[mp] --;
		add(x, mp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10980
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, m;
	cin >> n;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	cin >> m;
	vint b(m);
	rep(i, m) {
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	bool ans = true;
	int cnt = 0;
	rep(i, m) {
		for (cnt;cnt < n;cnt++) {
			if (a[cnt] == b[i]) {
				cnt++;
				break;
			}
			if (cnt == n - 1) {
				ans = false;
			}
		}
	}
	YES(ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N, K; cin >>N>>K;
    vector<ll> P(N); cin >> P;
    vector<ll> s(N);
    rep(i, N) {
        s[i] = (i == 0 ? 0 : s[i-1]) + P[i];
    }
// cout_h(s);
    ll ma = 0;
    rep(i, N-K+1) {
        ll sumk = s[i+K-1] - (i==0 ? 0 : s[i-1]); //D1(sumk);
        chmax(ma, sumk);
    }
    double ans = (ma + K) / 2.0;

    cout<<std::fixed<<std::setprecision(10);
    cout << ans << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll m, n;
    cin >> n >> m;
    ll arr[n];
    ld sum = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    sum /= ((ld)4 * (ld)m);
    ll count = 0;
    for (ll i = 0; i < n; i++)
    {
        if (arr[i] >= sum)
        {
            count++;
        }
    }
    if (count >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

int main()
{
	int n;
	cin>>n;
	long long int ans=0;
	long long int a;
	for(int i=0;i<n;i++)
	{
	    cin>>a;
	    ans+=(a-1);
	}
	cout<<ans<<'\n';
return 0;
}


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

int top,S[1000];

void push(int x);
int pop();

int main(){
	top = 0;
	int a,b;
	char c;
	
	while(scanf("%s",&c) != EOF){
		switch(c){
			case '+':
				b = pop();
				a = pop();
				push(a + b);
				break;
			case '-':
				b = pop();
				a = pop();
				push(a - b);
				break;
			case '*':
				b = pop();
				a = pop();
				push(a * b);
				break;
			default:
				push(atoi(&c));
				break;
			}
		}
		
		cout << pop() << endl;
}

void push(int x){
	++top;
	S[top] = x;
}

int pop(){
	--top;
	return S[top + 1];
}

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


int main()
{
	int n, k;
	cin >> n >> k;
	vector<double> px(n);
	for (int i = 0; i < n; i++) {
		double p_in;
		cin >> p_in;
		double px_in = (1 + p_in) / 2;
		px.at(i) = px_in;
	}

	double ans = 0;
	double sum = 0;
	for (int i = 0; i <= k - 1; i++) {
		sum += px.at(i);
		ans = sum;
	}

	if (n != k) {
		for (int i = 1; i <= n - k; i++) {
			sum = sum - px.at(i - 1) + px.at(i + k - 1);
			ans = max(ans, sum);
		}
	}

	cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    string s;
    cin >> s;
    bool f = 0;

    for(int i = 0;i < 7; ++i){
        if(i == 0){
            if(s.at(i) < '2')break;
        }
        if(i == 2){
            if(s.at(i) < '1')break;
        }
        if(i == 3){
            if(s.at(i) < '9')break;
        }
        if(i == 5){
            if(s.at(i) == '1')f = 1;
        }if(i == 6){
            if(s.at(i) > '4')f = 1;
        }
    }

    if(f)cout << "TBD" << endl;
    else cout << "Heisei" << endl;

}

Measured memory_bytes: 256