akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <iomanip>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int x[3], max = 0;
	rep(i,3){
		cin >> x[i];
		if(x[i] > max) max = x[i];
	}
	cout << x[0]+x[1]+x[2]+9*max;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,a,b,c,d,m1=0,m2=0,min=0,x,y;
    cin >>n>>a>>b>>c>>d;
    
    if(n%a==0){
    x=(n/a);
    m1=x*b;
    }
    else{
    x=(n/a)+1;
    m1=x*b;
    }
    if(n%c==0){
    y=(n/c);
    m2=y*d;
    }
    else{
    y=(n/c)+1;
    m2=y*d;    
    }
    if(m1>m2)
        min=m2;
    else
        min=m1;
    
    cout << min << endl;
    
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int t;
  cin >> t;
  
  while (t--) {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> x(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> x.at(i).at(j);
      }
    }
    
    vector<vector<int>> y(26, vector<int>(4));
    for (int i = 0; i < 26; i++) {
      y.at(i).at(0) = y.at(i).at(2) = 50;
      y.at(i).at(1) = y.at(i).at(3) = -1;
    }
    
   for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (x.at(i).at(j) == '.') continue;
        int keep = x.at(i).at(j) - 'A';
        y.at(keep).at(0) = min(y.at(keep).at(0), i);
        y.at(keep).at(1) = max(y.at(keep).at(1), i);
        y.at(keep).at(2) = min(y.at(keep).at(2), j);
        y.at(keep).at(3) = max(y.at(keep).at(3), j);
      }
    }
    
    vector<bool> z(26, false);
    while (true) {
      bool flag = false;
      for (int k = 0; k < 26; k++) {
        if (z.at(k)) continue;
        if (y.at(k).at(0) <= y.at(k).at(1)) {
          bool flag2 = true;
          for (int i = y.at(k).at(0); i <= y.at(k).at(1); i++) {
            for (int j = y.at(k).at(2); j <= y.at(k).at(3); j++) {
              if (x.at(i).at(j) != (char) (k + 'A') && x.at(i).at(j) != '#') flag2 = false;
            }
          }
          if (flag2) {
            flag = true;
            z.at(k) = true;
            for (int i = y.at(k).at(0); i <= y.at(k).at(1); i++) {
              for (int j = y.at(k).at(2); j <= y.at(k).at(3); j++) {
                x.at(i).at(j) = '#';
              }
            }
          }
        }
      }
      if (!flag) break;
    }
    
    bool flag3 = true;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (x.at(i).at(j) != '.' && x.at(i).at(j) != '#') flag3 = false;
      }
    }
    
    if (flag3) cout << "SAFE\n";
    else cout << "SUSPICIOUS\n";
  }
}


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

class Card
{
public:
	char suit;
	int number;
private:

};

vector<Card> Bubblesort(vector<Card> c, int n) {
	Card tmp;
	FOR(i, 0, n) {
		for (int j = n - 1; j >= i + 1; j--) {
			if (c[j].number < c[j - 1].number) {
				tmp = c[j];
				c[j] = c[j - 1];
				c[j - 1] = tmp;
				
			}
		}
	}
	return c;
}

vector<Card> SelectionSort(vector<Card> c, int n) {
	int minj;
	Card tmp;
	REP(i, n) {
		minj = i;
		FOR(j, i, n) {
			if (c[j].number < c[minj].number) {
				minj = j;
			}
		}
		tmp = c[i];
		c[i] = c[minj];
		c[minj] = tmp;
	}
	return c;
}

int main() {
	int n;
	cin >> n;
	vector<Card> c(n);
	vector<Card> a,b;

	REP(i, n) cin >> c[i].suit >> c[i].number;

	a = Bubblesort(c,n);
	b = SelectionSort(c, n);

	FOR(i, 0, n) {
		if (i == n - 1) { cout << a[i].suit << a[i].number << endl; }
		else { cout << a[i].suit << a[i].number << " "; }
	}
	cout << "Stable" << endl;

	FOR(i, 0, n) {
		if (i == n - 1) { cout << b[i].suit << b[i].number << endl; }
		else { cout << b[i].suit << b[i].number << " "; }
	}

	bool ans = true;
	REP(i, n) {
		if (a[i].suit == b[i].suit && a[i].number == b[i].number);
		else {
			ans = false;
		}
	}
	if (ans) {
		cout << "Stable" << endl;
	}
	else { cout << "Not stable" << endl; }
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[n],b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    int tmp = 0, ans = 0;
    for(int i = 0; i < n; i++){
        if(ans < a[i]){
            ans = a[i];
            tmp = i;
        }
    }
    cout << ans + (int)b[tmp] << endl; 

    return 0;
}



Measured memory_bytes: 4416
# 現在の数curに対して直前の数としてあり得る範囲は、cur ~ cur + A[i] - 1の範囲内
# さらにA[i-1]の倍数である必要があるため、上記範囲内のA[i-1]の倍数の最大最小値を設定する
# 直前の数がない場合(最後)はcur, cur + A[i]をそのまま出力
import sys
readline = sys.stdin.readline

K = int(readline())
A = list(map(int,readline().split()))[::-1] # ややこしいので逆順で見ていく

mincur = 2
maxcur = 2

def get_min_val(c,a): # c以上のaの倍数の最小値を求める
  return ((c - 1)//a + 1) * a

def get_max_val(c,a): # c以下のaの倍数の最大値を求める
  return (c // a) * a

if A[0] != 2:
  print(-1)
  exit(0)
  
for i in range(len(A)):
  mincur = mincur
  maxcur = maxcur + A[i] - 1
  if i + 1 < len(A):
    mincur = get_min_val(mincur,A[i + 1])
    maxcur = get_max_val(maxcur,A[i + 1])
    if mincur > maxcur:
      print(-1)
      exit(0)
print(mincur,maxcur)


Measured memory_bytes: 15020
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 400 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int n;
int a[maxN];
ll pref[maxN];
ll dp[maxN][maxN];

ll solve(int l, int r) {
	if (l == r)
	{
		return 0;
	}
	if (dp[l][r] != -1)
		return dp[l][r];
	ll& ans = dp[l][r];
	ans = INF;
	for (int i = l; i <= r - 1; ++i)
	{
		// partitioning at position i means that the aggregate silme
		// on the left(l,i) and on the right(i+1,r) are t be merged
		ans = min(ans, solve(l, i) + solve(i + 1, r) + (pref[r] - pref[l - 1]));
	}
	return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	FIO
	cin >> n;
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		pref[i] = pref[i - 1] + a[i];
	cout << solve(1, n);
	return 0;
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
#define MOD 1000000007 
//ll dx[4] = {1,-1,0,0};
//ll dy[4] = {0,0,1,-1};

ll pasc[100][100];
ll getPasc(ll n,ll k){
  //cout<<"p"<<n<<" "<<k<<endl;
  if(pasc[n][k]!=0){
    return pasc[n][k];
  }else{
    pasc[n][k] = getPasc(n-1,k-1)+getPasc(n-1,k);
    return pasc[n][k];
  }
}

int main(){
  REP(i,100){
    REP(j,100){
      pasc[i][j] = 0;
    }
  }
  REP(i,100){
    pasc[i][0] = 1;
    pasc[i][i] = 1;
  }
  
  ll n,a,b;
  cin>>n>>a>>b;
  ll v[n];
  REP(i,n){
    cin>>v[i];
  }
  
  sort(v,v+n);
  double mean = 0;
  for(int i=n-a;i<n;i++){
    mean += v[i];
  }
  mean /= a;
  cout<<setprecision(7)<<mean<<endl;

  ll minV = v[n-a];
  ll minS;
  REP(i,n){
    if(v[i] == minV){
      minS = i;
      break;
    }
  }
  ll minG;
  REP(i,n){
    if(v[i] > minV){
      minG = i-1;
      break;
    }else if(i==n-1){
      minG = n-1;
      break;
    }
  }
  ll x,y;
  x = minG-(n-a)+1;
  y = minG-max(minS,n-b)+1;
  ll z = minG-minS+1;
  if(v[minS]!=v[n-1]){
    y = x;
  }
  //cout<<z<<endl;
  ll baai=0;
  for(ll i=x;i<=y;i++){
    baai += getPasc(z,i);
  }
  cout<<baai<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

// Antsbook p.59
ll w1[3], v1[3], w2[3], v2[3];
ll dp1[5001], dp2[25000001];
ll n;

ll knap(){
    rep(i, 3){
        repr(j, w1[i], n+1){
            dp1[j] = max(dp1[j], dp1[j-w1[i]] + v1[i]);
        }
    }
    ll d = dp1[n] + n;
    rep(i, 3){
        repr(j, w2[i], d+1){
            dp2[j] = max(dp2[j], dp2[j-w2[i]] + v2[i]);
        }
    }
    return dp2[d] + d;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n;
    ll ga, sa, ba;
    cin >> ga >> sa >> ba;
    ll gb, sb, bb;
    cin >> gb >> sb >> bb;
    w1[0] = ga;
    w1[1] = sa;
    w1[2] = ba;
    v1[0] = gb - ga;
    v1[1] = sb - sa;
    v1[2] = bb - ba;
    w2[0] = gb;
    w2[1] = sb;
    w2[2] = bb;
    v2[0] = ga - gb;
    v2[1] = sa - sb;
    v2[2] = ba - bb;
    cout << knap() << endl;
    return 0;
}

Measured memory_bytes: 195584
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]

index = 0
for i in range(H):
    cnt = 0
    for j in range(W):
        if c[i][j] == '#':
            index += 1
            cnt = index
            c[i][j] = cnt
        if c[i][j] == '.' and cnt != 0:
            c[i][j] = cnt

for i in range(H):
    for j in reversed(range(W - 1)):
        if c[i][j] == '.':
            c[i][j] = c[i][j + 1]

for i in range(H - 1):
    for j in range(W):
        if c[i][j] != '.' and c[i + 1][j] == '.':
            c[i + 1][j] = c[i][j]

for i in reversed(range(1, H)):
    for j in range(W):
        if c[i][j] != '.' and c[i - 1][j] == '.':
            c[i - 1][j] = c[i][j]


for i in range(H):
    for j in range(W):
        if j != W - 1:
            print(c[i][j], end=' ')
        else:
            print(c[i][j])

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

int main()
{
    std::string a, b;
    std::cin >> a >> b;
    if (b.size() > a.size()) {}
    else {
        int diff = a.size() - b.size();
        for (int i = 0; i <= diff; i++) {
            if (a[i] == b[0]) {
                bool ismatch = true;
                for (int j = 1; j < b.size(); j++) {
                    if (a[i+j] != b[j]) {
                        ismatch = false;
                        break;
                    }
                }
                if (ismatch) std::cout << i << std::endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define ull unsigned long long

int main(){
    ll a,b,v,w,t;
    ull dist;
    scanf("%lld%lld",&a,&v);
    scanf("%lld%lld",&b,&w);
    scanf("%lld",&t);
    if (a>=b) dist=a-b;
    else dist=b-a;
    if (w>=v) printf("NO");
    else{
        if (t*(v-w)>=dist) printf("YES");
        else printf("NO");
    }
    return 0;
}


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

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

  int ans = (a + b + 2 - 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
if not (a+b-1 <= n <= a*b):
  print(-1)
  exit()
n -= a
l = list()
for i in range(b,a*b+1,b):
  t = min(n,b-1)
  l += [i-j for j in range(t+1)]
  n -= t
d = dict()
g = sorted(l)
for i,x in enumerate(g,1):
  d[x] = i
l = list(map(lambda x:d[x], l))
print(*l)

Measured memory_bytes: 45904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



public class Main{
	public static void main(String[] args){

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		int num, a, b;
		String str, command, p;
		String[] array_command;
		char[] array_str, p_str;
		char x;


		try{
			str=reader.readLine();
			num=Integer.parseInt(reader.readLine());

			for(int i=0;i<num;i++){
				command=reader.readLine();
				array_command=command.split(" ");
				a=Integer.parseInt(array_command[1]);
				b=Integer.parseInt(array_command[2]);


				if(command.matches(".*print.*")){
					System.out.println(str.substring(a, b+1));

				}else if(command.matches(".*reverse.*")){
					array_str=str.toCharArray();

					for(int j=0;j<=(b-a-1)/2;j++){
						x=array_str[a+j];
						array_str[a+j]=array_str[b-j];
						array_str[b-j]=x;
					}
					str=String.valueOf(array_str);

				}else if(command.matches(".*replace.*")){
					p=array_command[3];
					p_str=p.toCharArray();
					array_str=str.toCharArray();

					for(int j=a;j<b+1;j++){
						array_str[j]=p_str[j-a];
					}
					str=String.valueOf(array_str);
				}


			}//?????????for?????????




		}catch(IOException e){
			System.out.print(e);
		}
	}

}

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

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

  if (0 < a)
    puts("Positive");
  else if (b < 0) {
    if ((b - a + 1) % 2 == 0)
      puts("Positive");
    else
      puts("Negative");
  } else
    puts("Zero");
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>

#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

int main(){
    llong N,M;
    llong P,Y;
    llong index=0;
    llong rank;
    cin >> N >> M;
    
    vector<vector<llong> > PQ_TABLE(N);
    vector<pair<llong, llong> > ANS_TABLE(M);
    map<llong, pair<llong, llong> > dict;
    for(int i=0; i<M; i++){
        cin >> P >> Y;
        PQ_TABLE[P-1].push_back(Y);
        dict[Y].first = P;
        dict[Y].second = i;
    }
    for(int i=0; i<N; i++){
        sort(PQ_TABLE[i].begin(), PQ_TABLE[i].end());
    }
    for(int i=0; i<N; i++){
        while(!PQ_TABLE[i].empty()){
            rank = PQ_TABLE[i].size();  
            Y = PQ_TABLE[i][PQ_TABLE[i].size()-1];
            PQ_TABLE[i].pop_back();
            P = dict[Y].first;
            ANS_TABLE[dict[Y].second].first = P;
            ANS_TABLE[dict[Y].second].second = rank;
        }
    }
    for(int i=0; i<M; i++){
        printf("%06lld%06lld\n", ANS_TABLE[i].first, ANS_TABLE[i].second);
    }
    return 0;
}


Measured memory_bytes: 15936
/*
 * test.cpp
 *
 *
 *      Author: Fireworks
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<iomanip>
#include<fstream>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>

using namespace std;

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
long long mod = 1000000007LL;
long long base = 10000007;
long long large = 1000000000000000000LL;



int solve(string s){

	int n = (int)s.length();
	vector<int> pre(n,-1);
	int p = 0;
	for(int i=1;i<n;i++){
		pre[i] = p;
		if(s[i]=='0') p=i;
	}
	vector<int> dp(n,0);
	for(int i=1;i<n;i++){
		dp[i] = dp[i-1];
		if(s[i]=='1'){
			if(s[i-1]=='0'){
				int pos = pre[i-1];
				if(pos==-1) continue;
				for(int j=pos+1;j<i-1;j++){
					dp[i] = max(dp[i],dp[j-1]+i-j+1-2);
				}
			}else{
				int pos = pre[i];
				if(pos>1) dp[i] = max(dp[i],dp[pos-2]+i-pos);
			}
		}
	}
	return dp[n-1];
}
int main(){

	int n;

	string s;
	cin>>n>>s;
	vector<string> w;
	s = "0" + s;
	s = s + "0";
	string t = "0";
	for(int i=1;i<(int)s.length();i++){
		if(s[i-1]=='0'&&s[i]=='0'){
			w.push_back(t);
			t="";
		}
		t.push_back(s[i]);
	}
	w.push_back(t);



	int ans = 0;
	for(int i=0;i<(int)w.size();i++){
		//cout<<w[i]<<endl;
		ans+=solve(w[i]);
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 28064
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int n;
    int hh,mm,ss,st,en,t;
    int time[86401];
    char ch;
    while(1){
        cin >> n;
        if(n == 0)  break;
        for(int j = 0; j < 86400; j++){
            time[j] = 0;
        }
        for(int i = 0; i < n; i++){
            cin >> hh >> ch >> mm >> ch >> ss;
            st = hh * 3600 + mm * 60 + ss;
            cin >> hh >> ch >> mm >> ch >> ss;
            en = hh * 3600 + mm * 60 + ss;
            for(int j = st; j < en; j++){
                time[j]++;
            }
        }
        
        int maxt = 0;
        for(int i = 0; i < 86400; i++){
            if(maxt < time[i])  maxt = time[i];
        }
        
        cout << maxt << endl;
        
    }
    
    return 0;
}



Measured memory_bytes: 3344
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

main = do
  [a,b] <- getIs
  putStrLn . show $ a + (b `div` 2)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n,h,w;
    cin >> n >> h >> w;
    int ans=0;
    rep(i,n/2){
        int f,g;
        cin >> f >> g;
        int y;
        if (f+g<=w) y=f+g;
        else y=2*w-f-g;
        ans+=y*h;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3092
package main

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

// algorithm: bfs
func main() {
	n, m := readInt(), readInt()

	mat := make([][]int, n)
	for i := range mat {
		mat[i] = make([]int, 0)
	}

	for i := 0; i < m; i++ {
		a, b := readInt()-1, readInt()-1
		mat[a] = append(mat[a], b)
		mat[b] = append(mat[b], a)
	}

	q := []int{0}
	ans := make([]int, n)
	for len(q) > 0 {
		cur := q[0]
		q = q[1:]

		for _, next := range mat[cur] {
			if ans[next] != 0 {
				continue
			}
			ans[next] = cur + 1
			q = append(q, next)
		}
	}

	fmt.Println("Yes")
	for i := range ans[1:] {
		fmt.Println(ans[i+1])
	}
}

func main0() {
	n, m := readInt(), readInt()

	mat := make(map[int][]int)
	for i := 0; i < m; i++ {
		a, b := readInt(), readInt()
		if _, ok := mat[a]; !ok {
			mat[a] = make([]int, 0)
		}
		mat[a] = append(mat[a], b)
		if _, ok := mat[b]; !ok {
			mat[b] = make([]int, 0)
		}
		mat[b] = append(mat[b], a)
	}

	nexts := make([]move, len(mat[1]))
	for i := range mat[1] {
		nexts[i] = move{mat[1][i], 1}
	}

	visited := map[int]bool{1: true}
	ans := make([]int, n)
	for len(nexts) > 0 && len(visited) < n {
		tmpNexts := make([]move, 0)
		// fmt.Println(nexts)
		for i := range nexts {
			if visited[nexts[i].cur] {
				continue
			}
			visited[nexts[i].cur] = true

			ans[nexts[i].cur-1] = nexts[i].pre

			if _, ok := mat[nexts[i].cur]; !ok {
				continue
			}
			for j := range mat[nexts[i].cur] {
				tmpNexts = append(tmpNexts, move{mat[nexts[i].cur][j], nexts[i].cur})
			}
		}
		nexts = tmpNexts
	}

	fmt.Println("Yes")
	for i := range ans[1:] {
		fmt.Println(ans[i+1])
	}
}

type move struct {
	cur int
	pre int
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 18404
#include <bits/stdc++.h>
 
using namespace std;
 
const int inf = (int) 1e9;
const int N = 1234567;
 
int save_x[N], save_y[N];
 
vector <int> g[N], g_blue[N];
int d[N], d_blue[N];
int pr[N], pr_blue[N];
 
void dfs(int v, int pv) {
  if (d[v] >= d_blue[v]) {
    return;
  }
  int sz = g[v].size();
  for (int j = 0; j < sz; j++) {
    int u = g[v][j];
    if (u == pv) {
      continue;
    }
    pr[u] = v;
    d[u] = d[v] + 1;
    dfs(u, v);
  }
}
 
int n;
 
void get_d(int start) {
  for (int i = 0; i < n; i++) {
    d[i] = inf;
    pr[i] = -1;
  }
  d[start] = 0;
  pr[start] = start;
  dfs(start, -1);
}
 
int main() {
  int x, y;
  scanf("%d %d %d", &n, &x, &y);
  x--; y--;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", save_x + i, save_y + i);
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; i++) {
    int foo, bar;
    scanf("%d %d", &foo, &bar);
    foo--; bar--;
    g[foo].push_back(bar);
    g[bar].push_back(foo);
  }
  for (int i = 0; i < n; i++) {
    d_blue[i] = inf;
  }
  get_d(y);
  for (int i = 0; i < n; i++) {
    d_blue[i] = d[i];
    g_blue[i] = g[i];
    pr_blue[i] = pr[i];
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; i++) {
    int foo, bar;
    foo = save_x[i];
    bar = save_y[i];
    foo--; bar--;
    g[foo].push_back(bar);
    g[bar].push_back(foo);
  }
  get_d(x);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] < d_blue[i]) {
      mx = max(mx, 2 * d_blue[i]);
      for (int j = 0; j < (int) g[i].size(); j++) {
        int to = g[i][j];
        if (pr_blue[to] == i || pr_blue[i] == to || pr_blue[pr_blue[to]] == i || pr_blue[pr_blue[i]] == to || pr_blue[i] == pr_blue[to]) {
          continue;
        }
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << mx << endl;
  return 0;
}

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

using namespace std;

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

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

int ways[510000];
int dist[510000];

int okf[510000];
int okb[510000];
char s[510000];
char *p; 
int pos[510000]; 
int n,m; 

void func(){
     int i, j=-1;
     pos[0]=-1;
     for( i=1 ; i<m ; i++ ){
          while( j>=0 && p[j+1]!=p[i] )
                 j=pos[j];
          if( p[j+1]==p[i] )
              j++;
          pos[i]=j;
     }     
}

bool ok(int i, int j) {
	m = j-i+1;
	p=s+i;
	func();

	int period = (m - pos[m-1] - 1);
	return period == m || (m % period != 0);
}

int main() {
	scanf("%s", s);
	p = s;
	m = strlen(p);
	n = m;

	reverse(s,s+m);
	func();

	for (int i = 0; i < m; i++) {
		int period = (i+1) - pos[i] - 1;
		okb[i] = (period == i+1) || ((i+1) % period != 0);
	}

	reverse(s,s+m);
	func();

	for (int i = 0; i < m; i++) {
		int period = (i+1) - pos[i] - 1;
		okf[i] = (period == i+1) || ((i+1) % period != 0);
	}


	int period = m - pos[m-1] - 1;
	if (period == 1) {
		printf("%d\n",m);
		printf("1\n");
	}
	else if (period < m && m % period == 0) {
		int ans = 0;
		for (int i = 0; i < m-1; i++) {
			if (okf[i] && okb[m-i-2]) ans++;
		}
		printf("2\n");
		printf("%d\n", ans);
	}
	else {
		printf("1\n");
		printf("1\n");
	}

	/*printf("\n");

	ways[0] = 1;
	dist[0] = 0;

	for (int j = 0; j < n; j++) {
		dist[j+1] = -1;

		for (int i = 0; i <= j; i++) {
			if (ok(i,j)) {
				if (dist[j+1] == -1 || dist[j+1] > dist[i]+1) {
					dist[j+1] = dist[i]+1;
					ways[j+1] = 0;
				}
				if (dist[j+1] == dist[i]+1) {
					ways[j+1] = (ways[j+1] + ways[i]) % 1000000007;
				}
			}
		}
	}

	printf("%d\n%d\n", dist[n], ways[n]);*/
}

Measured memory_bytes: 6656
#include<cstdio>
#include<iostream>
#include<cstring>
#include<bitset>
using namespace std;
#define N 501
int dd[501];
int ne[N*N],fir[N],to[N*N],tot;
int a[N] , b[N] , c[N] , d[N];
bitset<501>used;//深入理解used表示曾经尝试过增广
int n1,v,n2,m;
int x,y;
int ans,cnt;
void add(int x,int y)
{
    to[++tot]=y;ne[tot]=fir[x];fir[x]=tot;
}
int r(int &x)
{
    char c=getchar();int forread=0;
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)){forread*=10;forread+=c-'0';c=getchar();}
    x=forread;
}
bool find(int x)
{
    if(used[x]) return 0;
    used[x]=1;
    for(int i=fir[x];i;i=ne[i])
    {
        {
            if(!dd[to[i]]||find(dd[to[i]]))
            {
                dd[to[i]]=x;return 1;
            }
        }
    }
    return 0;
}

int n;

int main()
{
    cin >> n;
    n1 = n2 = n;
    for(int i = 1;i <= n;++ i) {
    	cin >> a[i] >> b[i];
	}
	for(int i = 1;i <= n;++ i) cin >> c[i] >> d[i];
	for(int i = 1;i <= n;++ i) {
		for(int j = 1;j <= n;++ j)
		if(a[i] < c[j] && b[i] < d[j]) add(i , j);
	}
    for(int i=1;i<=n1;i++)
    {
        used=0;
        if(find(i)) cnt++;
    }
    printf("%d\n",cnt);
} 

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);
    auto BS = readln.split.to!(long[]);
    long r;
    foreach (i; 0..N) {
        auto b = BS[i];
        if (AS[i] >= b) {
            r += b;
        } else {
            r += AS[i];
            auto a = max(0, AS[i+1] + AS[i] - b);
            r += AS[i+1] - a;
            AS[i+1] = a;
        }
    }
    writeln(r);
}

Measured memory_bytes: 9580
from heapq import *
from collections import *
import os
import sys
sys.setrecursionlimit(1<<30)
from io import BytesIO, IOBase
import math
import bisect
from math import inf

 
ins = lambda: [int(x) for x in input()]
inp = lambda: int(input())
inps = lambda: [int(x) for x in input().split()]
 
from fractions import Fraction as F
def main():
    
    n=inp()
    a=inps()

    cnt=0
    for i in range(n):
        if (i+1)&1 and a[i]&1:
            cnt+=1
    print(cnt)
    


  
 
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
if __name__ == "__main__":
    main()
# import threading,sys
# sys.setrecursionlimit(1000000)
# threading.stack_size(1024000)
# thread=threading.Thread(target=main)
# thread.start()

Measured memory_bytes: 72564
using System;

class Program
    {
        static void Main(string[] args)
        {
          　string[] temp = Console.ReadLine().Split(' ');
            int AtoB = int.Parse(temp[0]);
            int BtoC = int.Parse(temp[1]) / 2;
            Console.WriteLine(AtoB+BtoC);
        }
    }

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

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

  int ans = 0;
  while (s.size() > 0) {
    if (s[0] != s.back()) {
      if (s[0] == 'x') {
	s += 'x';
	ans++;
      } else if (s.back() == 'x') {
	s.insert(0, "x");
	ans++;
      } else {
	puts("-1");
	return 0;
      }
    } else {
      s = s.substr(1, s.size() - 2);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define ar array

int main() {
	string s, t;
	cin >> s >> t;
	int val=0, cnt=0;
	for(int i=0; i<(int)s.size(); ++i) {
		int tmp=i;
		cnt=0;
		if((int)s.size()-i<(int)t.size())
			break;
		for(int j=0; j<(int)t.size(); ++j) {
			if(s[i]==t[j])
				cnt++;
			i++;
		}
		i=tmp;
		val=max(val, cnt);
	}
	cout << (int)t.size()-val << "\n";
}


Measured memory_bytes: 3624
n = gets.to_i
h = gets.split.map(&:to_i)
a = 0
i = 0
while (n > i + 1)
  c = 0
  while (n > i + 1) && (h[i] >= h[i + 1])
    c += 1
    i += 1
  end
  i += 1
  a = c if c > a
end
puts a

Measured memory_bytes: 8580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    string S;
    cin >> S;
    ll L = S.size();
    vector<ll> p = {1,4,3,12,9,10};

    vector<vector<ll>> dp(L+1, vector<ll> (13, 0));
    dp.at(0).at(0) = 1;
    for(ll i = 1; i < 13; i++){
        dp.at(0).at(i) = 0;
    }

    ll cnt = 7 - (L % 6) - 1;
    ll tmp, d;
    for(ll i = 1; i <= L; i++){
        tmp = (cnt + i) % 6;
        if(S.at(i-1) == '?'){
            for(ll j = 0; j < 13; j++){
                for (ll d = 0; d < 10; d++){
                    dp.at(i).at(j) += dp.at(i-1).at( (169+j-p.at(tmp)*d) % 13);        
                }
                dp.at(i).at(j) = dp.at(i).at(j) % MOD;
            }
        }
        else{
            d = (ll)(S.at(i-1) - '0');
            for (ll j = 0; j < 13; j++){
                dp.at(i).at(j) += dp.at(i-1).at( (169+j-p.at(tmp)*d) % 13);
            }
        }
    }
    printf("%lld\n", dp.at(L).at(5));
       
}




Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
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;
}

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

    int iter = max(x, y);
    ll ans = INF;

    rep(i, 100001)
    {
        ll tmp = 0;
        tmp += c * 2 * i;

        if (i < x)
        {
            tmp += a * (x - i);
        }

        if (i < y)
        {
            tmp += b * (y - i);
        }

        ans = min(ans, tmp);
    }

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

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

int main() {
  string S, C, L, R;
  int Q, T, F, B=-1;
  cin >> S >> Q;
  rep(i, Q){
    cin >> T;
    if(T==1) B*=-1;
    if(T==2){
      cin >> F >> C;
      if(F==1 && B==-1) L=C+L;
      else if(F==1 && B==1) R=R+C;
      else if(F==2 && B==-1) R=R+C;
      else L=C+L;
    }
  }
  S=L+S+R;
  if(B==1) reverse(S.begin(), S.end());
  cout << S << endl;
}

Measured memory_bytes: 1464
n, m, k = map(int, input().split())
A = [[] for _ in range(n)]
c = [0]*n

for i in range(n):
    c_as = list(map(int, input().split()))
    c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF

for s in range(0, 1 << n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0:
            continue
        cost_sum += c[i]
        for j in range(m):
            smart[j] += A[i][j]

    judge = True
    for j in range(m):
        if smart[j] < k:
            judge = False

    if judge:
        ans = min(ans, cost_sum)

if ans == INF:
    ans = -1

print(ans)

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.WriteLine(h.Count(i => i >= NK[1]));
        }
    }
}

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

using namespace std;

typedef long long ll;

int main(){
  ll N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;

  vector<bool> A(T.size(), true);

  ll nR=0;
  ll nS=0;
  ll nP=0;

  for(ll i=0; i<N; i++){
    if (i >= K && T[i] == T[i-K] && A[i-K]){
      A[i] = false;
      continue;
    }
    if (T[i] == 'r') ++nR;
    else if (T[i] == 's')++nS;
    else if (T[i] == 'p')++nP;
  }

  ll ret = nR*P + nS*R + nP*S;
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 3780
c = [list(map(int, input().split())) for i in range(3)]
r1 = sum(c[0][j] for j in range(3))
r2 = sum(c[1][j] for j in range(3))
r3 = sum(c[2][j] for j in range(3))
c1 = sum(c[i][0] for i in range(3))
c2 = sum(c[i][1] for i in range(3))
c3 = sum(c[i][2] for i in range(3))
if r1 % 3 == r2 % 3 == r3 % 3 and c1 % 3 == c2 % 3 == c3 % 3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int w = sc.nextInt(), h = sc.nextInt();
			if( (w|h) == 0 ) break;
			String[][] dp = new String[h+1][w+1];
			for(String[] a: dp) fill(a, "");
			String c = "";
			for(int i=1;i<=h;i++) {
				String l = sc.next();
				for(int j=1;j<=w;j++) if( '0' <= l.charAt(j-1) && l.charAt(j-1) <= '9' ){
					dp[i][j] = (isLarge(dp[i][j-1], dp[i-1][j])? dp[i][j-1]: dp[i-1][j]);
					if( l.charAt(j-1) != '0' || dp[i][j].length() != 0  ) dp[i][j] += l.charAt(j-1);
					if( isLarge(dp[i][j], c) ) c = dp[i][j];
				}
			}
			System.out.println(c);
		}
	}
	
	boolean isLarge(String a, String b) {
		if( a.length() != b.length() ) {
			return a.length()>b.length();
		}
		
		for(int i=0;i<a.length();i++) {
			if( a.charAt(i) > b.charAt(i) ) return true;
			if( a.charAt(i) < b.charAt(i) ) return false; 
		}
		return false;
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

//the definition of must-working days is that working on these days is a must, cannot be earlier and cannot be later. For example, we can define the earliest
// and the latest day for x-th working day, we can use greedy operation
int main(){
	int n,k,c;
	string s;
	scanf("%d %d %d",&n,&k,&c);
	cin>>s;

	//for first iteration, we pick greedily so that we get the earliest day for x-th working day. earliest[x] = the earliest day for x-th working day
	vi earliest, latest;
	int i;
	for(i=0;i<n;i++){
		if(s[i] == 'o'){
			earliest.pb(i);
			// printf("push earliest: %d\n",i);
			if(earliest.size() == k){break;}
			i += c;
		}
	}
	for(i=n-1;i>=0;i--){
		if(s[i] == 'o'){
			latest.pb(i);
			// printf("push latest: %d\n",i);
			if(latest.size() == k){break;}
			i -= c;
		}
	}

	assert(earliest.size() == latest.size() && latest.size() == k);
	reverse(latest.begin(), latest.end());
	for(i=0;i<k;i++){
		if(earliest[i] == latest[i]){
			printf("%d\n",earliest[i] + 1);
		}
	}
	return 0;
};

Measured memory_bytes: 3448
def partition(A,p,r):
    x = A[r]
    i = p-1
    for j  in range(p,r):
        if A[j] <= x :
            i = i+1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
    _tmp = A[i+1]
    A[i+1] = A[r]
    A[r] = _tmp 

    return i+1


def main():
    n = int(input())
    Array = list(map(int,input().split()))
    q = partition(Array,0,n-1)
    Array[q] = "[%d]"%Array[q]
    print(" ".join(map(str,Array))) # " ".join???????????§????????£??????????????£???
  

if __name__ == '__main__':
    main()

Measured memory_bytes: 16392
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> x(N);
	vector<int> y(N);
	vector<int> h(N);
	
	for (int i = 0; i < N; i++)
	{
		cin >> x[i] >> y[i] >> h[i];
	}
	
	// 中心座標のcxと中心座標のcyの値を用いた2重for文
	for (int cx = 0; cx <= 100; cx++)
	{
		for (int cy = 0; cy <= 100; cy++)
		{
			// 中心の高さの最小値1
			int height = 1;
			
			for (int i = 0; i < N; i++)
			{
				if (h[i] > 0)
				{
					// 高度 = 中心の高さH - |X - CX| - |Y - CY|
					// 中心の高さH = 高度 + |X - CX| + |Y - CY|
					height = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
				}
			}
			
			// 中心の高さが求まったあとは、全ての頂点でのチェックを行う。
			bool isCheck = true;
			for (int i = 0; i < N; i++)
			{
				if (max(height - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i])
				{
					isCheck = false;
				}
			}
			
			if (isCheck)
			{
				cout << cx << " " << cy << " " << height << endl;
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
int main()
{
    string s;
    cin >> s;
    for (char i = 'a'; i <= 'z'; i++)
    {
        if (s.find(i) == string::npos)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

 
signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> d(n);
    rep(i, 0, n) cin >> d[i];
    rep(i, 1, m + 1){
        rep(j, 0, n - 1){
            if((d[j] % i) > (d[j + 1] % i)) swap(d[j], d[j + 1]);
        }
        // cout << ' ' << i << endl;
        // rep(j, 0, n){
        //     cout << d[j] << endl;
        // }
    }
    rep(i, 0, n){
        cout << d[i] << endl;
    }
}

Measured memory_bytes: 1192
#include<cstdio>
using namespace std;
int main()
{
	
	int a;
	scanf("%d",&a);
	if(a>=400&&a<=599) printf("8\n");
	if(a>=600&&a<=799) printf("7\n");
	if(a>=800&&a<=999) printf("6\n");
	if(a>=1000&&a<=1199) printf("5\n");
	if(a>=1200&&a<=1399) printf("4\n");
	if(a>=1400&&a<=1599) printf("3\n");
	if(a>=1600&&a<=1799) printf("2\n");
	if(a>=1800&&a<=1999) printf("1\n");
	return 0;
 } 

Measured memory_bytes: 1656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<ll> A;

int num[1000010];

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

vector<pair<ll,int>> factorize(ll val){
  vector<pair<ll,int>> res;
  for(ll i=2;i*i<=val;i++){
    if(val%i==0){
      int cnt=0;
      while(val%i==0){
        cnt++;
        val/=i;
      }
      res.push_back(mkp(i,cnt));
    }
  }
  if(val!=1) res.push_back(mkp(val,1));
  return res;
}

int main(){
  cin>>N;
  A.resize(N);
  rep(i,N) cin>>A[i];

  for(int i=0;i<N;i++){
    vector<pair<ll,int>> v=factorize(A[i]);
    for(int j=0;j<v.size();j++){
      num[v[j].first]=max(num[v[j].first],v[j].second);
    }
  }

  ll ans=0;
  ll lca=1;
  for(int i=1;i<=1000000;i++){
    if(num[i]==0) continue;
    ll res=mod_pow(i,num[i]);
    mul(lca,res);
  }
  for(int i=0;i<N;i++){
    vector<pair<ll,int>> v=factorize(A[i]);
    ll res=lca;
    for(int j=0;j<v.size();j++){
      ll val=mod_pow(v[j].first,v[j].second);
      val=mod_pow(val,MOD-2);
      mul(res,val);
    }
    add(ans,res);
  }

  cout<<ans<<endl;

  return 0;
}


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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <ii, int> iii;

const int siz = 1e6 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e12;
const string file = "2";

int quickPow(int x, int n) {
    if (n == 0) {
        return 1;
    }

    int t = quickPow(x, n / 2);
    (t *= t) %= mod;

    if (n % 2 == 0) {
        return t;
    }

    return ((t * x) % mod);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int n;
    cin >> n;

    int tot = quickPow(10, n);
    int sub = (2 * quickPow(9, n)) % mod;
    int add = quickPow(8, n);

    cout << (tot - sub + add + mod) % mod;

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (ll i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
    ll n;cin>>n;
    vector<char>c(n);
    ll r=0,w=0;
    rep(i,n){
        cin>>c[i];
        if(c[i]=='R')r++;
        else w++;
    }
    ll cnt=0;
    rep(i,r){
        if(c[i]=='W')cnt++;
    }
    if(r>=cnt)cout<<cnt<<endl;
    else cout<<r<<endl;
        return 0;
}

Measured memory_bytes: 3536