akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

int main() {
    std::string score;
    std::cin >> score; // 文字列はcin, 数値はscanfでやったほうがいいかも

    // 文字列の中から'x'の数を数える
    int num_of_x; num_of_x = std::count(score.cbegin(), score.cend(), 'x');

    // 負けた回数が8以下ならば
    if (num_of_x < 8) {
        printf("YES\n");
    } else {
        // 8回以上ならば
        printf("NO\n");
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


#define MAX 200010
ll fac[MAX];
ll finv[MAX];
ll inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    repr(i,2,MAX){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}



int main(){
    ll H,W; cin >> H >> W;
    ll A,B; cin >> A >> B;
    COMinit();
    ll ans = 0;
    rep(i,H-A){
      ll now = 1;
      now *= (fac[B+i-1] * finv[B-1] % MOD) * finv[i] % MOD;
      now *= (fac[H+W-B-i-2] * finv[H-i-1] % MOD) * finv[W-B-1] % MOD;
      now %= MOD;
      ans += now;
      ans %= MOD;

    }
    cout << ans << endl;
}
 


Measured memory_bytes: 4992
function f()
    a = readline()
    if a == "SUN\n"
        print(7)
    elseif a == "MON\n"
        print(6)
    elseif a == "TUE\n"
        print(5)
    elseif a == "WED\n"
        print(4)
    elseif a == "THU\n"
        print(3)
    elseif a == "FRI\n"
        print(2)
    else 
        print(1)
    end
end

f()

Measured memory_bytes: 110076
import math
A, B, H, M = map(int, input().split())

dA = (H*60+M)*math.pi/360
dB = M*math.pi/30
dC = abs(dB - dA)
C = (A**2 + B**2 - 2*A*B*math.cos(dC))**(1/2)

print(C)

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

ass_a = {}
for aa in A:
    if aa not in ass_a:
        ass_a[aa] = 1
    else:
        ass_a[aa] += 1
ass_a = sorted(ass_a.items(), key=lambda x:x[1])

if len(ass_a) <= K:
    print(0)
else:
    ans = 0
    for i in range(len(ass_a)-K):
        ans += ass_a[i][1]
    print(ans)

Measured memory_bytes: 39932
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



template <class T>
map<T, int> prime_factors(T n)
{
	map<T, int> res;
	for (T i = 2; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			int c = 0;
			for ( ; n % i == 0; n /= i)
				++c;
			res[i] = c;
		}
	}
	if (n > 1)
		res[n] = 1;
	return res;
}
template <class T>
vector<T> divisors(T n)
{
	vector<T> res;
	for (T i = 1; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			res.push_back(i);
			if (i != n / i)
				res.push_back(n / i);
		}
	}
	return res;
}
vector<int> fact_num, take;
ll dfs(int depth)
{
	if (depth == take.size())
	{
		ll res = 1;
		for (int i = 0; i < take.size(); ++i)
			if (take[i] == fact_num[i])
				res *= fact_num[i] + 1;
		return res;
	}
	else
	{
		ll res = 0;
		for (int i = 0; i <= fact_num[depth]; ++i)
		{
			take[depth] = i;
			res += dfs(depth + 1);
		}
		return res;
	}
}
int main()
{
	ll L;
	while (scanf("%lld", &L), L)
	{
		map<ll, int> f = prime_factors(L);
		fact_num = vector<int>();
		foreach (it, f)
			fact_num.push_back(it->second);
		take.resize(fact_num.size());

		printf("%lld\n", (dfs(0) + 1) / 2);
	}
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll C, K, T[int(1e5+5)];

int main(){
  cin >> N >> C >> K;
  for (int i = 0; i < N; i++) cin >> T[i];
  sort(T, T + N);

  if (C == 1){
    cout << N << endl;
    return 0;
  }

  int ans = 1, cnt = 1; 
  ll lim = T[0] + K;
  for (int i = 1; i < N; i++){
    if (cnt == C){
      ans++; cnt = 1; lim = T[i] + K;
      continue;
    }
    if (lim < T[i]){
      ans++; cnt = 1; lim = T[i] + K;
      continue;
    }
    cnt++;
  }
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
const int N = 2e6;
const ll mod = 1e9+7;
ll fact[N+100],inv[N+100];

ll bigmod(ll a,ll b)
{
	if(b==0){
		return 1;
	}
	ll x = bigmod(a,b/2);
	x = (x*x)%mod;
	if(b%2){
		x = (x*a)%mod;
	}
	return x;
}
int main()
{
	fact[0] = 1,inv[0] = 1;
	for(int i=1;i<=N;i++){
		fact[i] = (fact[i-1]*i)%mod;
		inv[i] = bigmod(fact[i],mod-2);
	}
	int r1,r2,c1,c2;
	scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
	ll cur = 0,ans = 0;
	int x1 = c1,x2 = c1,y1 = r1,y2 = r1;
	while(1)
	{
		cur = (cur*2)%mod;
		ll t1 = fact[x1+y1-1];
		t1 = (t1*inv[x1])%mod;
		t1 = (t1*inv[y1-1])%mod;
		ll t2 = fact[x2+y2-1];
		t2 = (t2*inv[x2-1])%mod;
		t2 = (t2*inv[y2])%mod;
		if(y1-1<r1){
			cur = (cur+t1)%mod;
		}
		else{
			cur = (cur-t1+mod)%mod;
		}
		if(x2-1<c1){
			cur = (cur+t2)%mod;
		}
		else{
			cur = (cur-t2+mod)%mod;
		}
		ans = (ans+cur)%mod;
		if(y1==r2&&x2==c2){
			break;
		}
		if(x1<c2){
			x1++;
		}
		else{
			y1++;
		}
		if(y2<r2){
			y2++;
		}
		else{
			x2++;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 35008
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
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; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};


int main(){
  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC") << endl; 

  return 0;
}


Measured memory_bytes: 3628
a = int(input())
input_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(input_list[a-1])


Measured memory_bytes: 38256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let x:u32 = read();

    let mut mx:u32 = 0;
    for i in 1..x+2 {
        for j in 2..x+2 {
            if i.pow(j) > x {break;}
            //debug!(i,j, i.pow(j));
            mx = max(mx, i.pow(j));
        }
    }

    println!("{}", mx);

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    LL a[100005], b[100005];

    for( int i = 0; i < n; ++i ) {
        cin >> a[i] >> b[i];

    }

    LL ans = 0;
    LL tmp = 0;
    for( int i = n - 1; i >= 0; --i ) {
        a[i] += tmp;
        if( a[i] % b[i] ) {
            ans += b[i] - ( a[i] % b[i] );
            tmp += b[i] - ( a[i] % b[i] );
        }
    }

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



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

struct UnionFind{
    vector<int> par;
    vector<int> sizes;
    UnionFind(int n):par(n),sizes(n,1){ rep(i,n)par[i]=i; }

    //find root of x
    int find(int x){
        if(x!=par[x]) par[x] = find(par[x]);
        return par[x];
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x,int y){ return find(x) == find(y); }
    int size(int x){ return sizes[find(x)]; }
};

int main(void){
    ll n,m;
    cin >> n >> m;
    vector<pair<int,int>> vp(m);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        vp[i] = {a,b};
    }
    reverse(all(vp));
    vector<ll> res(m);
    res[0] = n*(n-1)/2;
    UnionFind uf(n);
    rep(i,m-1){
        int a = vp[i].first, b = vp[i].second;
        res[i+1] = res[i] - (uf.same(a, b) ? 0LL : (ll)uf.size(a) * (ll)uf.size(b));
        uf.unite(a,b);
    }
    reverse(all(res));
    rep(i,m){
        cout << res[i] << endl;
    }
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int h,w, k;
string s[10];
void solve(){
	cin >> h >> w >> k;
	for(int i = 0; i < h; i++){
		cin >> s[i];
	}
	
	int ans = 0;
	for(int i = 0; i < (1<<h); i++){
		for(int j = 0; j < (1<<w); j++){
			int cnt = 0;
			for(int ii = 0; ii < h; ii++){
				for(int jj = 0; jj < w; jj++){
					if((i>>ii&1) && (j>>jj&1)){
						if(s[ii][jj] == '#') cnt++;
					}
				}
			}
			if(cnt == k) ans++;
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3652
//https://atcoder.jp/contests/dp/tasks/dp_o
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int a[21][21];
LL dp[1<<21];
constexpr int mod =1e9+7;
int main(){
    int N;
    cin>>N;
    dp[0]=1;
    for(int i:range(N))for(int j:range(N))cin>>a[i][j];
    for(int b:range(1<<N)){
        bitset<21> bit(b);
        dp[b]%=mod;
        int i = __builtin_popcount(b);
        for(int j:range(N)){
            if(bit[j]==false&&a[i][j]){
                dp[b|(1<<j)]+=dp[b];
            }
        }
    }
    cout<<dp[(1<<N)-1]<<endl;
    return 0;
}

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


def main():
    import math
    import collections
    import itertools
    import string

    n = int(input())
    # s = [input() for _ in range(n)]
    a_z = string.ascii_lowercase
    counters = []
    for _ in range(n):
        s = input()
        # print(s)
        tmp_counter = {char: 0 for char in a_z}
        input_counter = collections.Counter(s)
        for char, count in input_counter.items():
            tmp_counter[char] += count
        counters.append(tmp_counter)

    char_common = {}
    for char in a_z:
        char_common[char] = float("INF")
        for counter in counters:
            char_common[char] = min(char_common[char], counter[char])
    
    ans = ''
    for char in a_z:
        ans += char_common[char] * char
    print(ans)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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 dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int r, D, x;
	cin >> r >> D >> x;
	vector<int>X(11);
	X[0] = x;
	for (int i = 1; i < 11; i++) {
		X[i] = r * X[i - 1] - D;
		cout << X[i] << endl;
	}
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    string s, t;
    cin >> s >> t;
    string t2 = t.substr(0, s.size());
    if (s == t2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3040
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    

    ll n,x,r,cnt = 0;
    cin >> n;string str = "";
    while (n > 0)
    {
        r = n%26;char a;
        if(!r){r = 1;a = 'a'+25;}
        else a = 'a'+r-1;
        //cout << a << endl;
        str+=a;
        n = (n-r)/26;
    }
    reverse(str.begin(),str.end());
    cout << str << endl;

   
    
    
    
    
    
    
    
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define fi first 
#define pb push_back
#define se second
#define mp make_pair
const int maxn = 300;
char s[maxn];
int a[maxn],ac;
ll k,ans;
int main(){
	cin>>s>>k;
	int n=strlen(s);
	int ls=0,j=0;
	while(j<n){
		if(!j||s[j]==s[j-1]) ls++;
		else{
			a[ac++]=ls;
			ls=1;
		}
		j++;
	}
	a[ac++]=ls;
	//cout<<ac<<endl; for(int i=0;i<ac;i++) cout<<a[i]<<' ';cout<<endl;
	for(int i=0;i<ac;i++) ans += a[i]/2;
	if(k>1&&s[0]==s[n-1]&&ac>1){
		ans-=a[0]/2+a[ac-1]/2;
		ans*=k;
		ans += (a[0]+a[ac-1])/2*(k-1)+a[0]/2+a[ac-1]/2;
	}else if(ac>1) ans*=k;
	else ans=(n*k)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  n = int(input())
  a = list(map(int,input().split()))
  a = sorted(a,reverse=True)
  print(a[0] - a[n-1])
  
  
if __name__ == '__main__':
  main()

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

int main(){
  int n; cin>>n;
  int t[n],sum=0;
  for(int i=0;i<n;i++){
    cin>>t[i]; sum+=t[i];
  }
  int m; cin>>m;
  for(int j=0,p,x;j<m;j++){
    cin>>p >>x;
    cout<<sum+x-t[p-1]<<endl;
  }
}

Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))
count=0
for i in range(N):
  for j in range(i,N):
    for k in range(j,N):
      if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i] and i<j and j<k and L[i]<L[j]+L[k] and L[j]<L[k]+L[i] and L[k]<L[i]+L[j]:
        count+=1
print(count)

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

ll N, K;

int main(void) {
  cin >> N >> K;

  ll ans = (1LL << 60);
  ll s = 1;
  REP(i, 0, N + 1) {
    ans = min(ans, s + (N - i) * K);
    s *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def e_flatten(MOD=10**9 + 7):
    from fractions import gcd
    from functools import reduce
    N = int(input())
    A = [int(i) for i in input().split()]

    l = reduce(lambda x, y: x * y // gcd(x, y), A) % MOD
    b = [(l * pow(a, MOD - 2, MOD)) % MOD for a in A]
    return sum(b) % MOD

print(e_flatten())

Measured memory_bytes: 6100
#include<bits/stdc++.h> 
using namespace std;
int v[55][27]={};
int f[27];
int main()
{ 
	memset(f,10,sizeof(f));
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<s.size();j++)
		{
			int x=s[j]-'a';
			v[i][x]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<26;j++)
		{
			f[j]=min(f[j],v[i][j]);
		}
	} 
	for(int i=0;i<26;i++)
	{
		if(f[i])
		{
			for(int j=1;j<=f[i];j++)
			{
				cout<<(char)('a'+i);
			}
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  int ok[512];
  int a, b, c, n, i[1024], j[1024], k[1024], r[1024];
  while(cin >> a >> b >> c, (a + b + c)){
    cin >> n;
    for(int s = 0;s < 512; s++) ok[s] = 2;
    for(int s = 0;s < n; s++){
      cin >> i[s] >> j[s] >> k[s] >> r[s];
      if(r[s] == 1)
	ok[i[s]] = ok[j[s]] = ok[k[s]] = 1;
    }
    for(int s = 0;s < n; s++){
      if(ok[i[s]] == 2 && ok[j[s]] == 1 && ok[k[s]] == 1)
	ok[i[s]] = 0;
      if(ok[i[s]] == 1 && ok[j[s]] == 2 && ok[k[s]] == 1)
	ok[j[s]] = 0;
      if(ok[i[s]] == 1 && ok[j[s]] == 1 && ok[k[s]] == 2)
	ok[k[s]] = 0;
    }
    for(int s = 1;s <= a + b + c; s++) cout << ok[s] << endl;	
  }
}


Measured memory_bytes: 1176
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std; 
 
#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/
 
void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}
 
int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;
 
	if(N==2)   return 1;
	if(N%2==0) return 0;
 
	for(i=3;i<N && N%i!=0;i+=2);
 
	if(i>=N) return 1;
	
	return 0;
}
 
int factorial(int N){  //Nの階乗を求める関数
	int ans=1;
 
	while(N--) ans*=(N+1);
	return ans;
}
 
//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;
 
    x = a[(first + last) / 2];
    i = first; j=last;
 
    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}
 
int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}
 
unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];
 
    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}

int main(){
    int N;
    char S[4000];
    int i,j,k;
    long r=0,g=0,b=0;
    long sum=0;

    scanf("%d %s",&N,S);
    
    rep(i,N){
        if(S[i]=='R') r++;
        if(S[i]=='G') g++;
        if(S[i]=='B') b++;
    }

    sum=r*g*b;
    
    rep(i,N-1){
        for(j=i+1;j<N;j++){
            if(S[i]==S[j]) continue;
            k=2*j-i;
            if(k>=N || S[i]==S[k] || S[j]==S[k]){
                continue;
            }
            sum--;
        }
    }

    printf("%ld\n",sum);
    return 0;
}


Measured memory_bytes: 3828
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();

    let mut a = vec![0; n+1];
    let vs: Vec<isize> = (0..n)
        .map(|_| {
            let v = iter.next().unwrap().parse().unwrap();
          a[v as usize] = a[v as usize] + 1;
          v
        })
        .collect();
    let s = a.iter().map(|n| if *n <= 1 {0} else {f(*n - 1)}).fold(0, |sum, a| sum + a);
  for v in vs {
    let n = a[v as usize];
    let x = if n <= 1 {0} else {f(n - 1)};
    let y = if (n-1) <= 1 {0} else {f(n - 2)};
    println!("{}", s - x + y);
  }
}

fn f(n: isize) -> isize {
  if n <= 1 {
    1
  } else {
    n * (n + 1) / 2
  }
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pli = pair<ll, int>;


struct UnionFind
{
    int n;
    vector<int> parent;
    vector<int> rank;
    UnionFind(int _n) :n(_n)
    {
        parent.assign(n, -1);
        rank.assign(n, 1);
    }

    int find(int i)
    {
        if (parent[i] == -1)
            return i;
        else
            return parent[i] = find(parent[i]);
    }

    void unite(int i, int j)
    {
        i = find(i);
        j = find(j);

        if (i == j) return;

        if (rank[i] == rank[j])
        {
            parent[j] = i;
            ++rank[i];
        }
        else
        {
            if (rank[i] < rank[j]) swap(i, j);
            parent[j] = i;
        }
    }

    bool is_same(int i, int j)
    {
        return find(i) == find(j);
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pli> values_index;
    rep(i, 0, n) 
    {
        ll value;
        cin >> value;
        values_index.emplace_back(value, i);
    }
    sort(values_index.begin(), values_index.end());

    UnionFind uf(n);
    rep(i, 0, m)
    {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    // validation
    int num_node = 2*(n-m-1);
    if (n < num_node)
    {
        cout << "Impossible" << endl;
        return 0;
    }

    // calculate cost;
    int num_first = 0;
    ll cost = 0;
    vector<int> used(n, 0), num_nodes(n, 0);
    for (auto v_i: values_index)
    {
        int i;
        ll value;
        tie(value, i) = v_i;

        if (num_nodes[uf.find(i)] == 0)
        {
            cost += value;
            ++num_first;
            ++num_nodes[uf.find(i)];
            used[i] = 1;
        }
    }
    if (num_first == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    num_node -= num_first;
    for (auto v_i: values_index)
    {
        if (num_node <= 0) break;

        int i;
        ll value;
        tie(value, i) = v_i;

        if (used[i] == 0)
        {
            cost += value;
            --num_node;
            used[i] = 1;
        }
    }
    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 3312
#include <iostream>
#include <algorithm>
#define REP(i,n) for(int (i)=0;(i)<int(n);(i)++)
using namespace std;

int main()
{
  int N, M, T;
  cin >> N >> M >> T;
  int a[N];
  REP(i,N) cin >> a[i];
  bool b[T] = {};
  REP(i,N){
    REP(j,M) b[a[i]-j-1] = true;
    REP(j,M+1) if(a[i]+j-1 < T) b[a[i]+j-1] = true;
  }
  cout << count(b,b+T,false) << endl;
}

Measured memory_bytes: 3068
N,M=gets.split.map &:to_i
v=[0]*(N+1)
M.times do
a,b=gets.split.map(&:to_i).minmax
  v[a] |= 1 if b==N
  v[b] |= 2 if a==1
end
puts v.any?{|i|i==3} ? :POSSIBLE : :IMPOSSIBLE


Measured memory_bytes: 3324
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			double[] a=new double[8];
			for(int i=0;i<8;i++)a[i]=sc.nextDouble();
			if(a[2]<a[4] || a[6]<a[0] || a[3]<a[5] || a[7]<a[1])System.out.println("NO");
			else System.out.println("YES");
			
		}
	}
}

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

typedef long long ll;

const int MAX_V = 10;
int d[MAX_V+10][MAX_V+10];
int n, v;

void floyd() {
    for(int k = 0; k < v; k++) {
        for(int i = 0; i < v; i++) {
            for(int j = 0; j < v; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    while(scanf("%d", &n) != EOF && n) {
        for(int i = 0; i < MAX_V; i++) fill(d[i], d[i]+MAX_V, 100001);
        int a, b, c;
        v = 0;
        for(int i = 0; i < n; i++) {
            scanf("%d%d%d", &a, &b, &c);
            d[a][b] = d[b][a] = c;
            v = max(v, max(a,b)+1);
        }
        for(int i = 0; i < v; i++) d[i][i] = 0;
        floyd();
        int ans = 1000000000, index = 0;
        for(int i = 0; i < v; i++) {
            int t = 0;
            for(int j = 0; j < v; j++) {
                if(i == j) continue;
                t += d[i][j];
            }
            if(ans > t) {
                ans = min(ans, t);
                index = i;
            }
        }
        printf("%d %d\n", index, ans);
    }
    return 0;
}


Measured memory_bytes: 3132
N = int(raw_input())
for i in range(0, N):
	ball = map(int, raw_input().split())
	stack = [[1, ball[0], 0]]
	flag = False
	while stack != []:
		now = stack.pop(-1)
		if now[0] == 10:
			flag = True
			break
		b = ball[now[0]]
		if now[1] < b: stack.append([now[0]+1, b, now[2]])
		if now[2] < b: stack.append([now[0]+1, now[1], b])
	if flag: print 'YES'
	else: print 'NO'


Measured memory_bytes: 4660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  N > 0;
  K > 0;
  cin >> N >> K;
  if ( N % K == 0)
  {
    cout << "0" << endl;
  }
  else {
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if (c > a&&c > b&&c*c == a*a + b*b)
			printf("YES\n");
		else if (b > a&&b > c&&b*b == a*a + c*c)
			printf("YES\n");
		else if (a > c&&a > b&&a*a == c*c + b*b)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<stdio.h>

int main(void){
	int a = 0, b = 0;
	scanf("%d %d", &a, &b);
	
	if (a > b)
		printf("a > b\n");
	else if (a < b)
		printf("a < b\n");
	else
		printf("a == b\n");

	return 0;
}


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

int main(){
    int n,k,l[100],ans=0;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&l[i]);
    sort(l,l+n);
    for(int i=n-1;i>=n-k;i--) ans += l[i];
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[100],p;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	p=0;
	for (int i=1;i<=n;i++) if (a[i]!=i)p++;
	if ((p==0)||(p==2)) printf("YES");else printf("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int gcd(int a,int b){
	if(!b) return a;
	return gcd(b,a%b);
}

int w,h,c;

int main(){
	cin>>w>>h>>c;
	int g=gcd(w,h);
	cout<<w/g*h/g*c<<endl;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

vector<int> E[100001];
int kotae[100001];
int Vis[100001];
void sagasu(int P, int D, int C) {
	if (D == 0 && kotae[P] == 0) kotae[P] = C;
	else if (Vis[P] < D) {
		Vis[P] = D;
		if (kotae[P] == 0) kotae[P] = C;
		for (int p : E[P]) {
			sagasu(p, D - 1, C);
		}
	}
}

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


	int N, M, Q;
	cin >> N >> M;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}
	cin >> Q;
	int v[100000], d[100000], c[100000];
	rep(i, Q) cin >> v[i] >> d[i] >> c[i];

	for (int i = Q - 1; i >= 0; i--) {
		sagasu(v[i], d[i], c[i]);
	}
	rep1(i, N) {
		co(kotae[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 8440
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;

int a, p;

int main() {
    cin >> a >> p;
    cout << (a * 3 + p) / 2;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C, D);

// ===

fn main() {
    let (a, b, c, d): (i32, i32, i32, i32) = read();
    let ac = min((a-c).abs(), max((a-b).abs(), (b-c).abs()));
    if ac <= d {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
double a[3001],f[3001][3001];

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	f[1][1]=a[1];
	f[1][0]=(double)(1-a[1]);
	for(int i=2;i<=n;i++){
		for(int j=0;j<=i;j++){
			f[i][j]=f[i-1][j]*(1.0-a[i])+f[i-1][j-1]*a[i];
		}
	}
	double ans=0.0;
	for(int i=(n+1)/2;i<=n;i++){
		ans+=f[n][i];
	}
	printf("%.9f",ans);
}


Measured memory_bytes: 68992
package main

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

const MAX int = 25

type Node struct {
	Parent int
	Left int
	Right int
}

var T []Node = make([]Node, MAX)
var N int

func preParse(u int) {
	if u == -1 {
		return
	}
	fmt.Printf(" %d", u)
	preParse(T[u].Left)
	preParse(T[u].Right)
}

func inParse(u int) {
	if u == -1 {
		return
	}
	inParse(T[u].Left)
	fmt.Printf(" %d", u)
	inParse(T[u].Right)
}

func postParse(u int) {
	if u == -1 {
		return
	}
	postParse(T[u].Left)
	postParse(T[u].Right)
	fmt.Printf(" %d", u)
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	N = nextInt(scanner)
	for i:=0; i<N; i++ {
		T[i].Parent = -1
		T[i].Left = -1
		T[i].Right = -1
	}
	for i:=0; i<N; i++ {
		index := nextInt(scanner)
		T[index].Left = nextInt(scanner)
		T[index].Right = nextInt(scanner)
		if T[index].Left != -1 {
			T[T[index].Left].Parent = index
		}
		if T[index].Right != -1 {
			T[T[index].Right].Parent = index
		}
	}
	root := 0
	for i:=0; i<N; i++ {
		if T[i].Parent == -1 {
			root = i
		}
	}
	fmt.Printf("Preorder\n")
	preParse(root)
	fmt.Printf("\nInorder\n")
	inParse(root)
	fmt.Printf("\nPostorder\n")
	postParse(root)
	fmt.Printf("\n")
}



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

bool compare(string s, string t){
    if (s.size() > t.size()) return true;
    if (s.size() < t.size()) return false;
    int k = (int)s.size();
    for (int i = 0; i < k; i++){
        if (s[i] > t[i]) return true;
        if (t[i] > s[i]) return false;
    }
    return true;
}

int main(){
    while (1){
        int w, h;
        cin >> w >> h;
        if (h == 0) break;
        vector<vector<char>> c(h, vector<char>(w));
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++) cin >> c[i][j];
        }
        vector<vector<string>> ans(h, vector<string>(w, "0"));
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (c[i][j] - '0' < 0 || c[i][j] - '0' > 9) continue;
                string cc = "";
                cc += c[i][j];
                if (compare(cc, ans[i][j])){
                    ans[i][j] = cc;
                }
                if (i > 0){
                    if (ans[i-1][j] != "0" && compare(ans[i-1][j] + cc, ans[i][j])){
                        ans[i][j] = ans[i-1][j]  + cc;
                    }
                }
                if (j > 0){
                    if (ans[i][j-1] != "0" && compare(ans[i][j-1] + cc, ans[i][j])){
                        ans[i][j] = ans[i][j-1] + cc;
                    }
                }
            }
        }
        string aaa = "0";
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (compare(ans[i][j], aaa)) aaa = ans[i][j];
            }
        }

        cout << aaa << endl;
    }
}



Measured memory_bytes: 3284
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <iomanip>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
// ****  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define fl(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define fi(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> dmap;
typedef set<int> dset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
/********** solver function **********/
double solve(int n, vector<double>&v, int k,vector<vector<double>>&dp){
    if( k>=v.size()) return 0;
	if( n==0){double a=1; for( int i=k;i<v.size();i++) a=a*(1-v[i]); return a;};
    if( n>v.size()-k) return 0; 

    if( n==1 && k==v.size()-1) return v[k];
    if( dp[n][k]!=2.0) return dp[n][k];
        double a=0;
        // if( n<=v.size()-k-1)
        a=(1-v[k])*solve( n, v,k+1, dp);
        double p=v[k]*solve( n-1,v,k+1, dp);
        // if( a!=0) return (a+p)/2 ;
        // else
        return dp[n][k]= (a+p);
}
/********** Main()  function **********/
int main()
{std::ios::sync_with_stdio(false);
	int n; cin>>n;
    vector<double> v(n);
    for( int i=0; i<n;i++)
    cin>>v[i];
    double x=0;
    // cout<<"K";
    vector<vector<double>>dp(n+1,vector<double>(n+1, 2.0));
    for( int i=n;i>n/2;i--){
        // double x=solve(i, v)/i;
        x=(x+solve( i, v, 0,dp));
    }
    cout<<setprecision(10);
    cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 73644
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<utility>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,d[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>d[i];
	sort(d+1,d+1+n);
	if(n%2==1)
	{
		cout<<0;
		return 0;
	}
	if(d[n/2]==d[n/2+1])
	{
		cout<<0;
		return 0;
	}
	else
	{
		cout<<d[n/2+1]-d[n/2];
		return 0;
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100001];
int main()
{
    ll i,n,c=0,c1=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%4==0)
        {
            c++;
        }
        else if(a[i]%4==2)
        {
            c1++;
        }
    }
    if(n/2<=c)
    {
        cout<<"Yes"<<endl;
    }
    else if(n/2>c)
    {
        if(((n/2)-c)*2<=c1)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 1024
from operator import mul
from functools import reduce


def inpl():
    return list(map(int, input().split()))


def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, A, B = inpl()

if A > B:
    print(0)
    exit()
elif A == B:
    print(1)
    exit()
elif N == 1:
    print(0)
    exit()
elif N == 2:
    print(1)
    exit()

# N > 2
# A < B
print(A + B * (N - 1) - (A * (N - 1) + B) + 1)


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; ++i) cin >> s[i];

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            bool flag = true;
            if(s[i][j] == '#') {
                flag = false;
                if(i > 0) 
                    if(s[i-1][j] == '#') flag = true;
                if(i < h-1) 
                    if(s[i+1][j] == '#') flag = true;
                if(j > 0) 
                    if(s[i][j-1] == '#') flag = true;
                if(j < w-1) 
                    if(s[i][j+1] == '#') flag = true;
            }
            if(!flag) {
                cout << "No" << '\n';
                return 0;
            }
        }
    }

    cout << "Yes" << '\n';

    return 0;
}

Measured memory_bytes: 256
# 解説動画より
# 分子/分母 で 分子<分母の時　分子がそのまま余りとなり余りは最大値となる
# ちなみに最後の数は、1で割ることになり、余りは０
# だから N-1までの和をとればよい 
N = int(input())
print(N*(N-1)//2)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, 2 * N) cin >> A[i];
	sort(A, A + 2 * N);
	ll res = 0;
	rep(i, 0, N) {
		res += A[i * 2];
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 384