akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>

long long seq[100005];
long long pre[100005];
int main(){
    int t,q;
    std::cin >> t >> q;
    std::string str;
    std::cin >> str;
    for(int i = 1; i < str.length(); ++ i){
        if (str[i - 1] == 'A' && str[i] == 'C'){
            seq[i + 1]++;
            seq[i] ++;
        }
    }
    for(int i = 1; i <= str.length(); i ++){
        pre[i] = pre[i - 1] + seq[i];
    }
    for(int i = 1; i <= q;  i ++){
        int l, r;
        std::cin >> l >> r;
        long long tmp = pre[r] - pre[l - 1];
        if (l - 2 > 0 && str[l - 2] == 'A' && str[l - 1] == 'C') tmp--;
        if (r < str.length() && str[r - 1] == 'A' && str[r] == 'C') tmp--;
        std::cout << tmp / 2 << std::endl;
    }
}


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

class Problem
{
private:
	// Variables
	int a;
	int b;
	
public:
	// Methods
	void input ()
	{
		cin >> a >> b;
	}
	
	void process ()
	{
		
	}
	
	void output ()
	{
		cout << ((a <= 8 && b <= 8) ? "Yay!" : ":(") << endl;
	}
};

int main ()
{
	Problem problem;
	problem.input();
	problem.process();
	problem.output();
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define bit(x,n) (x & (1<<(n)))
#define EPS 1e-8
#define all(x) (x).begin(),(x).end()
#define INF 0x3f3f3f3f3f3f3f
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<long long, long long> > vll;
typedef long double LD;

ii DR8[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
ii DR4[] = {{-1,0},{0,-1},{0,1},{1,0}};

const ll mod = 998244353;

// ll nop = 2;
// vi primes(nop+1,1);

// void sieve(){
//     primes[1] = primes[0] = 0;
//     for(ll i = 2;i * i <= nop;i++){
//         if(primes[i]){
//             for(ll j = i*i; j <= nop;j+=i){
//                 primes[j] = 0;
//             }
//         }
//     }
// }

// ll phi(ll n) {
//     ll tot = n;
//     for(ll i = 2;i*i <= n;i++) {
//         if(n%i == 0) {
//             tot -= tot/i;
//         }
//         while(n%i == 0) {
//             n /= i;
//         }
//     }
//     if(n > 1) {
//         tot -= tot/n;
//     }
//     return tot;
// }

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

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

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

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans *num)%mod;
        }
        num *= num;
        num %= mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    a %= mod;
    return mexp(a,mod-2);
}

void solve() {
    int k;
    cin>>k;
    if(k >= 30) deb1("Yes")
    else deb1("No")
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


Measured memory_bytes: 3660
def cc
    s = gets.chomp
    l = s.length

    if l == 1
        puts 0
        exit
    end

    ss = s.split(//).uniq
    if ss.length == 1
        puts l/2
        exit
    end

#    puts s
    cnt = 0
    for i in 2..l
        if s[i-2] == s[i-1]
            s[i-1] = (1 - s[i-1].to_i).to_s
            cnt += 1
        end
    end
#    puts s

    puts cnt
end

cc

Measured memory_bytes: 9596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin >> s;
	rep(i, 3) {
		if (s[i] == '1') {
			s[i] = '9';
		}
		else if (s[i] == '9') s[i] = '1';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
int main() {

	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++)
		cin >> v[i];

	int ans = 0;
	bool check = true;
	while (check) {

		for (int i = 0; i < N; i++) {
			if (v[i] % 2 == 1) {
				check = false;
				break;
			}
			else {
				v[i] /= 2;
			}
		}
		if(check)
			ans++;
	}
	cout << ans << endl;
	//cin >> N;


	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 1009; i++) {
        int c, d;
        c = i * 0.08;
        d = i * 0.10;
        if (c == a && d == b) {
            cout << i << endl;
            break;
        }
        if (i == 1009 && c != a && d != b) {
            cout << -1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define ed "\n";

int main(){
    int n,l;
    cin >> n >> l;
    if(l*(l+n-1)<=0) {cout << ((l+ n+l-1)*n)/2 << ed; return 0;}
    if(l>0) {cout << ((l+ n+l-1)*n)/2-l << ed; }
    else{ cout << ((l+ n+l-1)*n)/2-(n+l-1) <<ed;}
    return 0;
}

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

int main() {
  ll N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<vector<int>> A(N,vector<int>(M));

  for (int i=0; i<M; i++) {
    int b;
    cin >> b;
    B.at(i)=b;
  }

  for (int i=0; i<N; i++) {
    for (int j=0; j<M; j++) {
      int a;
      cin >> a;
      A.at(i).at(j) =a;
    }
  }
  int ans = 0;

  for (int i=0; i<N; i++) {
    int s = 0;
    for (int j=0; j<M; j++) {
      s += B.at(j) * A.at(i).at(j);
    }
    s += C;
    if (s > 0) {
      ans++;
    }
  }
  cout << ans << endl;
} 

Measured memory_bytes: 256
#include <cstdio>

int main(int argc, char *argv[]) {
	using namespace std;
	
	int rcv;
	
	while (EOF != fscanf(stdin, "%d", &rcv)) {
		int cnt = 0;
		for (int a = 0; a < 10; a++) {
			for (int b = 0; b < 10; b++) {
				for (int c = 0; c < 10; c++) {
					for (int d = 0; d < 10; d++) {
						if (a+b+c+d == rcv)
							cnt++;
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

#define INFTY 1000000001
#define MAX 500000

void mergeSort(int*,int,int);
void merge(int *,int,int,int);

int count;

int main(){
  int n,S[MAX],i;

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

  mergeSort(S,0,n);

  for(i=0;i<n-1;i++)
    printf("%d ",S[i]);

  printf("%d\n",S[i]);
  
  printf("%d\n",count);

  return 0;
}

void merge(int*A, int left,int mid,int right){
  int n1,n2,k,i,j;
  
  n1 = mid - left;
  n2 = right - mid;
  
  int L[n1],R[n2];
  
  for (i=0;i<n1;i++)
    L[i] = A[left + i];
  
  for (i=0;i<n2;i++)
    R[i] = A[mid + i];
  
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for (k=left;k<right;k++)
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      count++;
    }
    else {
      A[k] = R[j];
      j = j + 1;
      count++;
    }
}

void mergeSort(int *A, int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}



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

int calc(int size, int buf[]) {
	stack<P>st;
	int Max = 0;
	buf[size] = 0;
	rep(i, size + 1) {
		P p;
		p.first = buf[i]; p.second = i;
		if (st.empty())st.push(p);
		else {
			if (st.top().first < p.first)st.push(p);
			if (st.top().first > p.first) {
				while (!st.empty() && st.top().first >= p.first) {
					Max = max(Max, st.top().first*(i - st.top().second));
					p.second = st.top().second;
					st.pop();
				}
				st.push(p);
			}
		}
	}
	return Max;
}
char buf[700][700];
int T[700][700];
int main() {
	int h, w;
	while (scanf("%d%d", &h, &w), h) {
		rep(i, h)scanf("%s", buf[i]);
		rep(j, w)rep(i, h) {
			if (buf[i][j] == '*')T[i][j] = 0;
			else T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1;
		}
		int Max = 0;
		rep(i, h)Max = max(Max, calc(w, T[i]));
		printf("%d\n", Max);
	}
}

Measured memory_bytes: 4912
import java.util.*;
import java.lang.*;

// 10 3
// 4 5 6
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(solve(inputStr(sc, " "), inputStr(sc, " ")));
        // System.out.println(solve(inputStr(sc, " "), inputStr(sc, " ")) ? "Yes" :
        // "No");
    }

    /**
     * 指定された区切り文字で区切られた１行の文字列を、文字列配列にして返します。
     */
    private static String[] inputStr(Scanner sc, String... delimiter) {
        return sc.nextLine().split(delimiter == null ? " " : delimiter[0]);
    }

    private static Long[] convertStrToInt(String[] strArray) {
        return Arrays.stream(strArray).map(e -> new Long(Long.parseLong(e))).toArray(Long[]::new);
    }

    private static long solve(String[]... inputs) {
        Long[] firstArr = convertStrToInt(inputs[0]);
        long n = firstArr[0];
        long k = firstArr[1];
        Long[] secondArr = convertStrToInt(inputs[1]);
        return Arrays.stream(secondArr).sorted(Comparator.reverseOrder()).skip(k).reduce((long) 0, (sum, e) -> sum += e);
    }
}


Measured memory_bytes: 85820
(defun solve (str)
  (let* ((len (floor (length str) 2))
         (a (subseq str 0 len))
         (b (subseq (reverse str) 0 len)))
    (loop
       :for i :from 0 :to (1- (length a))
       :when (not (char= (aref a i) (aref b i)))
       :sum 1)))

(defun main ()
  (let ((s (read-line)))
    (format t "~A~%" (solve s))))

(main)


Measured memory_bytes: 8036
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
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; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
signed main(){
  int n;cin>>n;
  cout<<(n-1)/2<<endl;
  return 0;
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	a, b, t := oneInt(), oneInt(), oneInt()

	ans := int(math.Floor((float64(t)+0.5)/float64(a))) * b
	fmt.Println(ans)

}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


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

signed main(){
	int n,a[200010],ki = 0,gu = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(a[i] % 2) ki++;
		else gu++;
	}
	if(ki == n || gu == n) cout << 0 << endl;
	else{
		if(ki % 2) cout << n - 1 << endl;
		else cout << n - 2 << endl;
	}
}


Measured memory_bytes: 3840
from math import factorial

def comb(n, r):
	return factorial(n) // factorial(r) // factorial(n - r)

#print(comb(3, 1))

n, p = map(int, input().split())
b = list(map(int, input().split()))
a = [b[i] % 2 for i in range(n)]
zero = a.count(0)
one = n - zero


if p == 0:
	if one == 0:
		print(2 ** zero)
	else:
		num = 1
		for i in range(2, one + 1, 2):
			num += comb(one, i)
		print(num * (2 ** zero))

else:
	if one == 0:
		print(0)
	else:
		num = 0
		for i in range(1, one + 1, 2):
			num += comb(one, i)
		print(num * (2 ** zero))


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

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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

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

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

int main(){
  ll a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  
}


Measured memory_bytes: 256
n, k  = map(int, input().split())
As  = list(map(int, input().split()))


Aset = set(As)
As_tmp = [a for a in As]
from collections import defaultdict
d = defaultdict(int)

# # 自分より小さい数は何個あるか
# for a_set in sorted(Aset):
#     cnt = 0
#     for a in As_tmp:
#         if a_set > a:
#             cnt += 1
#     d[a_set] = cnt


# 1個目転倒数はいくつ？(初項)
cnt = 0
for i,ai in enumerate(As):
    for aj in As[i:]:
        # print(bi,bj)
        if ai > aj:
            cnt += 1 
# 最大の転倒数は、最大値を引いたもの(階差)
sumA = 0
rA = sorted(As,reverse=True)
for i,ai in enumerate(rA):
    for aj in rA[i:]:
        if ai > aj:
            sumA += 1 
# print("sum",sumA,"cnt",cnt) 
mod = 10**9 + 7     
ans = sumA*(k-1)*k//2 + cnt*k
print(ans%mod)

Measured memory_bytes: 3444
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define rep(i,n) for(int i = 0;i<(int)(n);i++);
using namespace std;
using ll = long long;
const ll INF = 100100100100100;

ll two(ll a) {//何回2で割れるか　２以上は変わらないので２にする
	ll cnt = 0;
	while (true) {
		if (a % 2 == 0) {
			a /= 2;
			cnt++;
		}
		else break;
	}
	if (cnt >= 2) return 2;
	else return cnt;
}
int main() {
	ll A, B;
	cin >> A >> B;
	if (A >= 2 * B) cout << A - 2 * B << endl;
	else cout << "0" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int N = s.size();
  bool f = true;

  rep(i, N) {
    if(s[i] != s[N-1-i]) {
      f = false;
    }
  }

  rep(i, (N-1)/2) {
    if(s[i] != s[(N-1)/2 - 1 - i]) {
      f = false;
    }
  }

  rep(i, N-(N+3)/2+1) {
    if(s[(N+3)/2-1+i] != s[N-1-i]) {
      f = false;
    }
  }

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

  return 0;
}

Measured memory_bytes: 3588
W, H, N = map(int, input().split())

lst = [[0] * W for _ in range(H)]
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for i in range(x):
            for j in range(H):
                lst[j][i] = 1
    elif a == 2:
        for i in range(x, W):
            for j in range(H):
                lst[j][i] = 1
    elif a == 3:
        for i in range(W):
            for j in range(y):
                lst[H - 1 - j][i] = 1
    elif a == 4:
        for i in range(W):
            for j in range(y, H):
                lst[H - 1 - j][i] = 1

ans = 0
for i in lst:
    ans += i.count(0)
    # print (i)
print (ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define speed  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);                    
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
#define ff first
#define ss second
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
int main()
{
   speed;
    ll t;
 //  cin>>t;
   t=1;
   while(t--)
   {   
     string s;
     cin>>s;
     ll n;
     n=s.length();
     ll pot=1;
     ll suf=0;
     vector<int>cnt(2019,0);//if(modulos of two suffixes with 2019  are equal then diff must be divisible by 2019)
     cnt[0]++;
     ll ans=0;
     for(ll i=n-1;i>=0;i--)
     {
          ll d=s[i]-'0';
           suf=(suf+d*pot)%2019;
           pot=(pot*10)%2019;
           ans=ans+cnt[suf];
           cnt[suf]++;

      }
      cout<<ans<<endl;
      
     
          

        
         
         

    }
       

     
     
   






}

Measured memory_bytes: 3724
n, k = map(int, input().split())
w = [int(input()) for i in range(n)]
l = max(w)
r = sum(w)

while l < r:
    m = (l + r) // 2
    stack = car = 0
    for i in w:
        stack += i
        if stack > m:
            stack = i
            car += 1
    if car < k:
        r = m
    else:
        l = m + 1
print(l)

Measured memory_bytes: 11144
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vl = vector<ll>;
using vpll = vector<pair<ll,ll>>;

int main() {
    bool flag1,flag2;
    ll N,M,count=0;
    cin>>N>>M;
    vl path(N);
    vpll path_list(M);
    rep(i,N){
        path[i]=i;
    }
    rep(i,M){
        cin>>path_list[i].first>>path_list[i].second;

    }
do{ 
    if(path[0]!=0){
        break;
    }
    
    flag1 = true;
    rep(i,N-1){
    flag2 = false;
    if(path[i]>path[i+1]){
        rep(j,M){
            if((path_list[j].second == path[i]+1)&&(path_list[j].first == path[i+1]+1)){
                flag2=true;
            }
        }

    }
    else{
        rep(j,M){
            if((path_list[j].first == path[i]+1)&&(path_list[j].second == path[i+1]+1)){
                flag2=true;
            }
    }
    
    }
    if(!flag2){
        flag1 = false;
        break;
    }
    
    }



if(flag1){
    count++;
}



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

cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  int64_t N;
  cin >> N;
  cout << N*(N-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
A, B, K = (int(x) for x in input().split(' '))

if A-K < 0:
  #まずBを計算
  B = B-(K-A) if (B-(K-A)) >= 0 else 0
  #続いてAを計算
  A = 0
else:
  A -= K  

print(A,B)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
inline long long myabs(long long x){return x<0?-x:x;}
int n,m;
vector<int>G[100010];
int dep[100010];
long long b[100010];
long long a[100010];
int par[100010];
int tot;
long long ans;
int u,v;
void prework(int x,int p)
{
	par[x]=p;
	b[x]=(dep[x]&1)?1:-1;
	for(int i=0;i<(int)G[x].size();i++)
	{
		int y=G[x][i];
		if(y==p)continue;
		if(dep[y])
		{
			if(dep[y]<dep[x])u=x,v=y;
			continue;
		}
		dep[y]=dep[x]+1;
		prework(y,x);
		b[x]+=b[y];
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dep[1]=1;
	prework(1,0);
	if(n-1==m)
	{
		if(b[1]!=0)
		{
			printf("-1");
			return 0;
		}
		for(int i=1;i<=n;i++)ans+=myabs(b[i]);
	}
	else
	{
		if((dep[u]-dep[v])%2==0)
		{
			if(b[1]%2!=0)
			{
				printf("-1");
				return 0;
			}
			long long t=b[1]/2;
			while(u)b[u]-=t,u=par[u];
			while(v)b[v]-=t,v=par[v];
			ans=myabs(t);
			for(int i=1;i<=n;i++)ans+=myabs(b[i]);
		}
		else
		{
			if(b[1]!=0)
			{
				printf("-1");
				return 0;
			}
			while(u!=v)
			{
				a[++tot]=b[u];
				dep[u]=0;
				u=par[u];
			}
			sort(a+1,a+tot+1);
			long long x=a[(tot+1)/2];
			ans=myabs(x);
			for(int i=1;i<=tot;i++)ans+=myabs(a[i]-x);
			for(int i=1;i<=n;i++)if(dep[i])ans+=myabs(b[i]);
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 15872
#include <map>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

string s;
map<char, int> M;

void init() {
    string A("AIDUNYAN");
    for (int i = 0; i < 8; i++) {
        M[ A[i] ]++;
    }
}

bool check(int i) {
    map<char, int> m;
    for (int j = i; j < i + 8; j++) {
        m[ s[j] ]++;
    }
    return m == M;
}

int main() {
    init();
    cin >> s;
    ostringstream os;
    for (int i = 0; i < s.size(); i++) {
        if (check(i)) {
            os << "AIZUNYAN";
            i += 7;
        } else {
            os << s[i];
        }
    }
    cout << os.str() << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int x, n;
    scanf("%d%d", &x, &n);
    set<int> z;
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        z.insert(tmp);
    }
    for (i = 0; i < 1000; i++) {
        int tmp=x-i;
        if (z.find(tmp) == z.end()) {
            printf("%d\n", tmp); return;
        }

        tmp = x + i;
        if (z.find(tmp) == z.end()) {
            printf("%d\n", tmp); return;
        }
    }


    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}





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

int F[102][102];

void setblock(int c, int d, int x, int y){
  if(d==0){
    for(int i=0;i<4;i++){
      F[y][x+i]=c;
      F[y+1][x+i]=c;
    }
  }else{
    for(int i=0;i<4;i++){
      F[y+i][x]=c;
      F[y+i][x+1]=c;
    }
  }

}

void DFS(int Y, int X, int c){
  if(F[Y][X]!=c)
    return;

  F[Y][X] = 6;

  DFS(Y-1, X  ,c);
  DFS(Y  , X+1,c);
  DFS(Y+1, X  ,c);
  DFS(Y  , X-1,c);
}

int main(){
  int w,h,xs,ys,xg,yg,n;
  while(true){
  cin >> w >> h;
  for(int i=0;i<h;i++){
   for(int k=0;k<w;k++){
     F[i][k]=-1;
   }
  }
  if(w==0&&h==0){
    break;
  }
  cin >> xs >> ys;
  cin >> xg >> yg;
  cin >> n;
  for(int i=0; i<n; i++){
    int c,d,x,y;
    cin >> c >> d >> x >> y;
    setblock(c,d,x,y);
  }

  DFS(ys,xs,F[ys][xs]);
  if(F[yg][xg]==6){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std; 
int n;
int a[200010];
long long ans;
int nw;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(nw<=a[i])nw=a[i];
		else{
			ans+=nw-a[i];
		}
	}
	cout<<ans<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 4372
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	char s[n+1];
	scanf("%s",s);
	int a=0;
	for(int i=0;i<n-2;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
		{
			a++;
			i+=2;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Edge {
    ll to, cost;
};

// 特定のルートまでに閉路があるか調べたいならこう
// https://atcoder.jp/contests/abc061/submissions/12926139
// https://atcoder.jp/contests/abc137/submissions/13373201
vector<ll> bellman_ford(int n, int s, vector<vector<Edge> > &graph) { // nは頂点数、sは開始頂点
    vector<ll> dist(n, INF);
    dist[s] = 0; // 開始点の距離は0
    for (int i = 0; i < n; i++) {
        for (int v = 0; v < n; v++) {
            for (int k = 0; k < graph[v].size(); k++) {
                Edge e = graph[v][k];
                if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
                    dist[e.to] = dist[v] + e.cost;
                }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int v = 0; v < n; v++) {
            for (int k = 0; k < graph[v].size(); k++) {
                Edge e = graph[v][k];
                if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
                    dist[e.to] = -INF;
                }
            }
        }
    }

    return dist;
}


int main() {
    int n, m;
    cin >> n >> m;
    struct E {
        int from, to;
        ll cost;
    };
    vector<E> v(m);
    for (E &e : v) cin >> e.from >> e.to >> e.cost, e.from--, e.to--;

    vector<vector<Edge>> g(n);
    for (E e : v) g[e.from].push_back(Edge{e.to, -e.cost});

    vector<ll> a1 = bellman_ford(n, 0, g);
    if (a1.back() <= -INF) {
        cout << "inf" << endl;
    } else {
        cout << -a1.back() << endl;

    }

}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
const int inf = 1e9;
int main() {
    int d;
    ll g;
    scanf("%d %lld", &d, &g);

    vector<ll> p(d), c(d);
    rep(i, d) scanf("%lld%lld", &p[i], &c[i]);

    ll res = inf;

    // 全完するかしないかの2とおりをd乗（問題数分）繰り返す
    for (int bit = 0; bit < (1 << d); ++bit) {
        ll point = 0;
        ll num = 0;
        rep(i, d) {

            // 1が立ってれば（その問題を全完する場合）
            if (bit & (1 << i)) {

                // 合計ポイント加算
                point += c[i] + p[i] * 100 * (i + 1);
                // 問題を解いた数。全完した場合なので++ではなくp[i]
                num += p[i];
            }
        }

        // 全完だけで目標をクリアした場合、一番少ない特典を取得
        if (point >= g) {
            res = min(res, num);
        }

        // 全完だけではクリアできなかった場合
        else {
            for (int i = d - 1; i >= 0; --i) {

                // その問題を全完してる場合次のループ
                if (bit & (1 << i)) continue;

                // 全完してなかったら目標を超えるまで、その問題がある限り、その問題を解く
                for (int j = 0; j < p[i]; ++j) {
                    if (point >= g) break;
                    point += 100 * (i + 1);
                    ++num;
                }
            }

            res = min(res, num);
        }
    }
    
    printf("%lld", res);
    return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll dp[105][2][5];
string n;
ll k;

ll rec(ll digit,ll tight,ll num){
    if(num>k)return 0;
    if(digit == n.length()){
        if(num==k)return 1;
        else return 0;
    }
    ll x = n[digit]-'0';
    ll r = tight?x:9;
    ll &res = dp[digit][tight][num];
    if(res!=-1)return res;
    res = 0;
    for(ll i=0;i<=r;i++){
        ll ans = 0;
        if(i!=0)ans=1;
        res+=rec(digit+1,(tight==1) && (i==r),num+ans);
    }
    return res;
}

int main(void){
    for(ll i=0;i<105;i++){
        for(ll j=0;j<2;j++){
            for(ll l=0;l<5;l++){
                dp[i][j][l]=-1;
            }
        }
    }
    cin>>n>>k;
    cout<<rec(0,1,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1<<19,mod=924844033;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1)
			ans=1LL*ans*x%mod;
	return ans;
}
int n;
vector <int> e[N];
int size[N],tax[N];
void dfs(int x,int pre){
	size[x]=1;
	for (auto y : e[x])
		if (y!=pre){
			dfs(y,x);
			size[x]+=size[y];
		}
	tax[size[x]]++;
	tax[n-size[x]]++;
}
int w[N],R[N],A[N],B[N];
void FFT(int a[N],int n){
	for (int i=0;i<n;i++)
		if (R[i]<i)
			swap(a[i],a[R[i]]);
	for (int t=n>>1,d=1;d<n;d<<=1,t>>=1)
		for (int i=0;i<n;i+=(d<<1))
			for (int j=0;j<d;j++){
				int tmp=1LL*w[t*j]*a[i+j+d]%mod;
				a[i+j+d]=(a[i+j]-tmp+mod)%mod;
				a[i+j]=(a[i+j]+tmp)%mod;
			}
}
void Mul(){
	int m,d;
	for (d=0,m=1;m<n*2;m<<=1,d++);
	w[0]=1,w[1]=Pow(5,(mod-1)/m);
	for (int i=2;i<m;i++)
		w[i]=1LL*w[i-1]*w[1]%mod;
	for (int i=0;i<m;i++)
		R[i]=(R[i>>1]>>1)|((i&1)<<(d-1));
	FFT(A,m);
	FFT(B,m);
	for (int i=0;i<m;i++)
		A[i]=1LL*A[i]*B[i]%mod;
	w[1]=Pow(w[1],mod-2);
	for (int i=2;i<m;i++)
		w[i]=1LL*w[i-1]*w[1]%mod;
	FFT(A,m);
	int inv=Pow(m,mod-2);
	for (int i=0;i<m;i++)
		A[i]=1LL*A[i]*inv%mod;
}
int Fac[N],Inv[N];
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return 1LL*Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++)
		e[i].clear();
	for (int i=1;i<n;i++){
		int a=read(),b=read();
		e[a].push_back(b);
		e[b].push_back(a);
	}
	memset(tax,0,sizeof tax);
	dfs(1,0);
	Fac[0]=Inv[0]=1;
	for (int i=1;i<=n;i++){
		Fac[i]=1LL*Fac[i-1]*i%mod;
		Inv[i]=1LL*Inv[i-1]*Pow(i,mod-2)%mod;
	}
	for (int i=1;i<n;i++)
		A[i]=1LL*tax[i]*Fac[i]%mod;
	for (int i=0;i<=n;i++)
		B[i]=Inv[n-i];
	Mul();
	for (int i=1;i<=n;i++)
		A[i+n]=1LL*A[i+n]*Inv[i]%mod;
	for (int i=1;i<=n;i++)
		printf("%lld\n",(1LL*C(n,i)*n-A[i+n]+mod)%mod);
	return 0;
}

/*

C(n,k) - ΣC(size[son],k)   -   C(n-size[x],k)

多项式大小 小于子树size

问题变成了
ans_i = Σ C(a[j], i) = a[j]! / i! / (a[j]-i)! 
	  a[j] + (a[j]-i) = i

令 A[i] =  i! 
令 B[i] = 1/C[i-n] 
令 C[i] =  (-i)!  (i<=0)  
	    =  0	  (i>0)   

ans[i] = Σ A[j] * B[i-j]  

*/

Measured memory_bytes: 46464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    string s, ans = "";
    cin >> s;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'B') {
            if (ans.size() != 0) ans.pop_back();
        } else
            ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
def solve():
    N, T, S = map(int, input().split())
    a = [tuple(map(int, input().split())) for _ in [0]*N]
    dp = [float("-inf")]*(T+1)
    dp[0] = 0

    for fun, mise_time in a:
        for prev_time in range(T-mise_time, -1, -1):
            from_fun, to_fun = dp[prev_time], dp[prev_time+mise_time]
            new_time = prev_time + mise_time
            new_fun = fun + from_fun
            if prev_time < S < new_time:
                new_time = S + mise_time
                if new_time > T:
                    continue
                to_fun = dp[new_time]
            if new_fun > to_fun:
                dp[new_time] = new_fun

    print(max(dp))


if __name__ == "__main__":
    solve()

Measured memory_bytes: 8272
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define for_p(i, a, b) for(int i = a; i < b; i++)
#define for_m(i, a, b) for(int i = a - 1; i >= b; i--)

//a = s1.size();
//vector<string> s1;
//string s2 = accumulate( s1.begin(), s1.end(), string() );

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0;
  int i = 0, j = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  char s1[200000], s2[200000], s3[200000];
  
  cin >> a;
  
  
  cout << a * a * a << endl;
}
  


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min({a+b,b+c,c+a}) << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val X = listOfInt().mapIndexed { i, v -> IndexedValue(i, v) }.sortedBy { it.value }
    val P = IntArray(N); repeat(N) { n -> P[X[n].index] = n }
    val c = N / 2
    val ans = Array(N) { n -> X[if (P[n] < c) c else c - 1].value }
    println(ans.joinToString("\n"))
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }


Measured memory_bytes: 129448
import java.io.*;

class Main{

    public static void main(String[] args)throws IOException{
	final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	int[][] card=new int[4][];
	for(int i=0;i<4;i++) card[i]=new int[13];
	for(int i=0;i<4;i++){
	    for(int j=0;j<13;j++){
		card[i][j]=0;
	    }
	}
	
	
	String str=br.readLine();
	int n=Integer.parseInt(str);
	for(int i=0;i<n;i++){
	    String[] st=br.readLine().split(" ");
	    String mark=st[0];
	    int num=Integer.parseInt(st[1]);
	    if(mark.equals("S")) card[0][num-1]++;
	    else if(mark.equals("H")) card[1][num-1]++;
	    else if(mark.equals("C")) card[2][num-1]++;	
	    else if(mark.equals("D")) card[3][num-1]++;
	}
	for(int i=0;i<4;i++){
	    for(int j=0;j<13;j++){
		if(card[i][j]==0){
		    if(i==0) System.out.println("S " + (j+1));
		    else if(i==1) System.out.println("H " + (j+1));
		    else if(i==2) System.out.println("C " + (j+1));
		    else if(i==3) System.out.println("D " + (j+1));
		}
	    }
	}
    }
}
    

Measured memory_bytes: 16940
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define ull unsigned long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define cbn(x,y) ((ll)fac[x]*inv[y]%mod*inv[(x)-(y)]%mod)
#define mod 1000000007
#define N 1009
using namespace std;

int read(); ll readll();
int n,m,a[N],cbn[N][N],dp[N][N];
int main(){
	scanf("%d%d",&n,&m);
	int i,j,k;
	for (i=0; i<=n; i++)
		for (j=cbn[i][0]=1; j<=i; j++) cbn[i][j]=(cbn[i-1][j]+cbn[i-1][j-1])%mod;
	for (i=1; i<=m; i++) scanf("%d",&a[i]);
	dp[0][0]=1;
	for (i=1; i<=m; i++)
		for (j=0; j<=n; j++)
			for (k=0; k<=j; k++) if (a[i]>=j-k)
				ad(dp[i][j],(ll)dp[i-1][k]*cbn[n-k][j-k]%mod*cbn[n-(j-k)][a[i]-(j-k)]);
	printf("%d\n",dp[m][n]);
	return 0;
}


int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  set<int> ok;
  for (int i = 0; i < K; ++i) {
	int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int tmp;
      cin >> tmp;
      ok.insert(tmp);
    }
  }
  cout << N - ok.size() << '\n';
  return 0;
}

Measured memory_bytes: 3628
n, y=map(int, input().split())
a=y//10000
b=y//5000
c=y//1000
y/=1000
for i in range(c+1):
    for j in range(n+1-i):
        k=n-i-j
        if 0<=k and i + 5*j + 10*k == y:
            print(k, j, i)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3188
let n = Scanf.scanf " %d" (+) 0
let ab_s = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let f a b = if a mod b = 0 then 0 else (a + b - 1) / b * b - a
let _ = List.fold_left (fun c (a, b) -> c + f (a + c) b) 0 @@ List.rev ab_s |> Printf.printf "%d\n"

Measured memory_bytes: 10624
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    int n,m;
    cin >> n >> m;
    VI a(n);
    rep(i,m) cin >> a[i];
    int ans = n;
    rep(i,m) {
      n -= a[i];
      if(n < 0) {
        cout << -1 << endl;
        return 0;
      }
    }
    cout << n << endl;
}


Measured memory_bytes: 9600
<?php

    /* // 3????????°????????§?°???¢???????????????????????????????????¢??°
    function compare($a, $b, $c){

        if($a < $b && $b < $c){

            return true;

        }else if($a > $b){

            return "a > b";

        }else if($a == $b){

            return "a == b";
        }

    }

    // 2????????°????????\???
    $num = preg_split('/ /', trim(fgets(STDIN)));
    // ???????????????
    echo(compare($num[0], $num[1])); */

    $num = preg_split('/ /', trim(fgets(STDIN)));

    echo($num[0] < $num[1] && $num[1] < $num[2] ? "Yes" : "No");

?>

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

int main()
{
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){
    cout << "No" << endl;
  }else
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(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));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	Graph<ll> g(n);
	int u,v,w;
	rep(i,n-1){
		cin>>u>>v>>w;
		u--;v--;
		g.add(u,v,w,false);
	}
	bool c=true;
	vl ans(n,-1);
	vb vstd(n,false);
	vstd[0]=true;
	ans[0]=0;
	queue<ll> q;
	q.push(0);
	while(!q.empty()){
		int t=q.front();q.pop();
		for(auto x:g.edge[t]){
			if(vstd[get<0>(x)]==false){
				vstd[get<0>(x)]=true;
				q.push(get<0>(x));
				if(get<1>(x)%2==0){
					ans[get<0>(x)]=ans[t];
				}
				else ans[get<0>(x)]=1-ans[t];
			}
		}
	}
	rep(i,n){
		cout<<ans[i]<<"\n";
	}
}


Measured memory_bytes: 8704
using System;
using System.Linq;

namespace abc069_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine((x[0] - 1) * (x[1] - 1));
        }
    }
}

Measured memory_bytes: 13268