akhauriyash/Code-Regression huggingface dataset:
h, w = gets.strip.split.map(&:to_i)
s = h.times.map { gets.strip.split('') }
ar = [[0,-1],[1,0],[0,1],[-1,0]]

def area(y,x, h, w)
  flag = false
  flag = true if 1<=x && x<=w && 1<=y && y<=h
  return flag
end

(1..h).each do |i|
  (1..w).each do |j|
    if s[i-1][j-1] == "#"
      judge = false
      (1..ar.length).each do |p|
        if area( i + ar[p-1][1], j + ar[p-1][0], h, w )
          if s[i + ar[p-1][1] - 1][j + ar[p-1][0] - 1] == "#"
            judge = true
          end
        end
      end
      unless judge
          puts "No"
          exit 0
      end
    end
  end
end

puts ('Yes')

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

using namespace std;

int main(){
    int a, b, c, x, cnt = 0;
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= min(a, x / 500); ++i) {
        int ri = x - 500 * i;
        for (int j = 0; j <= min(b, ri / 100); ++j) {
            int rj = ri - 100 * j;
            if (rj / 50 <= c) ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<deque>
#include<iomanip>
#include<ctime>
using namespace std;


int main()
{
	int N, M;
	cin >> N;//駒数

	vector<int> position(N);//駒の位置
	bool isHere[2020] = { false };//対象のマスに駒が存在しているか

	//駒の位置を入力
	for (int i = 0; i < N; i++) {
		cin >> position[i];

		//駒が存在してることのフラグ
		isHere[position[i]] = true;
	}

	cin >> M;//駒の前進回数

	//移動命令毎に処理
	for (int i = 0; i < M; i++) {
		int target;
		cin >> target;//移動対象の駒
		target -= 1;//配列の要素番号にする

		//移動元のマスがゴールでない場合 && 次のマスに駒が存在していない場合
		if (position[target] < 2019 && !isHere[position[target] + 1]) {
			isHere[position[target]] = false;//駒の存在フラグを消す
			position[target] += 1;//マス移動
			isHere[position[target]] = true;//駒の存在フラグを立てる
		}
	}

	for (int i = 0; i < position.size(); i++) {
		cout << position[i] << endl;
	}

	return 0;
}


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


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

class ABallDistribution {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int n,k;
        cin >> n >> k;

        if (k > n){
            cout << 1 << endl;
        }
        if (k == 1 || k == n){
            cout << 0 << endl;
        }else {
            int most = n - (k - 1);
            cout << most - 1 << endl;
        }
	}
};


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


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

long long arr[500];

int main()
{
    int i;
    long long length,total;
    string line;
    cin>>line;
    length=line.length();
    for(i=0;i<length;i++)
    {
        arr[line[i]]++;
    }
    total=(length*(length-1))/2;
    for(i='a';i<='z';i++)
    {
        if(arr[i]>1)
        {
            total-=(arr[i]*(arr[i]-1))/2;
        }
    }
    cout<<total+1<<endl;
    return 0;
}


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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<int> v;
		rep(i,n)
		{
			int temp;
			cin >> temp;
			v.push_back(temp);
		}

		int o = 32;
		int i = 0;
		while(o > 0)
		{
			o -= (o-1) % 5;

			if(o >= 0) cout << o << endl;
			else cout << 0 << endl;

			if(o == 0) break;
			
			o -= v[i%n];
			i++;

			if(o >= 0) cout << o << endl;
			else cout << 0 << endl;

		}
	}
	return 0;
}

Measured memory_bytes: 1220
<?php

$n = trim(fgets(STDIN));
$ta = explode(' ', trim(fgets(STDIN)));
$t = $ta[0];
$a = $ta[1];
$h = explode(' ', trim(fgets(STDIN)));

$diffs = [];
for($i=0; $i<$n; $i++){
  $temp = $t - $h[$i] * 0.006; 
  $diff = abs($temp-$a);
  $diffs[$i+1] = $diff;
}
asort($diffs);
$key = array_keys($diffs);

echo $key[0];
  
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define LL long long
#define lowbit(x) (x&(-x))

struct xx {
	int xi,yi;
	bool operator < (const xx &_) const {
		return xi < _.xi;
	}
} w[N];
const int mo = 998244353;
LL Pow[N],Cnt[N][5];

LL C[N<<1],ed;
void Update(int idx) {
	while(idx <= ed) {
		C[idx] ++;
		idx += lowbit(idx);
	}
	return ;
}
LL Sum(int idx) {
	LL res = 0;
	while(idx > 0) {
		res += C[idx];
		idx -= lowbit(idx);
	}
	return res;
}

void Add(LL &res,LL x) {
	res = res+x >= mo? res+x-mo:res+x;
	return ;
}

int B[N<<1];
int main() {
	int n;
	cin >> n;
	Pow[0] = 1;
	for(int i=1; i<=n; i++) Pow[i] = Pow[i-1]*2%mo;

	int tot = 0;
	for(int i=1; i<=n; i++) scanf("%d%d",&w[i].xi,&w[i].yi),B[++tot] = w[i].xi,B[++tot] = w[i].yi;
	sort(B+1,B+tot+1);
	ed = unique(B+1,B+tot+1)-B-1;
	for(int i=1; i<=n; i++) {
		w[i].xi = lower_bound(B+1,B+ed+1,w[i].xi) - B;
		w[i].yi = lower_bound(B+1,B+ed+1,w[i].yi) - B;
	}

	sort(w+1,w+n+1);

	for(int i=1; i<=n; i++) {
		Cnt[i][3] = Sum(w[i].yi);
		Cnt[i][2] = i-1-Cnt[i][3];
		Update(w[i].yi);
	}
	memset(C,0,sizeof(C));
	for(int i=n; i>=1; i--) {
		Cnt[i][4] = Sum(w[i].yi);
		Cnt[i][1] = n-i-Cnt[i][4];
		Update(w[i].yi);
	}
	LL Ans = 0;
	for(int i=1; i<=n; i++) {
		Add(Ans,Pow[n-1]);
		LL C1 = Pow[Cnt[i][1]]-1,C2 = Pow[Cnt[i][2]]-1,C3 = Pow[Cnt[i][3]]-1,C4 = Pow[Cnt[i][4]]-1;

		Add(Ans,C1*C3%mo);
		Add(Ans,C2*C4%mo);

		Add(Ans,C1*C3%mo*C2%mo);
		Add(Ans,C1*C3%mo*C4%mo);

		Add(Ans,C2*C4%mo*C1%mo);
		Add(Ans,C2*C4%mo*C3%mo);

		Add(Ans,C1*C2%mo*C3%mo*C4%mo);
	}
	cout<<Ans;
	return 0;
}

Measured memory_bytes: 15872
#include<cstdio>
        char a[50][51],b[50][51];
        int main()
        {
        int i,j,k,l,n,m;scanf("%d%d",&n,&m);
        for(i=0;i<n;i++)scanf("%s",a[i]);
        for(i=0;i<m;i++)scanf("%s",b[i]);
        for(i=0;i<=n-m;i++)
        for(j=0;j<=n-m;j++){
        bool f=true;
        for(k=0;k<m&&f;k++)
        for(l=0;l<m&&f;l++)
        if(a[i+k][j+l]!=b[k][l])f=false;
        if(f)return puts("Yes"),0;
        }
        puts("No");
        return 0;
        }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int N;
int A[20];
int x[20][20];
int y[20][20];
 
int counter(int x) {
  if(x == 0) return 0;
  return counter(x >> 1) + (x & 1);
}
 
int main() {
  cin >> N;
  for(int i = 1; i <= N; i++) {
    cin >> A[i];
    for(int j = 1; j <= A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  for(int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for(int i = 1; i <= N; i++) {
      if(!(bits & (1 << (i-1)))) continue;
      for(int j = 1; j <= A[i]; j++) {
	if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
      }
    }
    if(ok) ans = max(ans, counter(bits));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
print(n//3)

Measured memory_bytes: 77368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>

int BipartiteGraph(const std::vector<std::vector<int> >& g) {
	std::vector<int> color(g.size(), 0);

	std::stack<int> s;
	s.push(0);
	color[0] = 1;

	while (!s.empty()) {
		int V = s.top();
		s.pop();

		int nuru = (color[V] == 1 ? 2 : 1);

		for (size_t i = 0; i < g.size(); i++)
		{
			if (g[V][i] == 1) {
				if (color[i] == color[V]) {
					return -1;
				}
				else if (color[i] != 0) {
					continue;
				}
				s.push(i);
				color[i] = nuru;
			}
		}
	}
	return 1;
}


int main() {
	int n;

	std::cin >> n;

	std::vector<std::vector<int> > graph(n, std::vector<int>(n, 0));

	for (size_t i = 0; i < n; i++)
	{
		std::string s;

		std::cin >> s;

		for (size_t j = 0; j < s.length(); j++)
		{
			if (s[j] == '1') {
				graph[i][j] = 1;
				graph[j][i] = 1;
			}
			else {
				graph[i][j] = 10000;
				graph[j][i] = 10000;
			}
		}
	}

	int is2graph = BipartiteGraph(graph);

	if (is2graph == -1) {
		std::cout << -1 << std::endl;
		return 0;
	}

	if (n == 2) {
		std::cout << 2 << std::endl;
		return 0;
	}

	for (size_t k = 0; k < n; k++)
	{
		for (size_t i = 0; i < n; i++)
		{
			for (size_t j = 0; j < n; j++)
			{
				graph[i][j] = std::min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}

	int max = 0;

	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = 0; j < n; j++)
		{
			max = std::max(max, graph[i][j]);
		}
	}

	std::cout << max + 1 << std::endl;

	return 0;
}

Measured memory_bytes: 384
#include  <iostream>
#include  <stdio.h>
using namespace std;


int main(){

    int N;
    int K;
    int J;
    cin >> N;
    cin >> K;

    if(N % 2 == 1){
        N = N + 1;
    }

    J = N / 2;

    if(J >= K){
        cout << "YES";
    }else{
        cout << "NO";
    }
    

}

Measured memory_bytes: 256
#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];
	}
	
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4024
#include<cstdio>
#include<algorithm>
#include<iostream> 
using namespace std;
int main(){
	int n;
	int a[100010];
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int j=1,ans=n;
	
	while (j<n){
		if (a[j]==a[j+1]) {
			ans-=2;
			j+=2;
		}
	else j++;
	}
	cout<<ans;
	return 0;
	
} 

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


int main (){
    int N;
    cin>>N;
    vector<int> A(N), B(N), C(N);
    for(int i=0; i<N; i ++){
        cin>>A.at(i);
    }
    for(int i=0; i<N; i ++){
        cin>>B.at(i);
    }
    for(int i=0; i<N-1; i ++){
        cin>>C.at(i);
    }
    int man=0;
    for(int i= 0; i<N; i++){
        //man +=B.at(A.at(i)-1);
      man+=B.at(i);
        if(i>0){
            if(A.at(i-1)+1==A.at(i)){
                man +=C.at(A.at(i-1)-1);
            }
        }
    }
    cout<<man<<endl;

}

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

const int N = (int)1e5 + 9;

vector < vector <int > > adj;
int vis[N] ,dp[N];
int dfs(int u){
	vis[u] = 1;
	for(auto to : adj[u]){
		if(!vis[to])
			dfs(to);
		dp[u] = max(dp[u],1+dp[to]);
	}
}
int32_t main()
{
	int n,m;
	cin>>n>>m;
	adj.resize(n+3);

	// int dp[n+3];
	// memset(dp,0,sizeof(dp));

	for(int i=0;i<m;i++){
		int u , v ;cin>>u>>v;
		adj[u].push_back(v);
	}

	for(int i=1;i<=n;i++){
		if(!vis[i])dfs(i);
	}
	cout << *max_element(dp,dp+n+1);


	return 0;
}        

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define test cout<<"#"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll h, w;
	cin>>h>>w;
	char v[h][w];
	for(ll x = 0; x < h; x++)
	{
		for(ll y = 0; y < w; y++)
		{
			cin>>v[x][y];
		}
	}
	ll ans[h+1][w+1];
	memset(ans, 0, sizeof(ans));
	if(v[0][0] == '#')
	{
		cout<<0<<"\n";
		return 0;
	}
	ans[1][1] = 1;
	for(ll x = 1; x <=h; x++)
	{
		for(ll y = 1; y<=w; y++)
		{
			if(!(x==1 && y==1))
			{
				if(v[x-1][y-1] == '#')
					ans[x][y] = 0;
				else
					ans[x][y] = (ans[x-1][y]%mod + ans[x][y-1]%mod)%mod;
				
			}
		}
	}
	cout<<ans[h][w]<<"\n";
}


Measured memory_bytes: 9088
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = lambda: sys.stdin.readline().rstrip()

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

#dp[i][j]は最初のi枚まで投げてj枚表になる確率
#初期化
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
#初期条件 0枚投げたとき0枚表→1
dp[0][0] = 1

for i in range(N):
    for j in range(N):
        dp[i+1][j] += dp[i][j] * (1 - p[i])
        dp[i+1][j+1] += dp[i][j] * p[i]

#i == N で j >= (N+1)/2 のものを足し合わせる
ans = 0
for j in range((N+1)//2, N+1):
    ans += dp[N][j]
print(ans)

Measured memory_bytes: 257544
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	int n; cin >> n;
	string s; cin >> s;

	int before[2] = {0}, after[2] = {0};
	each(c, s) after[c == '#']++;

	int ans = after[0];

	each(c, s) {
		after[c == '#']--;
		before[c == '#']++;
		ans = min(ans, before[1]+after[0]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


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

    return 0;
}


Measured memory_bytes: 256
from collections import deque
k = int(input())
l = deque([i for i in range(1, 10)])
# print(l)

for i in range(k):
    x = l.popleft()
    mod = x % 10
    if mod != 0:
        l.append(x*10 + mod - 1)
    l.append(x*10 + mod)
    if mod != 9:
        l.append(x*10 + mod + 1)

print(x)

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

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

    int cnt = 0;
    int tmp_cnt = 0;

    for (int i = 1; i < N; ++i) {
        if (H[i - 1] >= H[i]) {
            tmp_cnt++;
            cnt = max(tmp_cnt, cnt);
        } else
            tmp_cnt = 0;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{};

char s[10023];

il bool q(int x,int y){
	for(;x<y;x++,y--) if( s[x]!=s[y] ) return 0;
	return 1;
}

int main(){
	scanf("%s",s+1);
	int n = strlen(s+1);
	puts(q(1,n) && q((n+3)/2,n) && q(1,(n-1)/2) ? "Yes":"No");
	return 0;
}


Measured memory_bytes: 128
N = int(input())
counter = 0

for i in range(1,N+1,2):
    #約数の数が奇数かどうかを判定する
    sho = 0
    for j in range(1,i+1):
        if i % j == 0:
            sho += 1
    if sho == 8:
        counter += 1

print(counter)

Measured memory_bytes: 2940
def calc(a, b, c, aa, bb, cc)
    [(aa - a).abs + (bb - b).abs + (cc - c).abs,
     (aa - a).abs + (bb - c).abs + (cc - b).abs,
     (aa - b).abs + (bb - a).abs + (cc - c).abs,
     (aa - b).abs + (bb - c).abs + (cc - a).abs,
     (aa - c).abs + (bb - a).abs + (cc - b).abs,
     (aa - c).abs + (bb - b).abs + (cc - a).abs].min
end

n, a, b, c = gets.split.map(&:to_i)
lengths = n.times.map{ gets.to_i }

arr = [0, 1, 2, 3]
(n-1).times do
    arr = arr.product([0,1,2,3]).collect{ |set| set.flatten }
end

ans = 10000000
arr.select{ |set| set.include?(1) && set.include?(2) && set.include?(3) }.each do |set|
    aa = 0
    bb = 0
    cc = 0
    count = [0, 0, 0]
    set.each_with_index do |len, i|
        if len == 1
            aa += lengths[i]
            count[len - 1] += 1
        elsif len == 2
            bb += lengths[i]
            count[len - 1] += 1
        elsif len == 3
            cc += lengths[i]
            count[len - 1] += 1
        end 
    end
    total = calc(a, b, c, aa, bb, cc) + (count.reduce(:+) - 3) * 10
    if ans > total
        ans = total
    end
end
puts ans
    

Measured memory_bytes: 34168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

template<class T> inline bool chmin(T& a, T b) 
{ if (a > b) { a = b; return true; } return false; }

template<class T> inline bool chmax(T& a, T b) 
{ if (a < b) { a = b; return true; } return false; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {

  ll X;  cin >> X;

  ll m = X % 100;
  ll d = X / 100;
  ll d5 = m / 5;
  ll m5 = m % 5;
  ll d4 = m5 / 4;
  ll m4 = m5 % 4;
  ll d3 = m4 / 3;
  ll m3 = m4 % 3;
  ll d2 = m3 / 2;
  ll m2 = m3 % 2;
  ll d1 = m2 / 1;
  ll m1 = m2 % 1;

  ll sum = d5 + d4 + d3 + d2 + d1;
  if (sum > d) print(0);
  else print(1);

  return 0;
}


Measured memory_bytes: 256
def judge_even():
    for i in range(len(n_list)):
        if n_list[i]%2 == 0:
            n_list[i] = n_list[i]//2
        else:
            return False
    return True


if __name__ == '__main__':
    _ = int(input())
    n_list = [int(n) for n in input().split()]

    count = 0
    while True:
        if judge_even():
            count += 1
        else:
            break

    print(count)

Measured memory_bytes: 3060
import 'dart:io';

void main() {
  List<int> input1 = stdin.readLineSync().split(' ').map((i) => int.parse(i)).toList();
  List<int> input2 = stdin.readLineSync().split(' ').map((i) => int.parse(i)).toList();

  for(int i = 0; i < input1[1]; i++) {
    input1[0] -= input2[i];
  }
  if(input1[0] >= 0) {
  	print(input1[0]);
  } else {
    print('-1');
  }
}

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

using namespace std;

class ProcessClass
{
    private:
    public:
        ProcessClass(){}
        ProcessClass(string _Name, int _Q)
        { Name = _Name; Q = _Q; }
        string Name;
        int EndTime;
        int Q;
    
};

class QueueClass
{
    private:
      int Head, Tail;
      ProcessClass *Array;
    public :
        QueueClass(){}
        QueueClass(int NSIZE)
        { Array = new ProcessClass[NSIZE]; Head = Tail = 0;  }
        ~QueueClass()
        { delete [] Array; }
        
        ProcessClass Front()
        { return Array[Head]; }
        void Pop()
        { ++Head; }
        void Push(ProcessClass value)
        { Array[Tail++] = value; }
        
        bool IsEmpty()
        { return Head == Tail; }
    
        
};

int main()
{
    QueueClass Que(1000000);
    int N, QMax;
    int cTime = 0;
    
    cin >> N >> QMax;
    
    for (int i = 0; i < N; ++i)
    {
        string Name; cin >> Name;
        int Q; cin >> Q;
        
        Que.Push(ProcessClass(Name, Q));
    }
    
    while(!Que.IsEmpty())
    {
        ProcessClass aProc = Que.Front();
        Que.Pop();
        
        if(aProc.Q <= QMax)
        {
            cTime += aProc.Q;
            cout << aProc.Name << " " << cTime << endl;
        }
        else 
        {
            cTime += QMax;
            Que.Push(ProcessClass(aProc.Name, aProc.Q - QMax));
        }
    }
    
    return 0;
}


Measured memory_bytes: 20732
S = input()
lowerCase = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
allLower = True
for i in S:
    if i not in lowerCase:
        allLower = False
        break
if len(S)==6 and allLower:
    if S[2]==S[3] and S[4]==S[5]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;


const int MOD = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  n++;
  ll ans = 0;
  for(ll i=k; i<=n; i++){
    ans = (ans%MOD)+((i%MOD)*(n-i)%MOD)%MOD+1;
  }
  dunk(ans);
}


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

const int INF = 1e9+7;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p.at(i);
	int now=p.at(0);
	int ans=0;
	rep(i, n){
		if(p.at(i) <= now){
			ans++;
			now=p.at(i);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
  char S[4];
  char T[4];
  cin >> S;
  cin >> T;
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      count += 1;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main (){
    int k;
    cin >> k;
    if(k%2==1){
        cout << floor(k/2)*(floor(k/2)+1);
    }else{
        cout << k/2*k/2;
    }
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n)  for(int i=0;i<n;i++)
#define per(i,n)  for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin >> a >> b >> c;
    if (c-a-b > 0 && (c-a-b) * (c-a-b) > 4 * a * b){
        cout << "Yes";
    }
    else cout << "No";
    
    return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int s, f;
        cin >> s >> f;
        if (b <= s || f <= a) {
            continue;
        }
        else {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
ll c;
ll x[125252];
ll v[125252];
ll vsm[125252];
ll lft[125252], rgt[125252];
ll lmx[125252], rmx[125252];

int main(){
  scanf("%d%lld",&n,&c);
  REP(i,n)scanf("%lld%lld",x+i,v+i);
  vsm[0] = 0ll;
  REP(i,n)vsm[i+1] = vsm[i]+v[i];
  lft[0] = rgt[0] = 0ll;
  REP(i,n){
    lft[i+1] = vsm[i+1] - x[i];
    rgt[i+1] = vsm[n]-vsm[n-1-i] - (c-x[n-1-i]);
  }
  lmx[0] = rmx[0] = 0ll;
  REP(i,n){
    lmx[i+1] = max(lmx[i], lft[i+1]);
    rmx[i+1] = max(rmx[i], rgt[i+1]);
  }
  ll ans = 0ll;
  FOR(i,0,n+1){
    // printf("i: %lld, n-i: %lld\n",lmx[i], rmx[n-i]);
    // printf("%lld, %lld\n",(i==0?0ll:x[i-1]), (i==n?0ll:c-x[i]));
    CHMAX(ans, lmx[i] + rmx[n-i] - min((i==0?0ll:x[i-1]), (i==n?0ll:c-x[i])));
  }
  printf("%lld\n",ans);
  return 0;
}


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

using namespace std;
using std::string;

int main() {
	int N;
	int W = 0;
	string S;
	cin >> N >> S;

	int Q = N / 2;

	if (N % 2 == 0) {
		for (int i = 0; i < Q;i++) {
			if (S[i] == S[Q + i]) {
				W++;
				if (W == Q) {
					cout << "Yes" << endl;
				}
			}
			else cout << "No" << endl;
		}
	}
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
fun main() = Thread(null, ::abc170b, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc170b() {
    val (num, legs) = readLine()!!.split(' ').map { it.toInt() }

    for (crane in 0..num) {
        val turtle = num - crane
        if (crane * 2 + turtle * 4 == legs) return println("Yes")
    }

    println("No")
}


Measured memory_bytes: 36804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string L;
    cin >> L;
    ll keta = L.size();
    ll dp[100010][2] = {};
    dp[0][0] = 1;
    rep(i,0,keta){
        ll D = L[i] - '0';
        rep(mask,0,2){
            ll end = (mask ? 2 : D+1);
            rep(d,0,end){
                if(d == 0){
                    dp[i+1][mask || d < D] += dp[i][mask];
                }else{
                    dp[i+1][mask || d < D] += 2 * dp[i][mask];
                }
                dp[i+1][mask || d < D] %= MOD;
            }
        }
    }
    ll ans = (dp[keta][0] + dp[keta][1]) % MOD;
    print(ans);
    
}

Measured memory_bytes: 2000
#include<stdio.h>
int main(){
  int n,m,x,i,count1=0,count2=0;
  scanf("%d%d%d",&n,&m,&x);
  int a[m+1];
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
    if(a[i]<x)
      count1++;
    else
      count2++;
  }
  printf("%d\n",count1<count2?count1:count2);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  // rep(i, 10) {
  //   cout << i << endl;
  // }

  int N, M;
  cin >> N;
  cin >> M;
  multiset<int, greater<int> > a;

  int in;
  rep(i, N) {
    cin >> in;
    // cout << in << endl;
    a.insert(in);
  }

  rep(i, M) {
    multiset<int>::iterator itr = a.begin();
    int max_val = *itr;
    // cout << max_val << endl;
    a.erase(itr);
    a.insert(max_val / 2);
  }

  ll sum = 0;
  for (multiset<int>::iterator it = a.begin(); it != a.end(); ++it) {
    // cout << *it << endl;
    sum = sum + *it;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

N = I()
A = LMI()

s = A[0]
for i in range(1, N):
    s = s ^ A[i]

ans = [0] * N
for i, a in enumerate(A):
    ans[i] = s ^ A[i]
print(*ans)

Measured memory_bytes: 97000
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] dp = new int[N+1];
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextInt();
			dp[arr[i]]++;
		}
		long TOTAL = 0;
		for (int i = 1; i <= N; i++) {
			TOTAL+=C2(dp[i]);
		}
		for (int k = 0; k < N; k++) {
			long Temp = TOTAL-C2(dp[arr[k]]);
			Temp+=C2(dp[arr[k]]-1);
			System.out.println(Temp);
		}
	}
	public static long C2(long N) {
		return N*(N-1)/2;
	}
}

Measured memory_bytes: 96468
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()
	cnt1 := strings.Count(s, "1")
	fmt.Println(2 * min(cnt1, len(s)-cnt1))

}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1980
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int n;
long long s;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i)
        if (i % 3 && i % 5)
            s += i;
    cout << s;
    PLEC
}


Measured memory_bytes: 3640
#include <iostream>

const int MAX = 101;
const int NIL = -1; 
const int UPBOUND = (1 << 20);

using namespace std;

int prim(int adj_matrix[][MAX], int n, int u);


int main()
{
	int adj_matrix[MAX][MAX] = {0};		
	
	int n;
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			int e; cin >> e;
			adj_matrix[i][j] = e == -1? UPBOUND: e;
		}
	}
	
//	for (int i = 0; i < n; i++)
//	{
//		for (int j = 0; j < n; j++)
//		{
//			cout << adj_matrix[i][j] << " ";
//		}
//		cout << endl;
//	}

	
	cout << prim(adj_matrix, n, 1) << endl;
} 


int prim(int adj_matrix[][MAX], int n, int u)
{
	int cost[MAX]; //记录最小权值
	int edge[MAX]; //记录选中的边
	
	
	for (int v = 1; v <= n; v++)
	{
		cost[v] = adj_matrix[u][v];
		edge[v] = u;
	}	 
	
	cost[u] = NIL; //排除u 
	
	while (true)
	{
		int w = NIL;
		int min = 3000; //权值上限 
		for (int v = 1; v <= n; v++)
		{
			if (cost[v] != NIL && cost[v] < min)
			{
				min = cost[v];
				w = v;
			} 
		}
		
		if (w == NIL) break;
		
		cost[w] = NIL;
		
		//更新最小权值数组 
		for (int v = 1; v <= n; v++)
		{
			if (cost[v] > adj_matrix[w][v] && adj_matrix[w][v] != NIL)
			{
				cost[v] = adj_matrix[w][v];
				edge[v] = w;			
			}
		}
				
	}
	
	
	//求生成树的权值
	int sum = 0;
	for (int v = 1; v <= n; v++)
	{
		if (v != u)
		sum += adj_matrix[v][edge[v]];
	} 
	
	return sum;	
	
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define ii pair<int,ll>
using namespace std;

int n;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string t,s;cin>>t>>s;
    int ans = 0;
    for(int i = 0;i<3;i++){
        if(s[i]==t[i])ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n,m,ans=0;
  cin >> n >> m;
  vector<int> k(m),p(m);
  vector<vector<int>> s(m,vector<int>(10));
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]) cin >> s[i][j];
  }
  rep(i,m) cin >> p[i];

  for(int bit=0; bit< (1<<n); bit++){
    vector<bool> on(n,false);
    for(int i=0; i<n; i++){
      if(bit & (1<<i)) on[i]=true;
      else on[i]=false;
    }
    bool ok=true;
    rep(j,m){
      int cnt=0;
      rep(k,sz(s[j])){
        if(on[s[j][k]])cnt++;
      }
      if(cnt%2!=p[j]) ok=false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

char a[50][50], b[50][50];
int n, m;

int main() {
	int sum = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			bool b00 = true;
			for (int k = 0; k < m; k++){
				for (int h = 0; h < m; h++){
					if (a[i + k][j + h] != b[k][h]){
						b00 = false;
					}
				}
			}
			if (b00)sum++;
		}
	}
	if (sum != 0)cout << "Yes"; else cout << "No";
	cout << endl;
	return 0;
}

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


int main() {
    int n; cin >> n;
    map<int, int> D, T;
    rep(i, n){
        int d; cin >> d; D[d]++;
    }
    int m; cin >> m;
    bool ok = true;
    rep(i, m){
        int t; cin >> t;
        if(D[t] <= 0){
            ok = false; break;
        }
        D[t]--;
    }
    if(ok) cout << "YES" << ln;
    else cout << "NO" << ln;   
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    double A[100];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    double ans=0;
    for(int i=0; i<N; i++){
        ans += 1/A[i];
    }
    
    cout << fixed << setprecision(7) << 1/ans << endl;
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n, legs;
	cin >> n >> legs;

	bool pos = false;

	for (int i = 0; i <= n; i++) {
		if (legs == (i*2 + (n-i)*4)) {
			// deb(i);
			pos = true;
			break;
		}
	}

	cout << (pos ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N;cin >> N;
    vector<vector<int>> v(N, vector<int> (3));
    vector<int> from{0,0,0};
    string ans = "Yes";
    for(int i=0;i<N;i++){
        vector<int> to(3);
        cin >> to[0] >> to[1] >> to[2];
        int d = abs(to[1]-from[1]) + abs(to[2]-from[2]);
        int t = to[0] - from[0];
        if(! (t>=d && (t-d)%2==0)) ans = "No";

        from = {to[0], to[1], to[2]};
    }
    cout << ans << endl;
}


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

using namespace std;

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

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

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

int n;

int main() {
	while (cin >> n&&n) {
		bool f[100][100] = {};
		vector<int> vi;
		vector<string> vs;
		int pre = 0;
		vector<P> buf[2000];
		REP(i, n) {
			string s;
			cin >> s;
			int cnt = 0;
			for (int j = 0; j <= s.size(); j++) {
				if (s[j] == '.')cnt++;
				else break;
			}
			if (pre <= cnt) {
				if (cnt != 0)buf[cnt].push_back({ i,i });
			}
			else {
				if (cnt != 0) {
					buf[cnt][buf[cnt].size() - 1].second = i;
					buf[cnt].push_back({ i,i });
				}
			}
			pre = cnt;
			string t = s.substr(cnt, s.size() - cnt);
			string buf = "";
			REP(j, cnt) {
				if (j == cnt - 1)buf += "+";
				else buf += " ";
			}
			t = buf + t;
			vs.push_back(t);
			vi.push_back(cnt);
		}
		//REP(i, 5) {
		//	cout << i << endl;
		//	REP(j, buf[i].size()) {
		//		cout << "!" << buf[i][j].first << " "
		//			<< buf[i][j].second << " ";
		//	}
		//	cout << endl;
		//}
		FOR(i, 1, 2000) {
			REP(j, buf[i].size()) {
				P p = buf[i][j];
				for (int k = p.first + 1; k < p.second; k++) {
					vs[k][i - 1] = '|';
				}
			}
			//REP(i, vs.size()) {
			//	cout << vs[i] << endl;
			//}
			//cout << endl;
		}
		REP(i, vs.size()) {
			cout << vs[i] << endl;
		}
	}
}

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

int main(){
    int ans = 0;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }

    for(int i = 0; i < n; i++){
        ans += a.at(i) - 1;
    }

    cout << ans << endl;
}

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

using namespace std;

const int maxn = 2e5 + 7;
const int BASE = 1202;
const int somod = 1e9 + 69;
string s;

int Hash[maxn], n, Pow[maxn];

int Get(int i, int j)
{
    return ((Hash[j] - Hash[i - 1] * Pow[j - i + 1] % somod) % somod + somod) % somod;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
    cin >> s;
    n = s.length();
    s = ' ' + s;
    Pow[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        Hash[i] = (Hash[i - 1] * BASE + s[i]) % somod;
        Pow[i] = Pow[i - 1] * BASE % somod;
    }
    int old = -1, gau = 0, ans = 0;
    for(int i = 1; i <= n; i++)
    {
        gau = gau * BASE + s[i];
        if(gau != old)
        {
            old = gau;
            ans++;
            gau = 0;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
bool Grid[55][55];

int main()
{
  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++)
  {
    for (int j = 1; j <= w; j++)
    {
      char c;
      cin >> c;
      Grid[i][j] = c == '#';
    }
  }
  for (int i = 1; i <= h; i++)
  {
    for (int j = 1; j <= w; j++)
    {
      if (!Grid[i][j])
        continue;
      if (!Grid[i - 1][j] && !Grid[i + 1][j] && !Grid[i][j - 1] && !Grid[i][j + 1])
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std ;
int sa(int a,int b){if(a>b) return a-b ; return b-a ;}

int main(){
	int n,x,y ;  cin >> n >> x >> y ;  x-- ; y-- ;
	vector<int> ans(n,0) ;
	for(int i=0;i<n;i++)  for(int j=i+1;j<n;j++)  ans.at(min(j-i,sa(i,x)+sa(j,y)+1))++ ;
	for(int i=1;i<=n-1;i++)  cout << ans.at(i) << endl ;
}


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

void q_sort(long numbers[],long A[], long left, long right);

int main(void){
  long N,A[200000],amin,sum,B[200000];
  int i,t;
  t=0;
  sum=0;
  if(scanf("%ld",&N)>1){
    exit(1);
  }
  
  for(i=0;i<N;i++){
    if(scanf("%ld %ld",&A[i],&B[i])>2){
    exit(1);
  }
  }
  q_sort(B,A,0,N-1);
  
  for(i=0;i<N;i++){
    //printf("%d %ld %ld\n",i,A[i],B[i]);
    sum+=A[i];
    //printf("%d %ld %ld %ld \n",i,A[i],B[i],sum);
    //printf("%ld\n",sum);
    if(sum>B[i]){
      t=1;
      break;
    }
  }
  if(t==0){
 printf("Yes");
  }
 else{
 printf("No");
 }
  return 0;
}

void q_sort(long numbers[],long A[], long left, long right)
{
    long l_hold, r_hold;
    long pivot,pa;

    l_hold = left;
    r_hold = right;
    pivot = numbers[left];
    pa=A[left];
    while (left < right)
    {
        while ((numbers[right] >= pivot) && (left < right))
            right--;
        if (left != right)
        {
            numbers[left] = numbers[right];
	    A[left]=A[right];
            left++;
        }
        while ((numbers[left] <= pivot) && (left < right))
            left++;
        if (left != right)
        {
            numbers[right] = numbers[left];
	    A[right]=A[left];
            right--;
        }
    }
    numbers[left] = pivot;
    A[left]=pa;
    pivot = left;
    left = l_hold;
    right = r_hold;
    if (left < pivot)
      q_sort(numbers,A, left, pivot-1);
    if (right > pivot)
      q_sort(numbers,A, pivot+1, right);
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);


class Edge{
public:
	int from, to, cost;
	Edge(int from = 0, int to = 0, int cost = 0) :
			from(from), to(to), cost(cost){}

	bool operator < (const Edge &e) const{
		return cost < e.cost;
	}
	bool operator >(const Edge &e) const{
		return cost > e.cost;
	}

};

class Node{
public:
	vector<Edge> edges;
	int dist;
	Node(){
		dist = INFTY;
	}
};

class Graph{
public:
	vector<Node> nodes;
	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
	}
	Node& operator[](int i){
		return nodes[i];
	}
};

class Data{

public:
	int dist;
	Edge *edge;
	Data(int dist, Edge *edge) {
		this->dist = dist;
		this->edge = edge;
	}

	bool operator < (const Data &d) const{
		return dist < d.dist;
	}
	bool operator >(const Data &d) const{
		return dist > d.dist;
	}
};

Graph G(0);

int dijkstra(int from, int to){

	priority_queue<Data, vector<Data>, greater<Data>> pq;
	Edge e0 = Edge(-1, from, 0);
	Data d0 = Data(from, &e0);
	pq.push(d0);

	while(!pq.empty()){
		Data d = pq.top(); pq.pop();
		Edge &e = *d.edge;
		Node &n = G[e.to];
		if(n.dist <= d.dist) continue;
		n.dist = d.dist;
		// cerr << n.dist << endl;

		for(auto &ee: n.edges){
			pq.push(Data(n.dist + ee.cost, &ee));
		}
	}

	return G[to].dist;
}

int main() {

	int K;
	cin >> K;
	G = Graph(K);

	// Undirected graph
	for(int i = 1; i <= K - 1; i++){

		int from, to, cost;
		from = i; to = (i + 1) % K; cost = 1;
		G[from].edges.push_back(Edge(from, to, cost));
		from = i; to = (i * 10) % K; cost = 0;
		G[from].edges.push_back(Edge(from, to, cost));
	}

	cout << dijkstra(1, 0) << endl;
}

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

int main() {
  char c;
  cin >> c;
  if(c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o'){
    cout << "vowel" << endl;
  
  }
  else{
    cout << "consonant" << endl;
  }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
const ll MOD = 998244353;

int main() {
    int n, k; cin >> n >> k;
    V<P<int, int> > v(k);
    for(int i = 0; i < k; i++) cin >> v[i].first >> v[i].second;

    V<ll> dp(n, 0), s(n + 1, 0);
    dp[0] = 1, s[1] = 1;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < k; j++){
            int l = max(0, i - v[j].second);
            int r = max(0, i - v[j].first + 1);
            dp[i] += (s[r] - s[l] + MOD) % MOD;
            dp[i] %= MOD;
        }
        s[i + 1] = dp[i] + s[i];
        s[i + 1] %= MOD;
    }
    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 6380
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define SENTINEL 2000000000
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int main() {
    int a;
    cin >> a;
    cout << 3 * a * a << endl;
}

Measured memory_bytes: 256