akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main() {
    double a, b, c, d, e, f;
    double x, y;

    while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
        y = (c*d-a*f) / (b*d-a*e);
        x = (c-b*y)/a;

        printf("%.3lf %.3lf\n", x, y);
    }

    return 0;
}


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

int main()
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<int> ls(n);
	for (auto &l : ls)
	{
		cin >> l;
	}
	sort(ls.begin(), ls.end());
	int ans = 1 << 30;
	for (int i = 1; i < (1 << n); i++)
	{
		for (int j = 1; j < (1 << n); j++)
		{
			for (int k = 1; k < (1 << n); k++)
			{
				if ((i & j) || (i & k) || (j & k))
				{
					continue;
				}
				int aa = 0, bb = 0, cc = 0;
				for (int l = 0; l < n; l++)
				{
					if ((i >> l) & 1)
					{
						aa += ls[l];
					}
					if ((j >> l) & 1)
					{
						bb += ls[l];
					}
					if ((k >> l) & 1)
					{
						cc += ls[l];
					}
				}
				int tmp = 10 * (__builtin_popcount(i) - 1) + 10 * (__builtin_popcount(j) - 1) + 10 * (__builtin_popcount(k) - 1);
				tmp += abs(a - aa);
				tmp += abs(b - bb);
				tmp += abs(c - cc);
				ans = min(ans, tmp);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

struct P
{
	int L;
	int R;
	bool operator < (const P &x)const{
		return R < x.R;
	}
};
int N, M;
vector<P> vec;

int main(){
	cin >> N >> M;
	vec.resize(M);
	rep(i,M) cin >> vec[i].L >> vec[i].R;

	sort(vec.begin(), vec.end());
	int cnt = M;
	int maxR;
	rep(i,M){
		if(i==0){
			maxR = vec[0].R;
		}else{
			if(maxR > vec[i].L) cnt--;
			else maxR = vec[i].R;
		}
		//cout << "maxR: " << maxR << endl;
	}

	cout << cnt << endl;

}

Measured memory_bytes: 1024
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,t; cin>>n>>t; 
    int  ans = 0, mn = 2e9, x , mx = 0 ; 
    for (int i=0;i<n;i++){
        cin >> x ; 
        mn = min(mn, x) ; 
        if (mx == x-mn) ans++;
        else if (x-mn > mx) { 
            mx = x-mn;
            ans = 1 ; 
        }
    }
    cout << ans << endl ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3624
/**
  @file d2.cpp
  @title D - Cake 123
  @url https://atcoder.jp/contests/abc123/tasks/abc123_d
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

template <class T>
void show(vector<T>& v) {
  for (uint i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << "\n";
}

int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<LL> A(X, 0);
  vector<LL> B(Y, 0);
  vector<LL> C(Z, 0);

  REP(i, X) { cin >> A[i]; }
  REP(i, Y) { cin >> B[i]; }
  REP(i, Z) { cin >> C[i]; }

  sort(ALL(A), std::greater<LL>());
  sort(ALL(B), std::greater<LL>());
  sort(ALL(C), std::greater<LL>());

  vector<LL> ABC;
  REP(i, X) {
    REP(j, Y) {
      REP(k, Z) {
        if (i * j * k <= K) {
          ABC.push_back(A[i] + B[j] + C[k]);
        }
      }
    }
  }
  sort(ALL(ABC), std::greater<LL>());

  REP(i, K) { cout << ABC[i] << "\n"; }

  return 0;
}


Measured memory_bytes: 35176
//#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;

bool isNum(string s,int start, int length) {
	for (int i = 0; i < length; i++) {
		if (s[i + start] >= '0' && s[i + start] <= '9') {
			continue;
		}
		return false;
	}
	return true;
}

int main() {
	int A, B;
	string S;
	cin >> A >> B;
	cin >> S;
	if (isNum(S, 0, A) && isNum(S, A + 1, B) && (S[A] == '-')) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	//string qwe;cin >> qwe;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <set>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void aising2019_a(vector<vector<int>> v) {

    int n = v[0][0];
    int h = v[1][0];
    int w = v[2][0];
    
    
    cout << (n-h+1) *(n-w+1)<<endl;
    

}

int main() {

    //        vector<vector < string>> vec_arr_result;
    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata2();

    aising2019_a(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 300006;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC\n";
    } else cout << "ABC\n";
    return 0; 
}
 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >>N;
    vector<int> P(N); cin >> P;
    vector<int> Q(N); cin >> Q;

    vector<int> R(N);
    iota(all(R), 1);

    int p = -1, q = -1;
    int i = 0;
    do {
        if (p == -1 && P == R) {
            p = i;
            if (q != -1) break;
        }
        if (q == -1 && Q == R) {
            q = i;
            if (p != -1) break;
        }
        i++;
    } while (next_permutation(all(R)));

    int ans = abs(p-q);

    cout << ans << endl;
}


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


using namespace std;

int main() {

	uint64_t M, N;


	cin >> N >> M;
	if (N % 2 == 1) {
		for (uint64_t i = 0; i < M; i++) {
			cout << i + 1 << " " << N - i-1 << endl;;

		}
		return 0;
	}
	else {
		for (uint64_t i = 0; i < M;i++) {
			
			if (i+1>N/4) cout << N / 2 - i << " " << N / 2 + 2 + i << endl;
			else cout << N / 2 - i << " " << N / 2 + 1 + i << endl;
		}
		return 0;
	}


}

Measured memory_bytes: 3636
import fractions
a,b=map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

v=fractions.gcd(a, b)
ans=prime_factorize(v)
print(len(set(ans))+1)


Measured memory_bytes: 5176
#include <iostream>

void swap(int& x, int& y)
{
	int tmp = x;
	x = y;
	y = tmp;
}

void maxHeapify(int* A, int i, int H)
{
	int l = 2*i;   // left child
	int r = 2*i+1; // right child
	
	int largest;
	if (l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	if (r <= H && A[r] > A[largest]) largest = r;
	
	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(A, largest, H);
	}
}

void buildMaxHeap(int* A, int H)
{
	for (int i=H/2; i>=1; i--) maxHeapify(A, i, H);
}

int main()
{
	int H; std::cin >> H;
	
	int* heap = new int[H+1];
	
	for (int i=1; i<=H; i++) std::cin >> heap[i];
	
	buildMaxHeap(heap, H);
	
	for (int i=1; i<=H; i++) std::cout << " " << heap[i];
	std::cout << std::endl;
	
	delete[] heap;
	
	return 0;
}



Measured memory_bytes: 4560
#include <stdio.h>
#define MAX 101

int A[MAX][MAX], s[MAX], h[MAX];

void serch(int x, int y){
  int i;
  h[x] = y;
  for(i=1; i<=s[x]; i++){
    if(h[A[x][i]] > y)
      serch(A[x][i], y+1);
  }
}

int main(){
  int i, j, k, n;
  
  scanf("%d", &n);
  for(i=1; i<=n; i++){
    h[i] = 10000;
    for(j=1; j<=n; j++)
      A[i][j] = 0;
  }
  
  for(i=1; i<=n; i++){
    scanf("%d", &k);
    scanf("%d", &s[k]);
    for(j=1; j<=s[k]; j++)
      scanf("%d", &A[k][j]);
  }
  
  serch(1,0);
  
  for(i=1; i<=n; i++){
    if(h[i] == 10000)
      h[i] = -1;
    printf("%d %d\n", i, h[i]);
  }
  return 0;
}
  

Measured memory_bytes: 1880
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;i++)
using namespace std;
void cmax(int&x,const int&y){x=x>y?x:y;}
void cmin(int&x,const int&y){x=x<y?x:y;}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	std::string s,t;
	cin>>s>>t;
	int l1=s.size();
	int l2=t.size();
	int ans=1e9;
	rep(i,0,l1-l2){
		int p1=i;
		int p2=0;
		int qwq=0;
		while(p2<l2){
			if(s[p1]!=t[p2])++qwq;
			p1++;
			p2++;
		}
		cmin(ans,qwq);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin>>str;
  for(int i=0;i<str.length();i++)
  {
     if(i%2==0)
     {
         if(str[i]=='L')
         {
             cout<<"No"<<endl;
             return 0;
         }
     }
     else
     {
         if(str[i]=='R')
         {
             cout<<"No"<<endl;
             return 0;
         }
     }
  }
  cout<<"Yes"<<endl;
 
  return 0;
 }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var c = Console.ReadLine().ToInt();
		
		double p = c / 1.08;
		int k = (int)p;
		
		for(int i = k; i < k + 10; i++)
		{
			if(c == (int)(i * 1.08))
			{
				Console.WriteLine(i);
				return;
			}
		}
		Console.WriteLine(":(");
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13140
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
    #define vec(n) vector<int>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

  
  
    int main(){
      long a,b,x;
      cin >> a >> b >> x;
      long res,res1,res2;
      if(a == 0)res1 = -1;
      res1 = a/x;
      if(a%x == 0)res1 -= 1;
      res2 = b/x;
      res = res2-res1;
      cout << res <<endl;

      
      
    }

    


Measured memory_bytes: 256
s = int(input())

tmp = [s] + [0]*(10**6 - 1)
for i in range(1,10**6+1):
    if tmp[i-1]&1:
        tmp[i] = 3*tmp[i-1]+1
    else:
        tmp[i] = tmp[i-1]//2
    if tmp.count(tmp[i]) == 2:
        print(i+1)
        exit()

Measured memory_bytes: 18676
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a*n, b) << endl;
}

Measured memory_bytes: 256
def main():
    S = input()
    S = S.replace("BC", "D")
    N = len(S)
    ans = 0
    a_cnt = 0
    for i in range(N):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3500
n, k = map(int, input().split())
if k == 0:
    print(n**2)
    exit()

ans = 0
# 割る値bを固定して該当するaの個数を足し上げる
for b in range(k+1, n + 1):
    q = n // b
    r = n % b
    if r < k:
        ans += q * (b-k)
    else:
        ans += q * (b-k) + (r-k+1)
print(ans)


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

#define pb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vi vector
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define LOCAL 0
#define forn(i, l, r) for(int i = l; i <= r; i++)
#define pii pair<int,int>
#define f80 long double

#define int long long int
//typedef long long int ll;

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

main(){
    IO;
    if(LOCAL){
        freopen("inp.txt", "r", stdin);
    }
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    forn(i, 0, n - 1)
    {
        if(c * i + (n - 1 - i) * (-d) <= b - a && b - a <= d * i + (n - 1 - i) * (-c))
        {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}

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

using namespace std;
using namespace atcoder;

const int MAX = 300001;
int op(int a, int b) { return max(a, b); }
int e() { return 0; }
int main() {
	segtree<int, op, e> seg3(MAX);
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		int v;
		scanf("%d", &v);
		seg3.set(v, 1 + seg3.prod(max(0, v - k), min(MAX, v + k + 1)));
		//printf("updated %d to %d\n", v, seg3.get(v));
	}
	printf("%d\n", seg3.all_prod());
	return 0;
}

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

int main(void){
  long long a,b,num,max=0;
  cin>>a>>b>>num;
  if((b-1)>num){
    max =((a*num)/b)-a*(num/b);
  }
    else{
    num=b-1;
    max=((a*num)/b)-a*(num/b);
  }
  cout<<max<<endl;;
  return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if (A > C && B < C){
    cout << "Yes" << endl;
  }
  else if (A < C && B > C){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  
 
  

Measured memory_bytes: 3644
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <climits>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int, in){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}

using V = vector<int>;

int main() {
	for (int N; (N = in());) {
		vector<V> w(N, V(N + 1)), c(1 << N, V(N, INT_MAX));
		V b(1 << N);
		for (auto &i: w)
			for (auto &j: i)
				j = in();
		for (int i = 0; i < N; i++)
			c[0][i] = w[i][0];
		for (size_t i = 1; i < c.size(); i++) {
			int m = i & ~-i, n = __builtin_ctz(i);
			for (int j = 0; j < N; j++)
				c[i][j] = min(c[m][j], w[j][n + 1]);
		}
		for (int i = b.size() - 2; i >= 0; i--) {
			b[i] = INT_MAX;
			for (int j = 0; j < N; j++)
				if (!((i >> j) & 1))
					b[i] = min(b[i], b[i + (1 << j)] + c[i][j]);
		}
		outl(b[0]);
	}
}


Measured memory_bytes: 9292
S = input()
ls = []
for i in S:
    ls.append(i)
a = set(ls)
if len(a) != 2:
    print("No")
elif ls[0] == ls[1] == ls[2] or ls[1] == ls[2] == ls[3]:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

combination c(1e7 + 10);

int main() {
  int r1, r2, c1, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  mint ans1 = c(r2 + c2 + 2, c2 + 1);
  mint ans2 = c(r2 + 1 + c1, c1);
  mint ans3 = c(c2 + 1 + r1, r1);
  mint ans4 = c(c1 + r1, c1);
  mint ans = ans1 - ans2 - ans3 + ans4;
  cout << ans.x << endl;
}

Measured memory_bytes: 156544
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String n = in.nextString();
            out.println(n.equals(new StringBuilder(n).reverse().toString()) ? "Yes" : "No");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23124
from functools import reduce

import fractions

def gcd(x, y):
 
    if x > y:
        small = y
    else:
        small = x
    for i in range(1, small+1):
        if((x % i == 0) and (y % i == 0)):
            gcd = i
             
    return gcd
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

    
def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    v = lcm(*a) -1
    ans = sum(v % x for x in a)
    print(ans)
    
        
if __name__ == '__main__':
    main()


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B, C;

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

    std::cin >> A >> B >> C;

    int S = std::min({A, B, C}), T = std::max({A, B, C}), U = (A + B + C) - (S + T);
    int res = 10 * T + (S + U);

    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)


#define NUM 4

int main(void){

	int n[NUM];
	scanf("%d %d %d %d", &n[0],&n[1],&n[2],&n[3]);


	int flag[NUM]={0};

	REP(i,NUM){
		switch(n[i]){
			case 1:
				if(flag[0] == 1){
					printf("NO\n");
					return 0;
				}else{
					flag[0]++;
					break;
				}

			case 4:
				if(flag[1] == 1){
					printf("NO\n");
					return 0;
				}else{
					flag[1]++;
					break;
				}

			case 7:
				if(flag[2] == 1){
					printf("NO\n");
					return 0;
				}else{
					flag[2]++;
					break;
				}

			case 9:
				if(flag[3] == 1){
					printf("NO\n");
					return 0;
				}else{
					flag[3]++;
					break;
				}
			default:
				printf("NO\n");
				return 0;
		}


	}

	printf("YES\n");
	return 0;

}


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

using namespace std;
int n;
int main()
{
    cin>> n;
    int x=n%10;
    if(x == 2 || x==4 || x==5 ||x==7 || x==9){
        cout<<"hon";
        return 0;
    }
    if(x==0 || x==1 || x==6 ||x==8){
        cout<<"pon";
        return 0;
    }
    if(x==3){
        cout<<"bon";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3636
// B - Resistors in Parallel
#include <stdio.h>

int main(void){
    int i, n;
    double a[1000], sum=0.0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%lf", &a[i]);
        sum+=(1.0/a[i]);
    }
    printf("%f\n", 1.0/sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<iomanip>
#include <deque>
#include <algorithm>
#include <vector>
#include <stdio.h>

using namespace std;
int main(){
    int n;
    int mem;
    cin >> n;
    vector<int> x;
    string ans = "YES";
    for(int i=0;i<n;i++){
        cin >> mem;
        x.push_back(mem);
    }
    sort(x.begin(),x.end());
    for(int i=0;i<n;i++){
        if(x[i]==x[i+1]){
            ans = "NO";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
import sys
from collections import deque

n = int(sys.stdin.readline())
q = deque()
for i in range(n):
    cmd = sys.stdin.readline()[:-1]
    if cmd[0] == 'i':
        q.appendleft(cmd[7:])
    elif cmd[6] == ' ':
        try:
            q.remove(cmd[7:])
        except:
            pass
    elif cmd[6] == 'F':
        q.popleft()
    else:
        q.pop()

print(' '.join(q))

Measured memory_bytes: 103336
object Main {
    def main(args: Array[String]) {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        var a = new Array[Int](n);
        for (i <- 0 to n - 1) {
            val k = sc.nextInt
            a(i) = k;
        }
        if (a.max < a.sum - a.max) {
            println("Yes")
        } else {
            println("No")
        }
    }
}

Measured memory_bytes: 27968
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int 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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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;
}

const int MOD = 998244353;
const ll INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A; string S;
	cin >> A >> S;
	if (A >= 3200) {
		print(S);
	}
	else print("red");
}



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

int main() {
  int N;
  cin>>N;
  vector<int> odds(N/2);
  vector<int> evens(N/2);
  for(int i=0;i<N;i++){
    if(i%2==0){cin>>evens.at(i/2);}
    else{cin>>odds.at(i/2);}
  }
  
  int cnt=1,ev1=0,ev1_cnt=0,ev2=0,ev2_cnt=0;
  sort(evens.begin(),evens.end());
  for(int i=0;i<N/2;i++){
    if(i==0){
      cnt=1;
    }else if(evens.at(i-1)==evens.at(i)){
      cnt++;
      if(i==N/2-1){
        if(cnt>=ev1_cnt){ev2=ev1;ev2_cnt=ev1_cnt;ev1=evens.at(i);ev1_cnt=cnt;}
        else if(cnt>ev2_cnt){ev2=evens.at(i);ev2_cnt=cnt;}
      }
    }else{
      if(cnt>=ev1_cnt){ev2=ev1;ev2_cnt=ev1_cnt;ev1=evens.at(i-1);ev1_cnt=cnt;}
      else if(cnt>ev2_cnt){ev2=evens.at(i-1);ev2_cnt=cnt;}
      cnt=1;
      if(i==N/2-1){
        if(cnt>=ev1_cnt){ev2=ev1;ev2_cnt=ev1_cnt;ev1=evens.at(i);ev1_cnt=cnt;}
        else if(cnt>ev2_cnt){ev2=evens.at(i);ev2_cnt=cnt;}
      }
    }
  }
  
  int od1=0,od1_cnt=0,od2=0,od2_cnt=0;
  sort(odds.begin(),odds.end());
  for(int i=0;i<N/2;i++){
    if(i==0){
      cnt=1;
    }else if(odds.at(i-1)==odds.at(i)){
      cnt++;
      if(i==N/2-1){
        if(cnt>=od1_cnt){od2=od1;od2_cnt=od1_cnt;od1=odds.at(i);od1_cnt=cnt;}
        else if(cnt>od2_cnt){od2=odds.at(i);od2_cnt=cnt;}
      }
    }else{
      if(cnt>=od1_cnt){od2=od1;od2_cnt=od1_cnt;od1=odds.at(i-1);od1_cnt=cnt;}
      else if(cnt>od2_cnt){od2=odds.at(i-1);od2_cnt=cnt;}
      cnt=1;
      if(i==N/2-1){
        if(cnt>=ev1_cnt){ev2=ev1;ev2_cnt=ev1_cnt;ev1=evens.at(i);ev1_cnt=cnt;}
        else if(cnt>ev2_cnt){ev2=evens.at(i);ev2_cnt=cnt;}
      }
    }
  }

  if(ev1!=od1){
    cout<<(N/2-ev1_cnt)+(N/2-od1_cnt)<<endl;
  }else if(ev1_cnt==od1_cnt){
    if(ev2_cnt>=od2_cnt){cout<<(N/2-ev2_cnt)+(N/2-od1_cnt)<<endl;}
    else{cout<<(N/2-ev1_cnt)+(N/2-od2_cnt)<<endl;}
  }else if(ev1_cnt>od1_cnt){
    cout<<(N/2-ev1_cnt)+(N/2-od2_cnt)<<endl;
  }else{
    cout<<(N/2-ev2_cnt)+(N/2-od1_cnt)<<endl;
  }
}

Measured memory_bytes: 768
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>


using namespace std;

typedef long long ll;
const double PI = acos(-1.0);
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

vector<int> vec[505];
vector<int>::iterator it;

int main(){
    ios::sync_with_stdio(false);
    int i, N, M, Q, ans, x, y;
    while(scanf("%d%d%d", &N, &M, &Q)!=EOF){
        for(i = 0; i < M; i++){
            scanf("%d%d", &x, &y);
            vec[x].push_back(y);
        }
        for(i = 1; i <= N; i++){
            sort(vec[i].begin(), vec[i].end());
        }
        while(Q--){
            ans = 0;
            scanf("%d%d", &x, &y);
            for(i = x; i <= y; i++){
                it = upper_bound(vec[i].begin(), vec[i].end(), y);
                ans += it - vec[i].begin();
            }
            printf("%d\n", ans);
        }
        for(i = 0; i <= N; i++){
            vec[i].clear();
        }
    }

    return 0;
}

Measured memory_bytes: 2176
"use strict";
const main = arg => {
  let Nums = arg.split(" ").map(x=>x*1);
  let ans = 0;
  ans = Math.max(Nums[0]*Nums[1],Nums[0]+Nums[1],Nums[0]-Nums[1])
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n){
        ll t;cin>>t;
        a[i]=t-1;
    }
    vector<ll> vis(n,-1);
    ll pos = 0;
    ll time = 0;
    while(vis[pos]==-1&&k>time){
        vis[pos]=time;
        pos=a[pos];
        time++;
    }
    if(time==k){
        cout<<pos+1;
        return 0;
    }
    k -= time;
    k %= (time-vis[pos]);
    rep(i,k){
        pos=a[pos];
    }
    cout<<pos+1<<endl;
        return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; 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--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   int N,M;cin >> N >> M;
   vector<pair<ll,int>> AB(N);
   
   rep(i,N){
      ll A;int B;
      cin >> A >> B;
      AB[i] = make_pair(A,B);
   }
   sort(AB.begin(),AB.end());
   ll ans = 0;
   for(int i=0;i<N;i++){
      int buy = min(M,AB[i].second);
      ans += buy * AB[i].first;
      M -= buy;
   }
   cout << ans << endl;


   return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, m;
  cin >> n >> m;
  ll k;
  cin >> k;
  vector<ll> a(n);
  cin >> a;
  vector<ll> b(m + 1);
  rep3(i, 1, m + 1) cin >> b[i];
  rep3(i, 1, m + 1) b[i] += b[i - 1];

  int it = ub(b, k);
  it--;
  cerr << it << endl;
  int ans = it;

  ll sum = 0;
  rep(i, n) {
    sum += a[i];
    if (sum > k) break;
    it = ub(b, k - sum);
    it--;
    chmax(ans, i + 1 + it);
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < s.size()-2; i++) {
    if (s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C') {
      ans++;}
  }
  cout << ans << endl;
}

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

int main()
{
    int n, k;
    cin >> n >> k;

    vector<string> d;
    rep(i,k) {
        string tmp;
        cin >> tmp;
        d.push_back(tmp);
    }

    int ans = 0;
    for(int i=n; i<100000; i++){
        string sn = to_string(i);
        bool isFind = false;
        rep(j,d.size()){
            if( sn.find(d[j]) != std::string::npos ) {
                isFind = true;
                break;
            }
        }
        if(!isFind){
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
 
int main(){
    while(true){
        int a , b;
        char op;
        scanf("%d %c %d", &a,&op,&b);
        if(op == '+'){
            printf("%d\n",a+b);
        }else if(op == '-'){
            printf("%d\n",a-b);
        }else if(op == '*'){
            printf("%d\n",a*b);
        }else if(op == '/'){
            printf("%d\n",a/b);
        }else{
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
int main()
{
	long long int a;
	char s;
	long long int b;
	scanf(" %lld",&a);
	scanf(" %c",&s);
	scanf(" %lld",&b);
	if(s=='+')
	printf("%lld\n",a+b);
	else
	printf("%lld\n",a-b);
}

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

bool dfs(int i,int j){
  //cerr << i << ' ' << j << endl;
  if(i >= n) return 0;
  if((int)vs[i].size() <= j ) return 0;
  if(vs[i][j] == '.'){
    bool ret = dfs(i+1,j);
    vs[i][j] = (ret?'|':'.');
    return ret;
  }
  else if(vs[i][j] == '+')  return 1;
  else return 0;
}

int main(){
  while(cin >> n , n){
    vs.clear();
    rep(i,n){string in; cin >> in; vs.push_back(in);}
    //cerr << vs.size() << endl;
    rep(i,n)rep(j,vs[i].size() - 1){
      if(vs[i][j] == '.' && vs[i][j+1] != '.'){
        //cerr << '1' << endl;
        vs[i][j] = '+';
        break;
      }
    }
    rep(i,n-1){rep(j,vs[i].size()){
      if(vs[i][j] == '+'){dfs(i+1,j); break;}
    }
  }
  rep(i,n)rep(j,vs[i].size()){
    if(vs[i][j] == '.'){vs[i][j] = ' ';}
  }
    for(auto s: vs)  cout << s << endl;
  }
}


Measured memory_bytes: 3724
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll turn=0;
    while(1){
        if(turn==0){
            c-=b;
            if(c<=0){
                cout<<"Yes"<<endl;
                return 0;
            }
        }else{
            a-=d;
            if(a<=0){
                cout<<"No"<<endl;
                return 0;
            }
        }
        //cout<<a<<" "<<c<<endl;
        turn^=1;
    }
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if(i == 0 || i == H - 1 || j == 0 || j == W - 1)
                    cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)
typedef pair<int,int> P;
int n,k;
vector<P> stone[200];
int dp[151][11][78];
int solve(int h,int idx,int k){
  if(h == n-1 || (h == n-2 && k != 0)) return 0;
  if(dp[h][idx][k] != -1) return dp[h][idx][k];
  int ret = INF;
  int s = stone[h][idx].second;
  int w = stone[h][idx].first;
  for(int i=0;i<stone[h+1].size();i++){
    int nw = stone[h+1][i].first;
    int ns = stone[h+1][i].second;
    ret = min(ret,solve(h+1,i,k)+((s+ns)*abs(w-nw)));
  }
  if(k != 0 && h+2 <= n-1){
    for(int i=0;i<stone[h+2].size();i++){
      int nw = stone[h+2][i].first;
      int ns = stone[h+2][i].second;
      ret = min(ret,solve(h+2,i,k-1)+((s+ns)*abs(w-nw)));
    }
  }
  return dp[h][idx][k] = ret;
}
    

int main(){
  while(cin >> n >> k , n){
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
      int m; cin >> m;
      for(int j=0;j<m;j++){
	int a,b; cin >> a >> b;
	stone[i].push_back(P(a,b));
      }
    }
    int ans = INF;
    for(int i=0;i<stone[0].size();i++){
      ans = min(ans,solve(0,i,k));
    }
    if(k != 0){
      for(int i=0;i<stone[1].size();i++){
	ans = min(ans,solve(1,i,k-1));
      }
    }
    cout << ans << endl;
    for(int i=0;i<n;i++){
      stone[i].clear();
    }
  }
}

Measured memory_bytes: 1756
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
const int Maxn=200005;
pair<pair<int,int>,int> x[Maxn];
int n;
set<int> X,Y;
vector<pair<int,pair<int,int> > > e;
bool cmp(pair<pair<int,int>,int> a,pair<pair<int,int>, int> b){
	return a.first.second<b.first.second;
}
bool cmp1(pair<pair<int,int>,int> a,pair<pair<int,int>, int> b){
	return a.first.first<b.first.first;
}
int p[Maxn];
void _init(){
	for (int i=0;i<Maxn;i++) p[i]=i;
}
int findset(int x){
	return p[x]=(p[x]==x)?x:findset(p[x]);
} 
void Union(int x,int y){
	x=findset(x);
	y=findset(y);
	p[x]=y;
}
int main(){
	_init();
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d %d",&x[i].first.first,&x[i].first.second);
		x[i].second=i+1;
	}
	sort(x,x+n,cmp1);
	for (int i=0;i<n-1;i++){
		e.push_back(mp(abs(x[i].first.first-x[i+1].first.first),mp(x[i].second,x[i+1].second)));
	}
	sort(x,x+n,cmp);
	for (int i=0;i<n-1;i++){
		e.push_back(mp(abs(x[i].first.second-x[i+1].first.second),mp(x[i].second,x[i+1].second)));
	}
	sort(e.begin(),e.end());
	int cost=0;
	for (int i=0;i<e.size();i++){
		if (findset(e[i].second.first)!=findset(e[i].second.second)){
			Union(e[i].second.first,e[i].second.second);
			cost+=e[i].first;
		}
	}
	printf("%d\n",cost);
}

Measured memory_bytes: 6516
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main(){
    double a, b, x;
    cin >> a >> b >> x;

    x /= a;

    double ans = 0;
    if(x <= a * b / 2.0){
        const double a2 = 2 * x / b;
        ans = rad_to_deg(M_PI / 2.0 - atan2(a2, b));
    }else{
        const double b2 = 2 * x / a - b;
        ans = rad_to_deg(M_PI / 2.0 - atan2(a, b - b2));
    }
    printf("%.8f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	long long n,a,ans=10000000;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		int c=0;
		while(a%2==0){
			a/=2;
			c++;
		}
		if(c<ans)
			ans=c;
	}
	cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3616
/**
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/                          
All Required Header Files ********/
#include <bits/stdc++.h>  
using 		namespace 		std;
using 		lli= 			long long  int;
using 		ulli= 			unsigned long long int;
using 		ld= 			long double;
int main() {
	
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	
	lli n,k;
	cin>>k>>n;
	lli a[n];
	for(lli i=0;i<n;i++) {
		cin>>a[i];
	}
	sort(a,a+n);
	lli ans=0,maxi=0;
	for(lli i=1;i<n;i++) {
		ans+=a[i]-a[i-1];
		maxi=max(maxi,a[i]-a[i-1]);
	}
	if(maxi>(k-a[n-1]+a[0]))
	ans=ans+k-a[n-1]+a[0]-maxi;
	cout<<ans;
	
	
	return 0;
}


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

int main() {
    vector<int> iwana(2), yamame(2);
    for(int i = 0; i < 2; ++i) {
        cin >> iwana[i] >> yamame[i];
    }
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<int> s(2);
    for(int i = 0; i < 2; ++i) {
        s[i] = iwana[i] * a + yamame[i] * b + iwana[i] / 10 * c + yamame[i] / 20 * d;
    }

    if(s[0] > s[1]) cout << "hiroshi" << endl;
    else if(s[0] < s[1]) cout << "kenjiro" << endl;
    else cout << "even" << endl;
}



Measured memory_bytes: 3080