akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n, k;
    scan(n, k);

    double ans = 0;

    foreach (i ; 1 .. n + 1) {
        double t = 1.0 / n;
        while (i < k) {
            i *= 2;
            t *= 1.0 / 2;
        }
        ans += t;
    }

    writefln("%.12f", ans);
}























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc156/tasks/abc156_b

read row ; A=($row) ; n=$((A[0])) ; k=$((A[1]))
ans=$((0))
while [ $((n)) -gt $((0)) ] ; do
  ans=$((ans + 1))
  n=$((n / k))
done
echo $ans


Measured memory_bytes: 376
//Author : Ayush Jain

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
const int N=1e5 + 5;
const int M=1e5 + 5;

ull pw[67];
void pre()
{
	pw[0]=1;
	for(int i=1;i<64;i++) pw[i]=2*pw[i-1];
}

int main()
{
	ios_base::sync_with_stdio(false);
	pre();
	ll n,m;
	cin>>n>>m;
	ll p=1;
	for(int i=0;i<m;i++) p*=2;
	ll ans=(m*1900 + (n-m)*100)*p;	
	cout<<ans<<endl;
		
	return 0;
}

Measured memory_bytes: 256
d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j<3;j++){e[i]="+-*"[j];if(y(o-1,n+1,i+1,0))return 1;}if(n|i==6)for(j=0;j<4;j++)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,0))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,0)||puts("0");}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

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

	int n, i;
	cin >> n;
	vl a(n);
	rep(i, 0, n)
		cin >> a[i];
	ll ans = 0;
	rep(i, 1, n)
	{
		if(a[i] < a[i - 1])
		{
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	cout << ans;
}

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;

    vector<int>vec(b);
    for(int i=1; i<=b; i++){
        int m = a%b;
        m *= i;
        m %= b;
        vec[i-1] = m;
    }
    bool f = 0;
    for(int i=0; i<b; i++){
        if(vec[i]==c) f = 1;
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3616
//////AGC039-B//////
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
int n,m,l,q,ans=-100;
void Main(){
    cin>>n>>m;
    cout<<max(0,n-m*2)<<endl;
}
int main(){
    Main();
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A=in(),B=in();
	
	cout << (A-1)*(B-1) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {

        while (true)
        {
            String[] s = Console.ReadLine().Split(' ');

            int num = int.Parse(s[0]);
            int sum = int.Parse(s[1]);

            if (num == 0 && sum == 0)
            {
                break;
            }

            int count = 0;

            for (int i = 1; i <= num; i++)
            {
                for (int j = i + 1; j <= num; j++)
                {
                    for (int k = j + 1; k <= num; k++)
                    {
                        if (i + j + k == sum)
                        {
                            count++;
                        }
                    }
                }
            }

            Console.WriteLine(count);

        }

    }

}

Measured memory_bytes: 9188
N=int(input())
s=input()
ans = s
flag_A = True
r = 0
l = 0
while flag_A:
    flag_B =False
    for n,i in enumerate(s):
        if n != len(s)-1 and i =="(" and s[n+1] ==")":
            s = s[:n]+s[n+2:]
            flag_B = True
            break
    if not flag_B:
        flag_A = False
for i in s:
    if i ==")":
        r += 1
    else:
        l += 1
print("("*r+ans+")"*l)

Measured memory_bytes: 3064
import * as fs from 'fs';

const input = fs.readFileSync("/dev/stdin", "utf8").split(' ');

const five = input.filter(x => {
    return parseInt(x) === 5;
});

const seven = input.filter(x => {
    return parseInt(x) === 7;
})

if (five.length === 2 && seven.length === 1) {
    console.log('YES');
} else {
    console.log('NO');
}


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ins(s);
    inl(q);
    int r=0;
    string bf="",af="";
    REP(i,q){
        ini(t);
        if(t==1){
            r= (r+1)%2;
        }else{
            ini(f); ins(c);
            if(f==1){
                if(r==0) bf= c+bf;
                else af+=c;
            }else{
                if(r==0) af+=c;
                else bf= c+bf;
            }
        }
    }
    s= bf+s+af;
    if(r==1){
        reverse(s.begin(), s.end());
    }
    out(s);

    
}

Measured memory_bytes: 1316
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
const int INF=1e9;
int main(){
    int N,T[10000]={0};
    cin>>N;
    for(int i=0;i<N-1;i++)cin>>T[i+1];
    int dp[2][5100][2];
    fill_n(**dp,4*5100,INF);
    dp[0][0][0]=0;
    for(int i=0;i<N;i++){
        int m=min(i,5005);
        for(int j=0;j<=m;j++){
            dp[(i+1)&1][j+1][0]=min(dp[i&1][j][0],dp[i&1][j][1]+T[i]);
            dp[(i+1)&1][j][1]=min(dp[i&1][j][1],dp[i&1][j][0]+T[i]);
            dp[i&1][j][0]=dp[i&1][j][1]=INF;
        }
    }
    cout<<min(dp[N&1][N/2][0],dp[N&1][N/2][1])<<endl;
    return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

vector<pair<long long, long long> > prime_factorize(long long n) { //素因数分解、pairのfirstに底、secondに底の何乗
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    auto p = prime_factorize(n);
    ll ans = 0;
    rep(i, sz(p)){
        ll tmp = 0;
        ll sum = 0;
        while(sum < p[i].sc){
            tmp++;
            sum += tmp;
            if(sum > p[i].sc) break;
            ans++;
        }
    }
    print(ans);

}



Measured memory_bytes: 3652
#include <iostream>
#include <stack>
int main()
{
  int n;
  std::stack<int> trains;
  while (std::cin >> n) {
    if (n == 0) {
      std::cout << trains.top() << std::endl;
      trains.pop();
    } else {
      trains.push(n);
    }
  }
  return 0;
}

Measured memory_bytes: 1200
# ABC070c
from fractions import gcd
from functools import reduce
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())


def lcm_base(a, b):
    return a * b // gcd(a, b)


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


def gcds(*numbers):
    return reduce(gcd, numbers)


t = [int(input()) for _ in range(n)]
print(lcm(*t))


Measured memory_bytes: 5076
#include <iostream>

using namespace std;

int main() {
	string t;
	cin >> t;
	
	int length = t.length();
	for (int i = 0; i < length; ++i) {
		if (t[i] != '?')
			continue;
		
		t[i] = 'D';
	}
	
	cout << t << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n, 0);
    rep1(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    ll ans = 0;
    rep1(i,k) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>

void maxHeapify(int *,int);
void Swap(int *,int,int);

int N;
int T[500010] ={0};

int main()
{
    int i, j;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d", &T[i]);
    }
    for (i = N/2+1; i >= 0; i--) {
        maxHeapify(T, i);
    }
    for (i = 0; i < N; i++) {
        printf(" %d", T[i]);
    }
    puts("");
  
    return 0;
}

void Swap(int T[], int x, int y)
{
    int tmp = T[x];
    T[x] = T[y];
    T[y] = tmp;
}

void maxHeapify(int T[], int i)
{
    int parent = i;
    int left = (i+1)*2 - 1;
    int right = (i+1)*2;
     
    int largest;
    if (right <= N && T[parent] < T[right]) {
        largest = right;
    }
    else {
        largest = parent;
    }
     
    if (left <= N && T[largest] < T[left]) {
        largest = left;
    }
  
    if (largest != parent) {
        Swap(T, largest, parent);
        maxHeapify(T, largest);
    }    
     
    return;
}
 

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
struct node {
	int key;
	node* parent, * left, * right;
};
node* nil, * root;
void insert(int key) {
	node* y = nil;//親
	node* x = root;
	node* z;
	z = (node*)malloc(sizeof(node));
	z->key = key;
	z->left = nil;
	z->right = nil;
	while (x!=nil) {
		y = x;
		if (z->key<x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y==nil) {
		root = z;
	}
	else {
		if (z->key<y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
};
void ino(node* u) {
	if (u == nil) {
		return;
	}
	ino(u->left);
	cout << " " << u->key;
	ino(u->right);
};
void pre(node* u) {
	if (u == nil) {
		return;
	}
	cout << " " << u->key;
	pre(u->left);
	pre(u->right);
}
void print(node* root) {
	ino(root);
	cout << endl;
	pre(root);
	cout << endl;
};
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		string order;
		cin >> order;
		if (order == "insert") {
			int key;
			cin >> key;
			insert(key);
		}
		else {
			print(root);
		}
	}
};




Measured memory_bytes: 26608
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007
#define INF INT_MAX/3

using namespace std;


long N, K;

vector<long> way[2001];
long dis[2001][2001];
vector<pair<long, long> >hen;



void dik(long start){
	priority_queue<pair<long, long>, vector<pair<long,long> >, greater<pair<long,long> > > Q;
	Q.push(make_pair(0, start));
	while(!Q.empty()){
		long po, cost;
		cost = Q.top().first;
		po = Q.top().second;
		//cout << "start" << start << "po=" << po << "cost" << cost << endl;
		Q.pop();
		if(dis[start][po] != INF){
			//cout << "con" << endl;
			continue;
		}
		dis[start][po] = cost;
		for(int i = 0; i < way[po].size(); i++){
			if(dis[start][way[po][i]] != INF){
				continue;
			}
			Q.push(make_pair(dis[start][po] + 1, way[po][i]));
		}
	}
}


void caldis(){
	for(int i = 0; i < N; i++){
		dik(i);
	}
}




int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			dis[i][j] = INF;
		}
	}
	for(int i = 0; i < N - 1; i++){
		long a, b;
		cin >> a >> b;
		a--;b--;
		way[a].push_back(b);
		way[b].push_back(a);
		hen.push_back(make_pair(a, b));
	}
	caldis();
	if(K%2 == 0){
		long long ans = INF;
		for(int mid = 0; mid < N; mid++){
			long long tmp = 0;
			for(int j = 0; j < N; j++){
				if(dis[mid][j] > K/2){
					tmp++;
				}
			}
			ans = min(tmp, ans);
		}
		cout << ans << endl;
	}else{
		long long ans = INF;
		for(int midhen = 0; midhen < hen.size(); midhen++){
			long long p1 = hen[midhen].first;
			long long p2 = hen[midhen].second;

			long long tmp = 0;
			for(int j = 0; j < N; j++){
				if((dis[p1][j] > (K-1)/2) && (dis[p2][j] > (K-1)/2)){
					tmp++;
				}
			}
			ans = min(tmp, ans);
		}
		cout << ans << endl;
	}

}


Measured memory_bytes: 31744
from collections import deque
import sys
import random
input = sys.stdin.readline


n, m, l = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
graph = [[] for i in range(n)]

for i in range(m):
    a, b, cost = info[i]
    if cost > l:
        continue
    a -= 1
    b -= 1
    graph[a].append((b, cost))
    graph[b].append((a, cost))

for i in range(n):
    graph[i] = random.sample(graph[i], len(graph[i]))
    
def dfs(start):
    INF = float("inf")
    visited_t = [INF]*n # 回数, 残り燃料
    visited_l = [0]*n
    visited_t[start] = 0
    q = deque([start])
    while q:
        pos = q.popleft()
        for next_pos, cost in graph[pos]:
            tmp = cost + visited_l[pos]
            times = visited_t[pos]
            next_times = visited_t[next_pos]
            if tmp <= l:
                if next_times > times:
                    q.append(next_pos)
                    visited_t[next_pos] = times
                    visited_l[next_pos] = tmp
                elif next_times == times:
                    if visited_l[next_pos] > tmp:
                        q.append(next_pos)
                        visited_t[next_pos] = times
                        visited_l[next_pos] = tmp
                else:
                    continue
            else:
                tmp = cost
                if next_times > times + 1:
                    q.append(next_pos)
                    visited_t[next_pos] = times + 1
                    visited_l[next_pos] = tmp
                elif next_times == times + 1:
                    if visited_l[next_pos] > tmp:
                        q.append(next_pos)
                        visited_t[next_pos] = times + 1
                        visited_l[next_pos] = tmp
                else:
                    continue
    return visited_t

ans = [None]*n
for i in range(n):
    ans[i] = dfs(i)

INF = float("inf")
q = int(input())
query = [list(map(int, input().split())) for i in range(q)]
for i in range(q):
    a, b = query[i]
    a -= 1
    b -= 1
    tmp = ans[a][b]
    if tmp == INF:
        print(-1)
    else:
        print(tmp)


Measured memory_bytes: 76764
#include<iostream>
#include<memory.h>
using namespace std;
int main()
{
	int n,m;
	int in[7] = { 0 };
	while (true){
		cin >> m;
		if (m == 0)break;
		memset(in, 0, sizeof(in));
		for (int i = 0; i < m; i++){
			cin >> n;
			if (n < 10)in[0]++;
			else if (n < 20)in[1]++;
			else if (n < 30)in[2]++;
			else if (n < 40)in[3]++;
			else if (n < 50)in[4]++;
			else if (n < 60)in[5]++;
			else in[6]++;
		}
		for (int i = 0; i < 7; i++){
			cout << in[i] << endl;
		}
	}
}

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

long long solve1(long long H,long long W){
	if( W <= 2 ) return 1e18;
	long long x = W / 3;
	long long y = W / 3 + (W % 3 >= 1);
	long long z = W / 3 + (W % 3 >= 2);
	return H * (max({x,y,z}) - min({x,y,z}));
}
long long solve2(long long H,long long W){
	long long ans = 1e18;
	for(int i = 1 ; i < W ; i++){
		long long x = (W - i) * H;
		long long y = (H / 2) * i;
		long long z = ((H+1)/2) * i; 
		ans = min(ans, max({x,y,z}) - min({x,y,z}));
	}
	return ans;
}
void solve(long long H, long long W){
	long long ans = 1e18;
	ans = min(ans,solve1(H,W));
	ans = min(ans,solve1(W,H));
	ans = min(ans,solve2(H,W));
	ans = min(ans,solve2(W,H));
	cout << ans << endl;
	
}

int main(){	
	long long W;
	long long H;
	scanf("%lld",&H);
	scanf("%lld",&W);
	solve(H, W);
	return 0;
}


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

int main() {
  ll n, m, ans = 1;
  cin >> n >> m;
  for (ll i = 1; i * i <= m; i++) {
    if (m % i == 0 && m / i >= n) {
      if (i >= n) ans = max(ans, m / i);
      if (m / i >= n) ans = max(ans, i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

# fact(int)
def fact(n):
  if(n == 1):
    return 1
  else:
    return (n * fact(n - 1))

# gcd(int,int)
def gcd(a,b):
  if a == 0:
    return b
  elif b == 0:
    return a
  else:
    return gcd(b,a % b)

# lcm(int,int)
def lcm(a,b):
  return (a * b / gcd(a,b))

# qsort(array[])
def qsort(seq):
  if len(seq) < 1:
      return seq
  pivot = seq[0]
  left = []
  right = []
  for x in range(1, len(seq)):
    if seq[x] <= pivot:
        left.append(seq[x])
    else:
        right.append(seq[x])
  left = qsort(left)
  right = qsort(right)
  foo = [pivot]
  return (left + foo + right)

# = map(int, input().split())
# = int(input())
# = raw_input().split()
# = list(int(i) for i in input().split())

h = int(input())
w = int(input())
n = int(input())

if n / h > n / w:
  print(math.ceil(n / w))
else:
  print(math.ceil(n / h))


Measured memory_bytes: 23208
#include <stdio.h>
#include <stdlib.h>

#define N 500001

int n;

void maxHeapify(int *A, int i){
  int l, r, largest, tmp;
  l = 2*i;
  r = 2*i+1;

  if(l<=n && A[l]>A[i])largest = l;
  else largest = i;
  if(r<=n && A[r]>A[largest])largest = r;
  if(largest != i){
    tmp = A[i];
    A[i]=A[largest];
    A[largest] = tmp;

    maxHeapify(A, largest);
  }
}
void buildMaxHeap(int *A){
  int i;

  for(i=n/2;i>=1;i--){
    maxHeapify(A, i);
  }

}
int main(){

  int A[N];
  int i;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }


  buildMaxHeap(A);


  for(i=1;i<=n;i++)
    printf(" %d",A[i]);
  printf("\n");

  return 0;

}

Measured memory_bytes: 2548
#include <stdio.h>

int main() {

  long long i,j,k,n,m,l,a,b,c;
  long long A[101][101] = {0};
  long long B[101][101] = {0};
  long long C[101][101] = {0};

  scanf("%lld %lld %lld",&n,&m,&l);

  for(j=0; j<n; j++) {
    for(i=0; i<m; i++) {

      scanf("%lld", &a);
      A[j][i] = a;
    
    }
  }

  for(j=0; j<m; j++){
    for(i=0;i<l;i++){
      scanf("%lld",&b);
      B[j][i] = b;
    }
  }

    for(i=0 ;i<n; i++) {
      for(j=0; j<l; j++){
	C[i][j] = 0;
	for(k=0;k<m; k++) {
	   C[i][j] += A[i][k]*B[k][j];  
	   /*    printf("%d ",C[i][j]); */
	}
	/* printf("\n"); */
      }
    }


     for(i=0; i<n; i++) {
      for(j=0; j<l; j++) {
	printf("%lld",C[i][j]);
	if(j !=l-1) {
	  printf(" ");
	}
      }
      printf("\n");
      } 

    return 0;

  }



Measured memory_bytes: 2984
//#define A
#undef DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
#if A
        for (int i = 11; i < 30; i++)
        {
            for (int _ = 0; _ < 10000; _++)
            {
                Random rng = new Random();
                var _a = Enumerable.Repeat(0, i).Select(_ => rng.Next() % 3 + 1).ToArray();
                var res2 = SolveStupid(_a);
                if (res2 == 2) continue;
                var res1 = Solve(_a);
                if (res1 != res2)
                {
                    Console.WriteLine(i);
                    Console.WriteLine(string.Join("", _a));
                }
            }
        }
#endif
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Select(x => x - '0').ToArray();
#if DEBUG
        SolveStupid(a);
#endif
        if (n < 10)
        {
            Console.WriteLine(SolveStupid(a));
            return;
        }
        Console.WriteLine(Solve(a));
    }

    public static int SolveStupid(int[] a)
    {
        int p = 0;
        while (a.Length > 1)
        {
            a = Simulate(a);
#if DEBUG
            p++;
            Console.Write(string.Join("", Enumerable.Repeat(" ", p)));
            Console.WriteLine(string.Join(" ", a));
#endif
        }
        return a[0];
    }

    public static int Solve(int[] a)
    {
        for (int i = 0; i < 5; i++)
        {
            a = Simulate(a);
        }
        var oneFlag = a.Contains(1);
        if (!oneFlag)
        {
            a = a.Select(x => x == 0 ? 0 : 1).ToArray();
        }
        int cur2Count = 0;
        var res = a[0];
        for (int i = 1, j = a.Length - 1; i <= a.Length - 1; i++, j--)
        {
            cur2Count += Count(j);
            cur2Count -= Count(i);
            if (cur2Count == 0) res += a[i];
        }
        return (res % 2) * (oneFlag ? 1 : 2);
    }

    public static int Count(int n)
    {
        int count2 = 0;
        while ((n & 1) == 0)
        {
            count2++;
            n >>= 1;
        }
        return count2;
    }

    static int[] Simulate(int[] a)
    {
        return a.Zip(a.Skip(1), (x, y) => Abs(x - y)).ToArray();
    }
}


Measured memory_bytes: 46884
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string.h>
#include <set>
using namespace std;
 
#define int long long
 
 
int gcd(int a, int b){
	
	if(b==0){
		return a;
	}
	
	return gcd(b,a%b);
	
}
 
 int lcm(int a, int b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
 
 
int f(int x){
	
	
	int res = 0;
	
	while( x%2 == 0){
		
		x/=2;
		res++;
	}
	
	return res;
	
}
 
 #define MOD 1000000007;
 
 int arr[300001];
 
int32_t main() {
 	
 	int n;
 	
 	cin >> n;
 	
 	for(int i=0; i<n; i++){	
 	 	cin >> arr[i];
	}
 
 	int ans =0 ;
 	
 	for(int i=0; i<60; i++){
 		
 		int x = 0;
 		
 		for(int j=0; j<n; j++){
 			
 			//int f = 1 << i;
 			
 			if(arr[j] >> i & 1 ){
 				x++;
			}
 		}
 			int now = x* (n-x) % MOD;
 			
 			for(int j=0; j<i; j++){
 				now = now * 2 % MOD;
			}
			 ans += now;
			 ans %= MOD;
		
 		
	 }
 		cout << ans << endl;
 	  
}
 
 
 

Measured memory_bytes: 5968
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n,x,t;
	cin>>n>>x>>t;
	if(n%x==0)
		cout<<(n/x)*t<<endl;
	else
		cout<<(n/x+1)*t<<endl;
}

Measured memory_bytes: 3632
// ------------------------------------
// Date:2018/ 3/ 5
// Problem:ABC 083 WideFlip d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  string inputStr;
  cin >> inputStr;
  int len = inputStr.size();
  int ans = len;
  REP(i, len - 1) {
    if (inputStr[i] != inputStr[i + 1]) {
      // ここでmax(i + 1, len - i - 1)の区間で反転をすることにより、全ての数字を同じにすることができる
      ans = min(ans, max(i + 1, len - i - 1));
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>

#define MAX 100
static const int INFTY =(1<<21);

int n,M[MAX][MAX];
int unvisited=0,decide=1,comp_decide=2;

void dijkstra(){
	int d[MAX];
	int state[MAX];
	for(int i=0;i<n;i++){
		d[i]=INFTY;
		state[i]=unvisited;
	}
	d[0]=0;
	state[0]=0;
	while(1){
		int mincost=INFTY,u=-1;
		for(int i=0;i<n;i++){
			if(d[i]<mincost&&state[i]!=comp_decide){
				u=i;
				mincost=d[i];
			}
		}
		if(u==-1) break;
		state[u]=comp_decide;
		for(int v=0;v<n;v++){
			if(state[v]!=comp_decide&&M[u][v]!=INFTY){
				if(d[v]>d[u]+M[u][v]){
					d[v]=d[u]+M[u][v];
					state[v]=decide;
				}
			}
		}
	}
	for(int i=0;i<n;i++){
			printf("%d %d\n",i,(d[i]==INFTY ? -1:d[i]));
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			M[i][j]=INFTY;
		}
	}
	int u,k,v,c;
	for(int i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(int j=0;j<k;j++){
			scanf("%d %d",&v,&c);
			M[u][v]=c;
		}
	}
	dijkstra();
}


Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		long val =n;
		long sum=0;
	     for(int i=0;i<3;i++){
	    	 sum+=val;
	    	 val*=n;
	     }
		System.out.println(sum);

	}

}

Measured memory_bytes: 35772
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)
#define read(x) scanf("%d", &x)
#define readv(x, n) vi x(n); forn(i,0,n) scanf("%d", &x[i])

#define pb push_back
#define mp make_pair
bool can[100000001];

int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "wt", stdout);
//#endif
    ll s;
    cin>>s;
    ll ans = 0;
    vll num(11);
    num[1] = 9;
    forn(i,2,11) num[i] = num[i-1]*10%mod;
    ll curnum = num[7];
    forn(dl,8,s+1) {
        curnum = curnum*10%mod;
        if(2*dl > s && dl<s) continue;
        if(s % dl == 0) {
            ll len = s/dl;
            ans += (curnum + 1 + mod - len) % mod;
        }
        ll rdl = s%dl;
        if (rdl == 0) rdl = dl;
        ll maxr = (s-1)/(dl+1);
        maxr -= rdl;
        if(maxr >= 0) {
            ans = (ans +1+maxr/dl)%mod;
        }
    }
    forn(dl,7,8) {
        if(s % dl == 0 && s <= 7*num[7]) {
            int len = s/dl;
            ans += (num[dl] + 1 + mod - len) % mod;
        }
        ll rdl = s%dl;
        if (rdl == 0) rdl = dl;
        while(s - rdl*8 > num[7]*7) rdl+=dl;
        ll maxr = (s-1)/(dl+1);
        maxr -= rdl;
        if(maxr >= 0) {
            ans = (ans +1+maxr/dl)%mod;
        }
    }
    
    can[0] = 1;
    ll sum = 0;
    ll canmax = 1e18;
    forn(i,1,9) {
        if(i==7) {
            canmax = sum;
            can[canmax] = 0;
        }
        forn(j,0,num[i]) {
            sum += i;
            if(sum > s+ canmax) break;
            if(sum >= s && can[sum - s]) ans ++;
            if(i<7) can[sum] = 1;
        }
    }
//    sum = canmax;
//    forn(j,0,num[7]) {
//        sum += i;
//    }
    ans%=mod;
//    if(s > num[8]*8) {
//        s -= num[8]*8;
//    }
    cout<<ans;
}


Measured memory_bytes: 6400
# 点(x, y)から長方形の中心を通る直線を引くと面積を半分にすることができ、分割された小さい方の面積が最大となる
# 点(x, y)が長方形の中心と一致する場合、直線は複数存在する

w, h, x, y = map(int, input().split())

s = w * h
s_min = s / 2

# 中心
a = w / 2
b = h / 2

divide = 0

if x == a and y == b:
    divide = 1
    print(s_min, divide)
else:
    print(s_min, divide)

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

int main(){
  int n;
  cin>>n;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  vector<pair<int, int> > pairs(n);
  REP(i,n){
    pairs[i]=make_pair(a[i],i);
  }
  sort(pairs.begin(),pairs.end());
  REP(i,n){
    cout<<pairs[i].second+1<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define drep(i,cc,n) for(int i=cc;i>n;--i)
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; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main() {
    int a,b;
    cin>>a>>b;
    if((a * b) % 2 != 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fin freopen("input", "r", stdin);
#define fout freopen("output", "w", stdout);
#define wt(x) cerr << #x << ": " << x << " ";
#define whatis(x) {cerr << #x << ": " << x << endl;}
#define whatis2(x, y) {wt(x); wt(y); cerr << endl;}
#define whatis3(x, y, z) {wt(x); wt(y); wt(z); cerr << endl;}
#define whatis4(x, y, z, a) {wt(x); wt(y); wt(z); wt(a); cerr << endl;}
using namespace std;

typedef long long ll; typedef unsigned long long ull; typedef long double ld;
const ll MOD = 1000000007; const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int mx = 1e5;
ll dp[102][mx + 2];

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

    ll n, cap;
    cin >> n >> cap;
    vector<pair<ll, ll>> item(n + 1);

    for (int i = 1; i <= n; ++i) {
        cin >> item[i].first >> item[i].second;
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= cap; ++j) {
            if (j >= item[i].first) {
                dp[i][j] = max (dp[i-1][j], dp[i-1][j-item[i].first] + item[i].second);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    /* for (int i = 1; i <= n; ++i) { */
    /*     for (int j = 0; j <= cap; ++j) { */
    /*         cout << dp[i][j] << '\t'; */
    /*     } */
    /*     cout << endl; */
    /* } */

    cout << dp[n][cap] << endl;
    


    return 0;
}


Measured memory_bytes: 78464
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, w;
    cin >> n >> w;
    int weight[n] = {};
    ll value[n] = {};
    for(int i=0;i<n;++i)
    {
        cin >> weight[i] >> value[i];
    }

    ll dp[n+1][w+1] = {};
    dp[0][0] = 0;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<=w;++j)
        {
            if(j+weight[i] <= w)
            {
                dp[i+1][j + weight[i]] = max(dp[i+1][j+weight[i]], dp[i][j] + value[i]);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    ll ret = 0;
    for(int i=0;i<=w;++i)
    {
        ret = max(ret, dp[n][i]);
    }

    cout << ret << endl;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int d;
	scanf("%d",&d);
	//printf("%d\n",d);
	if(d==25)
		printf("Christmas");
	else if(d==24)
		printf("Christmas Eve");
	else if(d==23)
		printf("Christmas Eve Eve");
	else
		printf("Christmas Eve Eve Eve");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
  
using namespace std;

#define pi 3.141592653589793

#define MAX 1000000000

bool ismax(string comp, string ans)
{
	// compが大きい場合true
	while(ans[0] == '0') ans.erase(0, 1);
	while(comp[0] == '0') comp.erase(0, 1);
	if(ans.length() < comp.length()) return true;
	else if(ans.length() == comp.length()){
		int n = 0;
		while(n < ans.length() && ans[n] == comp[n]){
			n++;
		}
		if(n == ans.length() || ans[n] - '0' < comp[n] - '0') return true;
		else return false;
	} else return false;
}

string bigger(string comp1, string comp2)
{
	// 第一引数の方が大きい場合true
	// int l1 = comp1.length(), l2 = comp2.length();
	// while(comp1[0] == '0') comp1.erase(0, 1);
	// while(comp2[0] == '0') comp2.erase(0, 1);
	// if(comp1 == "" && comp2 == ""){
		// if(l1 > l2) return true;
		// else return false;
	// }
	if(comp1.length() > comp2.length()) return comp1;
	else if(comp1.length() == comp2.length()){
		int n = 0;
		while(n < comp1.length() && comp1[n] == comp2[n]){
			n++;
		}
		if(n == comp1.length() || comp1[n] - '0' > comp2[n] - '0') return comp1;
		else return comp2;
	} else return comp2;
}

string solve(int w, int h, char c[71][71])
{
	string ans = "";
	string result[72][72];
	for(int i = h; i > 0; i--){
		result[i][w + 1] = "";
	}
	for(int i = w; i > 0; i--){
		result[h + 1][i] = "";
	}
	result[h + 1][w + 1] = "";
	for(int i = h; i > 0; i--){
		for(int j = w; j > 0; j--){
			result[i][j] = "";
			if(isdigit(c[i][j])){
				result[i][j] += c[i][j];
				result[i][j] += bigger(result[i + 1][j], result[i][j + 1]);
				if(ismax(result[i][j], ans)) ans = result[i][j];
			}
		}
	}
	while(ans[0] == '0') ans.erase(0, 1); 
	return ans;
}


int main()
{
	int w, h;
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		char c[71][71];
		for(int i = 1; i < h + 1; i++){
			for(int j = 1; j < w + 1; j++){
				cin >> c[i][j];
			}
		}
		cout << solve(w, h, c) << endl;
	}
	return 0;
}

Measured memory_bytes: 1368
#include <iostream>

using namespace std;

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

    p += p;
    string::size_type pos = p.find(s);
    if (pos != -1)
        cout << "Yes" <<endl;
    else
        cout << "No" << endl;
     return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<string> S;
    for (int i = 1; i <= k; i++) {
        rep(j,n-i+1){
            string t = s.substr(j,i);
            S.pb(t);
        }
    }
    sort(all(S));
    S.erase(unique(all(S)), S.end());
    cout << S[k-1] << endl;
    return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int A[N];
    for (int count = 0; count < N; count++) {
        cin >> A[count];
    }
    int one, left, right;
    for (int count = 0; count < N; count++) {
        if (A[count] == 1) {
            one = count;
            left = count;
            right = count;
        }
    }
    int ans_count = 0, count = 0;
    bool left_start = false, first_time_check = true, left_end_check = false, right_end_check = false;
    if ((one * 2) < (N - 1)) {
        left_start = true;
    }
    while ((left != 0) || (right != (N - 1))) {
        if (left_start) {
            while (true) {
                A[left] = 1;
                count++;
                if (left == 0) {
                    if (count == K) {
                        count = 0;
                        ans_count++;
                    } else if (right == (N - 1)) {
                        ans_count++;
                    } else {
                        right++;
                    }
                    left_start = false;
                    left_end_check = true;
                    break;
                }
                if (count == K) {
                    first_time_check = false;
                    count = 0;
                    ans_count++;
                    break;
                }
                left--;
            }
        } else {
            while (true) {
                A[right] = 1;
                count++;
                if (right == (N - 1)) {
                    if (count == K) {
                        count = 0;
                        ans_count++;
                    } else if (left == 0) {
                        ans_count++;
                    } else {
                        left--;
                    }
                    left_start = true;
                    right_end_check = true;
                    break;
                }
                if (count == K) {
                    first_time_check = false;
                    count = 0;
                    ans_count++;
                    break;
                }
                right++;
            }
        }
        if (left_end_check && right_end_check) {
            break;
        }
    }
    
    cout << ans_count << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main() {
  double a,b,x;
  cin>>a>>b>>x;
  double s=x/a;
  double rad;
  double deg;
  if(s>=a*b/2){
    double h=2*(a*b-s)/a;
    double PI=acos(-1);
    rad=atan2(h,a);
  }else{
    double w=s*2/b;
    double PI=acos(-1);
    rad=atan2(b,w);
  }
  double PI=acos(-1);
    deg=(rad/(2*PI))*360;
  printf("%.10f\n",deg);
}

Measured memory_bytes: 4164