akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C

bool is_prime(int x) {
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;
	int sq = sqrt(x);
	for (int i = 3; i <= sq; i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (is_prime(a)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      char c;
      cin >> c;
     
      if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c== 'o') {
        cout << "vowel" << endl;
      }
      else {
        cout << "consonant" << endl;
      }
     
    }

Measured memory_bytes: 256
//dp[x+1][y] := x枚まで使った時に総和をyにできるか?
//dp[0][0] = 0 (0 <= i <= N)
//もしdp[i][j] = trueなら、dp[i+1][j] = true; dp[i+1][j + a[i]] = true;
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i = 0; i < (int)n; ++i)

const int MAX_N = 5010;
const int MAX_K = 5010;
ll a[MAX_N];
int N; ll K;
bool dp[MAX_N][MAX_K];

bool need(int p) { //p枚目(0-indexed)のカードは必要かどうか
    REP(i, N+1) REP(j, K) dp[i][j] = false;
    dp[0][0] = true;
    REP(i, N){
        if(i == p) { 
            REP(j, K) dp[i+1][j] = dp[i][j];
            continue;
        }
        else {
            for(ll j = 0; j < K; ++j) if(dp[i][j]) {
                dp[i+1][j] = true;
                if(j + a[i] < K) dp[i+1][j + a[i]] = true;
            }
        }
    }
    
    for(int i = max(0LL, K - a[p]); i < K; ++i) if(dp[N][i]) return true;
    return false;
}

int main()
{
    scanf("%d %lld", &N, &K);
    REP(i, N) scanf("%lld", &a[i]);
    sort(a, a + N);
    int low = 0, high = N-1;
    while(high - low > 1) {
        int mid = (high + low)/2;
        if(need(mid)) high = mid;
        else          low  = mid;
    }
    if(!need(high)) printf("%d\n", high + 1);
    else if(need(low)) printf("0\n");
    else printf("%d\n", low + 1);
    return 0;
}

Measured memory_bytes: 24704
n, m = map(int, input().split())
h = list(map(int, input().split()))

good = 0

obs = [[] for i in range(n) ]

for i in range(m):
    a, b = map(int, input().split())
    obs[a-1].append(b)
    obs[b-1].append(a)

for idx,o in enumerate(obs):
    higher = True
    if len(o) == 0:
        good += 1
        continue
    o = set(o)
    for i in o:
        if h[idx] <= h[i-1]:
            higher = False
    if higher:
        good += 1

print(good)

Measured memory_bytes: 31948
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
	int n;
	cin >> n;
	vector<int>a;
	int ans = 0;
	int last = 74751;
	f(n){
		int add;
		cin >> add;
		if(add==last+1){
			a.pb(last-1);
		}
		last = add;
	}
	f(n){
		int add;
		cin >> add;
		ans += add;
	}
	int z[n+5]={};
	f(n-1){
		cin >> z[i];
	}
	for(auto i:a){
		ans += z[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;

int n, u, v;
int a[100005], b[100005];
vector<int>V[1000005];
vector<pair<int, int>>takahashi, aoki;

void input(){
  cin >> n >> u >> v;
  for(int i = 1; i < n; ++i){
    cin >> a[i] >> b[i];
    //cout << a[i] << b[i] << endl;
    V[a[i]].push_back(b[i]);
    V[b[i]].push_back(a[i]);
  }
}


void bfs1(int root){
  int flag[1000005], cnt[100005];
  for(int i = 1; i < n; ++i){
    flag[i] = 0;
    cnt[i] = 0;
    //aokicnt[i] = 100005;
  }
  queue<int> Q;
  flag[root] = 1;
  //aokicnt[root] = 0;
  Q.push(root);
  while(!Q.empty()){
    int tmp = Q.front();
    Q.pop();
    for(int i = 0; i < V[tmp].size(); ++i){
      if(!flag[V[tmp][i]]){
        flag[V[tmp][i]] = 1;
        Q.push(V[tmp][i]);
        cnt[V[tmp][i]] = cnt[tmp] + 1;
        //aokicnt[V[tmp][i]] = min(cnt[tmp] + 1, aokicnt[V[tmp][i]]);
      }
    }
  }
  for(int i = 1; i <= n; ++i){
    //cout << i << " " << cnt[i] << endl;
    aoki.push_back(make_pair(cnt[i], i));
    //aokicnt[i] = cnt[i];
  }
  sort(aoki.begin(), aoki.end());
}


int flag2[100005];

int bfs2(int root, int goal){
  int flag[100005], cnt[100005];
  for(int i = 1; i <= n; ++i){
    flag[i] = 0;
    flag2[i] = 0;
    cnt[i] = 100005;
  }
  queue<int> Q;
  flag[root] = 1;
  cnt[root] = 0;
  Q.push(root);
  while(!Q.empty()){
    int tmp = Q.front();
    Q.pop();
    for(int i = 0; i < V[tmp].size(); ++i){
      if(!flag[V[tmp][i]]){
        flag2[tmp] = 1;
        flag[V[tmp][i]] = 1;
        Q.push(V[tmp][i]);
        cnt[V[tmp][i]] = min(cnt[tmp] + 1, cnt[V[tmp][i]]);
      }
    }
  }
  return cnt[goal];
}

int takahashicnt[100005];
void bfs3(int root){
  int flag[100005], cnt[100005];
  for(int i = 1; i <= n; ++i){
    flag[i] = 0;
    flag2[i] = 0;
    cnt[i] = 100005;
  }
  queue<int> Q;
  flag[root] = 1;
  cnt[root] = 0;
  Q.push(root);
  while(!Q.empty()){
    int tmp = Q.front();
    Q.pop();
    for(int i = 0; i < V[tmp].size(); ++i){
      if(!flag[V[tmp][i]]){
        flag2[tmp] = 1;
        flag[V[tmp][i]] = 1;
        Q.push(V[tmp][i]);
        cnt[V[tmp][i]] = min(cnt[tmp] + 1, cnt[V[tmp][i]]);
      }
    }
  }
  //return cnt[goal];
  for(int i = 1; i <= n; ++i){
    takahashicnt[i] = cnt[i];
  }
}

int main(){
  input();
  bfs1(v);
  bfs3(u);
  int nige = u;
  for(int i = aoki.size() - 1; i >= 0; --i){
    if(aoki[i].first > takahashicnt[aoki[i].second] && flag2[aoki[i].second] != 1){
      nige = aoki[i].second;
      break;
    }
  }
  // nigeが高橋くんが追い詰められる場所
  //cout << nige << endl;
  int ans = 0;
  //int c = aoki[nige].first - bfs2(u, nige);
  ans = bfs2(v, nige);
  cout << ans - 1 << endl;
  //cout << nige << endl;
  //cout << bfs2(1, 9) << endl;
  //cout << bfs2(5, 2) << endl;
  
}

Measured memory_bytes: 33524
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            char[] buf = new char[1];
            boolean c = false;
            boolean f = false;
            while (in.read(buf) == 1) {
                if (buf[0] == 'C') {
                    c = true;
                }
                if (c && buf[0] == 'F') {
                    f = true;
                    break;
                }
            }
            if (c && f) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 8148
#include<stdio.h>
long long int gcd(long long int a,long long int b){return a%b==0?b:gcd(b,a%b);}
int main(void)
{
	int T,i;
	long long int a,b,c,d,take;
	scanf("%d",&T);
	for(i=0;i<T;i++)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(a<b || d<b)
		{
			puts("No");
			continue;
		}
		else if(c>=b)
		{
			puts("Yes");
			continue;
		}
		take=gcd(d,b);
		if(b-take+a%take>c)
			puts("No");
		else
			puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdint>
using namespace std;

const int64_t M = 998244353;
int64_t dfs(vector<vector<int64_t>> &dp, vector<vector<int64_t>> &dp2, const vector<int64_t> &v, const int64_t &n, int64_t i, int64_t s);

int64_t dfs2(vector<vector<int64_t>> &dp, vector<vector<int64_t>> &dp2, const vector<int64_t> &v, const int64_t &n, int64_t i, int64_t t) {
	if (dp2[i][t] != -1) return dp2[i][t];
	if (i == 0) return dp2[i][t] = dfs(dp, dp2, v, n, i, t);
	return dp2[i][t] = (dfs(dp, dp2, v, n, i, t) + dfs2(dp, dp2, v, n, i-1, t)) % M;
}

int64_t dfs(vector<vector<int64_t>> &dp, vector<vector<int64_t>> &dp2, const vector<int64_t> &v, const int64_t &n, int64_t i, int64_t s) {
	if (dp[i][s] != -1) return dp[i][s];
	if (v[i] > s) return dp[i][s] = 0;
	if (v[i] == s) return dp[i][s] = i+1;
	int64_t t = s - v[i];
	if (i == 0) return dp[i][s] = 0;
	return dp[i][s] = dfs2(dp, dp2, v, n, i-1, t);
}

int main() {
	ios_base::sync_with_stdio(false);
	int64_t n, sum;
	cin>>n>>sum;
	vector<int64_t> v(n, 0);
	for (int64_t i = 0; i < n; i++) cin>>v[i];
	
	vector<vector<int64_t>> dp(n, vector<int64_t>(sum+1, -1));
	vector<vector<int64_t>> dp2(n, vector<int64_t>(sum+1, -1));

	int64_t res = 0;
	for (int64_t i = 0; i < n; i++) {
		res = (res + dfs(dp, dp2, v, n, i, sum) * (n-i) % M) %M;
	}

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

Measured memory_bytes: 141440
def update_max_num(temp, max_num):
    if temp>max_num:
        max_num=temp
    return max_num
    
a,b = input().split()
a=int(a)
b=int(b)

max_num=a+b
temp=a-b
max_num=update_max_num(temp, max_num)
temp=a*b
max_num=update_max_num(temp, max_num)

print(max_num)




Measured memory_bytes: 3060
import numpy as np
N,K = map(int,input().split())
P = np.zeros(N) + (1 / N)
A = np.arange(1,N+1)
while np.any(A < K):
    P[A < K] = P[A < K] / 2
    A[A < K] = A[A < K] * 2
print(np.sum(P))

Measured memory_bytes: 13912
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#include<ctype.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int comp(const void*a, const void*b) {
	return *(int*)a - *(int*)b;
}
int main(){
	int v, d;
	while (~fscanf(stdin, "%d%d", &v, &d)) {
		int c=1,i=2;
		int fib[1001] = { 1,2 };
		for (; i <=v ; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % 1001;
		qsort(fib, v+1, sizeof(int), comp);
		for (i = 2; i <= v; i++)
			if (fib[i] - fib[i - 1] >= d) c++;
		P(d, c);
	}
	return 0;
}

Measured memory_bytes: 644
h,w,k = map (int,input().split())
s = [0] * h
aans =10000000
for i in range(h):
    s[i] = [int(i) for i in str(input())]
for i in range(2 ** (h - 1)):
    ans = 0

    kugiri = [0] * (h - 1)
    for j in range(h - 1):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            kugiri[j] = 1

    box = [0] * (sum(kugiri) + 1)
    ans += sum(kugiri)
    for j in range(w): #横に見てる
        
        box[0] += s[0][j]
        num = 0
        for l in range(1,h): #縦に足し合わせる
            num += kugiri[l-1]

            box[num] = s[l][j] + box[num]

        for l in range(len(box)):
            if box[l] > k and j != 0:
                box = [0 for _ in range(sum(kugiri) + 1)]
                num = 0
                box[0] += s[0][j]
                for m in range(1, h):
                    num += kugiri[m - 1]
                    box[num] = s[m][j] + box[num]
                ans += 1
                break
            elif box[l] > k and j == 0:
                ans += 10000000000

    aans =min(aans,ans)


print(aans)




Measured memory_bytes: 47068
N=int(input())

p=list(map(int,input().split()))

for i in range(1,N):
    add=list(map(int,input().split()))
    p0=p[0]
    p1=p[1]
    p2=p[2]
    p[0]=max(add[0]+p1,add[0]+p2)
    p[1]=max(add[1]+p2,add[1]+p0)
    p[2]=max(add[2]+p0,add[2]+p1)

print(max(p))



Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define M 1000000007
#define sz 200005
#define pb push_back
typedef long long ll;
using namespace std;
int ST[4*sz];
ll v[sz];
void build(int tl,int tr,int p){
	if(tl==tr)
	{
		ST[p]=v[tl];
		return ;
	}
	int tm=(tl+tr)/2;
	build(tl,tm,2*p);
	build(tm+1,tr,2*p+1);
	ST[p]=min(ST[2*p],ST[2*p+1]);
}
int query(int tl,int tr,int l,int r,int p){
	if(tl>=l&&tr<=r)
		return ST[p];
	if(tr<l||tl>r)
		return 1000000000;
	int tm=(tl+tr)/2;
	return min(query(tl,tm,l,r,2*p),query(tm+1,tr,l,r,2*p+1));
}
ll dp1[200005];
int main(){
	ll n,a,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		v[i]=a;
	}
	build(1,n,1);
	for(ll i=1;i<=n;i++)
	{
		int low=1,high=i,mid;
		while(low<=high)
		{
			mid=(low+high)/2;
			int qq=query(1,n,mid,i,1);
			if(qq<v[i])
				low=mid+1;
			else if(qq>=v[i])
				high=mid-1;
			
		}
	//	cout<<low<<endl;
		dp1[i]+=v[i]*(i+1-low)+dp1[low-1];
		ans+=dp1[i];
	}
	cout<<ans<<endl;
	return 0;	
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(N);
	vector<int> b(N);

	vector<int> c(M);
	vector<int> d(M);
	for (size_t i = 0; i < N; i++)
	{
		cin >> a[i] >> b[i];
	}
	for (size_t i = 0; i < M; i++)
	{
		cin >> c[i] >> d[i];
	}

	for (size_t i = 0; i < N; i++)
	{
		int L_D = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		int num;
		num = 0;
		for (size_t j = 1; j < M; j++)
		{
			if (L_D > (abs(a[i] - c[j]) + abs(b[i] - d[j])))
			{
				L_D = (abs(a[i] - c[j]) + abs(b[i] - d[j]));
				num = j;
			}
		}
		cout << (num + 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)
#define lf_cin(X) scanf("%lf", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion

static char w[101][11];
int main(void) {
	int n, i, l;

	i_cin(n); 
	s_cin(w[0]); l = strlen(w[0]) - 1;
	for (i = 1; i < n; i++) {
		s_cin(w[i]);
		if (w[i - 1][l] != w[i][0]) { S_RTN("No");}
		l = strlen(w[i]) - 1;
	}
	qsort(w, n, sizeof(w[0]), s_asorts);
	for (i = 1; i <= n; i++) {
		if (!strcmp(w[i - 1], w[i])) { S_RTN("No"); }
	}
	S_RTN("Yes");
}



//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;

int c[200000];
signed main() {
	int a, b,sum=0;
	cin >> a >> b;
	for (int d = 0; d < a; d++)scanf("%lld", &c[d]);
	for (int e = 1; e < a; e++) {
		if (c[e] + c[e - 1] > b) {
			sum += min(c[e] + c[e - 1] - b,c[e]);
			c[e] -= min(c[e] + c[e - 1] - b, c[e]);
		}
	}
	if (c[0] + c[1] > b)sum += c[0] + c[1]-b;
	cout << sum << endl;
}

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

int main(){
   int N, K, Q;
   cin >> N >> K >> Q;
   vector<int> A(Q);
   for (int i=0; i<Q; i++){
      cin >> A.at(i);
   }
   vector<int> v(N+1, 0);
   for (int x : A){
      v.at(x)++;
   }
   for (int i=1; i<N+1; i++){
      v.at(i) = v.at(i) - Q + K;
      if (v.at(i) <= 0){
         cout << "No" << endl;
      } else{
         cout << "Yes" << endl;
      }
   }

}



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

int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0; i<3; i++){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,k;
string s;
int main(){
	cin>>n>>s>>k;
	for (int i=0;i<s.size();i++) if (s[i]!=s[k-1]) s[i]='*';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

int main() {
    int a, b;
    cin >> a >> b;
    int ans = a - (a > b ? 1 : 0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
}
int main() {
    int a,b;cin>>a>>b;
    int com=a;
    int ans=1;
    while(com<b){
        com+=a;
        if(ans!=0){
            com--;
        }
        ans++;
    }
    if(b==1){
        std::cout << 0 << std::endl;
    }else std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n],dp[n][3];
	for(int i=0; i<n; i++)
		cin>>a[i]>>b[i]>>c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i=1; i<n; i++)
	{
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
	}
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <math.h>

#define N 10000

int isPrime(int);

int main()
{

  int n, i, r, a=0;

  scanf("%d", &n);

  for(i=0; i<n; i++){
  scanf("%d", &r);

  if(isPrime(r) == 1)
    a++;

  }

  printf("%d", a);
  printf("\n");

  return 0;
}

int isPrime(int r)
{

  int i;

  if(r == 2) return 1;

  if(r<2 || r%2==0) return 0;

  i = 3;
  while(i <= sqrt(r)){
    if(r % i == 0) return 0;
    i = i + 2;
  }

  return 1;

}

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

int n, k;
ll h[100010];
ll dp[100010];

ll rec(int i){
    if(dp[i] < INF) return dp[i];
    if(i == 0) return 0;

    ll res = INF;
    for(int j = 1; j <= k; j++){
        if(i < j) break;
        chmin(res, rec(i-j) + abs(h[i] - h[i - j]));
    }

    return dp[i] = res;
}

int main(){
    cin >> n >> k;
    rep(i, n) cin >> h[i];

    fill(dp, dp + 100010, INF);

    cout << rec(n-1) << ln;
}
    

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

using namespace std;
const int maxn=2e5+10;
int n;
struct Le
{
	int l,r;
}t[maxn];
int ans=0;
bool cmp(Le a,Le b) {
	if(a.l==b.l) return a.r>b.r; 
	return a.l<b.l;
}
int preR[maxn],sufR[maxn];
int main() 
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d%d",&t[i].l,&t[i].r);
		ans=max(ans,(t[i].r-t[i].l+1));
	}
	sort(t+1,t+n+1,cmp);
	preR[0]=1000000000;sufR[n+1]=1000000000;
	for(int i=1;i<=n;++i) preR[i]=min(preR[i-1],t[i].r);
	for(int i=n;i;i--) sufR[i]=min(sufR[i+1],t[i].r);//cout<<sufR[i]<<" ";
	//puts("");
	for(int i=1;i<n;++i) {
		ans=max(ans,max(0,preR[i]-t[i].l+1)+max(0,sufR[i+1]-t[n].l+1));
	}
	for(int i=1;i<n;++i) {
		ans=max(ans,t[i].r-t[i].l+1+max(0,min(sufR[i+1],preR[i-1])-t[n].l+1));
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define REP(i,n) for(int i = 0;i<n;i++)
int vec1[]={0,1,-1,1,-1,0};
int vec2[]={1,1,0,0,-1,-1};

int t,n;
int table[200][200];

typedef pair<int,int> pii;
typedef pair<int,pii> piii;
queue<piii> q1;

int ans;

int solve(int y,int x){
	queue<piii> q1;
	q1.push(make_pair(0,make_pair(y,x)));
	while(!q1.empty()){
		if(t <= q1.front().first)
			return 0;
		REP(i,6){
			int n_y = q1.front().second.first + vec1[i];
			int n_x = q1.front().second.second + vec2[i];
			if(table[n_y][n_x] == 0){
				ans++;
				table[n_y][n_x] = 1;
				q1.push(make_pair(q1.front().first + 1,make_pair(n_y,n_x)));
			}
		}
		q1.pop();
	}
	return 0;
}


int main(){
	while(cin>>t>>n,t+n){
		ans = 0;
		fill_n(table[0],200*200,0);
		REP(i,n){
			int x,y;
			cin>>x>>y;
			table[100+y][100+x] = 1;
		}
		int x,y;
		cin>>x>>y;
		table[100+y][100+x] = 1;
		solve(100+y,100+x);
		cout<<ans+1<<endl;
	}
	return 0;
}

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

int main(){
  	string S, C;
  	long Q;
  	int T, F;
  	bool isReverse = false;
  
  	cin >> S >> Q;
  
  	for (int i = 0; i < Q; i++) {
	  cin >> T;
      
      if (T == 1) {
        //reverse(S.begin(), S.end());
        isReverse = isReverse ? false : true;
      } else {
        cin >> F >> C;
        if (F == 1) {
          if (isReverse == false) {
          	S.insert(0, C);
          } else {
            S.insert(S.size(), C);
          }
        } else {
          if (isReverse == false) {
          	S.insert(S.size(), C);
          } else {
            S.insert(0, C);
          }
        }
      }
      //cout << S << endl;
    }
  	if (isReverse) {
      //reverse(S.begin(), S.end());
      int length = S.length();
      for (int i = 0; i < length; i++) {
        cout << S[length- i - 1];
      }
      cout << endl;
      return 0;
    }
  
  	cout << S << endl;
  	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;



int main() {
	

	int n,m;
	cin >> n>>m;

	int x, y,ans;

	x = n*(n-1);
	y = m*(m-1);


		ans = x/2 + y/2;
	
	cout << ans << endl;
	



	return 0;
}




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

int main(){
  string S;
  cin >> S;
  int i,k,n;
  int64_t ret, tmp, cache;
  ret = 0;
  n = S.size();
  rep0(i, (1<<n-1)){
    tmp = 0;cache=S[0] - '0';
    bitset<10> bit(i);
    rep0(k, n-1){
      if (bit.test(k)){
        tmp += cache;
        cache=(S.at(k+1) - '0');
      }
      else{
        cache *= 10;
        cache += (S.at(k+1) - '0');
      }
    }
    tmp += cache;
    ret += tmp;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int m,n;
	int s,f,s1,i;
	
	while(1){
	s1=0;
	cin>>n;
	if(n==0) break;
	cin>>m;
	for(i=0;i<m;i++){
		cin>>s>>f;
		s1+=f-s;
	}
	
	if(s1>=n) cout<<"OK"<<endl;
	else cout<<n-s1<<endl;
	}
	return 0;
}	


Measured memory_bytes: 3132
#include<stdio.h>
int main(void)
{
 int a,b,c,d;
 int ab,cd;

 scanf("%d%d%d%d",&a,&b,&c,&d);

 ab = a * b;
 cd = c * d;

 if(ab < cd)
  {
   printf("%d",cd);
  }

 if(ab > cd)
  {
   printf("%d",ab);
  }

 if(ab == cd)
  {
   printf("%d",ab);
  }

 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5],maxa,maxt=-1,sum=0;
  vector<int> b(5);
  for(int i=0;i<5;++i)cin>>a[i];
  for(int i=0;i<5;++i){
    if(a[i]%10&&maxt<10-a[i]%10){
      maxt=10-a[i]%10;
      maxa=i;
    }
  }
  if(maxt==-1)maxa=0;
  for(int i=0;i<5;++i){
    if(i!=maxa){
      sum+=a[i]+(a[i]%10?10-a[i]%10:0);
    }
  }
  cout<<sum+a[maxa];
  return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll a,b;
  string s;
  cin>>a>>b>>s;
  string res ="Yes";
  FOR(i,0,a+b+1){
    if(i==a && s[a]!='-') res="No";

    if(i!=a){
      if(!(s[i]=='0'||s[i]=='1'||s[i]=='2'||s[i]=='3'||s[i]=='4'||
         s[i]=='5'||s[i]=='6'||s[i]=='7'||s[i]=='8'||s[i]=='9')){
           res="No";
         }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[200030];
int main() {
	int n, t;
	long long ans = 0;
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i != 0) {
			if (t > a[i] - a[i - 1]) {
				ans += a[i] - a[i - 1];
			}
			else {
				ans += t;
			}
		}
	}
	cout << ans + t << endl;
	return 0;
}

Measured memory_bytes: 1792
N = int(input())
def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
  for c in '753':
    ret += dfs(s + c)
  return ret
print(dfs('0'))


Measured memory_bytes: 2940
def sm(x):
    a = 0
    a += (x%10)
    a += (x//10)%10
    a += ((x//10)//10)%10
    a += (((x//10)//10)//10)%10
    a += ((((x//10)//10)//10)//10)%10
    return a

N, A, B = map(int,input().split())
ans = 0
for i in range(1, N+1):
    if A <= sm(i) <= B:
        ans += i
print(ans)

Measured memory_bytes: 3064
def b_magic2():
    A, B, C = [int(i) for i in input().split()]
    K = int(input())

    count = 0
    while A >= B:
        count += 1
        B *= 2
    while B >= C:
        count += 1
        C *= 2
    return 'Yes' if count <= K else 'No'

print(b_magic2())

Measured memory_bytes: 9104
# include <bits/stdc++.h>
using namespace std;
const int D = 105, N = 1e4 + 100, mod = 1e9 + 7;
long long dp[D][2][2], n, m, ans;
string s;
int main(){
    cin >> s >> n;m = s.size();
    dp[0][0][1] = 1;
    s = '0' + s;
    for(int i = 1; i <= m; i++){
        for(int j = 0; j < n; j++){  
            for(int d = 0; d < 10; d++){
                int x = (j - d + 15 * n) % n;
                dp[j][1][0] += dp[x][0][0];
                if(d == s[i] - '0'){
                    dp[j][1][1] += dp[x][0][1];
                }
                if(d < s[i] - '0'){
                    dp[j][1][0] += dp[x][0][1];
                }
                if(dp[j][1][0] >= mod)dp[j][1][0] -= mod;
                if(dp[j][1][0] >= mod)dp[j][1][0] -= mod;
            }
        }
        for(int j = 0; j < n; j++){
            dp[j][0][0] = dp[j][1][0];
            dp[j][0][1] = dp[j][1][1];
            dp[j][1][0] = dp[j][1][1] = 0; 
        }
    }  
    cout << (dp[0][0][0] + dp[0][0][1] - 1 + mod) % mod << endl;
}

Measured memory_bytes: 256
def parent(i: int) -> int:
	return i // 2

def left(i: int) -> int:
	return 2 * i

def right(i: int) -> int:
	return 2 * i + 1

if __name__ == "__main__":
	H = int(input())
	A = [None]
	A = A + list(map(int, input().split()))
	for i in range(1, H + 1):
		print(f"node {i}: key = {A[i]}, ", end="")
		if parent(i) >= 1:
			print(f"parent key = {A[parent(i)]}, ", end="")
		if left(i) <= H:
			print(f"left key = {A[left(i)]}, ", end="")
		if right(i) <= H:
			print(f"right key = {A[right(i)]}, ", end="")
		print()


Measured memory_bytes: 5692
import sys
input = sys.stdin.readline


def read():
    N, Y = map(int, input().strip().split())
    return N, Y


def solve(N, Y):
    for i in range(0, 2001):
        for j in range(0, 2001):
            k = N - i - j
            if k >= 0 and 10000 * i + 5000 * j + 1000 * k == Y:
                return "%d %d %d" % (i, j, k)
    return "-1 -1 -1"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 3060
#-- Breadth First Search
#-----------------------------------------------------

#-- matrix
n = gets.to_i
matrix = Array.new(n) { [0] * n }

n.times do
    cols = gets.split.map(&:to_i)
    x = cols.shift; x -= 1; cols.shift
    cols.each { |col| matrix[x][col - 1] = 1 }
end


#-- 初期値設定
ds = [0] * n
vs = [false] * n; vs[0] = true
queue = [0]

while queue != []
    x = queue.shift
    matrix[x].each_with_index do |y, i|
        if y == 1 && vs[i] == false
            queue << i
            vs[i] = true
            ds[i] = ds[x] + 1
        end
    end
end

#-- 到達できないノードは-1に変更
[*1...ds.length].each do |i|
    ds[i] = -1 if ds[i] == 0
end

#-- 表示
ds.each_with_index do |d, i|
    puts "#{i+1} #{d}"
end


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

using namespace std;


int main(){
    int N,K;cin >> N >> K;
        string s;cin >> s;
        vector<int> ruiseki;
        ruiseki.push_back(0);
        vector<pair<int,int>> vec;
        int w = s.at(0)-'0';
        int uku = 0;
        for(int i = 0;i < N;i++){
            if(w == s.at(i)-'0'){
                uku++;
            }else{
                vec.push_back({w,uku});
                w = s.at(i)-'0';
                uku = 1;
            }
        }
        vec.push_back({w,uku});
    //    for(int a = 0;a < vec.size();a++)cout<<vec.at(a).first<<" "<<vec.at(a).second<<endl;
   //     cout<<vec.size()<<endl;
        N = vec.size();
        int right = 0;
        int sum = 0;
        int ans = 0;
        int write = 0;
        for (int left = 0; left < N; ++left) {
                while (right < N && write <= K) {
                    /* 実際に right を 1 進める */
               //     cout<<sum<<endl;
                    if(vec.at(right).first == 0 && write == K)break;
                    //if(K < write)break;
                    sum += vec.at(right).second;
                    ans = max(ans,sum);
               //     cout<<write<<endl;
                    if(vec.at(right).first == 0)write++;
                    ++right;
                }
         //       ans = max(ans,sum);
         //       cout<<right<<" "<<left<<endl;
                /* break した状態で right は条件を満たす最大なので、何かする */
                // ex: res += (right - left);
                //ans = max(ans,right-left);
                /* left をインクリメントする準備 */
                if (right == left) ++right;
                sum -= vec[left].second;
                if(vec.at(left).first == 0)write--;
            }
        cout<<ans<<endl;
}


Measured memory_bytes: 1528
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	double sx, sy;
	double tx, ty;
	int q;
	int x, y;
	int x1, y1, x2, y2;
	int i;

	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	sx = x1, sy = y1;
	tx = x2, ty = y2;

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d %d", &x, &y);
		double px = x, py = y;

		double bx = tx - sx, by = ty - sy;
		double ax = px - sx, ay = py - sy;
		double r = (ax * bx + ay * by) / (bx * bx + by * by);
		double cx = sx + bx * r, cy = sy + by * r;

		printf("%.10f %.10f\n", cx, cy);
	}

	return 0;
}

Measured memory_bytes: 640
import collections
n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]

s = collections.Counter(a)
t = collections.Counter(b)

ans=0
for x in s.keys():
  if x in t.keys():
    if ans < s[x] - t[x]:
      ans=s[x] - t[x]
  else:
    if ans<s[x]:
      ans=s[x]
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int a[100010];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,0,2*m){
		int t;
		scanf("%d",&t);
		a[t]^=1;
	}
	int ans=1;
	rep(i,1,n+1)ans&=!a[i];
	puts(ans?"YES":"NO");
	return 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=2;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
int a,b=1,c=0,d=0;
  cin>>a;
  if(2<a){
  rep(i,200){
    rep1(j,a+i-1){
    if((a+i)%j==0){
      d++;
     goto A;
     
      }
      else if(j==a+i-1){
       b=a+i;
        goto B;
      }
    }
    A:
    c++;
    }
  B:
  cout<<b<<endl;
    }
else
  cout<<2;
      }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, m;
    cin >> n >> m;
    vll a(n);
    REP(i, n) cin >> a[i];
    VSORT(a);
    vector<P> p;
    ll b, c;
    REP(i, m){
        cin >> b >> c;
        p.push_back(P{c, b});
    }
    sort(p.rbegin(), p.rend());
    vll d(2 * n + 10);
    ll id = 0;
    REP(i, m){
        c = p[i].first, b = p[i].second;
        REP(j, b) d[id + j] = c;
        id += b;
        if(id >= n) break;
    }
    ll res = 0;
    REP(i, n) res += max(a[i], d[i]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4336
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
tmp=0
for i in range(N):
    A=list(map(int,input().split()))
    tmp=0
    for a,b in zip(A,B):
        tmp+=a*b
    tmp+=C
    if tmp>0:
        ans+=1
print(ans)
    

Measured memory_bytes: 3060
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

int f(PII a, PII b)
{
    Int m = Int(1e9);
    Int mm = m*m;
    
    Int x = Int(a.first)*Int(b.second) % m;
    Int y = Int(b.first)*Int(a.second) % m;
    Int z = Int(a.second)*Int(b.second) % mm;
    return (x*m + y*m + z) % mm == 0 ? 1 : 0;
}

void solve(int test)
{
    int n;
    cin >> n;
    int i, j, k, l;
    int cnt[47][47];
    CLEAR(cnt, 0);
    FOR(i, 0, n)
    {
        double d;
        cin >> d;
        d *= 1e9;
        Int a = Int(d + 0.5);
        int cnt2 = 0;
        int cnt5 = 0;
        while(a % 2 == 0)
        {
            a /= 2;
            ++cnt2;
        }
        while(a % 5 == 0)
        {
            a /= 5;
            ++cnt5;
        }
        ++cnt[cnt2][cnt5];
    }
    
    Int res = 0;
    FOR(i, 0, 47)
        FOR(j, 0, 47)
            if(cnt[i][j] != 0)
            {
                if(i + i >= 18 && j + j >= 18) res += Int(cnt[i][j])*Int(cnt[i][j] - 1)/2;
                FOR(k, 0, 47)
                    FOR(l, 0, 47)
                        if(PII(i, j) > PII(k, l) && i + k >= 18 && j + l >= 18)
                            res += Int(cnt[i][j])*Int(cnt[k][l]);
            }

    cout << res << endl;
}

int main()
{
    int T = 1, t;
    //cin >> T;
    FOR(t, 0, T)
    {
        solve(t);
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define ALL(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int a,b,c;
int n,m,cnt,ans;

main()
{
        cin>>n;

        vpii v;
        rep(i,n)
        {
                int a,b;
                cin>>a>>b;
                v.push_back(make_pair(b,a));
        }

        sort(ALL(v));


        //cout<<endl;
        for(auto it : v)
        {
                m+=it.second;
                //cout<<it.first<<" "<<it.second<<" "<<m<<" "<<(it.first>=m)<<endl;
                if(it.first<m)
                {
                        cout<<"No"<<endl;
                        return 0;
                }
        }
        //cout<<endl;

        cout<<"Yes"<<endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,in[M],dp[M];
int main()
{
    while (~scanf("%d",&n)) {
        REP(i,1,n) scanf("%d",&in[i]);
        dp[1] = 0;
        REP(i,2,n) {
            dp[i] = dp[i-1] + abs(in[i]-in[i-1]);
            if (i-2>=1) dp[i] = min(dp[i], dp[i-2] + abs(in[i]-in[i-2]));
        }
        printf("%d\n", dp[n]);
    }
    
    return 0;
}




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

int main()
{
    this_thread::sleep_for(0.99s);
    int n;
    cin>> n;
    cout << n/3600 << ':';
    n-=3600*(n/3600);
    cout << n/60 << ':';
    n-=60*(n/60);
    cout << n << '\n';
    
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class BReverseAndCompare {
public:
        ll A[26];
void solve(std::istream& cin, std::ostream& cout) {
    memset(A,0, sizeof(A));
    string s;
    cin >> s;
    for(char c : s)A[c - 'a'] ++;
    ll sum = 0;
    _for(i,26)sum += (A[i]*(A[i]-1))/2;
    cout << (ll)s.size()*(s.size()-1)/2 - sum +1<< endl;
}
};


#undef int
int main() {
	BReverseAndCompare solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
N=int(input())
A=list(map(int,input().split()))

S=[]
temp=0
for i in range(N):
    temp=temp+A[i]
    S.append(temp)

from collections import Counter

cnt=Counter(S)

ans=0
for c in cnt.values():
    ans+=c*(c-1)//2

if cnt[0]!=0:
    ans+=cnt[0]

print(ans)



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c; cin >> a >> b >> c;
  bool ok = false;
  if(a+b>=c) ok = true;

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3584
N, M = map(int, input().split())
P, Y, P_new, P_Y = [], [], [], []
for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)

for p in P:
    p_dig = len(str(p))
    add_0 = 6- p_dig
    P_new.append('0'*add_0 + str(p))
for m in range(M):
  temp =[]
  temp += [P_new[m], Y[m], m+1]
  P_Y.append(temp)
  
P_Y = sorted(P_Y, key=lambda x:(x[0], x[1]))
P_Y[0].append(1)

num = 1
for m in range(1,M):
    if P_Y[m][0] == P_Y[m-1][0]:
        num = num + 1
        P_Y[m].append(num)
    else:
        num = 1
        P_Y[m].append(num)

for m in range(M):
    n_dig = len(str(P_Y[m][3]))
    add_0 = 6- n_dig
    P_Y[m].append('0'*add_0 + str(P_Y[m][3]))
    P_Y[m].append(P_Y[m][0] + P_Y[m][4])

P_Y = sorted(P_Y, key=lambda x: x[2])

for m in range(M):
    print(P_Y[m][5])


Measured memory_bytes: 51336
moji_list = []
for i in range(5):
  moji_list.append(int(input()))
k = int(input())

check = 0

for i in moji_list:
  for j in moji_list:
    if abs(i-j) > k:
      check = 1
      
if check == 0:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3060
use proconio::{input, fastout};
use std::cmp::{max};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        a: [usize; n],
        b: [usize; m],
    }
    let mut temp_cost = 0;
    let mut i = 0;
    while i < a.len() {
        if k < (temp_cost + a[i]) {
            break;
        }
        temp_cost += a[i];
        i += 1;
    }
    // println!("{}", i);
    let mut res = i;
    let mut j = 0;
    // while j < b.len() && k >= (temp_cost - a[i] + b[j]) {
    while j < b.len() {
        // println!("{}", j);
        if k >= temp_cost + b[j] {
            // println!("A");
            temp_cost += b[j];
            j += 1;
            res = max(i + j, res);
        } else {
            // println!("B");
            if i == 0 {
                break;
            }
            // println!("C -- {}", i);
            temp_cost -= a[i - 1];
            i -= 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

int n, K, c;

int main() {
	scanf("%d%d", &n, &K);
	ll ans = 0;
	if (K & 1) {
		c = n / K;
		ans = 1ll * c * c * c;
	} else {
		c = n / K;
		ans = 1ll * c * c * c;
		c = (n + (K >> 1)) / K;
		ans += 1ll * c * c * c;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<sstream>

using namespace std;

int main(){
		int n,num,cont,v;
		string a,nex;
				stringstream ss;
				char bin[100];
	while(1){
		
		scanf("%d",&n);
		
		if(n==0){break;}
		cin>>a;
		
		for(int i=0;i<n;i++){
			cont=0;
			while(1){
				if(cont>=a.size()){break;}
				
				num=a[cont];
				
				v=0;
				while(1){
					if(a[cont]!=num){break;}
					v++;
					cont++;
				}
				/*
				ss.str("");
				ss<<v;*/
				
				sprintf(bin,"%d",v);
				nex+=bin;
				
				//nex+=ss.str();
				nex+=num;
			}
			a=nex;
			nex="";
		}
			cout<<a<<endl;
	}
}

Measured memory_bytes: 0
N,M=map(int,input().split())
l=[]
r=[]
for i in range(M):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)
big=min(r)
small=max(l)
print(big-small+1 if big-small>=0 else 0)

Measured memory_bytes: 10984
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    
    for i in 0..1000 {
    	let p = n - 4 * i;
        if p < 0 {
        	break;
        }
        if p % 7 == 0 {
        	println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352