akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

typedef long long LL;
const int MAX = 200001;
const LL MOD = 1000000007;

long long fact[MAX];
long long inv[MAX];

LL mod_pow(LL x,LL n){
    LL ret = 1;

    while(n){
        if(n & 1)ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }

    return ret;
}

LL mod_P(int n,int k){
    if(n < k)return 0;
    return fact[n] * inv[n - k] % MOD;
}

LL mod_C(int n,int k){
    if(n < k)return 0;
    return mod_P(n,k) * inv[k] % MOD;
}

LL mod_H(int n,int k){
    return mod_C(n + k - 1,n - 1);
}

void init(){
    fact[0] = inv[0] = 1;
    for(int i = 1;i < MAX;i++){
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = mod_pow(fact[i],MOD - 2);
    }
}

int main(){
    init();
    int n,k;

    cin >> n >> k;

    LL ans = 1;

    for(int i = 1;i <= min(n - 1,k);i++){
        ans = (ans + ((mod_C(n,i) * mod_H(n - i,i)) % MOD)) % MOD;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;
using namespace std;

const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;

int a, b, c, d;

void code() {
    cin >> a >> b >> c >> d;
    cout << max({(ll)b * d, (ll)a * d, (ll)a * c, (ll)b * c}) << "\n";
}

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

    int t = 1;
    // cin>>t;

    while (t-- > 0) {
        code();
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;

int main (void) {
  string s;
  int str, end;
  int ans=0;
  cin >> s;
  int n=s.length();
  for (int i=0; i<n; i++) {
    if (s[i]=='A') {
      str =i;
      break;
    }
  }
  for (int j=n-1; j>=0; j--){
    if (s[j]=='Z') {
      end =j;
      break;
    }
  }
  ans = end - str +1;
  cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a < b){
if(b < c){
System.out.printf("%d %d %d\n",a,b,c);
}else if(a < c){
System.out.printf("%d %d %d\n",a,c,b);
}else{
System.out.printf("%d %d %d\n",c,a,b);
}
}else{
if(a < c){
System.out.printf("%d %d %d\n",b,a,c);
}else if(b < c){
System.out.printf("%d %d %d\n",b,c,a);
}else{
System.out.printf("%d %d %d\n",c,b,a);
}
}
sc.close();
}
}


Measured memory_bytes: 26408
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <chrono>
#include <random>
#include <numeric>
using namespace std;
int a[35];
int main()
{
  int n,m,tmp,tmp2;
  int count = 0;
  cin >> n >> m;
  for(int i = 0; i < n; i++){
	cin >> tmp;
    for(int j = 0; j < tmp; j++){
      cin >> tmp2;
      a[tmp2-1]++;
    }
  }

  for(int i = 0; i < m; i++){
    if(a[i] == n)
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
nums = [int(i) for i in input().split()]

d = defaultdict(int)
a = 0
for num in nums:
    if 1 <= num <= 399:
        d['ash'] += 1
    elif 400 <= num <= 799:
        d['brown'] += 1
    elif 800 <= num <= 1199:
        d['green'] += 1
    elif 1200 <= num <= 1599:
        d['water'] += 1
    elif 1600 <= num <= 1999:
        d['blue'] += 1
    elif 2000 <= num <= 2399:
        d['yellow'] += 1
    elif 2400 <= num <= 2799:
        d['orange'] += 1
    elif 2800 <= num <= 3199:
        d['red'] += 1
    else:
        a += 1
MIN = len(d)
if MIN == 0 and a > 0:
    MIN = 1
MAX = len(d) + a
print(MIN, MAX)

Measured memory_bytes: 38256
#include<stdio.h>
int main(void){
    int a,b,W,H,c,d;
    while(1){
        scanf("%d%d",&H,&W);
        if (H==0||W==0)break;
        for(a=0;a<H;a++){
            for(b=0;b<W;b++){
                    c=a+b;
                    d=c%2;
                    if(d==0){
                        printf("#");
                    }else printf(".");
            }
        printf("\n");
    }
    printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n, m = LI()
    # py = LIR(m)
    lst = [[] for i in range(n)]
    ans = [0 for i in range(m)]

    for i in range(m):
        p, y = map(int, input().split())
        lst[p - 1].append((y, i))

    for i in range(n):
        if len(lst[i]) > 1:
            lst[i].sort()
        for j, pair in enumerate(lst[i]):
            ans[pair[1]] = str(i+1).zfill(6) + str(j + 1).zfill(6)

    for i in range(m):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 56600
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define endl 			"\n"
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(100);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int digit_sum(int a)
{
	int m, sum = 0;
	while (a)
	{
		m = a % 10;
		sum = sum + m;
		a = a / 10;
	}
	return sum;
}
int32_t main()
{
	Raghav();
	float r, g;
	cin >> r >> g;
	cout << g * 2 - r;
	return 0;

}

Measured memory_bytes: 3792
#include<stdio.h>

#define N 36
 
struct y {
  int value;
  char moji;
};
 
 main(){
  int i,j,n,m,minj;
  struct y a[N],b[N],c,d;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&a[i].moji, &a[i].value);
    b[i] = a[i];
  }
 
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j].value < a[j-1].value){
      c = a[j];
      a[j] = a[j-1];
      a[j-1] = c;
      }
    }
  }
   
  printf("%c%d",a[0].moji,a[0].value);
  for(i=1;i<n;i++){
    printf(" %c%d",a[i].moji,a[i].value);
  }
  printf("\n");
  printf("Stable\n");

  for(i=0;i<n-1;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(b[j].value < b[minj].value){
    minj = j;
      }
    }
    d = b[i];
    b[i] = b[minj];
    b[minj] = d;
  }
 
  printf("%c%d",b[0].moji,b[0].value);  
  for(i=1;i<n;i++){
    printf(" %c%d",b[i].moji,b[i].value);
  }
 
  for(i=0;i<n;i++){
    if(a[i].moji != b[i].moji){
      m=0;
      break;
    }
    else if(a[i].moji == b[i].moji){
      m=1;
    }
  }
  printf("\n");
    if(m==1)printf("Stable\n");
    if(m==0)printf("Not stable\n"); 
    return 0;
}

Measured memory_bytes: 612
#include<stdio.h>

int main(void)
{
int num[3];
int i,j,tmp;

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

if(num[0]>num[1]){
tmp=num[0];
num[0]=num[1];
num[1]=tmp;
}

if(num[1]>num[2]){
tmp=num[1];
num[1]=num[2];
num[2]=tmp;
}

if(num[0]>num[1]){
tmp=num[0];
num[0]=num[1];
num[1]=tmp;
}

for(j=0;j<2;j++){
printf("%d ",num[j]);
}
printf("%d",num[2]);
printf("\n");

return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  for(int i=0; i<vec.size(); i++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size()-1) << endl;
}

int main(){
  int64_t N,K,S;
  cin >> N >> K >> S;
  if(S==1000000000){
    for(int i=0; i<K; i++) cout << S << endl;
    for(int i=0; i<N-K; i++) cout << 1 << endl;
  }
  else{
    for(int i=0; i<K; i++) cout << S << endl;
    for(int i=0; i<N-K; i++) cout << S+1 << endl;
  }
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main(){
  char c[10001];
  while(scanf("%s",c) != EOF){
    int ioi_cnt=0,joi_cnt=0;
    for(int i=0;i<strlen(c)-2;i++){
      if(c[i+1] == 'O' && c[i+2] == 'I'){
	if(c[i]=='I') ioi_cnt++;
	if(c[i]=='J') joi_cnt++;
      }
    }  
    cout<< joi_cnt<< endl<< ioi_cnt<< endl;
  }
}

Measured memory_bytes: 1168
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a<=b){
        REP(i,b){
            cout << a;
        }
        cout << endl;
    }else if(a>b){
        REP(i,a){
            cout  << b;
        }
        cout << endl;
    }

    return 0;
}

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

int main(){
 int a,b,h,w; cin >> a >> b >> h >> w;
 double deg=abs((60*h+w)/2.0-6*w);
 double rag=(M_PI*deg)/180;
 double ans=sqrt(a*a+b*b-2*a*b*cos(rag));
 cout << setprecision(10) << ans << endl;
}


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

public class Main {
	public static void main(String[] args){

		Scanner scn = new Scanner(System.in);
		
		int a = scn.nextInt();
		int b = scn.nextInt();
		System.out.println((a*b) + " " + (a+a+b+b));
	}
}

Measured memory_bytes: 26132
#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 Max_N=410;
const LL INF=1e15;
	
LL dp[Max_N][Max_N];
LL sum[Max_N];

LL dfs(int l, int r){
	if(dp[l][r]!=INF) return dp[l][r];
	for(int k=l+1; k<r; k++){
		dp[l][r]=min(dp[l][r],dfs(l,k)+dfs(k,r)+sum[r]-sum[l]);
	}
	return dp[l][r];
}

int main(){
	int N;
	cin >> N;
	vector<LL> a(N);
	rep(i,N) cin >> a[i];
	rep(i,N) sum[i+1]=sum[i]+a[i];
	rep(i,Max_N){
		rep(j,Max_N) dp[i][j]=INF;
	}
	rep(i,N) dp[i][i+1]=a[i];
	cout << dfs(0,N)-sum[N] << endl;

	return 0;
}

Measured memory_bytes: 1536
#!/usr/bin/env python3
from collections import defaultdict,deque
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
def LI(): return map(int, input().split())
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    h, w, K = LI()
    y1, x1, y2, x2 = LI()
    q = deque()
    field = [[False] * (w + 2)] + [None] * h + [[False] * (w + 2)]
    for i in range(1, h + 1):
        field[i] = [False] + [True] * w + [False]
    for i in range(1, h + 1):
        s = input().rstrip()
        for j in range(1, w + 1):
            if s[j-1] == "@":
                field[i][j] = False
    q.append((x1, y1))
    ans = 0
    c = [[0] * (w + 2) for i in range(h + 2)]
    while q:
        next_q = deque()
        while q:
            x, y = q.pop()
            if (x, y) == (x2, y2):
                print(ans)
                return
            for i in range(1, K + 1):
                if field[y + i][x]:
                    if not c[y + i][x]:
                        next_q.append((x, y + i))
                        c[y + i][x] = 1
                else:
                    break
            for i in range(1, K + 1):
                if field[y][x + i]:
                    if not c[y][x + i]:
                        next_q.append((x + i, y))
                        c[y][x + i] = 1
                else:
                    break
            for i in range(1, K + 1):
                if field[y - i][x]:
                    if not c[y - i][x]:
                        next_q.append((x, y - i))
                        c[y - i][x] = 1
                else:
                    break
            for i in range(1, K + 1):
                if field[y][x - i]:
                    if not c[y][x - i]:
                        next_q.append((x - i, y))
                        c[y][x - i] = 1
                else:
                    break
            field[y][x] = False
        ans += 1
        q = next_q
    print(-1)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 143452
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    vector<int> vec(5);
    rep(i, 5) cin >> vec[i];
    rep(i, 5){
        if(vec[i] == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
 
int main()
{
  	float L;
  	cin>>L;
  	
  	cout<<fixed<<setprecision(6)<<((L*1.0/3)*(L*1.0/3)*(L*1.0/3));
  	
	return 0;
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=22;
const int mod=1e9+7;

int n,a[N][N],dp[1<<N];

int main(){
	n=input();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			a[i][j]=input();
		}
	}

	dp[0]=1;

	for(int i=0;i<(1<<n);i++){
		int t= __builtin_popcount(i);
		for(int j=1;j<=n;j++){
			if(i&(1<<(j-1))&&a[t][j]){
				dp[i]=(dp[i]+dp[i^(1<<(j-1))])%mod;
			}
		}
	}
	printf("%d\n",dp[(1<<n)-1]);
}

Measured memory_bytes: 10496
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n, m, x;
vector<E> vec;
UnionFind uf(1005);

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	cin >> n >> m >> x;
	llint u, v, w;
	for(int i = 1; i <= m; i++){
		cin >> u >> v >> w;
		vec.push_back(make_pair(w, make_pair(u, v)));
	}
	sort(vec.begin(), vec.end());
	
	llint mst = 0, mx = 0; uf.init();
	for(int i = 0; i < vec.size(); i++){
		w = vec[i].first, u = vec[i].second.first, v = vec[i].second.second;
		if(uf.same(u, v)) continue;
		uf.unite(u, v);
		mst += w, mx = w;
	}
	if(x < mst){
		cout << 0 << endl;
		return 0;
	}
	
	llint ecnt = 0, ucnt = 0;
	for(int i = 0; i < vec.size(); i++){
		llint sum = 0; uf.init();
		sum += vec[i].first, uf.unite(vec[i].second.first, vec[i].second.second);
		for(int j = 0; j < vec.size(); j++){
			w = vec[j].first, u = vec[j].second.first, v = vec[j].second.second;
			if(uf.same(u, v)) continue;
			uf.unite(u, v);
			sum += w;
		}
		if(sum == x && i != 0) ecnt++;
		if(sum > x) ucnt++;
	}
	
	ecnt = modpow(2, ecnt);
	ecnt += mod-1, ecnt %= mod;
	ucnt = modpow(2, ucnt);
	
	llint ans = ecnt * ucnt % mod;
	ans *= 2, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
n = gets.to_i
s = gets.chomp.chars
ans = 1e10
cnt_w = []
cnt_b = []
cnt = 0
s.each do |c|
  if c == "#"
    cnt += 1
  end
  cnt_b << cnt
end
cnt  = 0
s.each do |c|
  if c == "."
    cnt += 1
  end
  cnt_w << cnt
end
ans = 0 if s.all?{|c| c == "#"}
(0..n-1).each do |i|
  ans = [cnt_b[i] + cnt_w[n-1] - cnt_w[i],ans].min
end
puts [ans,cnt_w[n-1]].min

Measured memory_bytes: 22036
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	string str,next;
	char st[10000];
	while(n=in()){
		scanf("%s",st);
		str=st;
//cout<<str<<endl;
		int i,j,k;
		for(i=0;i<n;i++){
			next="";
			k=0;
			for(j=0;j<str.size();j++){
				k++;
				if(j<str.size()-1&&str[j]==str[j+1]){
					;
				}else{
					stringstream ss;
					ss<<k;
					next+=ss.str();
					next+=str[j];
					k=0;
				}
			}
			str=next;
		}
		cout<<str<<endl;
//cout<<str<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.math.BigInteger;

public class Main  implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        BigInteger a = new BigInteger(in.nextToken());
        BigInteger b = new BigInteger(in.nextToken());
        if (a.compareTo(b) < 0) {
            System.out.println("LESS");
        } else if (a.compareTo(b) > 0) {
            System.out.println("GREATER");
        } else {
            System.out.println("EQUAL");
        }
    }


}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    using AB = tuple<int, int>;
    vector<AB> ab(m);
    rep(i, m){
        int a, b; cin >> a >> b;
        a--, b--;
        ab[i] = AB(a, b);
    }
    sort(_all(ab));
    ab.emplace_back(AB(n-1, n));

    int bmin = n;
    int nrm = 0;
    int cur = 0;
    rep(i, m+1){
        int a, b; tie(a, b) = ab[i];

        if(a >= bmin){
            nrm++;
            bmin = n;
        }

        chmin(bmin, b);
    }

    cout << nrm << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] arg)throws IOException{
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		 //br.readline(); = 入力された１行分を日本語変換して返してくれる。
		 String str = br.readLine();

		 /*配列の型(intとかStringとか) [] 配列名 = 配列を用意
		  *今回はstrAryって配列にstrを入れてる。
		  *str.split = splitってのはString内に用意されてるメソッド
		  *文字列を分割するときに使用。今回は空白で区切ってって仕様なので
		  *split(" ")としてます。*/
		 String[] strAry = str.split(" ");

		 /*おなじみの文字列から数値への変換。
		  *ただし今回は指定先が配列の何番って風になってる。*/
		 int a =  Integer.parseInt(strAry[0]);
		 int b =  Integer.parseInt(strAry[1]);
		 int c =  Integer.parseInt(strAry[2]);

		 /*if文で条件分岐
		  * a<b、b<cを行いどちらともtrueならYesを表示
		  * a<bがfalse、もしくはb<cがfalse、またはどちらもfalseならNoを表示
		  */

		 if(a < b){
			 if(b < c){
				 System.out.println("Yes");
			 } else System.out.println("No");
		 } else System.out.println("No");

	}
}

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

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

const ll MAX_N = 8;
ll N, M;
std::vector< std::vector<ll> > vedge(MAX_N, std::vector<ll>(MAX_N, INF));

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << *it << " ";
    if ((it - begin) % 20 == 19 || it == end - 1) { std::cout << std::endl; }
  }
}

bool is_ok(std::vector<ll>& path)
{
  if (path[0] != 0) return false;

  bool judge = true;
  for (ll i = 0; i < N - 1; i++) {
    if (vedge[path[i]][path[i+1]] == INF) {
      judge = false;
    }
  }
  return judge;
}

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

  std::cin >> N >> M;
  for (ll i = 0; i < M; i++) {
    ll a, b;
    std::cin >> a >> b;
    a--; b--;
    vedge[a][b] = 1;
    vedge[b][a] = 1;
  }

  std::vector<ll> path(N, 0LL);
  for (ll i = 0; i < N; i++) {
    path[i] = i;
  }

  ll ans = 0LL;
  do {
    if (is_ok(path)) {
      //printVec(path.begin(), path.end());
      ans++;
    }
  } while (std::next_permutation(path.begin(), path.end()));

  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, p[SIZE], ps[SIZE];

  cin >> N;

  for (int i=0; i<N; i++) {
    cin >> p[i];
    ps[i] = p[i];
  }

  sort(ps, ps+N);

  int counter = 0;

  for (int i=0; i<N; i++) {
    counter += ps[i] != p[i];
  }

  cout << (counter <= 2 ? "YES" : "NO") << endl;


  return 0;
}


Measured memory_bytes: 256
# this is smart N, *D = map(int, read().split())
import sys
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = input()
s = input()

temp = ''
dq = deque()
for _ in s:
    if _ != temp:
        dq.append(_)
    temp = _
ans = len(dq)

print(ans)

Measured memory_bytes: 4212
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A*N, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define REP(i,n) for(int i=0;i<n;i++)
    #define LOOP(i,x,n) for(int i=x;i<n;i++)
    #define ALL(v) (v).begin(),(v).end()
    #define PB push_back
    #define MP make_pair
    #define FIR first
    #define UB upper_bound
    #define LB lower_bound
    #define int long long
    using namespace std;
    const int MOD=1000000007;
    const int INF=1000000009;
     
    signed main(){
      double r,g;
      cin>>r>>g;
      cout<<2*g-r<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>

int tree[500000];
int size;

int main(){
    scanf("%d", &size);
    for(int i=0; i<size; i++) {
        int tmp;
        scanf("%d", &tmp);
        tree[i] = tmp;
    }

    for(int i=0; i<size; i++) {
        printf("node %d: ", i+1);
        printf("key = %d, ", tree[i]);
        if(i > 0){
            printf("parent key = %d, ", tree[(i-1)/2]);
        }
        if(2*i+1 < size){
            printf("left key = %d, ", tree[2*i+1]);
        }
        if(2*i+2 < size){
            printf("right key = %d, ", tree[2*i+2]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 1844
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

int main(void) {
  int s; cin >> s;
  int up = s / 100; int down = s % 100;
  bool yymm = (0 <= up && up <= 99) && (1 <= down && down <= 12);
  bool mmyy = (1 <= up && up <= 12) && (0 <= down && down <= 99);
  if (yymm && mmyy) 
    cout << "AMBIGUOUS" << endl;
  else if (yymm)
    cout << "YYMM" << endl;
  else if (mmyy)
    cout << "MMYY" << endl;
  else
    cout << "NA" << endl; 

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    
int main(){
    string s;
    cin >> s;
    int flag = 0;
    for(auto &e : s){
        if(e == 'C') flag = 1;
        if(e == 'F' && flag){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define Y second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=2e5+5;
const ll MOD=1e9+7;
//}}}
int main(){
	IOS;
	ll x1,x2,yy1,y2,n,sz=0,arr[MAX];
	cin>>x1>>yy1>>x2>>y2;
	if(x1>x2){
		swap(x1,x2);
		swap(yy1,y2);
	}
	cin>>n;
	vector<pll> v; v.clear();
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		if(min(x1,x2)<=x&&x<=max(x1,x2)&&min(yy1,y2)<=y&&y<=max(yy1,y2))
			v.emplace_back(x,y);
	}
	if(y2<yy1)
		for(int i=0;i<SZ(v);i++)
			v[i].Y=-v[i].Y;
	sort(ALL(v));
	for(pii ii:v){
		debug(ii.F,ii.Y);
		int p=lower_bound(arr,arr+sz,ii.Y)-arr;
		if(p==sz)	arr[sz++]=ii.Y;
		else		arr[p]=ii.Y;
	}
	debug(sz);
	long double ans= (abs(x2-x1)+abs(y2-yy1)) *100;
	ans-=( (long double)20-5*acos(-1) )*(long double)sz;
	if(sz==min(abs(x2-x1),abs(y2-yy1))+1)
		ans+=5*acos(-1);
	cout<<setprecision(50)<<fixed<<ans<< '\n';
	return 0;
}

Measured memory_bytes: 6512
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val k = sc.nextInt

  val res = (1 to n).foldLeft(1){(acc, i) =>
    Math.min(acc * 2, acc + k)
  }

  println(res)

}

Measured memory_bytes: 25644
import java.io.*;

class Main {
    static int n;
    static StringBuilder sb = new StringBuilder("");

    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        n = Integer.parseInt(br.readLine());
        
        drawKoch(0, 0, 100, 0, 1);

        sb.append(100.0).append(" ").append(0.0).append("\n");

        System.out.print(sb.toString());
    }

    public static void drawKoch(double p1x, double p1y, double p2x, double p2y, int count) {
        if (count == n + 1) {
            sb.append(p1x).append(" ").append(p1y).append("\n");
            return;
        }

        double sx = (p2x - p1x) / 3 + p1x;
        double sy = (p2y - p1y) / 3 + p1y;
        double tx = p2x - (p2x - p1x) / 3;
        double ty = p2y - (p2y - p1y) / 3;

        double ux = ((tx - sx) - Math.sqrt(3) * (ty - sy)) / 2 + sx;
        double uy = ((ty - sy) + Math.sqrt(3) * (tx - sx)) / 2 + sy;

        count++;
        drawKoch(p1x, p1y, sx, sy, count);
        drawKoch(sx, sy, ux, uy, count);
        drawKoch(ux, uy, tx, ty, count);
        drawKoch(tx, ty, p2x, p2y, count);
    }
}

Measured memory_bytes: 29520
N, K, S = map(int, input().split())

A = [0]*N

for i in range (0, K):
	A[i] = S

if S == 10**9-1:
	for i in range (K, N):
		A[i] = 10**9
else:
	for i in range (K, N):
		A[i] = 10**9-1

print(*A)

Measured memory_bytes: 10808
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define inf ((int)1e6)
#define MAX 10003

int num[] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
int m, arr[10];
pii dp[MAX];

pii get_dp(int n) {
    if (n == 0) {
        return {0, 0};
    } else if (dp[n].first != -1) {
        return dp[n];
    } else {
        pii ans = {-inf, 0};
        for (int i = m-1; i >= 0; --i) {
            if (n-num[arr[i]] >= 0) {
                pii curr = get_dp(n-num[arr[i]]);
                curr = {curr.first+1, arr[i]};
                ans = max(ans, curr);
            }
        }
        return dp[n] = ans;
    }
}

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

    int n;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> arr[i];
        --arr[i];
    }
    sort(arr, arr+m);
    fill(dp, dp+MAX, make_pair(-1, -1));
    get_dp(n);
    while (n > 0) {
        cout << dp[n].second+1;
        n -= num[dp[n].second];
    }
    cout << "\n";
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>

int n;
int W[1000], S[1000], V[1000];


std::vector<std::pair<int, long long int> > dp0, dp1, dp2;

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d%d%d", W+i, S+i, V+i);
  std::vector<std::pair<int, int> > v;
  for(int i = 0; i < n; i++){
    v.emplace_back(S[i] + W[i], i);
  }
  std::sort(v.begin(), v.end());

  std::vector<long long int> sum(n+1);
  for(int i = n-1; i >= 0; i--) sum[i] = sum[i+1] + V[v[i].second];

  dp0.emplace_back(0, 0);
  for(int i = 0; i < n; i++){
    int j = v[i].second;
    for(const auto &x: dp0){
      if(x.first > S[j]) break;
      dp1.emplace_back(x.first + W[j], x.second + V[j]);
    }
    auto i0 = dp0.begin();
    auto i1 = dp1.begin();
    long long int best = std::max(dp0.back().second, dp1.empty() ? 0 : dp1.back().second);
    while(i0 != dp0.end() && i0->second + sum[i+1] < best) ++i0;
    while(i1 != dp1.end() && i1->second + sum[i+1] < best) ++i1;

    while(i0 != dp0.end() && i1 != dp1.end()){
      if(i0->first <= i1->first && i0->second >= i1->second) ++i1;
      else if(i0->first >= i1->first && i0->second <= i1->second) ++i0;
      else if(i0->first <= i1->first) dp2.push_back(*i0), ++i0;
      else dp2.push_back(*i1), ++i1;
    }
    dp2.insert(dp2.end(), i0, dp0.end());
    dp2.insert(dp2.end(), i1, dp1.end());
    dp1.clear();
    dp0.swap(dp2);
    dp2.clear();
//    for(const auto &x: dp0) printf("(%d %lld) ", x.first, x.second);
//    puts("");
  }
  printf("%lld\n", dp0.back().second);
  return 0;
}


Measured memory_bytes: 896
#!/usr/bin/env/ python3
S = input()
#N = int(input())
#A, B, C = input().split()
#N, M = map(int, input().split())

#N = int(input())
#A = [int(x) for x in input().split()]

#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(S[0][1])
N = len(S)
flag = True
for i in range(int((N-1)/2)):
    if S[i] != S[int((N-1)/2)-1-i]:
        flag = False
        break
for i in range(int((N+3)/2), N):
    if S[i] != S[N-1-i]:
        flag = False
        break
if flag: print('Yes')
else: print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(void){
  long long N,c=0;
  cin >> N;
  for(long long i = 1;i<N;i++){
    c = i+c;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	ll n;
	cin >> n;
	if (n % 2 == 1) {
		put(0);
		return 0;
	}
	n /= 2;
	ll res = 0;
	while (n>0) {
		res += n / 5;
		n /= 5;
	}
	put(res);
	return 0;
}


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

# print(N, A)

def num_two(n):
    count = 0
    while n % 2 == 0:
        n //= 2
        count += 1
    return count

ans = 0
for a in A:
    ans += num_two(a)
print(ans)


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

long long int a, b, x;
long long int ans;
long long int c, d;

int main(){
	scanf("%lld %lld %lld", &a, &b, &x);
	if(a % x == 0) c = a / x;
	else c = a / x + 1;
	d = b / x;
	ans = d - c + 1;
	printf("%lld\n", ans);
	return 0;
}

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

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

int main() {

  long long A, B, C, D;
  long long g, l;
  cin >> A >> B >> C >> D;
  
  long long count_B, count_A;
    
  g = gcd(D,C); //最大公約数
  l = C*D/g;	//最小公倍数
      
  count_B = B - B/C;
  count_B -= B/D;
  count_B += B/l;
  
  count_A = A-1 - (A-1)/C;
  count_A -= (A-1)/D;
  count_A += (A-1)/l;
  
  cout << count_B - count_A << endl;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n,m;
    while(cin >> n >> m, n+m){
        auto Ld = vectors(301,301,INF);
        auto Sd = vectors(301,301,INF);
        rep(i,n)Ld[i][i] = Sd[i][i] = 0;
        rep(i,m){
            int a,b,c; char s;
            cin >> a >> b >> c >> s;
            --a,--b;
            if(s == 'L'){
                cmin(Ld[a][b],c);
                Ld[b][a] = Ld[a][b];
            }else{
                cmin(Sd[a][b], c);
                Sd[b][a] = Sd[a][b];
            }
        }
        rep(k,n)rep(i,n)rep(j,n){
            cmin(Sd[i][j],Sd[i][k] + Sd[k][j]);
            cmin(Ld[i][j],Ld[i][k] + Ld[k][j] );
        }
        int r; cin >> r;
        vector<int>v;
        rep(i,r){
            int t; cin >> t;
            v.push_back(--t);
        }
        auto dp = vectors(1000+1,300+1,INF);
        dp[0][v[0]]=0;
        rep(i,r-1){
            /*if(i == 0){
                rep(k,n)dp[0][k] = Ld[v[i]][k] + Sd[v[i]][k] + Ld[k][v[i]];
            }*/
            rep(j,n){
                cmin(dp[i+1][j],dp[i][j]+Ld[v[i]][v[i+1]]);
                rep(k,n){
                    cmin(dp[i+1][k],dp[i][j] + Ld[v[i]][j] + Sd[j][k] + Ld[k][v[i+1]]);
                }
            }
        }
        int ans = INF;
        rep(i,n)cmin(ans,dp[r-1][i]);
        cout << ans << endl;
    }
}



Measured memory_bytes: 6708
#include <iostream>
#include <map>
#include <vector>

int A[3][3];
bool M[3][3];

int main()
{
  std::map<int, std::vector<bool*>> mark;

  for (int i = 0; i < 3; ++i)
  {
    for (int j = 0; j < 3; ++j)
    {
      int a;
      std::cin >> a;
      A[i][j] = a;

      if (mark.find(a) == mark.end())
      {
        mark.insert(std::make_pair(a, std::vector<bool*>()));
      }

      auto ret = mark.find(a);
      ret->second.push_back(&M[i][j]);
    }
  }

  int N;
  std::cin >> N;
  while (static_cast<bool>(N--))
  {
    int b;
    std::cin >> b;
    auto ret = mark.find(b);
    if (ret != mark.end())
    {
      for (auto p : ret->second)
      {
        *p = true;
      }
    }
  }

  bool ok = false;
  for (int i = 0; i < 3; ++i)
  {
    ok = true;
    for (int j = 0; j < 3; ++j)
    {
      if (!M[i][j])
      {
        ok = false;
        break;
      }
    }
    if (ok)
    {
      break;
    }
  }

  if (!ok)
  {
    for (int i = 0; i < 3; ++i)
    {
      ok = true;
      for (int j = 0; j < 3; ++j)
      {
        if (!M[j][i])
        {
          ok = false;
          break;
        }
      }
      if (ok)
      {
        break;
      }
    }
  }

  if (!ok)
  {
    ok = true;
    for (int i = 0; i < 3; ++i)
    {
      if (!M[i][i])
      {
        ok = false;
        break;
      }
    }
  }

  if (!ok)
  {
    ok = true;
    for (int i = 0; i < 3; ++i)
    {
      if (!M[i][2 - i])
      {
        ok = false;
        break;
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;


int main() {
	int H, W;
	cin >> H >> W;
	vector<string> V(H+W, string(H+W, '.'));
	int id = 0;
	for (int i = 0; i < H; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < s.size(); ++j) {
			if (s[j] == '#') {
				V[i+j][i+W-1-j] = '#';//id++ + '0';
			}
		}
	}
//	for(string v : V) {
//		cout << v << endl;
//	}
	int N = H + W;
	VVI A(N, VI(N, 0));
	for (int i = 0; i < N; ++i) {
		int s = 0;
		for (int j = 0; j < N; ++j) {
			s += V[i][j] == '#';
			A[i][j] = s;
			if (i) A[i][j] += A[i-1][j];
		}
	}
	auto sum = [&](int i0, int i1, int j0, int j1) {
		if (i0 > i1) return 0;
		if (j0 > j1) return 0;
//		cout << i0 << " " << j0 << " " << i1 << " " << j1 << " " << N << endl;
		int s = A[i1][j1];
		if (j0 > 0) s -= A[i1][j0-1];
		if (i0 > 0) s -= A[i0-1][j1];
		if (j0 > 0 && i0 > 0) s += A[i0-1][j0-1];
		return s;
	};
	long long t = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (V[i][j] == '#') {
				for (int k = 1; (k+i) < N && (k+j) < N; ++k) {
					// left and down
					if (V[i][j+k] == '#') {
						t += sum(i+k, i+k, j, j+k);
					}
					if (V[i+k][j] == '#') {
						t += sum(i+1, i+k, j+k, j+k);
					}
				}
				for (int k = 1; (i-k) >= 0 && (j-k) >= 0; ++k) {
					// left and down
					if (V[i][j-k] == '#') {
						t += sum(i-k, i-k, j-k+1, j);
					}
					if (V[i-k][j] == '#') {
						t += sum(i-k+1, i-1, j-k, j-k);
					}
				}
			}
		}
	}
	cout << t << endl;

	return 0;
}

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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << '\n';
    return 0;
}


Measured memory_bytes: 256