akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=10001,INF=1<<30;

int main(){

    string S,T;cin>>S>>T;
    int a=S.size(),b=T.size();
    
    int dp[a+1][b+1];
    
    for(int i=0;i<a+1;i++){
        for(int j=0;j<b+1;j++){
            dp[i][j]=INF;
        }
    }
    
    for(int i=0;i<a+1;i++){
        dp[i][0]=i;
    }
    for(int i=0;i<b+1;i++){
        dp[0][i]=i;
    }
    
    for(int i=1;i<=a;i++){
        for(int j=1;j<=b;j++){
            if(S[i-1]==T[j-1]){
                dp[i][j]=min({dp[i][j],dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]});
            }else{
                dp[i][j]=min({dp[i][j],dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+1});
            }
        }
    }
    
    cout<<dp[a][b]<<endl;
}





Measured memory_bytes: 7136
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int g(int x) {
    for (int i = 10; ; i *= 10) {
        if (x < i) return i;
    }
}

int f(int x, int y) {
    return x * g(y) + y;
}

void main() {
    int n; readf("%d\n", &n);
    int[] xs = new int[n];
    foreach (i; 0 .. n) {
        readf("%d\n", &xs[i]);
    }
    xs = xs.sort.uniq.array;
    int m[3] = [int.max, int.max, int.max];
    foreach (i; 0 .. n) {
        foreach (j; 0 .. n) {
            if (i == j) continue;
            foreach (k; 0 .. 3) {
                int x = f(xs[i], xs[j]);
                if (m[k] >= x) {
                    int s = x, t;
                    foreach (l; k .. 3) {
                        t = m[l];
                        m[l] = s;
                        s = t;
                    }
                    break;
                }
            }
        }
    }
    m[2].writeln;
}

Measured memory_bytes: 1108
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;




int main() {
int A,B,K;
cin>>A>>B>>K;
if(B-A+1<=2*K){
  rep4(i,A,B){
    cout<<i<<endl;
  }
}
else{
  rep4(i,A,A+K-1)cout<<i<<endl;
  rep4(i,B-K+1,B)cout<<i<<endl;
}
return 0;
}

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

// 2019/1/6 Educational DP contest
//https://atcoder.jp/contests/dp/tasks/dp_a

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


int main(){
	int n,h;
	if(scanf("%d",&n)==EOF){return 0;}
	int height[n];
	for(int i = 0; i < n; i++){
		if(scanf("%d",&h)==EOF){return 0;}
		height[i] = h;
	}
	
	int min_cost[n];
	min_cost[0] = 0;
	min_cost[1] = abs(height[1]-height[0]);
	
	for(int i = 2; i<n; i++){
		 min_cost[i] = min(min_cost[i-1] + abs(height[i]-height[i-1]), min_cost[i-2] + abs(height[i]-height[i-2]));
		 //printf("min_cost[%d] = %d\n", i, min_cost[i]);
	}
	
	printf("%d\n", min_cost[n-1]);
	return 0;
	

}

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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

 
	ll t, i, x, j, y, 	z, k, n;
	db a, b;
	cin >> a >> b;
	z = (a * b);
	ce(z)
}


Measured memory_bytes: 3736
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    final long mod = 1000000000+7;
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
        out.flush();
//        System.out.println(main.solve());
    }
    // segment tree to record minimum value
    // Each point has a infinite distance from 0 (except itself)
    void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> set = new HashSet<>(n/2+1);
        for(int i=0;i<n;i++){
            set.add(sc.nextInt());
        }
        if(set.size()==n) out.println("YES");
        else out.println("NO");
    }
}



Measured memory_bytes: 100588
s = input()
list_s = list(s)

a_num = len(s)
z_num = -1

for i in range(len(s)):
    if list_s[i] == "A":
        if a_num > i:
            a_num = i

    if list_s[i] == "Z":
        z_num = i

print(z_num - a_num + 1)

Measured memory_bytes: 4840
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    static final String HASHMARK = "#";
    
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(
                    new InputStreamReader(System.in));
            
            String sStr;
            while ((sStr = stdReader.readLine()) != null) {
                String[] inputs = sStr.split(" ");
                
                int h = Integer.valueOf(inputs[0]);
                int w = Integer.valueOf(inputs[1]);
                
                if (h == 0 && w == 0) {
                    break;
                    // nothing to do.
                }
                
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        System.out.print(HASHMARK);
                    }
                    System.out.println();
                }
                System.out.println();
            }
            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 30920
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    cin >> n;
    int ans = inf;
    
    rep(i,0,n+1){
	int c = 0;
	int a = i;
	int m = 1;
	while(1){
	    if(m*6 > a)break;
	    m *= 6;
	}
	while(a >0){
	    c += a/m;
	    a %= m;
	    while(m > a)m /= 6;
	}
	
	a = n - i;
	m = 1;
	while(1){
	    if(m*9 > a)break;
	    m *= 9;
	}
	while(a >0){
	    c += a/m;
	    a %= m;
	    while(m > a)m /= 9;
	}

	ans = min(ans,c);
    }
    P(ans);
    return  0;
}


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

using namespace std;
long long a,b;
char fuhao;
int main()
{
 cin>>a>>fuhao>>b;
 if(fuhao=='+')cout<<a+b<<endl;
 if(fuhao=='-')cout<<a-b<<endl;
 if(fuhao=='*')cout<<a*b<<endl;
 if(fuhao=='/')cout<<a/b<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int power(int x,int y){
    int res=1LL;
    while(y){
        if(y&1){
            res=(res*x)%MOD;
        }
        x=(x*x)%MOD;
        y=(y>>1);
    }
}
int s[6]={0};
int v[6]={0};
int n,m;
vector <int> z;
int check(int i){
    z.clear();
    int k=i;
    while(k){
        z.pb(k%10);
        k/=10;
    }
    if(z.size()!=n)return 0;
    rep(i,1,m){
        int x=s[i];
        int y=v[i];
        if(z[n-s[i]]!=v[i])
            return 0;
    }
    return 1;

}

signed main()
{
    
    speed
    cin>>n>>m;
    vector <int> lol(n,-1);
    int f=1;
    rep(i,1,m){
        cin>>s[i]>>v[i];

    }
    if(n==1){
        int flag=0;
        rep(i,1,m){
            if(v[i]!=0)
            {
                flag=1;
            }
        }
        if(!flag){
            cout<<0<<endl;
            exit(0);
        }
    }
    rep(i,1,1000){
        if(check(i)){
            cout<<i<<endl;
            exit(0);
        }
    }
    cout<<-1<<endl;
    
 


  



    

    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define QWQ puts("successfully enter.")
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define FILL(a,val) memset(a,val,sizeof(a))
int n;
void display(initializer_list<int> out)
{
	cout<<"DISPLAY:";
	for(auto x:out) cout<<x<<' ';
	puts("");
}
bool isprime(int p)
{
	if(p<2) return false;
	for(int i=2;i*i<=p;i++)
		if(p%i==0)
			return false;
	return true;
}
int main()
{
	cin>>n;
	for(int i=n;;i++)
		if(isprime(i))
		{
			cout<<i;
			return 0;
		}
	return 0;
}

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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    string s=to_string(a)+to_string(b);
    int hoge=stoi(s);
    
    string ans="No";
    
    for(int i=1;i<=1000;i++){
        if(i*i==hoge) ans="Yes";
        if((double)hoge/(double)i==(double)i) ans="Yes";
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
//  यस्य स्मरणमात्रेण जन्मसंसारबन्धनात् ।  विमुच्यते नमस्तस्मै विष्णवे प्रभविष्णवे ॥
 
 
 
/****
*     Author- Indrajeet Mishra
*             MNNIT Allahabad, Prayagraj
*             Chemical Engineering undergraduate
 
 
 
****/
 
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
 
#include <bits/stdc++.h>
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)
 
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=0;cin>>n;
    ll flag=0;
    if(n>81)cout<<"No";
    else{
        for(ll i=9;i>=1;i--){
            if(n%i==0){
                if(n/i<=9){
                    cout<<"Yes";
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0)cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static int isBomb(char c) {
    if (c == '#') {
      return 1;
    } else {
      return 0;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    String S[] = new String[H];
    for (int i = 0; i < H; i++) {
      S[i] = sc.next();
    }
    char c[][] = new char[H][W];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (S[i].charAt(j) == '#') {
          System.out.print("#");
        } else {
          int bomb = 0;
          if (i != 0) {
            if (j != 0) bomb += isBomb(S[i-1].charAt(j-1));
            bomb += isBomb(S[i-1].charAt(j));
            if (j != W - 1) bomb += isBomb(S[i-1].charAt(j+1));
          }
          if (j != 0) bomb += isBomb(S[i].charAt(j-1));
          if (j != W - 1) bomb += isBomb(S[i].charAt(j+1));
          if (i != H - 1) {
            if (j != 0) bomb += isBomb(S[i+1].charAt(j-1));
            bomb += isBomb(S[i+1].charAt(j));
            if (j != W - 1) bomb += isBomb(S[i+1].charAt(j+1));
          }
          System.out.print(bomb);
        }
      }
      System.out.println();
    }
  }

}


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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 }, dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

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, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> point) { ll x = get<0>(point), y = get<1>(point); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }
void out_sequence(vector<ll> &out) { REP(i, out.size()) { cout << out[i]; if (i == out.size() - 1) cout << endl; else cout << " "; } }

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll N; cin >> N;
	ll ans = 0;
	ll cnt = 1, before = -1;
	REP(i, N) {
		ll a; cin >> a;
		if (before == a) {
			cnt++;
		} else {
			ans += cnt / 2;
			cnt = 1;
		}
		before = a;
	}
	cout << ans + cnt / 2 << endl;

	return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	
	
	set<int> st={1};
	
	for(int cr=6;cr<=n; cr*=6) st.insert(cr);
	for(int cr=9;cr<=n; cr*=9) st.insert(cr);
	//for(auto x :st) printf("%d, ",x); puts("");
	VI dp(n+10, MD); dp[0]=0;
	rep(i, n) if(dp[i]<MD) for(auto g: st){
		if(i + g <= n) dp[i+g] = min(dp[i+g], dp[i]+1);
	}
	cout << dp[n] <<"\n";
	return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

int N,L,M;
string s;
vector<int> e;

vector<int> operator*(const vector<int>& a,const vector<int>& b){
  vector<int> res(a.size());
  rep(i,a.size())res[i]=b[a[i]];
  return res;
}

vector<int> seq(int l,int r){
  if(s[l]!='('){
    int i=l+1;
    while(i<r&&isdigit(s[i]))i++;
    if(i==r){ // opr
      int num=stoi(s.substr(l+1,r-l-1));
      num--;
      vector<int> res=e;
      if(s[l]=='L'){
        rep(i,M){
          if(i/N==num){
            int base=(i/N)*N;
            res[i]=(i-base-1+N)%N+base;
          }
        }
      }else if(s[l]=='R'){
        rep(i,M){
          if(i/N==num){
            int base=(i/N)*N;
            res[i]=(i-base+1)%N+base;
          }
        }
      }else if(s[l]=='U'){
        rep(i,M){
          if(i%N==num){
            int base=i%N;
            res[i]=((((i-base)/N)-1+N)%N)*N+base;
          }
        }
      }else{
        rep(i,M){
          if(i%N==num){
            int base=i%N;
            res[i]=((((i-base)/N)+1)%N)*N+base;
          }
        }
      }
      return res;
    }
  }

  vector<int> res=e;
  for(int i=l;i<r;){
    if(s[i]=='('){ // rept
      int j=i+1;
      int lev=1;
      while(lev!=0){
        if(s[j]=='(')lev++;
        if(s[j]==')')lev--;
        j++;
      }
      int k=j;
      while(k<r&&isdigit(s[k]))k++;
      vector<vector<int> > nxt(vector<vector<int> >(30,vector<int>(M)));
      nxt[0]=seq(i+1,j-1);
      repl(b,1,30)nxt[b]=nxt[b-1]*nxt[b-1];
      int t=stoi(s.substr(j,k-j));
      rep(b,30){
        if((t>>b)&1)res=res*nxt[b];
      }
      i=k;
    }else{ // seq
      int j=i+1;
      while(j<r&&isdigit(s[j]))j++;
      res=res*seq(i,j);
      i=j;
    }
  }
  return res;
}

int main(){
  cin>>N>>L;
  M=N*N;
  cin>>s;
  rep(i,M)e.push_back(i);
  vector<int> res=seq(0,L);
  vector<int> ans;
  rep(i,M)ans.push_back(i);
  rep(i,M)ans[res[i]]=i;
  rep(i,N){
    rep(j,N){
      printf("%d%c", ans[i*N+j]+1,j==N-1?'\n':' ');
    }
  }
  return 0;
}



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

void swap(int &a, int &b)
{
	int box = a;

	a = b;
	b = box;
}

int main()
{
	int n, aa[100], a, b;

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> aa[i];

	a = b = 0;

	for (int i = 0; i < n; i++){
		for (int j = n-1; j > i; j--){
			if (aa[j] > aa[j - 1])
				swap(aa[j], aa[j - 1]);
		}
	}
	for (int i = 0; i < n; i++){
		if (i % 2 == 0)
			a += aa[i];
		else
			b += aa[i];
	}

	cout << a - b << endl;

	return 0;

}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

vector<set<ll>> S(20);
int lunlun(int n){
    if(n == 1){
        for(ll i = 1; i <= 9; i++) S[n].insert(i);
    }
    for(ll i : S[n-1]){

    }
    return S[n].size();
}

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

    queue<ll> que;
    for(int i = 1; i<= 9; i++){
        que.push(i);
        K--;
        if(K == 0){
            cout << i << endl;
            return 0;
        }
    }

    while(1){
        ll i = que.front();
        que.pop();
        ll last = i % 10;
        if(last != 0){
            que.push(i * 10 + last - 1);
            K--;
            if(K == 0){
                cout << i * 10 + last - 1 << endl;
                return 0;
            }
        }

        que.push(i * 10 + last);
        K--;
        if(K == 0){
            cout << i * 10 + last << endl;
            return 0;
        }
        if(last != 9){
            que.push(i * 10 + last + 1);
            K--;
            if(K == 0){
                cout << i * 10 + last + 1 << endl;
                return 0;
            }
        }
    }
}

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

const int DIM = 1e5 + 5;

pair<int, int> seg[DIM];
multiset<long long> lft, rgt;

int main(void)
{
    int n;
    scanf("%d", &n);
    
    long long ld = 0, rd = 0, ans = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d %d", &seg[i].first, &seg[i].second);
        
        if (i == 1) {
            lft.insert(seg[i].first);
            rgt.insert(seg[i].first);
        }
        else {
            ld += seg[i].second - seg[i].first;
            rd += seg[i - 1].second - seg[i - 1].first;
            
            long long ps = seg[i].first,
                      le = *lft.rbegin() - ld,
                      ri = *rgt.begin()  + rd;
        
            if (ps < le) {
                ans += le - ps;
                lft.erase(prev(lft.end()));
                
                lft.insert(ps + ld);
                lft.insert(ps + ld);
                rgt.insert(le - rd);
            }
            else
            if (ps > ri) {
                ans += ps - ri;
                rgt.erase(rgt.begin());
                
                rgt.insert(ps - rd);
                rgt.insert(ps - rd);
                lft.insert(ri + ld);
            }
            else {
                lft.insert(ps + ld);
                rgt.insert(ps - rd);
            }
        }
    }
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 10368
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

char c[4] = {'m', 'c', 'x', 'i'};
int d[4] = {1000, 100, 10, 1};

int main()
{
	int n;
	cin >> n;
	rep(i,0,n) {
		string a[2];
		cin >> a[0] >> a[1];
		int b[2] = {};
		rep(i,0,2) {
			rep(j,0,4) {
				rep(k,0,a[i].size()) {
					if (a[i][k] == c[j]) {
						if (k == 0) {
							b[i] += d[j];
							a[i] = a[i].substr(1);
						}
						else {
							int e = a[i][k-1] - '0';
							b[i] += e * d[j];
							a[i] = a[i].substr(2);
						}
					}
				}
			}
		}
		int sum = b[0] + b[1];
		string ans;
		rep(i,0,4) {
			int x = sum / d[i];
			sum %= d[i];
			if (x >= 2) ans += '0'+x;
			if (x) ans += c[i];
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    double mean = (double)sum / (double)n;
    int p = ceil(mean - 0.5);
    ll ans = 0;
    rep(i, n) ans += (a[i] - p) * (a[i] - p);
    out(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n);
  queue<int> even, odd;
  for (int i = 0; i < n; ++i) {
    Cin(int, a);
    if (a % 2 == 0)
      even.push(a);
    else
      odd.push(a);
  }

  while (true) {
    if (sz(odd) >= 2) {
      int a = odd.front();
      odd.pop();
      int b = odd.front();
      odd.pop();

      if ((a + b) % 2 == 0)
        even.push(a + b);
      else
        odd.push(a + b);
    } else if (sz(even) >= 2) {
      int a = even.front();
      even.pop();
      int b = even.front();
      even.pop();

      if ((a + b) % 2 == 0)
        even.push(a + b);
      else
        odd.push(a + b);
    } else
      break;
  }

  cout << (sz(even) + sz(odd) == 1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    cap = [chr(i) for i in range(65, 65 + 26)]
    N = ii()
    S = li()
    T = ['' for i in range(len(S))]
    for i in range(len(S)):
        T[i] = cap[(ord(S[i]) + 13 + N) % 26]
    print(''.join(T))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
<?php

list($a,$b,$c) =  explode(" ",trim(fgets(STDIN)));
$array = [$a,$b,$c];
sort($array);

$count = 0;
if($a%2 == 0)$count++;
if($b%2 == 0)$count++;
if($c%2 == 0)$count++;

if($count){
    echo 0;
    exit;
}

echo $array[0] * $array[1];

Measured memory_bytes: 2936
from collections import deque

H, W = map(int, input().split())
X = [[[0, 1][a=="#"] for a in input()] for i in range(H)]

ch = [[0] * W for _ in range(H)]
move = [(-1,0), (1,0), (0,-1), (0,1)]
ans = 0
for i in range(H):
    for j in range(W):
        if ch[i][j]:
            continue
            
        q = deque([(i,j)])
        a = [0, 0]
        while q:
            x, y = q.popleft()
            ch[x][y] = 1
            a[(x+y)%2] += 1
            for m in move:
                nx = x + m[0]
                ny = y + m[1]
                if nx >= 0 and nx < H and ny >= 0 and ny < W and X[x][y] != X[nx][ny]:
                    if ch[nx][ny] == 0:
                        q.append((nx,ny))
                        ch[nx][ny] = 1
        ans += a[0] * a[1]

print(ans)

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

int main()
{
  long long N,A,B;
  cin >> N >> A >> B;
  long long X,Y;
  X = N/(A+B)*A;
  Y = N%(A+B);
  Y = min(Y,A);
  cout << X+Y;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    vector<int> xh(n);
    map<int,int> yh;
    rep(i,n){
        xh[i]=(i+1)+a[i];
        yh[(i+1)-a[i]] ++;
    }
    in cnt=0ll;
    rep(i,n){
        yh[(i+1)-a[i]] --;
        cnt +=(in)yh[xh[i]];
    }
    cout<<cnt<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 21760
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n, k, r, s, p; cin >> n >> k >> r >> s >> p;
  string t; cin >> t;
  int ans = 0;
  REP(i, k) {
    int prev = -1;
    for (int j = i; j < n; j += k) {
      if (t[j] == 'r') {
        if (prev == 0) {
          prev = -1;
        } else {
          ans += p;
          prev = 0;
        }
      } else if (t[j] == 's') {
        if (prev == 1) {
          prev = -1;
        } else {
          ans += r;
          prev = 1;
        }
      } else {
        if (prev == 2) {
          prev = -1;
        } else {
          ans += s;
          prev = 2;
        }
      }
      // cout << ans << '\n';
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	string S;
	cin >> S;
	int len = S.length();
	int cost = 0;
	int c = 0;
	for (int i = 0; i < len; i++) {
		if (!(i%2)) {
			if (S[i] != '0') {
				c++;
			}
		} else {
			if (S[i] != '1') {
				c++;
			}
		}
	}
	cost = c;
	c = 0;
	for (int i = 0; i < len; i++) {
		if (!(i%2)) {
			if (S[i] != '1') {
				c++;
			}
		} else {
			if (S[i] != '0') {
				c++;
			}
		}
	}
	cost = min(cost, c);
	cout << cost << endl;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef double db;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
int n,m,k,rt;

int main(){
    scanf("%d%d%d",&n,&m,&k);
    if(n<m) swap(n,m);
    int ans=k/n+(k%n>0);
    printf("%d\n",ans);
    return 0;
}
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R register
#define Make std::make_pair

const int MAX = 500020;

int cnt;
std::map<int, int> lty[MAX];
std::vector< std::pair<int, int> > Node[MAX];
std::deque<int> points;
int dis[MAX];

inline int giveCnt(int a, int b) {
	if (lty[a].count(b)) {
		return lty[a][b];
	}
	return lty[a][b] = ++cnt;
}

inline void add(int x, int y, int z) {
	Node[x].push_back(Make(y, z));
	Node[y].push_back(Make(x, z));
	return;
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		giveCnt(i, 0);
	}
	for (int i = 1; i <= m; i++) {
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		int X = giveCnt(x, 0);
		int Y = giveCnt(y, 0);
		int X1 = giveCnt(x, c);
		int Y1 = giveCnt(y, c);
		add(X1, Y1, 0);
		add(X, Y1, 1);
		add(X1, Y, 1);
	}
	memset(dis, -1, sizeof dis);
	dis[1] = 0;
	points.push_back(1);
	
	while (points.size()) {
		int u = points.back();
		points.pop_back();
		for (std::vector< std::pair<int, int> >::iterator it = Node[u].begin(); it != Node[u].end(); it++) {
			if (dis[it->first] == -1 || dis[it->first] > dis[u] + it->second) {
				dis[it->first] = dis[u] + it->second;
				if (it->second == 1) {
					points.push_front(it->first);
				} else {
					points.push_back(it->first);
				}
			}
		}
	}
	
	printf("%d\n", dis[n] >> 1);
    return 0;
}

Measured memory_bytes: 79232
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int vx[]={1,0,-1,0},vy[]={0,-1,0,1};

int main(){
    for(;;){
        int n,m;
        scanf("%d %d\n",&n,&m);
        if(n==0&&m==0) break;
        char ma[100][100];
        int dx,dy;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                scanf("%c",&ma[i][j]);
                if(ma[i][j]=='&'){
                    dx=i;
                    dy=j;
                }
            }
            scanf("\n");
        }
        int dist[100][100];
        const int INF=100000;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                dist[i][j]=INF;
            }
        }
        dist[dx][dy]=0;
        priority_queue<pair<int,P>,vector<pair<int,P> >,greater<pair<int,P> > > que;
        que.push(make_pair(0,P(dx,dy)));
        while(!que.empty()){
            pair<int,P> now=que.top();
            que.pop();
            int di=now.first,nox=now.second.first,noy=now.second.second;
            if(dist[nox][noy]<di) continue;
            for(int v=0;v<4;v++){
                int nex=nox+vx[v],ney=noy+vy[v];
                if(0<=nex&&nex<m&&0<=ney&&ney<n){
                    if(ma[nox][noy]=='#'){
                        if(dist[nex][ney]>dist[nox][noy]){
                            dist[nex][ney]=dist[nox][noy];
                            que.push(make_pair(dist[nex][ney],P(nex,ney)));
                        }
                    }else{
                        int nedist=dist[nox][noy];
                        if(ma[nex][ney]=='#') nedist++;
                        if(dist[nex][ney]>nedist){
                            dist[nex][ney]=nedist;
                            que.push(make_pair(dist[nex][ney],P(nex,ney)));
                        }
                    }
                }
            }
        }
        int mi=INF;
        for(int i=0;i<m;i++){
            mi=min(mi,dist[i][0]);
            mi=min(mi,dist[i][n-1]);
        }
        for(int i=0;i<n;i++){
            mi=min(mi,dist[0][i]);
            mi=min(mi,dist[m-1][i]);
        }
        printf("%d\n",mi);
    }
}

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

#define fast_io ios::sync_with_stdio(false)

int dig[12][12];

int first_dig(int k)
{
    while(k >= 10)
        k /= 10;
    return k;
}
int main()
{
	fast_io;
	int n;
	cin >> n;
	for(int k=1;k<=n;k++)
		dig[first_dig(k)][k%10]++;
	long long ans = 0;
	for(int i=0;i<10;i++)
		for(int j=0;j<10;j++)
			ans = ans + 1ll*dig[i][j]*dig[j][i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	bool f = true;
	REP(i, 100000)
	{
		int t = c + i * 60;
		if (t % (a + b) <= a)
		{
			f = false;
			cout << t << endl;
			break;
		}
	}
	if (f) puts("-1");
	return 0;
}
 

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int a[3];
  rep(i,0,3) cin>>a[i];
  sort(a,a+3);
  int num=a[2]*10+a[1]+a[0];
  cout<<num<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	string s;
	cin >> s;
	rep(i,(1 << 3)) {
		int x = s[0] - '0';
		rep(j,3) {
			if (i & (1 << j)) {
				x += s[j+1] - '0';
			} else {
				x -= s[j+1] - '0';
			}
		}
		if (x == 7) {
			string t = s.substr(0, 1);
			rep(j,3) {
				if (i & (1 << j)) {
					t = t + "+" + s[j + 1];
				} else {
					t = t + "-" + s[j + 1];
				}
			}
			cout << t + "=7" << endl;
			return;
		}
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		char[] cs=sc.next().toCharArray();
		int[] N=new int[cs.length];
		int K=sc.nextInt();
		for(int i=0;i<cs.length;++i) {
			N[i]=cs[i]-'0';
		}
		long[][][] dp=new long[N.length+1][K+1][2];
		dp[0][0][0]=1;
		for(int i=0;i<N.length;++i) {
			for(int j=0;j<2;++j) {
				for(int k=0;k<=K;++k) {
					for(int next=0;next<=(j==0?N[i]:9);++next) {
						int nj=next<N[i]?1:j;
						int nk=k+(next!=0?1:0);
						if(nk<=K&&nj<=2)
							dp[i+1][nk][nj]+=dp[i][k][j];
					}
				}
			}
		}
		System.out.println(dp[N.length][K][0]+dp[N.length][K][1]);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 23892
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}

int sign(LL n) { return n == 0 ? 0 : n / abs(n); }
int main() {
  int n;
  cin >> n;
  VEC<LL> a(n);
  REP(i, 0, n) { cin >> a[i]; }
  auto make = [&](LL tgt) -> LL {
    VEC<LL> cur(n, 0);
    cur[0] = a[0];
    LL cnt = 0;

    if (sign(cur[0]) != sign(tgt)) {
      cnt += abs(a[0] - tgt);
      cur[0] = tgt;
    }
    // DUMP(tgt, a);
    // DUMP(0, cnt, cur);
    REP(i, 1, n) {
      tgt = -tgt;
      cur[i] = cur[i - 1] + a[i];

      if (sign(cur[i]) != sign(tgt)) {
        cnt += abs(cur[i] - tgt);
        cur[i] = tgt;
      }
      // DUMP(i, cnt, cur);
    }
    return cnt;
  };
  cout << min(make(1), make(-1)) << endl;

  return 0;
}


Measured memory_bytes: 1804
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n, m;

int ed[1000][1000];

int cl[2];
int cc[1200];
int was[1000];
int dp[1000];

void dfs1(int v, int c) {
	++cl[c];
	cc[v] = c;
	was[v] = 1;
	for (int i = 0; i < n; ++i) {
		if (i == v || ed[i][v])
			continue;
		if (was[i] && cc[i] == cc[v]) {
			cout << -1 << "\n";
			exit(0);
		}
		if (!was[i])
			dfs1(i, c ^ 1);
	}
}


int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		ed[a][b] = ed[b][a] = 1;
	}
	dp[0] = 1;
	for (int i = 0; i < n; ++i)
		if (!was[i]) {
			cl[0] = cl[1] = 0;
			dfs1(i, 0);
			for (int j = n; j >= 0; --j) {
				int x = 0;
				if (j >= cl[0])
					x |= dp[j - cl[0]];
				if (j >= cl[1])
					x |= dp[j - cl[1]];
				dp[j] = x;
			}
		}
	int ans = n * n;
	for (int i = 0; i <= n; ++i)
		if (dp[i])
			ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 3072