akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long
#define ld double
#define pb push_back
#define mod 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
main()
{
    IO
    ll n;
    cin>>n;
    string g;
    map<ll,map<ll,ll>> ae;
    for(int x=0;x<n;x++)
    {
        cin>>g;
        ll f=0;
        ll i=g.length()-1;
        for(int y=0;y<g.length();y++)
        {
            if(g[y]!='.')
               f=f*10ll+(g[y]-'0');
            else
                i=y;
        }
        ll s=g.length()-1-i;
        ll fi=0;
        ll t=0;
        while(f%5==0 && f>0)
        {
            ++fi;
            f/=5;
        }
        while(f%2==0 && f>0)
        {
            ++t;
            f/=2;
        }
        ++ae[fi-s][t-s];
    }
    ll ans=0;
    for(int x=-30;x<=30;x++)
     for(int y=-30;y<=30;y++)
       for(int z=-30;z<=30;z++)
        for(int k=-30;k<=30;k++)
         {
             if(min(z+x,y+k)>=0)
             {if(x==z && k==y)
                ans+=((ae[x][y]*(ae[x][y]-1)));
             else
                ans+=(ae[x][y]*ae[z][k]);}
                //cout<<x<<" "<<y<<" "<<z<<" "<<k<<"\n";
         }
        cout<<ans/2;

}


Measured memory_bytes: 3808
while True:
    a, op, b = input().split()

    a = int(a)
    b = int(b)

    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    elif op == "?":
        break


Measured memory_bytes: 5592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    string s, h;
    cin >> s >> h;
    cout << h + s;
    return 0;
}

Measured memory_bytes: 3572
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    H = I()

    count = 0
    while(H>0):
        H = H // 2
        count += 1

    print(pow(2,count)-1)



if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    //vector<ll> X(N);
    //string s;
    //in >> s;
    //vector<string> s;
    //s.resize(N);
    ll N,tmp;
    in >> N;
    vector<ll> A(N-1),ans(N);
    REP(i,N-1){
        ans[i]=0;
        in >> A[i];
        ans[A[i]-1]++;
    }
    
    REP(i,N-1){
        out << ans[i] << endl;
    }
    out << 0 << endl;
    
    


    
    
    
}

Measured memory_bytes: 6332
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i=0; i<n; i++) cin >> p.at(i);
	sort(p.begin(), p.end());
	int ans=0;
	for(int i=0; i<n-1; i++) ans+=p.at(i);
	ans+=p.at(n-1)/2;
	cout << ans << endl;
	return 0;
}

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

int main(){
  long long N,A,B;
  cin>>N>>A>>B;
  long long ans=0;
  ans+=N/(A+B)*A;
  long long res=N%(A+B);
  if(res>A){
    ans+=A;
  }else{
    ans+=res;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr int inv(LL x, int m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr int mpow(LL a, LL k, int m) { int r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }


int main() {
    string s;
    cin >> s;
    int n = s.length();
    LL ans = 0;
    for (int i = n - 1, cnt = 0; i >= 0; i--) {
        cnt += s[i] == 'W';
        if (s[i] == 'B') ans += cnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
A_list = [int(elem) for elem in input().split(' ')]
assert N >= 4
assert len(A_list) == N

# cummulative sum
cuml_A_list = [0] * N
cuml_A_list[0] = A_list[0]
for i in range(1, N):
    cuml_A_list[i] = cuml_A_list[i-1] + A_list[i]

best_diff = max(cuml_A_list[0], cuml_A_list[1]-cuml_A_list[0], cuml_A_list[2]-cuml_A_list[1], cuml_A_list[-1]-cuml_A_list[2])\
        - min(cuml_A_list[0], cuml_A_list[1]-cuml_A_list[0], cuml_A_list[2]-cuml_A_list[1], cuml_A_list[-1]-cuml_A_list[2])

left_sep = 0
right_sep = 2

# time complexity: O(N)
for mid_sep in range(1, N - 2):
    left_sum = cuml_A_list[mid_sep - 1]
    right_sum = cuml_A_list[-1] - cuml_A_list[mid_sep - 1]

    while abs(cuml_A_list[mid_sep] - 2*cuml_A_list[left_sep]) > abs(cuml_A_list[mid_sep] - 2*cuml_A_list[left_sep + 1]):
        left_sep += 1
    while abs(cuml_A_list[-1] - 2*cuml_A_list[right_sep] + cuml_A_list[mid_sep]) > abs(cuml_A_list[-1] - 2*cuml_A_list[right_sep + 1] + cuml_A_list[mid_sep]):
        right_sep += 1
    diff = max(cuml_A_list[left_sep], cuml_A_list[mid_sep] - cuml_A_list[left_sep], cuml_A_list[right_sep] - cuml_A_list[mid_sep], cuml_A_list[-1] - cuml_A_list[right_sep])\
        - min(cuml_A_list[left_sep], cuml_A_list[mid_sep] - cuml_A_list[left_sep], cuml_A_list[right_sep] - cuml_A_list[mid_sep], cuml_A_list[-1] - cuml_A_list[right_sep])
    best_diff = min(best_diff, diff)
print(best_diff)


Measured memory_bytes: 111964
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1;
const int maxm = 1e5 + 1;

int hd[maxn], nx[maxm], e[maxm];
int dp[maxn];

int dfs(int x)
{
    if (dp[x])
        return dp[x];
    for (int i = hd[x]; i; i = nx[i])
        dp[x] = max(dp[x], dfs(e[i]) + 1);
    return dp[x];
}

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1, x, y; i <= m; ++i) {
        scanf("%d%d", &x, &y);
        nx[i] = hd[x], hd[x] = i, e[i] = y;
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans = max(ans, dfs(i));
    printf("%d\n", ans);
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb fflush(stdout)

int start = 2e5;
int meta = 2e5;

const int max_n = 5e5;

int a[max_n];

int main () {
	make(n);
	makev(v, n);
	a[start] = v[0];
	meta++;
	for (int i = 1; i < n; i++) {
		if (i % 2 == 0) {
			a[start-1] = v[i];
			start--;
		} else {
			a[meta] = v[i];
			meta++;
		}
	}
	if (n%2 == 1) {
		for (int i = start; i != meta; i++) {
			printf("%d ", a[i]);
		}
	}
	else {
		for (int i = meta - 1; i >= start; i--) {
			printf("%d ", a[i]);
		}
	}
	printf("\n");
}


Measured memory_bytes: 3828
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
flag = false
(n-1).times do |i|
  if h[i+1] - h[i] < -1
    puts "No"
    exit
  elsif h[i+1] - h[i] == -1 && flag
    puts "No"
    exit
  elsif h[i+1] - h[i] == -1
    flag = true
  elsif h[i+1] - h[i] > 0
    flag = false
  end
end
puts "Yes"


Measured memory_bytes: 9612
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	priority_queue<pair<int,int> >h;
	while(a--){
		int w;
		cin>>w;
		h.push(make_pair(w,1));
	}
	while(b--){
		int w;
		cin>>w;
		h.push(make_pair(w,2));
	}
	while(c--){
		int w;
		cin>>w;
		h.push(make_pair(w,3));
	}
	int z=x+y;
	int ans=0;
	while(z){
		pair<int,int>f=h.top();
		h.pop();
		if(f.second==3){
			ans+=f.first;
			--z;
		}
		else if(f.second==1&&x){
			ans+=f.first;
			--x;
			--z;
		}
		else if(f.second==2&&y){
			ans+=f.first;
			--y;
			--z;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10476
#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 pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

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; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int e, y, a[] = { 0, 1868, 1912, 1926, 1989, 3000 };
	char c[] = { 0, 'M', 'T', 'S', 'H' };
	cin >> e >> y;
	if (e) {
		cout << y + a[e] - 1 << endl;
	}
	else {
		for (int i = 1; i <= 4; ++i) {
			if (a[i] <= y && y < a[i + 1])
				cout << c[i] << y - a[i] + 1 << endl;
		}
	}

	return 0;
}

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

typedef long long ll;
int mod = 1e9 + 7;

int main() {
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if (x >= k) {
			cnt++;
		}
	}
	cout << cnt;
}



















Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	K := sc.nextInt()

	ary := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

	fmt.Println(ary[K-1])

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 640
/*  ex9_1
    Rikuta  */
#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 10
//スタックの定義
typedef struct stack
{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;
//スタックの初期化
void initialize_stack(stack *string);
//データの追加
void push(stack *string, char elem);
//データの取り出し
void pop(stack *string);
//stackの出力
void print_stack(stack *string);

int main(void)
{   
    //スタックを宣言
    stack string;
    //スタックを初期化
    initialize_stack(&string);
    while (1)
    {   
        //受け取る変数の宣言
        char temp_char;
        //入力
        scanf("%c", &temp_char);
        //入力が終了なら終わり
        if (temp_char=='\n')
        {
            break;
        }
        //Bが入力されたらスタックをpop
        if (temp_char=='B')
        {
            pop(&string);
        }
        //0,1ならそれをスタックにpush
        if (temp_char=='0'||temp_char=='1')        
        {
            push(&string, temp_char);
        }
    }
    //スタックを出力
    print_stack(&string);

    return 0;
}

//スタックの初期化
void initialize_stack(stack *string)
{   
    //スタックの要素数と最大の大きさとtopを初期化
    string->count = 0;
    string->size = SIZE;
    string->top = &(string->data[SIZE]);
}

//データの追加
void push(stack *string, char elem)
{   
    //スタックの長さが最大を超えていたら標準エラー出力
    if (string->count >= string->size)
    {
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else
    {   
        //スタックのtopは一個戻り，戻ったtopに要素が入る．要素数が1増える．
        string->top--;
        *(string->top) = elem;
        string->count++;
    }
}

//データの取り出し
void pop(stack *string)
{   
    //データに何も入っていなかったら
    if (string->count > 0)
    {   
        //スタックのトップを奥へ，要素数が1減る
        string->top++;
        string->count--;
    }
}

void print_stack(stack *string)
{   
    //stringの最後から要素数分出力
    for (int i = 0; i < string->count; i++)
    {
        printf("%c", string->data[SIZE - i - 1]);
    }
    //改行
    printf("\n");
}


Measured memory_bytes: 1596
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
int ceil(int a,int b){// a以上でbの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}
int main (void){
    int n,x;
    cin>>n>>x;
    vector<int> v(n,0);
    rep(i,n) cin>>v[i];
    int nokori=x;
    rep(i,n) nokori=nokori-v[i];
    sort(v.begin(),v.end());
    cout<<nokori/v[0]+n<<endl;
    return 0;
}

Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		var p = new int[N];
		for (int i = 0; i < N; i++)
		{
			p[i] = int.Parse(Console.ReadLine());
		}
		Console.WriteLine(p.Sum() - p.Max() / 2);
	}
}

Measured memory_bytes: 13268
import sys
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    for i, c in enumerate(S):
        i += 1
        if i % 2 == 0:
            if c == 'R':
                return 'No'
        else:
            if c == 'L':
                return 'No'
    return 'Yes'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

n, x = map(int,input().split())
ls = list(map(int,input().split()))
ls.append(0)
ans = 0

for i in range(n):
    if ls[i] != 0:
        if x < ls[i]+ls[i+1] :
            ans += (ls[i]+ls[i+1]) - x
            ls[i+1] = max(x - ls[i],0)
print(ans)

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  string s;
  cin >> n >> s;
  vector<ll> vec(26, 1);
  rep(i, n) ++vec[s[i]-'a'];
  mint ans = 1;
  rep(i, 26) ans *= vec[i];
  --ans;
  cout << ans.x << endl;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
const int MXN = 1e5 + 5;
vector<int> G[MXN];
int a[MXN],n,k,ans;
inline int dfs(int x,int fro) {
	int d=1;
	for(auto w:G[x]) {
		if(w==fro) continue;
		d=max(d,dfs(w,x)+1);
	}
	if(d==k&&fro!=1&&fro!=0) d=0,++ans;
	return d;
}
int main() {
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=2;i<=n;++i) {
		G[i].push_back(a[i]),G[a[i]].push_back(i);
	}
	if(a[1]!=1) ans++;
	dfs(1,0);
	cout<<ans;
}

Measured memory_bytes: 8960
#include <stdio.h>
#include <string.h>

int main(){
  char s[12];
  fgets(s, 12, stdin);
  int max = 0, count = 0;
  for (int i=0; i<strlen(s)-1; i++) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') count++;
    else {
      if (count > max) max = count;
      count = 0;
    }
  }
  if (count > max) max = count;
  printf("%d\n", max);
  return 0;
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
int main(void) {
  int a, b;
  cin >> a >> b;
  prt2(a*b, 2*(a+b));
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        string s;
        cin >> s;

        if (s[2] == s[3] && s[4] == s[5]) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }

        return 0;
}


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

int main() {
  int x,y;
  cin >> x ;
  y = x;
  int sen , syaku, ju, ichi, itimann, zyuumann, syakumann, sennmann, ioku = 0;
  ioku = x / 100000000;
  x = x % 100000000;
  sennmann = x / 10000000;
  x = x % 10000000;
  syakumann = x / 1000000;
  x = x % 1000000;
  zyuumann = x / 100000;
  x = x % 100000;
  itimann = x / 10000;
  x = x % 10000;
  sen = x / 1000;
  x = x % 1000;
  syaku = x / 100;
  x = x % 100;
  ju = x / 10;
  x = x % 10;
  ichi = x / 1;
  int z = sen + syaku + ju + ichi + itimann + zyuumann + syakumann + sennmann + ioku;
  if ( y % z == 0){
    cout << "Yes" << endl;
  }else{
   cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
int T;

const int MAXN = 1e6+10;
char str[MAXN];

int N,l,r,mid;
char sl,sr;

int main() {
	cin>>N;
	cout<<'0'<<endl;
	cin>>str;
	
	sl = str[0];
	if(str[0]=='V')	return 0;
	
	l=0,r=N;
	while(l<r){
		mid = (l+r)/2;
		cout<<mid<<endl;
		cin>>str;
		if(str[0]=='V')	return 0;
		sr = str[0];
		int cha = mid-l;
		if(cha%2==0){
			if(sl==sr)	{
				l = mid;
				sl = sr;
			}
			else	r = mid;
		}else{
			if(sl==sr)	r = mid;
			else	{
				l = mid;
				sl = sr;
			}
		}
	}
    return 0;
}



Measured memory_bytes: 852
#include<stdio.h>
main()
{
	int a, mod;
  	scanf("%d", &a);
  	mod = a % 10;
    
    if (mod==3){
      	printf("bon\n");
    }
  	else if (mod==0 || mod==1 || mod==6 || mod==8){
    	printf("pon\n");
    }
  	else{
    	printf("hon\n");
    }
  
  	return 0;
}

Measured memory_bytes: 1616
n = int(input())
m = list(map(int, input().split()))
ans = 0


if m == [i+1 for i in range(n)]:
    print(0)
elif 1 not in m:
    print(-1)
else:
    target = 1
    for i in m:
    
        if i == target:
            ans += 1
            target += 1

    print(n-ans)

Measured memory_bytes: 26268
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<cmath>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
ll n;
int ans=10000;
int main(){
	cin>>n;
	for(ll i=1;i<=sqrt(n);i++){
		if(n%i==0){
			ll x=max(n/i,i);
			int cnt=0;
			while(x>0)x/=10,cnt++;
			ans=min(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  std::string S; std::cin >> S;
  int ans = 0;
  for(int i = 0, j = S.size()-1; i < j; ++i, --j) {
    if(S[i] != S[j]) ++ans;
  }
  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;

int main()
{
	long long n, m, ans;
	cin >> n >> m;
	if (n * 2 == m)
	{
		ans = n;
	}
	else if (n * 2 < m)
	{
		m -= n * 2;
		ans = n + m / 4;
	}
	else
	{
		ans = m / 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int m=sc.nextInt();
				int n=sc.nextInt();
				if(m+n==0) break;
				int[] w=new int[n+1];
				int max=0;
				int sum=0;
				for(int i=0; i<n; i++) {
					w[i]=sc.nextInt();
					max=Math.max(w[i], max);
					sum+=w[i];
				}
				int mini=0;
				for(int i=max; i<=sum; i++) {
					int h=1;
					int[] book=new int[n+1];
					int end=0;
					for(int j=0; j<n; j++) {
						if(book[h]+w[j]>i) {
							h++;
							if(h>m) {
								end=1;
								break;
							}
						}
						book[h]+=w[j];
					}
					mini=i;
					if(end==0) break;
				}
				System.out.println(mini);

			}
		}
	}
}




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

#include <iostream>


#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;
auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};

int main()
{
	f();
	ll n,a,b;cin>>n>>a>>b;
	ll tot=(a+b);

	ll q=(n/tot);
	ll m=(n%tot);

	//cout<<((n/(a+b)*a)+min(a,n%(a+b)))<<'\n';
	cout<<((q*a)+min(a,m))<<'\n';
	return 0;
}


Measured memory_bytes: 384
unittest
{
	assert( [ "2 3 1" ].parse.expand.solve == "1.000000" );
	assert( [ "1000000000 180707 0" ].parse.expand.solve == "0.000181" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmd = input.front.split.to!( long[] );
	return tuple( nmd[ 0 ], nmd[ 1 ], nmd[ 2 ] );
}

auto solve( long n, long m, long d )
{
	// 隣り合う2項の美しさの期待値を計算
	auto ans = 0.0L;
	if( d == 0 ) ans = cast( real ) n / n ^^ 2;					// 全n^^2通りのうち、美しさがdのものはn通り
	else         ans = cast( real ) 2 * ( n - d ) / n ^^ 2;		// 全n^^2通りのうち、美しさがdのものは2(n-d)通り
	
	// 隣り合うm-1項に拡張
	ans *= m - 1;
	
	return format( "%0.6f", ans );
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int a, b; cin >> a >> b;
    vector<int> h(1005, 0);
    for(int i=1; i<1000; i++){
        h.at(i) = h.at(i-1) + i; 
    }

    for(int i=1; i<999; i++){
        if(b-a==h.at(i+1)-h.at(i)){
            dump(h.at(i));
            cout << h.at(i+1) - b << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main () {

    int scoreT = 0;     // 太郎のカード
    int scoreH = 0;     // 花子のカード

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {

        string cardT;   // 太郎のカード
        string cardH;   // 花子のカード

        cin >> cardT >> cardH;

        for (int j = 0; cardT[j] != 0 || cardH[j] != 0; j++) {
            
            if (cardT[j] > cardH[j]) {
                // cout << "ScoreT += 3" << endl;
                scoreT += 3;
                break;
            } else if (cardT[j] < cardH[j]) {
                // cout << "ScoreH += 3" << endl;
                scoreH += 3;
                break;
            }

            if (cardT[j + 1] == 0 && cardH[j + 1] == 0) {
                // cout << "ScoreT += 1 & ScoreH +- 1" << endl;
                scoreT += 1;
                scoreH += 1;
            }

        }
    }

    cout << scoreT << " " << scoreH << endl;

    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359
LL gcd(LL a, LL b){
	if(b > a) swap(a, b);
	LL tmp;
	while(b != 0){
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	LL N,X;
	cin >> N >> X;
	cout << (N-gcd(N,X))*3 << endl;

	return 0;
}


Measured memory_bytes: 256
import Data.Int
import Data.List
import Data.Array.Unboxed
import Data.Ix (range)

modulo :: Int64
modulo = 10^9 + 7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod x y = (x + y) `rem` modulo
subMod x y = (x - y) `mod` modulo
mulMod x y = (x * y) `rem` modulo
sumMod :: [Int64] -> Int64
sumMod = foldl' addMod 0

data Base = A | C | G | T deriving (Eq,Show,Ord,Enum,Ix)

bases :: [Base]
bases = [A,C,G,T]

baseTripleInterval :: ((Base,Base,Base),(Base,Base,Base))
baseTripleInterval = ((A,A,A),(T,T,T))

baseTripleRange :: [(Base,Base,Base)]
baseTripleRange = range baseTripleInterval

sumArr :: UArray (Base,Base,Base) Int64 -> Int64
sumArr = sumMod . elems

-- 出力 a:
--   a ! (s,t,u) : 問題文の条件を満たす長さ 3 の文字列のうち、stuから始まるもの
data3 :: UArray (Base,Base,Base) Int64
data3 = array baseTripleInterval
        [ (i,val)
        | i <- baseTripleRange
        , let val | i `elem` [(A,G,C),(G,A,C),(A,C,G)] = 0
                  | otherwise = 1
        ]

-- sumArr data3 == 61

-- 入力 a:
--   a ! (s,t,u) : 問題文の条件を満たす長さ k の文字列のうち、stuから始まるもの
-- 出力 a':
--   a' ! (s,t,u) : 問題文の条件を満たす長さ k+1 の文字列のうち、stuから始まるもの
step :: UArray (Base,Base,Base) Int64 -> UArray (Base,Base,Base) Int64
step arr = let n = sumArr arr -- 問題文の条件を満たす長さ k の文字列の個数
           in array baseTripleInterval
              [ (i,val)
              | i@(s,t,u) <- baseTripleRange
              , let val | i `elem` [(A,G,C),(G,A,C),(A,C,G)] = 0
                        -- 4文字のダメなパターンで、3文字パターンを含まないもの：ATGC, AGTC, AGGC
                        | i == (A,T,G) = sumMod [arr ! (t,u,v) | v <- [A,G,T]]
                        | i == (A,G,T) = sumMod [arr ! (t,u,v) | v <- [A,G,T]]
                        | i == (A,G,G) = sumMod [arr ! (t,u,v) | v <- [A,G,T]]
                        | otherwise = sumMod [arr ! (t,u,v) | v <- [A,C,G,T]]
              ]

main = do
  n <- readLn
  print $ sumArr $ iterate step data3 !! (n - 3)


Measured memory_bytes: 892
from decimal import *

dishes = []
for i in range(5):
    dishes.append(input())
    
idx = 0
min_ones_place = 9

for j in range(5):
    ones_place = int(dishes[j][-1])
    if ones_place != 0:
        if ones_place < min_ones_place:
            min_ones_place = ones_place
            idx = j
            
last_dish = int(dishes.pop(idx))

total_time = 0
for k in range(4):
    total_time += int(dishes[k])
    if total_time % 10 == 0:
        pass
    else :
        total_time = int(Decimal(str(total_time)).quantize(Decimal('1E1'), rounding=ROUND_UP))

total_time += last_dish
print(total_time)

Measured memory_bytes: 5076
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long long int A[200001];
int N;
long long int ans, B;
int main(void) {
	scanf("%d", &N);
	for(int k = 0; k < N; k++){
		long long int temp = 0;
		scanf("%lld", &temp);
		A[k] = temp % 1000000007;
		if(A[k] < 0){
			A[k] += 1000000007;
		}
	}

	for(int a = 1; a < N; a++){
				B += A[a];
				B = B % 1000000007;
				if(B < 0){
					B += 1000000007;
				}
			}

	ans = 0;

	for(int a = 0; a < N - 1; a++){
		ans += (A[a] * B) % 1000000007;
		B -= A[a + 1];
		if(B < 0){
			B += 1000000007;
		}

	}

	ans = ans % 1000000007;
	if(ans < 0){
				ans += 1000000007;
	}
	printf("%lld", ans);
	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define v vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    int n, ans = 0;
    string s;
    cin >> n >> s;
    rep(i,n-2){
        if(s[i] == 'A'&&s[i+1] == 'B'&&s[i+2] == 'C'){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#1236
q=int(input())
for _ in range(q):
    data=[]
    while 1:
        data+=list(map(int,input().split()))
        if data[-1]==0:
            break
    rooms=[(-1,1,[])]
    now=0
    i=0
    st=[]
    counter=[-1 for i in range(1000)]
    while data[i]!=0:
        while rooms[now][1]<=len(rooms[now][2]):
            now=st.pop()
        if data[i]>0:
            rooms.append((rooms[now][0]+1,data[i]+(1 if i==0 else 0),[]))
            counter[rooms[now][0]+1]=len(rooms)-1
            rooms[now][2].append(len(rooms)-1)
            rooms[len(rooms)-1][2].append(now)
            if len(rooms[now][2])<rooms[now][1]:
                st.append(now)
            now=len(rooms)-1
        elif data[i]<0:
            nxt=counter[rooms[now][0]+data[i]]
            rooms[nxt][2].append(now)
            rooms[now][2].append(nxt)
        i+=1
    for i in range(1,len(rooms)):
        print(i,end='')
        for e in sorted(rooms[i][2]):
            if e==0:
                continue
            print('',e,end='')
        print()






            






Measured memory_bytes: 6208
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N = IN();
	cout << "ABC" << N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline void chmin (long long& a, long long b) {
  if (a > b) a = b;
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> p(n + 2);
  p[0] = 0;
  p[n + 1] = n + 1;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  vector<long long> dp(n + 2, 1e18);
  dp[0] = 0;
  for (int i = 1; i <= n + 1; i++) {
    long long tmp = 0;
    for (int j = i - 1; j >= 0; j--) {
      if (p[j] < p[i]) {
        chmin(dp[i], dp[j] + tmp);
        tmp += b;
      } else {
        tmp += a;
      }
    }
  }
  cout << dp[n + 1] << '\n';
  return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import math

N = int(input())
D,X = map(int,input().split())
sum = 0

a = []
for i in range(N):
    a.append(int(input()))
    
for i in range(N):
    sum += math.floor((D-1)/a[i]) + 1
    
print(X + sum)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define in(a) a=read()
#define REP(i,k,n) for(int i=k;i<=n;i++)
using namespace std;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    for(;!isdigit(ch);ch=getchar())
        if(ch=='-')
            f=-1;
    for(;isdigit(ch);ch=getchar())
       x=x*10+ch-'0';
    return x*f;
}
int main(){
	int n;
	char ch[1000010];
	int a[1000010],b[1000010];
	in(n);
	int flag=0;
	scanf("%s",ch+1);
	int ans=999999;
	REP(i,1,n){
		b[i]=b[i-1];
		if(ch[i]=='#')  b[i]++;
	}
	for(int i=n;i>=1;i--){
		a[i]=a[i+1];
		if(ch[i]=='.')  a[i]++;
	}
	for(int i=0;i<=n;i++){
		ans=min(ans,b[i]+a[i+1]);
	}
	cout<<ans;
	return 0;
}

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

int S;
long long D = 1000000007;
long long res;
long long pw10[1000010];
int num[20];
long long A[1000010], A2[1000010];
int AL, A2L;

long long calc_pw10(int b)
{
	if(b<=1000000)
		return pw10[b];
	long long x=10;
	long long y=1;
	while(b>0){
		if(b%2==1){
			y *= x;
			y %= D;
		}
		b/=2;
		x*=x;
		x%=D;
	}
	return y;
}

int calc(int ii)
{
	int i, j;
	i = ii;
	int b = 0;
	while(i>0){
		b ++;
		i/=10;
	}
	i = ii;
	j = S;
	while(b>0){
		if(j<=(1ll*i-num[b])*b){
			if(j%b==0 && j>=b)
				return 1;
			else
				return 0;
		}
		else{
			j -= (1ll*i-num[b])*b;
			i = num[b];
			b --;
		}
	}
	return -1;
}

void solve()
{
	int i;
	pw10[0] = 1;
	for(i=1; i<=1000000; i++){
		pw10[i] = pw10[i-1]*10;
		pw10[i] %= D;
	}
	num[1] = 0;
	num[2] = 9;
	num[3] = 99;
	num[4] = 999;
	num[5] = 9999;
	num[6] = 99999;
	num[7] = 999999;
	num[8] = 9999999;
	num[9] = 99999999;
	num[10] = 999999999;
	long long tmp;
	//if(S>=7){
		/*for(i=7; i<=100; i++){
			if(S%i==0){
				tmp = 9*calc_pw10(S/i-1);
				tmp %= D;
				res += tmp;
				res %= D;
			}
			else{
				res ++;
				res %= D;
			}
		}*/
		/*for(i=8; i<=S; i++){
			if(S%i==0){
				tmp = 9*pw10[i-1];
				tmp %= D;
				res += tmp;
				res %= D;
			}
			else{
				if(S/i<=i){
					res ++;
					res %= D;
				}
			}
		}
		i = 7;
		if(S%i==0){
			tmp = 9*pw10[i-1];
			tmp %= D;
			res += tmp;
			res %= D;
		}
		else{
			res ++;
			res %= D;
		}*/
		for(i=1; i<=S; i++){
			if(S%i==0){
				if(S/i<=7)
					break;
				if(S/i<=8){
					//tmp = 7*pw10[S/i-1];
					tmp = 7*calc_pw10(S/i-1);
					tmp %= D;
					res += tmp;
					res %= D;
					break;
				}
				else{
					//tmp = 9*pw10[S/i-1]-(i-1);
					tmp = 9*calc_pw10(S/i-1)-(i-1);
					tmp %= D;
					res += tmp;
					res %= D;
				}
				if(i+1>0 && S/(i+1)<=7)
					break;
			}
			else{
				if(S/i<=7)
					break;
				res ++;
				res %= D;
				if(S/(i+1)<=7)
					break;
			}
			//if(S/i<=8){
			//	i --;
			//	break;
			//}
		}
		/*if(S%i==0){
			tmp = 8*pw10[S/i-1];
			tmp %= D;
			res += tmp;
			res %= D;
		}
		else{
			res ++;
			res %= D;
		}*/
	//}
	for(i=30000000-1; i>=1; i--){
		//if(i%1000==0)
		//	printf("%d\n", i);
		int r = calc(i);
		if(r==1){
			res ++;
			res %= D;
			//A[AL] = i;
			//AL ++;
		}
		else if(r==-1)
			break;
	}
	printf("%lld\n", res);
}

long long res2;
void solve2()
{
	int i, j, k, b;
	res2 = 0;
	//for(i=1; i<=20000000-1; i++){
	for(i=1; i<=200000000-1; i++){
		k = 0;
		b = 0;
		while(1){
			j = i+k;
			//if(j==10000001)
			//	int oo = 1;
			if(j>=20000000)
				break;
			while(j>0){
				j/=10;
				b++;
			}
			if(b==S){
				res2 ++;
				res2 %= D;
				//A2[A2L] = i+k;
				//A2L ++;
			}
			if(b>S)
				break;
			k ++;
		}
	}
	printf("%lld\n", res2);
}

void test()
{
	int i;
	S = 9;
	solve();
	//solve2();
	if(res!=res2){
		printf("Wrong\n");
		for(i=0; i<A2L/2; i++)
			swap(A2[i], A2[A2L-1-i]);
		for(i=0; i<A2L; i++){
			if(A[i]!=A2[i])
				printf("%d %d", i, A2[A2L-1-i]);
		}
	}
}

int main()
{
	//test();
	scanf("%d", &S);
	solve();
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (max(max(a, b), c) == a)
		cout << a * 10 + b + c << endl;
	else if (max(max(a, b), c) == b)
		cout << a + b * 10 + c << endl;
	else
		cout << a + b + c * 10 << endl;
	return 0;
}

Measured memory_bytes: 256
h,w,t = map(int,input().split())
a = []
for _ in range(h):
    b = list(map(str,input()))
    a.append(b)


ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for k in range(h):
            if ((i>>k)&1):
                for l in range(w):
                    if ((j>>l)&1):
                        if a[k][l] == "#":
                            cnt += 1
        if cnt == t:
            ans += 1

print(ans)

Measured memory_bytes: 73812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int r=scan.nextInt();
		if(r<1200) {
			System.out.println("ABC");
		}
		else if(r>=1200 && r<2800) {
			System.out.println("ARC");
		}
		else if(r>=2800)
		{
			System.out.println("AGC");
		}

	}

}

Measured memory_bytes: 35728
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;

int main(){
ULL N, P, c, ans=1; cin >> N >> P;
if(N==1){cout << P << "\n"; return 0;}
for(c=0; P%2==0; c++){P=P/2;}
ans=ans*pow(2,c/N);
for(ULL i=3; i*i<=P; i+=2){
   for(c=0; P%i==0; c++){P=P/i;}
   ans=ans*pow(i,c/N);
}
cout << ans << "\n";
}

Measured memory_bytes: 256
in_data = input()
 
data = in_data.split(' ')
A = int(data[0])
B = int(data[1])
if B == 1:
  print("0")
else:
  c = (B - 1) // (A - 1)
  d = (B - 1) / (A - 1)
  if c < d:
    c = c + 1
  print(c)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	//0250 start
	//0327 cording end
	//0351 sample matched AC
	//reference kmatsunaga's code
	
	int [] hash, pos;
	int max, n;
	int size = 400;
	ArrayList<String> anslist;
	HashSet<String> dup;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n == 0) break;
			max = sc.nextInt();
			hash = new int[size + 1];
			for(int i = 0 ; i < n * (n - 1) / 2 - 1; i++){
				hash[sc.nextInt()]++;
			}
			pos = new int[n];
			pos[0] = 0;
			pos[n-1] = max;
			anslist = new ArrayList<String>();
			dup = new HashSet<String>();
			dfs(0,0,n-1);
			for(int i = 0 ; i < anslist.size(); i++){
				System.out.println(anslist.get(i));
			}
			System.out.println("-----");
		}
	}
	
	private void dfs(int deep, int left, int right) {
		if(deep == n - 2){
			//System.out.println(Arrays.toString(pos));
			String str = tostr();
			if(dup.contains(str)) return;
			dup.add(str);
			anslist.add(str);
			return ;
		}
		
		int cand = max;
		for(;hash[cand] <= 0;cand--){
			if(cand == 0) break;
		}
		int pair = max - cand;
		if(hash[cand] < 0 || hash[pair] < 0) return ;
		pos[left + 1] = pair;
		dfs2(deep, left, right, pair, 0);
		pos[left + 1] = 0;
		
		pos[right - 1] = cand;
		dfs2(deep, left, right, cand, 1);
		pos[right - 1] = 0;
		
	}

	private void dfs2(int deep, int left, int right, int cand, int digit) {
		int nright = -1, nleft = -1;
		if(digit == 1){
			nright = right -1;
			nleft = left;
		}
		else{
			nright = right;
			nleft = left + 1;
		}
		
		boolean flg = false;
		
		for(int i = 0 ; i <= left; i++){
			if(hash[cand - pos[i]] <= 0){
				flg = true;
			}
		}
		
		if(! flg){
			for(int i = 0 ; i <= left; i++){
				hash[cand - pos[i]]--;
			}
			
			for(int i = right; i < n; i++){
				if(hash[pos[i] - cand] <= 0){
					flg = true;
					break;
				}
			}
			
			if(! flg){
				for(int i = right; i < n; i++){
					hash[pos[i] - cand]--;
				}
				
				dfs(deep + 1, nleft, nright);
				
				for(int i = right; i < n; i++){
					hash[pos[i] - cand]++;
				}
			}
			
			for(int i = 0 ; i <= left; i++){
				hash[cand - pos[i]]++;
			}
		}
	}

	private String tostr() {
		StringBuilder sb = new StringBuilder();
		for(int i = 1; i< pos.length; i++){
			sb.append(" " + (pos[i] - pos[i-1]));
		}
		return sb.substring(1);
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>

using namespace std;

int main()
{
	char c;
	scanf("%c",&c);
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
	printf("vowel\n");
	else
	printf("consonant\n");
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int i, j, k;
  char first, second, third, forth;
  char a[11], b[11], c[11];
  
  scanf("%s %s %s" ,a, b, c);
  
  for(i = 0; a[i] != '\0'; i++){}
  for(j = 0; b[j] != '\0'; j++){}

  if(a[i-1] == b[0] && b[j-1] == c[0]){
    printf("YES\n");
  } else{
    printf("NO\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(x-r>=0 && x+r<=W){
		if(y-r>=0 && y+r<=H){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
# coding:utf-8
import sys

def main():
    a = list(input())

    for i, tap in enumerate(a):
        i = i + 1
        if i % 2 != 0:
            if tap == 'L':
                print('No')
                sys.exit()

        elif i % 2 == 0:
            if  tap == 'R':
                print('No')
                sys.exit()

    print('Yes')

if __name__ == '__main__' :
    main()

Measured memory_bytes: 3060