akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}
ll dp[3005][3005];

int main() {
    IO;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++) {
        dp[0][i] = 1 + dp[0][i - 1];
    }
    for (int i = 1; i < n; i++) {

        if (s[i - 1] == '<') {
            for (int j = 1; j <= i + 1; j++)
                dp[i][j] = (dp[i - 1][j - 1] + dp[i][j - 1])%MOD;
        } else {
            for (int j = 1; j <= i + 1; j++)
                dp[i][j] = (dp[i - 1][i] - dp[i - 1][j - 1] + dp[i][j - 1])%MOD;
        }
    }

    ll ans = (dp[n - 1][n] + MOD) %MOD;
    cout << ans;
    return 0;
}


Measured memory_bytes: 69120
function Main(input) {
	var inputInt = parseInt(input, 10);
    var arr753 = [3, 5, 7];
	var count = 0;
  	var min = parseInt('123', 4);
  	var max = parseInt('1000000000', 4);
    for(var i = min; i <= max; i++) {
      var num3 = i.toString(4);
      if (num3.indexOf('0') >= 0 ) {
        continue;
      }
      num3 = num3.replace(/3/g, '7').replace(/2/g, '5').replace(/1/g, '3')
      if (parseInt(num3, 10) > inputInt) {
        break;
      }
      var a7 = num3.indexOf('7');
      var a5 = num3.indexOf('5');
      var a3 = num3.indexOf('3');
      if (a7 >= 0 && a5 >= 0 && a3 >= 0) {
      	count++;
      }
    }
    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10404
import java.util.*;

public class Main {
	static final int MOD = 1000000007;

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int[][] dp = new int[arr.length + 1][13];
		dp[0][0] = 1;
		for (int i = 0; i < arr.length; i++) {
			int x = -1;
			if (arr[i] != '?') {
				x = arr[i] - '0';
			}
			for (int j = 0; j < 10; j++) {
				if (x == -1 || x == j) {
					for (int k = 0; k < 13; k++) {
						int m = (k * 10 + j) % 13;
						dp[i + 1][m] += dp[i][k];
						dp[i + 1][m] %= MOD;
					}
				}
			}
		}
		System.out.println(dp[arr.length][5]);
	}
}


Measured memory_bytes: 33976
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,n,cnt;
	vector<int> kusi;
	cin>>n;
	kusi.resize(n*2);
	for(i=0;i<n*2;i++) cin>>kusi[i];
	cnt=0;
	sort(kusi.begin(),kusi.end(),greater<int>());
	for(i=0;i<n*2;i+=2) {
		if(i+1<n*2) {
			cnt+=kusi[i+1];
		}
	}
	cout<<cnt<<endl;
	exit(0);
}
	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;
//#define int long long

#define pb push_back
#define mp make_pair

struct Pair {
  int first;
  int second;
};

Pair p[105];

bool comp(const Pair &p1, const Pair &p2) {
  if(p1.first == p2.first) return p1.second < p2.second;
  return p1.first > p2.first;
}

int main(void) {
  cin.tie(0);
  int K, T, a, pre = -1, count = 0;

  cin >> K >> T;

  for (int i = 0; i < T; i++) {
    cin >> a;
    p[i].first = a; p[i].second = i;
  }

  for (int i = 0; i < K; i++) {
    sort(p, p + T, comp);
    //cout << endl;
    //for (int j = 0; j < T; j++) {
      //cout << p[j].first << " " << p[j].second << endl;
    //}
    if(p[0].second != pre) {
      p[0].first--;
      pre = p[0].second;
    } else {
      if(p[1].first != 0) {
        pre = p[1].second;
        p[1].first--;
      } else {
        count++;
        pre = p[0].second;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int C[100008];

int S[100005];

int Q, l[100005], r[100005];

int main(void) {

	cin >> Q;
	int tmp;
	for (int i = 1; i <= Q; i++) {
		cin >> tmp; l[i] = tmp;
		cin >> tmp; r[i] = tmp;
	}
	//=================
	for (int i = 2; i <= 100002; i++) {
		if (C[i] == 0) {
		int j = i*2;
		while (j < 100004) { C[j] = 1; j += i;}
		}
	}
	
	C[1] = 1;
	C[0] = 1;
	//=============

	/*for (int i = 1; i <= 500; i++) {
		if (C[i] == 0) { cout << i << endl; }
	}*/

	S[0] = 0;
	S[1] = 0; 

	for (int i = 2; i <= 100000; i++) {
		if (C[i] == 0 && C[(i + 1) / 2] == 0) { S[i] = S[i - 1] + 1; }
		else { S[i] = S[i - 1]; }
	}

	for (int i = 1; i <= Q; i++) {
		cout << S[r[i]] - S[l[i] - 1] << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main() {
	
	int A=0, B=0;
	scanf("%d %d", &A, &B);
	if(A<=8){
		if(B<=8){
			printf("Yay!");
		}
		else if(B>8){
			printf(":(");
		}
	}
	else if(A>8){
		printf(":(");
	}
	
	return 0;
}

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

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

void solve(long long N)
{
    int cnt = 0;
    for (int k = 1; k <= N; k++)
    {
        if (k % 2 == 1 && divisor(k).size() == 8)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
data = {k: 0 for k in range(1, 7)}
for _ in range(n):
    tmp = float(input())
    if tmp < 165.0:
        data[1] += 1
    elif 165.0 <= tmp < 170.0:
        data[2] += 1
    elif 170.0 <= tmp < 175.0:
        data[3] += 1
    elif 175.0 <= tmp < 180.0:
        data[4] += 1
    elif 180.0 <= tmp < 185.0:
        data[5] += 1
    else:
        data[6] += 1

for k, v in data.items():
    print("{}:{}".format(k, v*"*"))

Measured memory_bytes: 7652
#include <cstdlib>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

int main() {
	int N, i;
	cin >> N;
	vector<tuple<int, int, int>> txy(1 + N);
	for (i = 1; i <= N; ++i) cin >> get<0>(txy[i]) >> get<1>(txy[i]) >> get<2>(txy[i]);
	for (i = 0; i < N; ++i) {
		int a = abs(get<1>(txy[1 + i]) - get<1>(txy[i])) + abs(get<2>(txy[1 + i]) - get<2>(txy[i])), b = get<0>(txy[1 + i]) - get<0>(txy[i]);
		if (a > b || a % 2 != b % 2) break;
	}
	if (N == i) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 1408
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> ds(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> ds[i];
    }
    sort(ds.begin(), ds.end());
    int lower = ds[N / 2 - 1];
    int upper = ds[N / 2];
    cout << upper - lower << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std; void solve(); int main()
{ cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }
typedef long long ll;
template<class T>bool chmin(T &a, const T &b)
{ if (a<b) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b)
{ if (b<a) { a=b; return true; } return false; }
//----------------------------------------------------------------

ll gcd(ll m, ll n)
{
    if(m>n) swap(m,n);
    if(m==0) return n;
    return gcd(n%m, m);
}

ll lcm(ll a, ll b)
{
    ll g=gcd(a, b);
    ll x=a/g, y=b/g;
    return g*x*y;
}

void solve()
{
    int N;
    cin >> N;

    ll l=1; 
    for(int i=0; i<N; i++)
    {
        ll n;
        cin >> n;
        l=lcm(l, n);
    }
    cout << l << "\n";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string s, t, u;
	cin >> s >> t >> u;
	int cnt = 0;
	for( int i = 0; i < n; ++i ){
		if( s[i] == t[i] && t[i] == u[i] ){
			continue;
		} else if ( s[i] == t[i] || t[i] == u[i] || u[i] == s[i] ){
			cnt += 1;
		} else {
			cnt += 2;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
    int x, y;
    while(1) {
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;

        int tmp;
        if(x > y){
            tmp = x;
            x = y;
            y = tmp;
        }
        printf("%d %d\n", x, y);
    }

    return 0;
}



Measured memory_bytes: 2112
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MO 1000000007
#define MAXN 200000
using namespace std;
int inv[MAXN+5],fact[MAXN+5];
int PowMod(int a,int b)
{
	int ret=1;
	a%=MO;
	while(b!=0)
	{
		if(b&1)
			ret=1LL*ret*a%MO;
		a=1LL*a*a%MO;
		b>>=1;
	}
	return ret;
}
void prepare()
{
	fact[0]=1;
	for(int i=1;i<=MAXN;i++)
		fact[i]=1LL*fact[i-1]*i%MO;
	inv[MAXN]=PowMod(fact[MAXN],MO-2);
	for(int i=MAXN-1;i>=0;i--)
		inv[i]=1LL*inv[i+1]*(i+1LL)%MO;
}
int C(int n,int m)
{
	return 1LL*fact[n]*inv[m]%MO*inv[n-m]%MO;
}
int main()
{
	prepare();
	int r,c,A,B;
	scanf("%d %d %d %d",&r,&c,&A,&B);
	int ans=0;
	int val;
	for(int i=0;i<=r-1-A;i++)
	{
		val=1LL*C(i+B-1,i)*C(r-i-1+c-B-1,r-i-1)%MO;
		ans=(1LL*ans+val)%MO;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n) for(ll i=0;i<n;++i)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=a;--i)


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a;
    for(ll i=0;i<n;i++){
        ll x;cin>>x;
        a.push_back(x);
    }
    ll ok = 1e9;
    ll ng = 0;

    while(ok -ng > 1){
        ll mid = (ok + ng)/2;
        ll now = 0;
        for(ll i=0;i<n;i++){
            now += (a[i]-1)/mid;
        }
        if(now<=k){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
}

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

void Main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int S = 0;
  for (int i = 0; i < N; i++) {
    S ^= A[i];
  }

  for (int i = 0; i < N; i++) {
    cout << (S ^ A[i]) << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 4364
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 998244353;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL dp[SIZE],dp2[SIZE];
LL mypow(LL x,LL y){
    x%=MOD;
    LL res=1%MOD;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
int main(){
    int N; R(N);
    dp[0]=dp2[0]=1;
    int sum=0;
    FOR(i,1,N){
        int x; R(x);
        for(int j=sum;j>=0;j--){
            ADD(dp[j+x],dp[j]);
            ADD(dp[j],dp[j]);
            ADD(dp2[j+x],dp2[j]);
        }
        sum+=x;
    }
    LL an=1;
    REP(i,N)ADD(an,an+an);
    FOR(i,(sum+1)/2,sum){
        ADD(an,-dp[i]*3);
    }
    if(sum%2==0)ADD(an,dp2[sum/2]*3);
    W(an);
    return 0;
}


Measured memory_bytes: 4992
import sys
def input(): return sys.stdin.readline().strip()


def main():
    S = input() + 'Z'
    flag = False
    length = 0
    ans = 0
    for i, c in enumerate(S):
        if flag and (c == 'A' or c == 'T' or c == 'C' or c == 'G'):
            length += 1
        elif flag:
            ans = max(ans, length)
            length = 0
            flag = False
        elif c == 'A' or c == 'T' or c == 'C' or c == 'G':
            flag = True
            length = 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
n,m = map(int,input().split())

import numpy as np
from scipy.sparse.csgraph import shortest_path

l = np.array([[float("inf") for i in range(n)] for j in range(n)])
from collections import defaultdict
ans = defaultdict(int)
for _ in range(m):
   a,b,c = map(int,input().split())
   l[a-1][b-1] = c
   l[b-1][a-1] = c
   if a > b:
      ans[(b,a)] = 1
   else:
      ans[(a,b)] = 1

d, p = shortest_path(l, return_predecessors=True)


for pp in p:
   for idx, ppp in enumerate(pp):
      if idx < ppp:
         ans[(idx+1,ppp+1)] = 0
      else:
         ans[(ppp+1,idx+1)] = 0
print(sum(ans.values()))

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    ll mulA = 1;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        if(A[i] == 0) {
            mulA = 0;
            cout << mulA << endl;
            return 0;
        }
    }
    for(int i=0; i<N; i++) {
        if(A[i] <= 1000000000000000000LL/mulA) mulA *= A[i];
        else {
            mulA = -1;
            break;
        }
    }
    cout << mulA << endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void sub(string& s,int m){
    while(1){
        if(s[m]=='1'){
            s[m]='0';
            break;
        }
        else {
            s[m]='1';
            ++m;
        }
    }
    while(s.back()=='0')s.pop_back();
}

int main(){
    int n;
    cin>>n;
    string s(2*n,'0');
    s+='1';
    rep(i,n){
        int x;
        cin>>x;
        x=2*n-min(2*n,x);
        if(x>=s.size()){
            cout<<"No"<<endl;
        }
        else {
            cout<<"Yes"<<endl;
            sub(s,x);
        }
        //cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 3872
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<cmath>
using namespace std;
#define LL long long

LL x;
LL a[100005];

void init()
{
    for(LL i=1;i<=100000;++i)
        a[i]=i*(i+1)/2;
}

int main()
{
    init();
    //for(int i=1;i<=10;++i) cout<<a[i]<<endl;
    while(~scanf("%lld",&x))
    {
        LL pos=lower_bound(a+1,a+1+100000,x)-a;
        cout<<pos<<endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];
    int m;
    cin >> m;
    int b;
    int ans = 0;
    REP(i, m) {
        cin >> b;
        REP(i, n) if (b == a[i]) {
            ans++;
            break;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // dpPend と dpOkを0〜Kまで保持
  string N;
  int K;
  cin >> N >> K;
  vector<int> dpPend(K+1);
  vector<int> dpOk(K+1);
  dpPend[0] = 1;
  for (char n : N) {
    int cur = n - '0';
    if (cur == 0) {
      //vector<int> prevPend(K+1);
      vector<int> prevOk = dpOk;
      //swap(dpPend, prevPend);
      for (int i = K; i > 0; i--) {
        //dpPend[i] = prevPend[i-1];
        dpOk[i] += 9 * prevOk[i-1];
      }
    } else {
      // 1〜9の間
      vector<int> prevPend(K+1);
      vector<int> prevOk(K+1);
      swap(dpPend, prevPend);
      swap(dpOk, prevOk);
      for (int i = K; i >= 0; i--) {
        if (i == 0) {
          dpOk[i] = prevOk[i] + prevPend[i];
        } else {
          dpPend[i] = prevPend[i-1];
          dpOk[i] = prevOk[i] + 9 * prevOk[i-1] + prevPend[i] + (cur-1) * prevPend[i-1];
        }
      }
    }
  }
  ll ans = dpPend[K] + dpOk[K];
  cout << ans << '\n';  
  return 0;
}

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

using namespace std;

template <typename T = int64_t>
struct SegTree {
    using F = function<T(T, T)>;
    int N;
    vector<T> array;
    const F f;
    const T init;
    SegTree() {}
    SegTree(int len, const T &init, const F f) : f(f), init(init) {
        for (N = 1; N < len; N <<= 1);
        int n = 2 * N - 1;
        for (int i = 0; i < n; i++) array.push_back(init);
    }
    // $O(\log N)$
    void update(int k, T val) {
        k += N;
        array[k] = val;
        while (k >>= 1) array[k] = f(array[2 * k], array[2 * k + 1]);
    }
    // 右開区間$[l : r)$における結果を返す
    // $O(\log N)$
    T query(int l, int r) {
        T L = init, R = init;
        for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
            if (l & 1) L = f(L, array[l++]);
            if (r & 1) R = f(array[--r], R);
        }
        return f(L, R);
    }
};

const int64_t INF = 1e15;

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int64_t N, x;
    cin >> N >> x;
    int64_t ans = INF;
    vector<int64_t> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];

    SegTree<int64_t> tree(2 * N, INF,
        [](int64_t x, int64_t y) -> int64_t {return min(x, y);});
    for(int i = 0; i < 2 * N; i++) {
        tree.update(i, a[i % N]);
    }
    
    // k回魔法を唱えたと仮定
    for(int64_t k = 0; k < N; k++) {
        int64_t acc = 0;
        for(int i = 0; i < N; i++) {
            acc += tree.query(i + N - k, i + N + 1);
        }
        ans = min(ans, k * x + acc);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let mut count = 0usize;
    for i in 1..n + 1 {
        if i % 3 != 0 && i % 5 != 0 {
            count += i;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2240
#include <iostream>
#include <math.h>

using namespace std;

void solve(int a, int b, int c) {
	bool f = false;
	int max_num = max(a, max(b, c));
	int sub1, sub2;
	if (max_num != a) {
		sub1 = a;
		if (max_num != b) sub2 = b;
		else sub2 = c;
	} else if (max_num != b) {
		sub1 = b;
		sub2 = c;
	} 		
	if (pow(max_num, 2) == pow(sub1, 2) + pow(sub2, 2)) f = true;
	if (f) cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main() {
	int num, a, b, c;
	cin >> num;
	for (int i=0; i<num; i++) {
		cin >> a >> b >> c;
		solve(a,b,c);
	}
	return 0;
}

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

int main(){
	
	int h,w;cin>>h>>w;
	rep(i,h)rep(j,w)
	{
		string s;cin>>s;
		if(s == "snuke")
		{
			cout << char('A'+j);
			cout << i+1<<endl;
			return 0;
		}
		
	}
}

//cout << ans << endl;

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

int main() {
    int H,W; cin >> H >> W;
    vector<vector<char>> grid(H,vector<char>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> grid.at(i).at(j);
        }
    }

    const int dx[8] = {-1, -1, -1,  0,  0,  1, 1, 1};
    const int dy[8] = {-1,  0,  1, -1,  1, -1, 0, 1};
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (grid.at(i).at(j) == '#') continue;

            int count = 0;
            for (int d = 0; d < 8; ++d) {
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if(ni < 0 or H <= ni) continue;
                if(nj < 0 or W <= nj) continue;
                if(grid.at(ni).at(nj) == '#') count++;
            }
            //数えた周囲の地雷数を代入
            grid.at(i).at(j) = char(count + '0');
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << grid.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}

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

using namespace std;

long n,m,k;
static long d[31];

void Docfile()
{
  cin >> n >> m;
  for (int i=1;i<=n;i++)
  {
    long tmp;
    cin >> k;
    for (int j=1;j<=k;j++)
    {
      cin >> tmp;
      d[tmp]++;
    }
  }
}
  
void Xuli()
{
  long dem=0;
  for (int i=1;i<=m;i++)
    if (d[i]==n)
      dem++;
  cout << dem;
}
  
int main()
{
  Docfile();
  Xuli();
}
  


Measured memory_bytes: 256
s = int(input())

a = []
a.append(s)
i = 1
while True:
  if s % 2 == 1:
    s = 3*s+1
  else:
    s /= 2
  if s not in a:
    i += 1
    a.append(s)
  else:
    break

print(i+1)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll A,B,N;
    cin >> A >> B >> N;
    cout << A*min(B-1,N)/B <<endl;
    return 0;
}


Measured memory_bytes: 3584
import bisect
import sys
input = sys.stdin.readline
a, b, q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(a)] + [INF]
t = [-INF] + [int(input()) for i in range(b)] + [INF]
ans = []
for i in range(q):
    x = int(input())
    idxs = bisect.bisect(s, x)
    idxt = bisect.bisect(t, x)
    ans.append(min(x - min(s[idxs - 1], t[idxt -1]),
                     x - s[idxs - 1] + (t[idxt] - s[idxs - 1]),
                     t[idxt] - x + (t[idxt] - s[idxs - 1]),
                     x - t[idxt - 1] + (s[idxs] - t[idxt - 1]),
                     s[idxs] - x + (s[idxs] - t[idxt - 1]),
                     max(s[idxs], t[idxt]) - x,
                     x - min(s[idxs - 1], t[idxt -1])))
for i in range(q):
    print(ans[i])


Measured memory_bytes: 16452
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long

int dp[3001][3001], a[3001];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
    for (int i = 0; i < n; ++i)dp[i][i] = a[i];
    for (int i = 0; i < n - 1; ++i)dp[i][i + 1] = max(a[i], a[i + 1]);
    for (int k = 2; k < n; ++k)
        for (int i = 0, j = k; j < n; ++i, ++j)
            dp[i][j] = max(a[i] + min(dp[i + 1][j - 1], dp[i + 2][j]), a[j] + min(dp[i + 1][j - 1], dp[i][j - 2]));
    cout << dp[0][n - 1] * 2 - sum << endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int x, y, z;
    cin >> x >> y >> z;

    if(x%(y+z) != 0){
        if(x%(y+z) >= z) cout << x/(y+z) << endl;
        else cout << (x/(y+z))-1 << endl;
    } 
    else cout << (x/(y+z))-1 << endl;

    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 1;
    rep(i, n - 1)
    {
        if (s[i] != s[i + 1])
            cnt++;
    }
    OP(cnt);
    return 0;
}

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

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


    


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m;

vector<ll> G[1000010];
ll f[1000010];
bool c = false;

void dfs(ll now,bool t){
	if(f[now] != -1){
		if(f[now] == !t)c = true;
		return;
	}
	f[now] = t;
	rep(i,G[now].size())dfs(G[now][i],!t);
}

int main(){
	cin >> n >> m;
	rep(i,m){
		ll a,b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	fill(f,f+1000010,-1);
	dfs(1,false);
	ll sum = n*(n-1)/2;
	sum -= m;
	if(!c){
		ll b = 0;
		rep(i,n){
			if(f[i+1] == 0)b++;
		}
		if(b >= 1)sum -= b*(b-1)/2;
		ll w = n-b;
		if(w >= 1)sum -= w*(w-1)/2;
	}
	cout << sum << endl;
}

Measured memory_bytes: 36096
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long total = sc.nextLong();
        BigDecimal l = BigDecimal.valueOf(total).divide(BigDecimal.valueOf(3L), 8, RoundingMode.HALF_DOWN);

        System.out.println(l.pow(3).toPlainString());
    }
}


Measured memory_bytes: 22740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int X = in.nextInt();
            if (X >= 30)
            {
                out.print("Yes");
            } else
            {
                out.print("No");
            }
        }

    }
}



Measured memory_bytes: 27080
n = int(input())
A = [int(input())-1 for _ in range(n)]
a = A[0]
i = 1
aset = set()
while a != 1:
    a = A[a]
    if not a in aset:
        aset.add(a)
        i += 1
    else:
        print(-1)
        break
else:
    print(i)


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

using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pback pop_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vis vector<string>
#define vii vector<vector<int>>
#define mii map<int, int>
#define umii unordered_map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi,greater<int>>
#define setbits(x) __buitin_popcountll(x)
#define zrobits(x) __buitln_ctzll(x)
#define mod 1000000007 //1e9+7
#define inf 1e18
#define ps(x,y) fixed<<setpresicion(y)<<x
#define mk(arr,n,type) type *arr=new type[n]
#define w(x) int x;cin>>x; while(x--)
#define rg 1000005
#define deg(v) cout<<"Value is: "<<v<<endl
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(a,b) for(int i=a;i<b;i++)
#define frev(a,b) for(int i=(int)a;i>(int)b;--i)
//mt19937  ring(chrono: stready_clock::now().time_since_epoch().count)


void IO() {


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

string stoneBU(vi a, int k) {

	bool dp[k + 1];
	memset(dp, 0, sizeof(dp));

	for (int i = 1; i <= k; i++) {

		for (int move : a) {

			if (move > i) continue;
			if (dp[i - move] == 0) dp[i] = 1;
		}
	}

	

	return dp[k] ? "First" : "Second";
}
bool dp1[100005];
bool stoneTD(vi a, int i) {

	if (i == 0) return 1;

	if (dp1[i] != 0) return 1;

	for (int move : a) {

		if (move > i) continue;

		bool val = stoneTD(a, i - move);
		if (val) dp1[i] = val;
	}

	return dp1[i];
}

int32_t main() {

	FASTIO;
	//IO();

	int n, k; cin >> n >> k;
	memset(dp1, 0, sizeof(dp1));
	vi a(n);
	for (auto & i : a) cin >> i;

	cout << stoneBU(a, k) << endl;

	
	return 0;
}


Measured memory_bytes: 3876
import fractions

A,B,C,D = map(int, input().split())

def lcm(C,D):
  return C*D // fractions.gcd(C,D)
CD=lcm(C,D)

print(int(B-A+1-((B//C + B//D - B//CD) - ((A-1)//C + (A-1)//D - (A-1)//CD))))
  


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

template <typename _Ty>
struct Edge {
    int src, to;
    _Ty cost;

    constexpr Edge(int _to, _Ty _cost) noexcept
        : src(-1), to(_to), cost(_cost) {}
    constexpr Edge(int _src, int _to, _Ty _cost) noexcept
        : src(_src), to(_to), cost(_cost) {}
};
template <typename _Ty>
using WeightedGraph = std::vector<std::vector<Edge<_Ty>>>;

template <typename _Ty>
void dijkstra(std::vector<_Ty>& dist, std::vector<int>& prev,
              const WeightedGraph<_Ty>& g, int s) {
    constexpr _Ty inf = std::numeric_limits<_Ty>::max();
    dist.assign(g.size(), inf);
    prev.assign(g.size(), -1);

    using Pi = std::pair<_Ty, int>;
    std::priority_queue<Pi, std::vector<Pi>, std::greater<Pi>> q;
    dist[s] = 0;
    q.emplace(dist[s], s);
    while (!q.empty()) {
        _Ty cost;
        int idx;
        tie(cost, idx) = q.top();
        q.pop();
        if (dist[idx] < cost) continue;
        for (const auto& edge : g[idx]) {
            _Ty next_cost = cost + edge.cost;
            if (next_cost >= dist[edge.to]) continue;
            dist[edge.to] = next_cost;
            prev[edge.to] = idx;
            q.emplace(next_cost, edge.to);
        }
    }
}

Vi dist, prev_idx;
WeightedGraph<int> g;
Vi checked;
Vi tami;

int dfs(int u) {
    int tmp = dist[u];
    for (const auto& to : g[u]) {
        if (checked[to.to] != 0) continue;
        checked[to.to] = 1;
        tmp = max(tmp, dfs(to.to));
    }
    tami[u] = tmp;
    return tmp;
}

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

    int N, U, V;
    cin >> N >> U >> V;
    --U;
    --V;

    g.resize(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].emplace_back(b, 1);
        g[b].emplace_back(a, 1);
    }

    dijkstra(dist, prev_idx, g, V);

    tami.resize(N);
    checked.resize(N);
    checked[V] = 1;
    dfs(V);

    int ad = (dist[U] - 1) / 2;

    int max_tami = tami[U];
    int tmpU = U;
    for (int i = 0; i < ad; ++i) {
        tmpU = prev_idx[tmpU];
        max_tami = max(max_tami, tami[tmpU]);
    }

    cout << max_tami - 1 << endl;

    return 0;
}


Measured memory_bytes: 11520
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut ans = 5000;
    for i in 0..s.len() - t.len() + 1 {
        let mut count = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                count += 1;
            }
        }
        ans = if ans > count { count } else { ans };
    }

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


Measured memory_bytes: 2184
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	static boolean[] targetNumbers;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long gcd = calcGcd(A,B);
		
		System.out.println(A*B/gcd);
	}
	public static long calcGcd(long m,long n) {
		if(m < n) {
            long tmp = m;
            m = n;
            n = tmp;
        }
        long remainder = 0;
        while ((remainder = m % n) != 0) {
            m = n;
            n = remainder;
        }
        return n;
    }
	
}

Measured memory_bytes: 22100
#define M 999999
int T[M];main(i,j,r){for(T[0]=T[1]=1,i=2;i<M;i++)if(!T[i])for(j=2*i;j<M;j+=i)T[j]=1;for(;scanf("%d",&i),i;printf("%d\n",r))for(r=0,j=i+1;j<=2*i;j++)if(!T[j])r++;exit(0);}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

static LL P = 1000000007LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	cin >> N;
	vector<LL> A, S;
	map<LL, LL> M;
	A.push_back(0);
	S.push_back(0);
	for(int i=1; i<=N; i++){
		LL a;
		cin >> a;
		A.push_back(a);
		LL s = S[i-1] + a;
		S.push_back(s);
		if(M.count(s) == 0){
			M[s] = 1;
		}
		else{
			M[s]++;
		}
	}
	LL ans = 0;
	for(auto itr = M.begin(); itr != M.end(); itr++){
		LL k = itr->first;
		LL v = itr->second;
		if(v > 1){
			LL w = v*(v-1);
			w = w/2;
			ans += w;
		}
		if(k == 0){
			ans += v; //先頭a0から当該項までの部分列を加算
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 18756
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <iterator>
#include <algorithm>

typedef long long lint;

using namespace std;

void showIntArray(lint a[], lint n);

int main() {
  int ans = 0;
  string s;
  getline(cin, s);
  for (int i = 0; i < 15; i++) {
    if (i < s.length()) {
      if (s[i] == 'o') {
        ans++;
      }
    } else {
      ans++;
    }
  }
  if (ans >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

void showIntArray(lint a[], lint n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  int q;
  cin >> q;
  vector<ll> b(q), c(q);
  for(int i=0; i<q; i++){
    cin >> b[i] >> c[i];
  }
  ll total = 0;
  for (ll x : a) {
    total += x;}

  vector<ll> count(1e+05+100, 0);
  REP(i, n){
    count[a[i]]++;
  }
  REP(i, q){
    ll num = count[b[i]];
    total += num * (c[i] - b[i]);
    cout << total << endl;
    count[b[i]] = 0;
    count[c[i]] += num;
  }
  return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  ll N;
  cin>>N;
  ll tmp10(1), tmp8(1), tmp9(1);
  for(int i(0);i<N;i++){
    tmp10 *= 10;
    tmp8 *= 8;
    tmp9 *= 9;
    tmp10 %= MOD;
    tmp8 %= MOD;
    tmp9 %= MOD;
  }
  tmp9*= 2;
  tmp9 %= MOD;
  ll ans = (tmp10 + tmp8)%MOD;
  ans -= tmp9;
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3640
N = int(input())
prime = []
for i in range(1, 150):
    n = 1 + 10 * i
    for j in range(2, n+1):
        if n % j == 0:
            if n == j:
                prime.append(str(n))
            else:
                break

print(' '.join(prime[0:N]))


Measured memory_bytes: 2940
n = int(input())
h = list(map(int,input().split()))
c = 0
d = 0

for j in range(n-1):
  if h[j] >= h[j+1]:
    c += 1
  else:
    d = max(c,d)
    c = 0

d = max(c,d)
print(d)

Measured memory_bytes: 14252
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[1000001];
int main(){
for(int i=0;i<1000001;i++)p[i]=1;
p[0]=p[1]=0;
for(int i=2;i<1000001;i++)
if(p[i])
for(int j=i+i;j<1000001;j+=i)
p[j]=0;
for(int i=1;i<1000001;i++)p[i]+=p[i-1];
int a;while(scanf("%d",&a),a){
long long r=0;
while(a--){
int b,c;
scanf("%d%d",&b,&c);
r+=p[min(b+c,1000000)]-p[max(0,b-c-1)]-1;
}printf("%lld\n",r);}}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int h,w;
string maze[21];


int bfs(int sx, int sy, int gx, int gy, int memo[21][21]){
	queue<P> q;
	memo[sy][sx] = 0;
	for(int i = 0; i < 21; i++)for(int j = 0; j < 21; j++)memo[i][j] = 0;
	q.push(P(sx, sy));
	while(!q.empty()){
		int cx = q.front().first; int cy = q.front().second;
		// cout << cx << " " << cy << " "<< memo[cy][cx] << endl;
		q.pop();
		if(cx == gx and cy == gy)return memo[cy][cx];
		for(auto point: {P(-1,0), P(1,0), P(0, -1), P(0, 1)}){
			int nx = cx + point.first; int ny = cy + point.second;
			if((nx >= 0 && nx < w) && (ny >= 0 && ny < h) && maze[ny][nx] == '.'){
				if(memo[ny][nx] == 0){
					memo[ny][nx] = memo[cy][cx] + 1;
					q.push(P(nx, ny));
				}
			}

		}
	}
	return -1;
}


int main(){
	cin >> h >> w;
	// cout << h << " " << w << endl;
	for(int i = 0; i < h; i++)cin >> maze[i];
	int s_x,s_y;
	int g_x,g_y;
	int ans = 0;
	int count = 0;
	s_x = 0; s_y = 2;
	g_x = 4; g_y = 0;
	// int memo[21][21];
	// int temp = bfs(s_x, s_y, g_x, g_y, memo);
	// cout << temp << endl;
	for(s_x = 0; s_x < w; s_x++){
		for(s_y = 0; s_y < h; s_y++){
			if(maze[s_y][s_x] == '#')continue;
			for(g_x = 0; g_x <= w; g_x++){
				for(g_y = 0; g_y < h; g_y++){
					if(s_x == g_x and s_y == g_y)continue;
					if(maze[g_y][g_x] == '#')continue;
					int memo[21][21];
					count++;
					// cout << s_x << " " << s_y << endl;
					// cout << g_x << " " << g_y << endl;
					int temp = bfs(s_x, s_y, g_x, g_y, memo);
					// cout << count << " "<< temp << endl;
					ans = max(ans, temp);
				}
			}
		}
	}
	cout << ans  << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	vector<int> vc(26, 0);

	if(s.size() == 26){
		if(s == "zyxwvutsrqponmlkjihgfedcba"){
			cout << -1 << endl;
		}else{
			string temp = s;
			next_permutation(s.begin(), s.end());
			rep(i, s.size()){
				if(temp[i] == s[i]) cout << s[i];
				else{
					cout << s[i] << endl;
					break;
				}
			}
		}
		return 0;
	}

	rep(i, s.size()){
		char c = s[i];
		c -= 'a';
		vc.at(c)++;
	}
	cout << s;
	rep(i, 26){
		if(vc.at(i) == 0){
			char out = 'a' + i;
			cout << out << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
//		String[] array = new String[n];
//		for(int i=0;i<n;i++) {
//				array[i] = sc.next();
//		}
		sc.close();

		if(n==0) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}

	}
}


Measured memory_bytes: 35616