akhauriyash/Code-Regression huggingface dataset:
import heapq

K, T = map(int, input().split())
a = list(map(int, input().split()))
a = [(-a[i], i) for i in range(T)]

heapq.heapify(a)
cake_yesterday = -1
ans = 0

for i in range(K):
    cake1 = heapq.heappop(a)
    if cake1[1] != cake_yesterday:
        cake_yesterday = cake1[1]
        if cake1[0]+1 <= -1:
            heapq.heappush(a, (cake1[0]+1, cake1[1]))
    elif a:
        cake2 = heapq.heappop(a)
        cake_yesterday = cake2[1]
        heapq.heappush(a, (cake1[0], cake1[1]))
        if cake2[0]+1 <= -1:
            heapq.heappush(a, (cake2[0]+1, cake2[1]))
    else:
        if cake_yesterday == cake1[1]:
            ans += 1
        ans += -cake1[0] - 1
        break

print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define t ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
  fast;
  // Code from here....
  string str;
  cin>>str;
  ll sum = 0;
  for(int i=0; i<str.length(); i++){
    sum += (int)str[i] -48;
  }
  (sum%9 == 0) ? cout<<"Yes" : cout<<"No";
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
long long comb(int, int, int);
int purp;
long long memo[1001][101][11];

int main() {
  int total, n;
  while(cin >> n >> total, n || total) {
    for(int i = 0; i < 1001; ++i) for(int j = 0; j < 101; ++j) for(int k = 0; k < 11; ++k) memo[i][j][k] = -1;
    purp = total;
    cout << comb(0, 0, n) << endl;
  }
  return 0;
}

long long comb(int sum, int min, int n) {
  if(memo[sum][min][n] != -1) return memo[sum][min][n];
  if(n == 0 && sum == purp) return 1;
  if(sum > purp || n < 0) return 0;
  long long res = 0;
  for(int i = min; i <= 100; ++i) {
    res += comb(sum + i, i + 1, n - 1);
  }
  memo[sum][min][n] = res;
  return res;
}

Measured memory_bytes: 9844
N, M = map(int, input().split())
A, B = [], []
for _ in range(N):
    A.append(list(input()))
for _ in range(M):
    B.append(list(input()))

for y in range(N - M + 1):
    for x in range(N - M + 1):
        mc = 0
        for i in range(M):
            for j in range(M):
                if A[y + i][x + j] == B[i][j]:
                    mc += 1
                else:
                    break
            else:
                continue
            break
        if mc == M * M:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    // freopen("input.txt", "r", stdin);
    // freopen("output1.txt", "w", stdout);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> cost(n, INT_MAX);
    cost[0] = 0;
    for(int i = 1; i < n; i++) {
        for(int j = i - 1; j > max(-1, i - k - 1); j--) {
            cost[i] = min(cost[i], cost[j] + abs(a[i] - a[j]));
        }
    }

    cout << cost[n - 1];
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc =new Scanner(System.in);
		long N=sc.nextLong();
		long ans_final=0;
		long ans=(int)Math.sqrt(N);
		if(ans*ans==N) ans_final=N;
		else ans_final=ans*ans;

		System.out.println(ans_final);
	} 
}

Measured memory_bytes: 21844
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------






int main(void)
{

	int a[5][5];

	rep(i, 3)
	{
		rep(j, 3)
		{
			cin >> a[i][j];
		}
	}


	int n;
	cin >> n;
	bool bingo[3][3] = { false,false,false,false,false,false,false,false,false };

	vector<int> b(n+3);

	rep(i, n)
	{
		cin >> b[i];
	}

	//check

	bool ans = false;
	rep(i, 3)
	{
		rep(j, 3)
		{
			rep(k, n)
			{
				if (a[i][j] == b[k]) bingo[i][j] = true;
			}
		}
	}

	rep(i, 3)
	{
		if (bingo[0][i] && bingo[1][i] && bingo[2][i]) ans = true;
	}

	rep(j, 3)
	{
		if (bingo[j][0] && bingo[j][1] && bingo[j][2]) ans = true;
	}


	if (bingo[0][0] && bingo[1][1] && bingo[2][2]) ans = true;

	if (bingo[0][2] && bingo[1][1] && bingo[2][0]) ans = true;


	if (ans) cout << "Yes" << endl;

	else cout << "No" << endl;

}

Measured memory_bytes: 256
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n>>m>>k)
    {
    set<int> ss;
        for(i=0;i<k && (n+i)<=m;i++)
        {
            ss.insert(n+i);
        }
        for(j=0;j<k && (m-j)>=n;j++)
        {
            ss.insert(m-j);
        }
        set<int> ::iterator it;
        for(it=ss.B;it!=ss.E;it++)
        {
            cout<<*it<<en;
        }
    }
}



Measured memory_bytes: 256
<?php
$n  = trim(fgets(STDIN));
$ta = explode(' ', trim(fgets(STDIN)));
$t  = $ta[0];
$a  = $ta[1];
$h  = explode(' ', trim(fgets(STDIN)));

$min   = 100000;
$min_i = -1;
for ($i = 0; $i < $n; $i++) {
    $ht = $t - $h[$i] * 0.006;
    $diff = $ht > $a ? $ht - $a : $a - $ht;
    if ($diff < $min) {
        $min   = $diff;
        $min_i = $i;
    }
}

print $min_i + 1;



Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vl vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    REP(i,n-1){
        vec[i+1]+=vec[i];
    }
    map<ll,ll> ma;
    ll ans=0;
    ma[0]=1;
    REP(i,n){
        if(ma.find(vec[i])!=ma.end()){
            cerr<<i<<endl;
            ans+=ma[vec[i]];
        }
        ma[vec[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}

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

ll po(ll a, ll b){
    ll res = 1;
    ll tmp = a;
    while(b > 0){
        if(b % 2 == 1) res = res * tmp % MOD;
        b = b / 2;
        tmp = tmp*tmp % MOD; 
    }
    return res;
}

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    if(M == 1){
        if(N == K + 1){
            printf("1\n");
            return 0;
        }
        else{
            printf("0\n");
            return 0;
        }
    }

    ll MAX = 200005;
    vector<ll> inv(MAX);
    inv.at(1) = 1;
    for(ll i = 2; i < MAX; i++){
        inv.at(i) = (MOD*MOD - inv.at(MOD % i) * (MOD / i)) % MOD;
    }

    ll ans = 0;
    ll tmp = M * po(M-1, N-1) % MOD;
    ans += tmp;
    for(ll i = 1; i <= K; i++){
        tmp = tmp * (N-i) %MOD;
        tmp = tmp * inv.at(M-1) % MOD;
        tmp = tmp * inv.at(i) % MOD;
        ans = (ans+tmp) % MOD;
    }
    printf("%lld\n", ans);    
}



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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

/**
 * Brute DP:
 *
 * dp[i][j][k] is can player i win range [j..k] ?
 * dp[i][i][i] = true
 *
 * dp[i][j][k] = l[i][j] and r[i][k]
 * l[i][j] can player i win against the prefix before him to j?
 * possible if there's some player j <= k < i where l[k][j] and r[k][j - 1]
 *
 * Use bitmasks? O(n^3 / 64)? 
 */

using bs = bitset<2000>;
constexpr int MAXN = 2002;
bs a[MAXN];
bs l[MAXN], r[MAXN];

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

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        l[i].set(i);
        r[i].set(i);
    }

    for (int i = 1; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < i; ++j) {
            if (s[j] == '1') {
                a[i].set(j);
            } else {
                a[j].set(i);
            }
        }
    }
    for (int d = 1; d <= n; ++d) {
        for (int i = 0; i + d < n; ++i) {
            int j = i + d;
            if ((a[j] & l[i] & r[j - 1]).any()) {
                l[i].set(j);
            }
        }

        for (int i = d; i < n; ++i) {
            int j = i - d;
            if ((a[j] & l[j + 1] & r[i]).any()) {
                r[i].set(j);
            }
        }
    }

    int ans = (l[0] & r[n - 1]).count();
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
using ll = long long;


int main()
{
  int n;
  cin >> n;
  
  ll sum = 0;
  rep(i, n){
    ll y = n / i; 
    
    sum += i * ((y * (y + 1)) / 2);
  }
  
  cout << sum << endl;
}


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

using namespace std;

using Point = pair<int, int>;

vector<Point> ReadPoints(int n)
{
    vector<Point> points(n);
    for (auto &p : points) {
        cin >> p.first >> p.second;
    }
    return points;
}

int Distance(const Point &a, const Point &b)
{
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int FindClosest(const vector<Point> &checkpoints, const Point &student)
{
    auto min_id = 0;
    auto min_dist = Distance(student, checkpoints[min_id]);

    for (size_t i = 1; i < checkpoints.size(); i += 1) {
        auto curr_dist = Distance(student, checkpoints[i]);
        if (curr_dist < min_dist) {
            min_id = i;
            min_dist = curr_dist;
        }
    }
    return min_id;
}

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

    auto students = ReadPoints(n);
    auto checkpoints = ReadPoints(m);

    for (const auto &s : students) {
        cout << FindClosest(checkpoints, s) + 1 << "\n";
    }
    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++)
const long long INF = 100000000000;
typedef pair<int,int> P;
typedef long long ll;

#define PI 3.14159265359
/*
*/
//各々のnumberの出現回数が各々のnumberの社員の直属の部下の数
int main() {
	map<int, int> ma;//ma[i]は社員iの部下の数
	int N;
	cin >> N;
    vector<int> A(N-1);
	rep (i,N-1) {
		cin >> A[i];
	}
	rep (i,N-1) {
		ma[A[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << ma[i] << endl;
	}
}


Measured memory_bytes: 13524
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {
    int N;
    string S;
    cin >> N >> S;
    int max_v = 0;
    int val = 0;
    REP(i,0,S.size()){
        if(S[i] == 'I'){
            val++;
        }else{
            val--;
        }
        max_v = max(val,max_v);
    }

    cout << max_v << endl;

    return 0;
}


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

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans;
  
  const int lower = max(a, c);
  const int upper = min(b, d);
  
  if (lower > upper) ans = 0;
  else ans = upper - lower;
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n+1],b[n];
    ll cnt=0;
    for(int i=0; i<n+1; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    for(int i=n-1; i>=0; i--){
        int tmpb=b[i],tmpa=a[i+1],tmpc=a[i];
        a[i+1]-=min(b[i],a[i+1]);
        b[i]-=min(b[i],tmpa);
        cnt+=min(tmpa,tmpb);
        tmpb=b[i];
        a[i]-=min(b[i],a[i]);
        b[i]-=min(b[i],tmpc);
        cnt+=min(tmpb,tmpc);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while (true) {
   var [d, e] = arr.shift().split(" ").map(Number);
   if (d == 0 && e == 0) break;
   var min = Infinity;
   for (var i = 0; i < d; i++) min = Math.min(min, Math.abs(Math.sqrt(i * i + (d - i) * (d - i)) - e));
   console.log(min.toFixed(10));
}


Measured memory_bytes: 16292
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

random_device gen;
mt19937 rnd(gen());

const int nmax = 1000 * 1000 * 10 + 10;
const int kmax = 300;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

bool used[nmax], u[nmax];
int p[kmax];
int b[nmax];
vector<int> a, go[kmax];

bool ok(int v) {
	if (u[v]) return false;
	u[v] = true;
	for (int u : go[v]) {
		if (p[u] == -1) {
			p[u] = v;
			return true;
		}
	}
	for (int u : go[v]) {
		if (ok(p[u])) {
			p[u] = v;
			return true;
		}
	}
	return false;
}

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	for (int i = 2; i < nmax; i++) {
		used[i] = 1;
	}
	for (ll i = 2; i * i < nmax; i++) {
		if (!used[i]) continue;
		for (ll j = i * i; j < nmax; j += i) {
			used[j] = 0;
		}
	}
	used[0] = used[1] = used[2] = 0;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		b[x] ^= 1;
		b[x + 1] ^= 1;
	}
	for (int i = 0; i < nmax; i++) {
		if (b[i] == 1) {
			a.pb(i);
		}
	}
	n = a.size();
	assert(n < kmax);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			if (used[abs(a[i] - a[j])]) {
				go[i].pb(j);
			}
		}
	}
	int cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			cnt0++;
		} else {
			cnt1++;
		}
	}
	for (int j = 0; j < n; j++) {
		p[j] = -1;
	}
	int answer = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) continue;
		for (int j = 0; j < n; j++) {
			u[j] = 0;
		}
		if (ok(i)) answer++;
	}
	cout << answer + ((cnt0 - answer) / 2 + (cnt1 - answer) / 2) * 2 + ((cnt1 - answer) % 2) * 3 << endl;
	return 0;
}


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

int main()
{
    int n, w[105];
    long sum = 0, d, md, l, r;
    cin >> n;

    for (int i = 0; i < n; ++i)
    {
        cin >> w[i];
        sum += w[i];
    }

    l = 0;
    r = sum;
    md = sum;

    for (int i = 0; i < n; ++i)
    {
        l += w[i];
        r -= w[i];
        d = abs(r - l);
        if (d < md)
            md = d;
    }
    cout << md << endl;
    return 0;
}

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


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<double, double> P;


template <typename T>
class SegmentTree {
private:
    using F = function<T(T, T)>;
    int n, sz;
    vector<T> node;
    T u;
    F f;

    T query(int a, int b, int i, int l, int r) {
        if(r <= a || b <= l) {
            return u;
        }
        else if(a <= l && r <= b) {
            return node[i];
        }
        else {
            T vl = query(a, b, 2 * i + 1, l, (l + r) / 2);
            T vr = query(a, b, 2 * i + 2, (l + r) / 2, r);
            return f(vl, vr);
        }
    }

public:
    /**
     *
     * @param v  初期配列
     * @param func  nodeに対する操作
     * @param u2  Tの単位元
     */
    SegmentTree(vector<T> &v, const F func, T u2) : f(func), u(u2) {
        sz = v.size();
        n = 1;
        while(n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, u2);
        for(int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for(int i = n - 2; i >= 0; i--) {
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    void update(int i, T val) {
        i += (n - 1);
        node[i] = val;
        while(i > 0) {
            i = (i - 1) / 2;
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    T query(int l, int r){
        return query(l, r, 0, 0, n);
    }

    T operator[](const int &i) const { return node[i + n - 1]; }
};


const ll INF = (1LL << 31) - 1;

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> a(n, INF);
//    for(int i = 0; i < n; i++) {
//        cin >> a[i];
//    }
    SegmentTree<ll> seg(a, [](ll p, ll q) { return min(p, q); }, INF);
    int l, r;
    while(q--) {
        int c;  cin >> c;
        if(c == 0){
            int x; ll y;    cin >> x >> y;
            seg.update(x, y);
        }
        else {
            cin >> l >> r;
            cout << seg.query(l, r+1) << endl;
        }
    }
}


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

int main(){
	int N,ans = 0;
  	cin >> N;
    for(int i=0;i<N;i++){
      int l,r;
  	  cin >> l >> r;
      ans += r-l+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int a = sc.nextInt();
    		// 出力
                if (a == 7 || a == 5 || a == 3){
    		    System.out.println("YES");
                }else{
                    System.out.println("NO"); 
                }
    	}
    }

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  1<=N<=999;
 if(N%10==3){
   cout<<"bon"<<endl;
 }else{
   if(N%10==0||N%10==1||N%10==6||N%10==8){
     cout<<"pon"<<endl;
   }else{
     cout<<"hon"<<endl;
   }
 }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[25],b[25],c[25],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		cin>>b[i];
		ans+=b[i];
	}
	for(int i=1;i<=n-1;i++)cin>>c[i];
	for(int i=1;i<n;i++)
	
	{
		if(a[i+1]==a[i]+1)
		{
			ans+=c[a[i]];
		}
	}
	cout<<ans;
    return 0;
}

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


int main(){
  int n;
  cin >> n;
  vector<ll> a(n+1), b(n);
  rep(i, n+1) cin >> a.at(i);
  rep(i, n) cin >> b.at(i);
  
  ll ans = 0;
  rep(i, n){
    if(a.at(i) >= b.at(i)) ans += b.at(i);
    else{
      if(a.at(i)+a.at(i+1) >= b.at(i)){
        ans += b.at(i);
        a.at(i+1) -= (b.at(i) - a.at(i));
      }
      else{
        ans += a.at(i) + a.at(i+1);
        a.at(i+1) = 0;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
loop do
  n = gets.to_i
  break if n==0
  hash = Hash.new
  names = Array.new
  n.times do
    name,*points = gets.chomp.split
    points.map!(&:to_i)
    w=0
    d=0
    points.each do |x|
      w+=1 if x==0
      d+=1 if x==2
    end
    hash[name]=w*n+d
    names << name
  end
  i=0
  ans = names.sort_by do |x|
    [-hash[x],i+=1]
  end
  puts ans
end

Measured memory_bytes: 6108
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n,m;
	cin >> n >> m;
	vll a(n),b(n);
	vll c(m),d(m);
	rep(i,n)cin >> a[i] >> b[i];
	rep(i,m)cin >> c[i] >> d[i];

	rep(i,n){
		int dist = INF;
		int res = 0;
		rep(j,m){
			if(chmin(dist,abs(a[i]-c[j]) + abs(b[i]-d[j])))res = j+1;
		}
		cout << res << endl;
	}



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc057.contest.atcoder.jp/tasks/abc057_b

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, flag, ans = 0;
	cin >> n;
	vector<int> num(n);
	for (int i = 0; i < n; i++) {
		cin >> num.at(i);
	}
	flag = 1;
	while (flag){
		flag = 0;
		for (int i = 1; i < n; i++) {
			if (num[i] < num[i - 1]) {
				swap(num[i], num[i - 1]);
				ans++;
				flag = 1;
			}
		}
	}
	for (int k = 0; k < n; k++) {
		printf("%d", num.at(k));
		if (k != n - 1)cout << ' ';
		else cout << endl;
	}
	cout << ans << endl;
}


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

int main(){
  string s,base="AKIHABARA"; cin>>s;
  if(s.size()>base.size()){
    cout<<"NO"<<endl;
    return 0;
  }string renew="";
  int now=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=base[now] && base[now]=='A'){
      renew+='A';
      renew+=s[i];
      now++;
    }else{
      renew+=s[i];
    }
    now++;
  }
  if(now==8){
    renew+='A';
  }
  if(renew==base){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let N = get!(i64);
    let W = get!(String; N);

    let mut ans = "Yes";

    for i in 0..N {
        for j in 0..N {
            if i !=j && W[i as usize] == W[j as usize] {
                ans = "No";
            }
        }
        if i >= 1 {
            let s1 = &W[i as usize].chars().into_iter().collect::<Vec<_>>();
            let s2 = &W[(i - 1) as usize].chars().into_iter().collect::<Vec<_>>();
            if s2[s2.len() - 1] != s1[0] {
                ans = "No";
            }
        }
    }


    // 出力
    println!("{}", ans);
}

Measured memory_bytes: 4352
using System;

namespace Atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int b = int.Parse(Console.ReadLine());
            if (b % 2 == 0)
            {
                Console.WriteLine(b*b/4);
            }
            else
            {
                Console.WriteLine((b - 1) * (b + 1) / 4);
            }
        }
    }
}


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


int main() {
  ll N;
  cin>>N;
  ll ans=N-1,now;
  
  for(int i=2;i<N;i++){
      if(i>N/i){break;}
      if(N%i==0){
          now=i+N/i-2;
          ans=min(ans,now);
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
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(){
    ll n;cin >> n;
    vl m(n+1);rep(i,n+1)cin >> m[i];
    ll ans=0;
    rep(i,n){
        ll a;cin  >> a;
        if(a>m[i]){
            ans+=m[i];
            a-=m[i];
            m[i]=0;
            //cout <<a <<endl;
            if(a>m[i+1]){
                ans+=m[i+1];
                m[i+1]=0;
            }
            else {
                ans+=a;
                m[i+1]-=a;
            }
        }
        else{
            ans+=a;
            m[i]-=a;
        }
        //cout <<ans <<endl;
    }
     cout <<ans <<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
        int a=0,b=0;
        int length=0;
        int area=0;
        scanf("%d %d",&a,&b);

        length = (a*2) + (b*2);
        area = a*b;

        printf("%d %d\n",area,length);

        return 0;
}

Measured memory_bytes: 596
import sys

c=["light fly", "fly", "bantam", "feather", "light", "light welter",
   "welter", "light middle", "middle", "light heavy", "heavy"]
w=[48,51,54,57,60,64,69,75,81,91]
for s in map(float,sys.stdin):
    i=0
    for e in w:
        if e<s: i+=1
    print c[i]

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(input.readLine());
        System.out.println(String.format("%.0f",(0.5) * N * (N + 1)));
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
const int maxn=4005;
int n,sum[maxn][maxn];
char S[maxn];
long long ans;
int main()
{
	scanf("%d%s",&n,S+1);
	for (int i=1;i<=n;i++)
		if (S[i]=='R') S[i]=0; else
		if (S[i]=='G') S[i]=1; else S[i]=2;
	for (int i=n;i>=1;i--)
		for (int j=0;j<3;j++)
			sum[i][j]=sum[i+1][j]+(S[i]==j);
	for (int i=1;i<=n-2;i++)
		for (int j=i+1;j<=n-1;j++)
			if (S[i]!=S[j])
			{
				int k=0;
				if (S[i]==0 && S[j]==1) k=2; else 
				if (S[i]==1 && S[j]==0) k=2; else
				if (S[i]==0 && S[j]==2) k=1; else
				if (S[i]==2 && S[j]==0) k=1;
				ans+=sum[j+1][k];
				if (j+j-i<=n && S[j+j-i]==k) ans--;
			}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 19740
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

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

	int k = T.size();
	string S;
	for (int i = 0; i < k; i++) {
		if (T[i] == '?') S += 'D';
		else  S += T[i];
	}
	cout << S << endl;
}


Measured memory_bytes: 3924
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  string S;
  cin >> S;
  vector<int> LtoR(S.size(), -1), RtoL(S.size(), INF);
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'L') RtoL[i] = i;
    else LtoR[i] = i;
  }
  partial_sum(RtoL.rbegin(), RtoL.rend(), RtoL.rbegin(), [](int a, int b) { return min(a, b); });
  partial_sum(LtoR.begin(), LtoR.end(), LtoR.begin(), [](int a, int b) { return max(a, b); });

  vector<int> ans(S.size(), 0);
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'L') {
      int dist = LtoR[i] - i;
      if (dist % 2) ans[LtoR[i]+1]++;
      else ans[LtoR[i]]++;
    } else {
      int dist = i - RtoL[i];
      if (dist % 2) ans[RtoL[i]-1]++;
      else ans[RtoL[i]]++;
    }
  }
  for (auto e : ans) cout << e << ' ';
  cout << endl;
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	sort(a.begin(), a.end());
	cout << a.at(n-1)-a.at(0) << endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

llong N, K;
vector<llong> V;
vector<vector<vector<llong> >> memo;

llong dp(int left, int right, int many) {
	if (many == 0)
		return 0;
	if (left > right)
		return 0;
	if (memo[left][right][many] != inf)
		return memo[left][right][many];

	llong ret = 0;
	ret = max(ret, dp(left+1, right, many-1) + V[left]);
	ret = max(ret, dp(left, right-1, many-1) + V[right]);
	if (many > 1) {
		ret = max(ret, dp(left+1, right, many-2));
		ret = max(ret, dp(left, right-1, many-2));
	}

	return memo[left][right][many] = ret;
}

int main() {
	cin >> N >> K;
	V.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> V[i];

	memo.resize(N, vector<vector<llong> >(N, vector<llong>(K+1, inf)));
	cout << dp(0, N-1, K) << endl;

	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int p=in(),q=in(),r=in();
    cout<<min(p+q,min(q+r,r+p))<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] array = line.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		if (a < b) {
			System.out.println("a < b");

		}
		if (a > b) {
			System.out.println("a > b");

		}
		if (a == b) {
			System.out.println("a == b");

		}
	}

}

Measured memory_bytes: 26068
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string a,b;//入力
	int i = 0, j = 0, d = 0, kari = 0, old = 0, flag = 0; //内部で使用;
	int ans = 0; //出力

	cin >> a >> b;
	if (a.size() > b.size())flag = 1;
	else if (a.size() < b.size())flag = -1;
	else {//桁数同じ
		while (i < a.size()) {
			if (a[i] > b[i]) {
				flag = 1;
				break;
			}
			else if (a[i] < b[i]) {
				flag = -1;
				break;
			}
			else;
			i++;
		}
	}


	if (flag == 1) cout << "GREATER" << "\n";
	else if (flag == 0) cout << "EQUAL" << "\n";
	else cout << "LESS" << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int K,X;

int main(){
    cin>>K>>X;

    for(int i=X-K+1;i<=X+K-1;i++){
        cout<<i<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("in.txt", "r", stdin);
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    string fuck="";
    for(int i=0;i<n;i++){
        fuck+=s[i];
        fuck+=t[i];
    }
    cout<<fuck<<endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)

int main(){
    string s;
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    cin>>s;
    a--;b--;c--;d--;
    for(int i=a+1;i<max(c,d);i++){
        if(s[i]=='#'&&s[i-1]=='#'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(c<d){
        cout<<"Yes"<<endl;
        return 0;
    }
    for(int i=b;i<=d;i++){
        if(i+1>=n)continue;
        if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
string s;
int main(){
    cin>>s;
    rep(i,0,s.length()){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s;
}


Measured memory_bytes: 3728
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace FunProCon
{
    class FunProConSummer
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ls = new List<int>();
            for (int i = 0; i < s[0]; i++)
            {
                ls.Add(int.Parse(ReadLine()));
            }
            int cnt = ls.Count();
            int remain = s[1] - ls.Sum();

            WriteLine(
                cnt + (remain / ls.Min())
                );

        }

    }
}


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

int main(){
    int a,b; cin >> a >> b;
    string s_a = "", s_b = "";
    rep(i,a) s_b += char('0'+b);
    rep(i,b) s_a += char('0'+a);
    if(a > b)cout << s_b << endl;
    else cout << s_a << endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, m = MAP()
arr = [[] for _ in range(n)]
for _ in range(m):
    s, c = MAP()
    arr[s - 1].append(c)
tmp1 = [len(set(arr[i])) for i in range(n)]
tmp2 = Counter(tmp1)
if tmp2[0] + tmp2[1] != n or (len(arr[0]) and arr[0][0] == 0 and n != 1):
    print(-1)
    exit()
tmp3 = [str(arr[i][0]) if tmp1[i] else '0' for i in range(n)]
if tmp3[0] == '0' and n > 1:
    tmp3[0] = '1'
print(''.join(tmp3))


Measured memory_bytes: 59628
#include <stdio.h>

void swap(int *x, int *y){int t = *x; *x = *y; *y = t;}

int main(){
  int n, a[101], i, j, c = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d", a + i);

  for(i = 0; i < n; ++i)
    for(j = n - 1; j > i; --j)
      if(a[j] < a[j - 1]){
        swap(&a[j], &a[j - 1]);
        c++;
      }

  for(i = 0; i < n; ++i) printf(i != 0 ? " %d": "%d", a[i]);
  printf("\n%d\n", c);
  return 0;
}



Measured memory_bytes: 2080
def main():
    class UnionFind:
        def __init__(self, N):
            """
            N:要素数
            root:各要素の親要素の番号を格納するリスト.
                ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
            rank:ランク
            """
            self.N = N
            self.root = [-1] * N
            self.rank = [0] * N

        def find(self, x):
            """頂点xの根を見つける"""
            if self.root[x] < 0:
                return x
            else:
                while self.root[x] >= 0:
                    x = self.root[x]
                return x

        def union(self, x, y):
            """x,yが属する木をunion"""
            # 根を比較する
            # すでに同じ木に属していた場合は何もしない.
            # 違う木に属していた場合はrankを見てくっつける方を決める.
            # rankが同じ時はrankを1増やす
            x = self.find(x)
            y = self.find(y)
            if x == y:
                return
            elif self.rank[x] > self.rank[y]:
                self.root[x] += self.root[y]
                self.root[y] = x
            else:
                self.root[y] += self.root[x]
                self.root[x] = y
                if self.rank[x] == self.rank[y]:
                    self.rank[y] += 1

        def same(self, x, y):
            """xとyが同じグループに属するかどうか"""
            return self.find(x) == self.find(y)

    import sys
    n, q = map(int, sys.stdin.buffer.readline().split())
    uf = UnionFind(n)
    for _ in range(q):
        t, u, v = map(int, sys.stdin.buffer.readline().split())
        if t:
            print(int(uf.same(u, v)))
        else:
            uf.union(u, v)


main()


Measured memory_bytes: 76352
#include<stdio.h>
#include<string.h>

int main(void)
{
  char t[1000];
  char s[100];
  int c=0;
  int l;
  scanf("%s", s);
  
  do
    {
      scanf("%s", t);
      if(!strcmp(t, "END_OF_TEXT"))
	{
	  break;
	}
      l = strlen(t);
      for(int i = 0; i < l; i++)
	{
	  if(t[i] < 91)
	    {
	      t[i] = t[i]+32;
	    }
	}
      if(!strcmp(t, s))
	{
	  c++;
	}
    }while(1);
  printf("%d\n", c);
  return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    long int n;
    scanf("%ld\n",&n);
    long long int sa;
    long long int ans=0;
    long long int a[200005]={};
    REP(i,n)
    {
        scanf("%lld ",&a[i]);
        a[i]-=(i+1);
    }
    sort(a,a+n);
    long long int bod=a[n/2];
    REP(i,n)
    {
        sa=a[i]-bod;
        if(sa<0)sa=-sa;
        ans+=sa;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
s=input()
q=int(input())
for i in range(q):
    order=input().split()
    a=int(order[1])
    b=int(order[2])
    if len(order[0])==5:
        print(s[a:b+1])
    elif len(order)==3:
        s=s[:a]+''.join(reversed(list(s[a:b+1])))+s[b+1:]
    else:
        s=s[:a]+order[3]+s[b+1:]


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

vvi d;
vvi g;

void flyod(int n){
    d.resize(n,vi(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d[i][j]=INF;
            if(i==j){
                d[i][j]=0;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<g[i].size();j++){
            d[i][g[i][j]]=1;
        }
    }
    //int n=g.size();
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if (d[i][k] < INF && d[k][j] < INF){
                    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                }
            }
        }
    }

}

int main(){
    int H,W;
    cin>>H>>W;
    g.resize(H*W);
    vector<string> vs(H);
    for(int i=0;i<H;i++){
        cin>>vs[i];
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(vs[i][j]=='#'){
                continue;
            }
            if(i-1>=0&&vs[i-1][j]=='.'){
                g[i*W+j].push_back((i-1)*W+j);
                g[(i-1)*W+j].push_back(i*W+j);
                
            }
            if(i+1<H&&vs[i+1][j]=='.'){
                g[i*W+j].push_back((i+1)*W+j);
                g[(i+1)*W+j].push_back(i*W+j);
            }
            if(j-1>=0&&vs[i][j-1]=='.'){
                g[i*W+j].push_back(i*W+j-1);
                g[i*W+j-1].push_back(i*W+j);
            }
            if(j+1<W&&vs[i][j+1]=='.'){
                g[i*W+j].push_back(i*W+j+1);
                g[i*W+j+1].push_back(i*W+j);
            }
        }
    }
    flyod(H*W);
    //cout<<"ashish"<<endl;
    int ans=0;
    for(int i=0;i<d.size();i++){
        for(int j=0;j<d[i].size();j++){
            if(d[i][j]==INF){
                d[i][j]=-1;
            }
            //cout<<d[i][j]<<" ";
            ans=max(ans,d[i][j]);
        }
        //cout<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 896
n, m = map(int, input().split())
d = [-1 for i in range(n)]
flag = True

for i in range(m):
  s, c = map(int, input().split())
  if d[s - 1] > -1 and d[s - 1] != c:
    flag = False
  elif s == 1 and n > 1 and c == 0:
    flag = False
  else:
    d[s - 1] = c

if flag:
  ans = ""
  for i in range(n):
    if d[i] == -1:
      d[i] = (1 if i == 0 and n > 1 else 0)
    ans += str(d[i])
  print(ans)
else:
  print(-1)

Measured memory_bytes: 3064