akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, std::string S){
    VI w(N);
    VI b(N);
    int wcnt=0;
    int bcnt=0;
    REP(i, N){
        if(S[i]=='#')bcnt++;
        if(S[N-i-1]=='.')wcnt++;
        w[N-i-1]=wcnt;
        b[i]=bcnt;
    }
    int ans=600000;
    REP(i,N-1){
        debug(b[i])
        debug(w[i+1])
        ans=min(ans,b[i]+w[i+1]);
    }
    ans=min(ans,bcnt);
    ans=min(ans,wcnt);
    if(bcnt==0 || wcnt==0){cout<<0<<endl;}
    else cout<<max(0,ans)<<endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

namespace abc062_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[] s = new string[x[0]];
            for (int i = 0; i < x[0]; i++)
            {
                s[i] = Console.ReadLine();
            }
            for (int i = 0; i < x[1] + 2; i++)
            {
                Console.Write('#');
            }
            Console.WriteLine();
            for (int i = 0; i < x[0]; i++)
            {
                Console.WriteLine("#" + s[i] + "#");
            }
            for (int i = 0; i < x[1] + 2; i++)
            {
                Console.Write('#');
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13396
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

丈夫な橋から潤に採用していき、Union-findしていく

その時点でつながっているものを数える

全体からひけば答え

*/

class Edge{
	Node node1;
	Node node2;
	long value;
	this(Node node1, Node node2, long value){
		this.node1 = node1, this.node2 = node2;
		this.value = value;
	}
}

class Node{
	long id;
	long value;
	Group group;
	this(long id, long value){
		this.id = id;
		this.value = value;
	}
}

class Group{
	long value;
	long pendingEdgeCount;
	long id;
	Node[] nodes;
	this(Node node){
		this.id = node.id;
		this.nodes = [node];
		this.value = node.value;
	}
	void eat(Group gp){
		if(gp.nodes.length > this.nodes.length) gp.eat(this);
		else{
			foreach(nd; gp.nodes){
				this.nodes ~= nd;
				nd.group = this;
				this.value += nd.value;
			}
			this.pendingEdgeCount += gp.pendingEdgeCount;
		}
	}
}

void main(){
	long n = read.to!long;
	long m = read.to!long;
	
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i, 0);
	
	foreach(nd; nodes){
		nd.group = new Group(nd);
	}
	
	Edge[] edges;
	foreach(i; 0 .. m){
		long a = read.to!long - 1;
		long b = read.to!long - 1;
		
		edges ~= new Edge(nodes[a], nodes[b], i);
	}
	
	edges.sort!"a.value>b.value"();
	
	long[] answers;
	long total = n * (n - 1) / 2;
	long okcount = 0;
	foreach(ed; edges){
		answers ~= total - okcount;
		if(ed.node1.group.id != ed.node2.group.id){
			okcount += ed.node1.group.nodes.length * ed.node2.group.nodes.length;
			ed.node1.group.eat(ed.node2.group);
		}
	}
	
	foreach_reverse(ans; answers) ans.writeln;
	
}


Measured memory_bytes: 49532
#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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);
	
	int N;
	cin >> N;
	map<int,int> a;
	for(int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		if(a.count(tmp) == 0) a[tmp] = 1;
		else a[tmp]++;
	}

	int ans = 0;
	for(auto itr=a.begin(); itr!=a.end(); itr++){
		if(itr->first <= itr->second) ans += itr->second-itr->first;
		else ans += itr->second;
	}
	cout << ans << endl;

	return 0;
}



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

namespace CRemainderMinimization2019
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long l = inputs[0], r = inputs[1];

            // 2019 は素因数分解すると 3 * 673 となる
            // r 以下の 673 の倍数と 3 の倍数は下記の通り
            var multiple673 = (r / 673) * 673;
            var multiple3 = (r / 3) * 3;

            var minMod = int.MaxValue;
            if (l <= multiple673 && l <= multiple3)
            {
                minMod = 0;
            }
            else
            {
                for (var i = l; i <= r - 1; i++)
                {
                    for (var j = l + 1; j <= r; j++)
                    {
                        var mod = i * j % 2019;
                        if (mod < minMod) minMod = (int)mod;
                    }
                }
            }

            // 解答の出力
            Console.WriteLine(minMod);
        }
    }
}


Measured memory_bytes: 13268
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def inversion(a):
    "転倒していない組(l, r)の個数を求める"
    d = {av: i+1 for i, av in enumerate(sorted(a))}
    b = Bit(len(a))
    ans = 0
    for i, av in enumerate(a):
        ans += b.sum(d[av])
        b.add(d[av], 1)
    return ans


def solve(N: int, a: "List[int]"):

    def isOK(y):
        acc = (1 if aa >= y else -1 for aa in a)
        acc = tuple([0]) + tuple(accumulate(acc))
        invs = inversion(acc)
        if acc[0] == -1:
            invs -= 1
        return invs < (N*(N+1))//4

    def binary_search(x):

        ng = -1
        ok = len(x)+1

        while abs(ok - ng) > 1:
            mid = (ok + ng)//2
            if isOK(mid):
                ok = mid
            else:
                ng = mid
        return ng, ok

    ng, ok = binary_search(range(max(a)))
    print(ng)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 131256
# [i, j] の中に2019の倍数があれば、その倍数を選択すれば最小値を0

import math

L, R = map(int, input().split())
mod = 2019

# (A * B) % mod = (A % mod) * (B % mod) % mod
l = L % 2019
r = R % 2019

ans = None
# mod以上差があれば2019の倍数を含んでいる (ex. 2 & 2025)
if R - L >= mod:
    ans = 0
else:
    # mod以上差がなくても、あまりが0をまたぐ (ex. 2018 & 2025 => 2018 & 6) 場合
    if l > r:
        ans = 0
    else:
        _min = 2019 * 2019
        for i in range(l, r):
            for j in range(i+1, r+1):
                _min = min(_min, i*j%mod)
        ans = _min

print(ans)


Measured memory_bytes: 3060
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
// Time Complexity: faster than O(logN)[O(ArkInv(N))]
// UnionFind.data: if minus -> size of subtree (node is root)
// if plus -> parent of the node

struct UnionFind {
    vector<int> data;
    UnionFind(int sz){
        data.assign(sz,-1);
    }
    int find(int x){
        if(data[x]<0) return x;
        return data[x]=find(data[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x==y) return;
        if(data[x]>data[y]) swap(x,y);
        data[x]+=data[y];
        data[y]=x;
        return;
    }
    int size(int x){
        return (-data[find(x)]);
    }
    int same(int x,int y){
        return find(x)==find(y);
    }
};
#pragma endregion library

int main(){
    int n,m; cin >> n >> m;
    map<int,int> mp;
    rep(i,n){
        int p; cin >> p;
        mp[i+1]=p;
    }
    UnionFind uf(n+1);
    rep(i,m){
        int x,y; cin >> x >> y;
        uf.unite(x,y);
    }
    int ans=0;
    rep(i,n){
        if(uf.same(i+1,mp[i+1]))ans+=1;

    }
    cout << ans << '\n';
    
}

Measured memory_bytes: 5376
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>

using namespace std;
int main( )
{
	int N;
	cin>>N;
	if(1<=N&&N<=100)
    N=(1+N)*N/2;
    cout<<N<<endl;
		
	return 0;
}

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

using namespace std;

int main()
{
    vector<int> nums(4);
    for (int i = 0; i < 4; i++)
    {
        scanf("%d", &nums[i]);
    }
    sort(nums.begin(), nums.end());

    printf("%s\n", nums[0] == 1 && nums[1] == 4 && nums[2] == 7 && nums[3] == 9 ? "YES" : "NO");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>

using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
	{
		cout<<"Possible"<<endl;
	}
	else cout<<"Impossible"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

double calc(int x){
    double s = 0;
    int now = x;
    while (now>0){
        s += now % 10;
        now /= 10;
    }
    return (double)x / s;
}

int ketawa(int x){
    int s = 0;
    int now = x;
    while (now > 0)
    {
        s += now % 10;
        now /= 10;
    }
    return s;
}

bool sunuke(int x){
    repf(i,x+1,x+1000001){
        if (calc(x)>calc(i))
            return false;
    }
    return true;
}

int main()
{
    int k;
    cin >> k;
    int cnt = 1;
    ll bef,now;
    repf(i, 1, 10) cout << i << endl;
    bef = 9;
    k -= 9;
    while (k>0){
        int x = 1;
        while (9*cnt+ketawa(x)>x){
            now = x;
            rep(j, cnt){
                now *= 10;
                now += 9;
            }
            if (now<=bef){
                x++;
                continue;
            }
            cout << now << endl;
            x++;
            k--;
            bef = now;
            if (k==0)
                return 0;
        }
        cnt++;
    }
}

Measured memory_bytes: 256
a, b, k = map(int , input().split())

#もし高橋君がクッキーを 1 枚以上持っているなら、高橋君のクッキーを 1 枚食べる。
#そうでなく、もし青木君がクッキーを 1 枚以上持っているなら、青木君のクッキーを 1 枚食べる。
#高橋君も青木君もクッキーを持っていないなら、何もしない。

if k <= a:
  print(a-k, b)
elif a < k and k <= (a + b):
  print(0, a+b-k)
elif (a + b) < k:
  print(0, 0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=0;
  if(a>=k)
    ans=k;
  else if(a+b>=k)
    ans=a;
  else ans=a-(k-a-b);
  cout<<ans;
  return 0;
}


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

int main()
{
	int a, b, c , d , i;
	d = 0;
	cin >> a >> b >> c;
	for ( i= a ; i <= b ; i++ ){
		if (c%i == 0) d++;
	}
	cout << d << endl;
		return 0;
}



Measured memory_bytes: 3100
def factorials(M):#M!までのリストｘと其の逆元のリストyを返すmod INF
    INF=int(1e9+7)
    fac=[0]*(M+1)
    finv=[0]*(M+1)
    inv=[0]*(M+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,M+1):
        fac[i]=(fac[i-1]*i)%INF
        inv[i]=INF-(inv[INF%i]*(INF//i))%INF
        finv[i]=finv[i-1]*inv[i]%INF
    return fac,finv
def nCr(n,r):
    INF=int(1e9+7)
    if n<r or r<0 or n<0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%INF)%INF
N,K=map(int,input().split())
MOD=10**9+7
fac,finv=factorials(10**5)
for i in range(1,K+1):
    #N-K+1このポケットにi個選ぶ
    l=nCr(N-K+1,i)
    s=nCr(K-1,i-1)
    print((l*s)%MOD)


Measured memory_bytes: 45552
#!/usr/bin/python

def main():
    dishes = []
    for _ in range(5):
        dishes.append(int(input()))
    _sum = sum([maxtime(d) for d in dishes])
    _sum -= max([remtime(x) for x in dishes])
    print(_sum)
    
def maxtime(num):
    return (num + 9) // 10 * 10

def remtime(num):
    return maxtime(num) - num


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define ppa     pair<pair<int,int>,int>
#define pap     pair<int,pair<int,int>>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define qqq 400005


void Weapons19(){
    int n;cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                int p=__gcd(i,j);
                p=__gcd(p,k);
                sum+=p;
            }
        }
    }
    cout<<sum;




















}

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);


    Weapons19();
    
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#define llong long long
using namespace std;

const int N = 16;
const int P = 1000000007;
#define modinc(x) {if(x>=P) x-=P;}
#define negmod(x) {x=x%P+P; modinc(x);}
llong dp[N+2][(1<<N)+2];
int a[N+2];
llong fact[(1<<N)+2];
llong finv[(1<<N)+2];
int n,m;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	} return ret;
}
llong mulinv(llong x) {return finv[x+1]*fact[x]%P;}
llong comb(llong x,llong y) {return (x<0 || y<0 || x<y) ? 0ll : (fact[x]*finv[x-y]%P)*finv[y]%P;}

int main()
{
	fact[0] = 1ll;
	for(int i=1; i<=(1<<N); i++) fact[i] = fact[i-1]*i%P;
	finv[(1<<N)] = quickpow(fact[(1<<N)],P-2);
	for(int i=(1<<N)-1; i>=0; i--) finv[i] = finv[i+1]*(i+1)%P;
	scanf("%d%d",&n,&m);
	for(int i=0; i<m; i++) {scanf("%d",&a[i]); a[i]--;}
	reverse(a,a+m);
	dp[0][0] = 1ll;
	for(int i=0; i<m; i++)
	{
		for(int j=0; j<(1<<n); j++)
		{
			dp[i+1][j] += dp[i][j]; modinc(dp[i+1][j]);
			int rem = (1<<n)-a[i]-1;
			for(int k=0; k<n; k++) if(j&(1<<k)) rem -= (1<<k);
			for(int k=0; k<n; k++)
			{
				if((j&(1<<k))==0)
				{
					dp[i+1][j|(1<<k)] += dp[i][j]*comb(rem,(1<<k)-1)%P; modinc(dp[i+1][j|(1<<k)]);
				}
			}
		}
	}
	llong ans = 0ll;
	for(int i=0; i<(1<<n); i++)
	{
		int cnt = 0,rem = (1<<n)-1; llong cur = dp[m][i];
		for(int j=0; j<n; j++) if(i&(1<<j)) {cnt++; rem -= (1<<j);}
		for(int j=0; j<n; j++)
		{
			if((i&(1<<j))==0)
			{
				cur = cur*comb(rem,(1<<j))%P;
				rem -= (1<<j);
			}
		}
		ans += ((cnt&1) ? -1 : 1)*cur; negmod(ans);
	}
	for(int i=1; i<n; i++) ans = ans*fact[(1<<i)]%P;
	printf("%lld\n",ans*(1ll<<n)%P);
	return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }


int main(){
    int n; cin >> n;
    cout << 1110 - n << endl;
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  int maxa = 0;
  for ( int i = 0; i < n; i++ ) {
    cin >> a[i];
    maxa = max(maxa, a[i]);
  }
  
  int left = 0;
  int right = maxa;
  while ( right - left > 1 ) {
    int mid = (right+left)/2;

    long long cut = 0;
    for ( int i = 0; i < n; i++ ) {
      cut += (a[i]-1)/mid;
    }

    if ( cut <= k ) { right = mid; } else { left = mid; }
  }

  cout << right << endl;
  return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll answer = 0;
    for (int i = 0; i < S.size(); i++)
    {
        answer *= 10;
        if (S.at(i) == '1')
        {
            answer += 9;
        }
        else
        {
            answer += 1;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
//写経
//順番に約数をうつしていって
//半分超えたところで終わり。

#include <iostream>
#include <vector>
using namespace std;

int cnt_digits(long long n){
    int digits =0;
    while(n>0){
        n /=10;
        digits++;
    }

    return digits;
}

int main(void){
    long long n;
    cin >> n;

    int ans=cnt_digits(n);

    for(long long a= 1 ; a*a <=n; ++a ){
        if(n%a != 0){
            continue;
        }

        const long long b=n/a;

        const int cur=max(cnt_digits(a), cnt_digits(b));

        if(ans > cur){
            ans= cur;
        }
    }

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


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 205;
const int   mod = 998244353;

void add(int&a,int b)   {   a += b; if (a >= mod)   a -= mod;   }
void sub(int&a,int b)   {   a -= b; if (a <  0)     a += mod;   }

int mul(int a,int b)    {   return  1ll * a * b % mod;  }
int inv(int a,int p)    {   return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;    }
int Pow(int a,int b)    {
    int ans = 1;
    while  (b)  {
        if (b & 1)  ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}

string calc(string A,string B)  {
    while (A.size() && B.size())    {
        if (A.size() > B.size())
            A.swap(B);
        
        for(int i = 0 ; i < sz(A) ; ++i)    {
            B[i] ^= A[i];
            B[i] += '0';
        }
        reverse(all(B));    while (sz(B) && B.back() == '0')    B.pop_back();
        reverse(all(B));
    }
    if (A.empty())  return  B;
    if (B.empty())  return  A;

    assert(0);
}

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

    int n;  cin >> n;

    string lim; cin >> lim;
    string gcd;

    for(int i = 0 ; i < n ; ++i)    {
        string S;   cin >> S;
        if (i == 0) gcd = S;
        else        gcd = calc(gcd,S);
    }
    if (sz(lim) < sz(gcd))  {
        cout << "1\n";
        return  0;
    }
    string tmp = string(sz(lim),'0');
    int ans = 0;

    for(int i = 0 ; i <= sz(lim) - sz(gcd) ; ++i)   {
        if (lim[i] != tmp[i])
            for(int j = 0 ; j < sz(gcd) ; ++j)  {
                tmp[i + j] ^= gcd[j];
                tmp[i + j] += '0';
            }
        if (lim[i] == '1')
            add(ans,Pow(2,sz(lim) - sz(gcd) - i));
    }    
    if (tmp <= lim)
        ans++;
    
    cout << ans << endl;
}

Measured memory_bytes: 3704
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    K = int(input())
    k2 = K // 2
    if K % 2 == 1:
        print(k2 * (k2 + 1))
    else:
        print(k2 ** 2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		string ans = "consonant";
		if(str == "a" || str == "i" || str == "u" || str == "e" || str == "o"){
			ans = "vowel";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();

		int a[] = new int[105];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}


		int choco = 0;

		for (int i = 0; i < n; i++) {
			int days = 1;
			do {
				choco += 1;
				days += a[i];
			}while(days <= d);
		}

		choco += x;

		System.out.println(choco);
	}
}


Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
int n,h[100010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	for(int i=n;i>1;i--)
		if(h[i-1]-h[i]>=2)
		{
			printf("No\n");
			return 0;
		}
		else if(h[i-1]-h[i]==1)
			h[i-1]--;
	printf("Yes\n");
	return 0;
}

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

int main(){
    int n;
    bool ans = false;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s == "Y") {
            ans = true;
            break;
        }
    }
    if(ans){
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
}

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

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

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

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	vl sum(n+1);
	rep(i,n){
		sum[i+1]=sum[i]+v[i];
	}
	ll ans=LINF;
	range(i,0,n-1){
		chmin(ans,abs(sum[i+1]-(sum[n]-sum[i+1])));
	}
	puta(ans);
}


Measured memory_bytes: 3328
import math
a,b,C = map(float,input().split())

S = a*b*0.5*math.sin(math.radians(C)) 

c = (a**2 + b**2 -2*a*b*math.cos(math.radians(C)))**0.5

h = S*2/a

print(S)
print(a+b+c)
print(h)


Measured memory_bytes: 5700
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

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

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let k = read::<usize>();
    for &ch in &s {
        if ch == s[k - 1] {
            print!("{}", ch);
        } else {
            print!("*");
        }
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

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

    int ans = 0;
    while (1) {
        if (*max_element(h.begin(), h.end()) == 0) break;
        int l = 0;
        while (h[l] == 0) l++;
        int r = l + 1;
        while (r < N && h[r] > 0) r++;
        for (int i = l; i < r; i++) h[i]--;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!

s = input()
sList = list(s)
sList = [int(i) for i in s]
sCount = len(sList)
#print(sCount)

aaa = 0

for i in range(2**(sCount-1)):

    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(sCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    
    for i in range(sCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+'
    
    #print(sList)
    #print(binaryNumber)
    
    result = [None]*(len(sList)+len(binaryNumber))
    result[::2] = sList
    result[1::2] = binaryNumber
    
    while 0 in result:
        result.remove(0)
    
    #print(result)    
    result = map(str, result)
    resultStr = ''.join(result)
    
    aaa = aaa + eval(resultStr)
    
print(aaa)
        
    
    
    

Measured memory_bytes: 3064
#!/usr/bin/env python
import sys

if __name__ == '__main__':
    s = reduce(lambda a,b : a+b, sys.stdin).lower()

    for c in [chr(i) for i in range(0x61, 0x7b)]:
        print '{} : {}'.format(c, len(filter(lambda x: x==c, s)))


Measured memory_bytes: 4672
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

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

  int N;
  cin >> N;
  vector<int> a(N);
  for (auto &x: a) cin >> x;

  // b1 + b2 + b3 + b4 + b5 + b6 = a1
  //      b2      + b4      + b6 = a2
  //           b3           + b6 = a3
  //                b4           = a4
  //                     b5      = a5
  //                          b6 = a6

  vector<bool> b(N);
  for (int i = N; i >= 1; i--) {
    int ballCount = 0;
    for (int j = i * 2; j <= N; j+=i) {
      if (b[j-1]) ballCount++;
    }
    if (ballCount % 2 == a[i-1]) continue;
    else b[i-1] = true;
  }
  vector<int> ans;
  for (int i = 0; i < N; i++) {
    if (b[i]) ans.push_back(i+1);
  }

  cout << ans.size() << endl;
  for (auto &x: ans) cout << x << endl;

  return 0;
}


Measured memory_bytes: 2424
from itertools import product
n,m = map(int,input().split())
lamp = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in product([0,1],repeat=n):
    ac = True
    for k,b in enumerate(lamp):
        tmp = 0
        for a in b[1:]:
            tmp += i[a-1]
        if p[k] != tmp%2:
            ac = False
            break
    if ac:
        ans += 1
print(ans)



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::sort(a, a + n);
	
	int64_t res = 0;
	if (!(n & 1)) {
		int half = n / 2;
		int cnt = 0;
		for (int i = 0; i + 1 < n; i++) {
			if (i < half - 1) cnt += 2;
			else if (i < half) cnt++;
			else if (i < half + 1) cnt--;
			else cnt -= 2;
			res += (int64_t) (a[i + 1] - a[i]) * cnt;
		}
	} else {
		int half = n / 2;
		for (int i = 0; i < 2; i++) {
			int64_t cur_res = 0;
			int cnt = 0;
			for (int j = 0; j + 1 < n; j++) {
				if (j < half - i) cnt += 2;
				else if (j < half - i + 2) cnt += i ? 1 : -1;
				else cnt -= 2;
				cur_res += (int64_t) (a[j + 1] - a[j]) * cnt;
			}
			res = std::max(res, cur_res);
		}
	}
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  cout << ((a + b) + 2 -1) / 2 << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int64_t X, Y;
	std::cin >> X >> Y;

	size_t i = 0;
	for (int64_t x = X; x <= Y; x *= 2)
	{
		++i;
	}

	std::cout << i << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int count,num = 0;
  int side[1000][3] = {};

  scanf("%d", &num);

  for(count = 0;count < num;count++) {
    scanf("%d %d %d",&side[count][0],&side[count][1],&side[count][2]);
  }

  count = 0;
  while(count < num) {
    int sq[3] = {};
    sq[0] = side[count][0]*side[count][0];
    sq[1] = side[count][1]*side[count][1];
    sq[2] = side[count][2]*side[count][2];
    if(sq[0] == (sq[1] + sq[2]) || sq[1] == (sq[0]+sq[2]) || sq[2] == (sq[0] + sq[1])) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
    count++;
  }
  return 0;
}

Measured memory_bytes: 596
#include<complex>
#include<stdio.h>
#define F(a,b,c) acos((b*b+c*c-a*a)/2/b/c)
int main(){typedef double D;int n;D d,e,f,g,h,i;for(scanf("%d",&n);n--;){scanf("%lf%lf%lf%lf%lf%lf",&d,&g,&e,&h,&f,&i);std::complex<D> a(d,g),b(e,h),c(f,i);float A=abs(b-c),B=abs(c-a),C=abs(a-b),L=F(A,B,C),s=sin(2*L),t=sin(2*F(B,C,A)),u=sin(2*F(C,A,B)),v=s+t+u;printf("%.3f %.3f %.3f\n",(d*s+e*t+f*u)/v,(g*s+h*t+i*u)/v,A/sin(L)/2);}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
U_MAP mp;
ll dat[ohara];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n){
            dat[a[i]]++;
    }
    rep(i,2*1000+10)dat[i+1]+=dat[i];
    rep(i,n){
        rrep(j,i+1,n){
            b=a[i];
            c=a[j];
            ll hitotu=abs(b-c),futatu=b+c;
            ans+=dat[futatu-1]-dat[hitotu];
            if(hitotu<b&&b<futatu)ans--;
            if(hitotu<c&&c<futatu)ans--;
            //cout<<i<<" "<<j<<" "<<futatu<<" "<<hitotu<<"\n";
        }
    }
    Cout(ans/3);
    return 0;
}

Measured memory_bytes: 2304
n = int(input())
A = [int(i) for i in input().split()]
assert len(A) == n
S = sum(A)
ans = S
for i in range(1, n, 2):
    ans -= A[i] * 2
print(ans, end=' ')
for i in range(1, n):
    ans = A[i - 1] * 2 - ans
    print(ans, end=' ')
print()

Measured memory_bytes: 14092
def main():
    n, k = map(int, input().split())
    if n > k:
        print(0)
        return
    mod = 10 ** 9 + 7
    ans = 1
    for i in range(n):
        ans *= k - i
        ans %= mod

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  cout << max(max(a+a-1,b+b-1),a+b);
}

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

#define what_is(x) cout << #x << " is " << x << endl;
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 1000000000000000000
#define ninf -9223372036854775802
#define M 1000000007
#define eps 1e-9
#define MAX 5
#define N 8
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX];
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a, ll b, ll p) {
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    ll temp = vpow(a, b / 2, p);
    temp *= temp;
    temp %= p;
    if (b % 2 == 0)
        return temp;
    temp = temp * a;
    temp %= p;
    return temp;
}

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


ll inverseMod(ll a, ll b, ll p) {
    if (b == 0)
        return 1;
    ll temp = vpow(b, p - 2, p);
    ll ans = temp * a;
    ans %= p;
    return ans;
}
void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}

void factorial() {
    fact[0] = 1;
    fact[1] = 1;
    rep(i, 2, MAX) {
        fact[i] = (fact[i - 1] * i);
        // fact[i]%=M;
    }
}

void solve(ll ttt) {
	ll n;
	cin>>n;
	ll ans=0,ans2=0;
	if(n<2){
		ans2=0;
	}
	else{
		ll tot=1,two=1,one=1;
		//ans=(n*(n-1))%M;
		ll nn=n;
		//n-=2;
		//while(n>0){
			//ans*=10;
			//ans%=M;
			//n--;
		//}
		while(nn>0){
			tot*=10;
			tot%=M;
			one*=9;
			one%=M;
			two*=8;
			two%=M;
			nn--;
		}
		ans2=tot-2*one+two;
		ans2%=M;
		if(ans2<0)
			ans2+=M;
	}
	//what_is(ans2);

	cout<<ans2<<endl;
}

int main() {
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    // freopen("output1.txt","w",stdout);
#endif

    ll t = 1;
    //cin >> t;
    fix(12);
    rep(q, 1, t + 1) {
        // cout<<"Test case : "<<q<<endl;
        solve(q);
        //solve2();
    }
    return 0;

}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
char map[110][110];
int m, n;
signed main() {
	cin >> m >> n;
	for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++)cin >> map[i][j];
	for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++) {
		if (map[i][j] == 'o') {
			if (map[i][j - 1] != 'o'&&map[i][j - 1] != 'x')map[i][j - 1] = '*';
			if (map[i][j + 1] != 'o'&&map[i][j + 1] != 'x')map[i][j + 1] = '*';
		}
		else if (map[i][j] == 'x') {
			for (int p = -1; p <= 1; p++)for (int q = -1; q <= 1; q++)if (map[i + p][j + q] != 'o'&&map[i + p][j + q] != 'x')map[i + p][j + q] = '*';
		}
		else if (i == 1)if (map[i][j] != 'o'&&map[i][j] != 'x')map[i][j] = '*';
	}
	int ans = 0;
	for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++)if (map[i][j] == '-') ans++;
	cout << ans << endl;
}


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

d = {}

for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

ans = 0
for k, v in d.items():
    if k == v:
        continue
    elif v > k:
        ans += v - k
    else:
        ans += v

print(ans)


Measured memory_bytes: 17780
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.next()

  println(abc162a(n))
}

private fun abc162a(n: String): String {
  if (n.indexOf('7') != -1) {
    return "Yes"
  }

  return "No"
}


Measured memory_bytes: 37500
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	double N;
	vector<double>a(5);
	double time = 0;
	cin >> N;
	REP(i, 5) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	double m = a[0];
	time = ceil(N / m);
	time += 4;
	cout << setprecision(16) << time << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=200010;
int a[N];
ll solve(){
	int n=read();
	ll ans=0;
	for (int i=1;i<=n;++i){
		a[i]=read();
		if (a[i]-a[i-1]>1) return -1;
	}
	if (a[1]!=0) return -1;
	for (int i=n;i>=1;--i){
		if (a[i]==a[i+1]-1) continue;
		ans+=(ll)a[i];
	}
	return ans;
}
int main(){
	cout<<solve()<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N,K;
    cin>>N>>K;
    vint D(K);
    for (size_t i = 0; i < K; i++)
    {
        cin>>D[i];
    }
    
    for (size_t i = N; i <= N*20; i++)
    {
        string str = to_string(i);
        for (size_t j = 0; j < K; j++)
        {
            if(str.find(to_string(D[j])) != string::npos)
            goto L;
        }
        cout<<i<<endl;
        return 0;
        L:;
    }
    
    return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    
    int cnt = n/x;
    cnt *= t;
    if(n%x != 0)
      cnt += t;
    
    System.out.println(cnt);
  }
}

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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  int leng=100;
  vector<int> A_l;
  int count;
  if(A>B)count=B;
  else count=A;
  int C =0;

  for(int i=0;i<count;i++){
    int num=i+1;
    if(A%num==0&&B%num==0){
      A_l.push_back(num);
  }
  }
  sort(A_l.begin(),A_l.end(),greater<int>());
  cout<<A_l.at(K-1)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    if (abs(x - y) <= 1) cout << "Brown\n";
    else cout << "Alice\n";
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  int add = a;

  vector<int> amari(105);
  while(1){
    int r = a%b;
    if(amari.at(r)) break;
    amari.at(r)++;
    if(r==c){cout<<"YES"; return 0;}
    a+=add;
    a%=b;
    //cout << a << " ";
  }

  cout << "NO";
}

Measured memory_bytes: 3596
import statistics


n = int(input())
x = list(map(int, input().split()))
m_low = statistics.median_low(x)
m_high = statistics.median_high(x)
for i in range(n):
    if x[i] > m_low:
        print(m_low)
    elif x[i] <= m_high:
        print(m_high)


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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans;
    ans=max(a*c,b*d);
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String line=sc.nextLine();
		
		int n=Integer.parseInt(line);
		
		if(n>=400&&n<=599) {
			System.out.println(8);
		}else if(n>=600&&n<=799) {
			System.out.println(7);
		}else if(n>=800&&n<=999) {
			System.out.println(6);
		}else if(n>=1000&&n<=1199) {
			System.out.println(5);
		}else if(n>=1200&&n<=1399) {
			System.out.println(4);
		}else if(n>=1400&&n<=1599) {
			System.out.println(3);
		}else if(n>=1600&&n<=1799) {
			System.out.println(2);
		}else if(n>=1800&&n<=1999) {
			System.out.println(1);
		}
		
	
		
		
	}

}


Measured memory_bytes: 35724
#include<stdio.h>
#include<string.h>
#define Max 2000000
#define Infty (1<<30)

int H,A[Max+1];

void maxheap(int i){
  int l,r,max,tmp;
  l=2*i;
  r=2*i+1;

  if(l <= H && A[l]>A[i])max=l;
  else max=i;
  if(r<=H && A[r]>A[max])max=r;

  if(max!=i){
    tmp=A[i];A[i]=A[max];A[max]=tmp;
    maxheap(max);
  }
}
int extract(){
  int m;
  if(H<1)return -Infty;
  m=A[1];
  A[1]=A[H--];
  maxheap(1);
  return m;
}
void inckey(int i,int key){
  int tmp;
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2] < A[i]){
    tmp=A[i];A[i]=A[i/2];A[i/2]=tmp;
    i=i/2;
  }
}
void insert(int k){
  H++;
  A[H]=-Infty;
  inckey(H,k);
}


int main(){
  int key;
  char com[10];

    while(1)
      {
        scanf("%s",com);
        if(com[0]=='e' && com[1] == 'n')break;
        if(com[0]=='i'){
          scanf("%d",&key);
          insert(key);
        }
        else {
          printf("%d\n",extract());
        }
      }

  return 0;
}








Measured memory_bytes: 5636