akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split(" "))
S = [input() for _ in range(H)]

l, r, d, u = [[[0 for _ in range(W)] for _ in range(H)] for _ in range(4)]

for y in range(H):
    for x in range(W):
        if S[y][x] == "#":
            l[y][x] = -1
        elif x == 0:
            l[y][x] = 0
        else:
            l[y][x] = l[y][x-1] + 1
for y in range(H):
    for x in range(W-1, -1, -1):
        if S[y][x] == "#":
            r[y][x] = -1
        elif x == W-1:
            r[y][x] = 0
        else:
            r[y][x] = r[y][x+1] + 1
for x in range(W):
    for y in range(H):
        if S[y][x] == "#":
            u[y][x] = -1
        elif y == 0:
            u[y][x] = 0
        else:
            u[y][x] = u[y-1][x] + 1
for x in range(W):
    for y in range(H-1, -1, -1):
        if S[y][x] == "#":
            d[y][x] = -1
        elif y == H-1:
            d[y][x] = 0
        else:
            d[y][x] = d[y+1][x] + 1

max_num = 0
for y in range(H):
    for x in range(W):
        m = l[y][x] + r[y][x] + u[y][x] + d[y][x] + 1
        # if m > max_num:
        #     print(x, y, l[y][x], r[y][x], u[y][x], d[y][x], m)
        max_num = max(max_num, m)

print(max_num)

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

int main() {
  int a, b, result;
  char op;

  cin >> a >> op >> b;

  if ((a >= 1 && a <= 10000000000) && (b >= 1 && b <= 1000000000)) {
    if (op == '+') {
      result = a + b;
      cout << result << endl;
    }
    else if (op == '-') {
      result = a - b;
      cout << result << endl;
    }
    else {
      cout << "op is wrong" << endl;
    }
  }
  else {
    cout << "a or b is wrong" << endl;
  }
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    i64 n,a,b;
    cin>>n>>a>>b;
    i64 res=0;
    if(n==1){
        if(a==b)    res=1;
        else        res=0;
    }
    else if(a>b)    res=0;
    else            res = (b-a)*(n-2)+1;
    cout<<res<<endl;
    return 0;
}



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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <class T>
int sgn(T x) { return (x > 0) - (x < 0); }
template <class T>
struct Point
{
    typedef Point P;
    T x, y;
    explicit Point(T x = 0, T y = 0) : x(x), y(y) {}
    bool operator<(P p) const { return tie(x, y) < tie(p.x, p.y); }
    bool operator==(P p) const { return tie(x, y) == tie(p.x, p.y); }
    P operator+(P p) const { return P(x + p.x, y + p.y); }
    P operator-(P p) const { return P(x - p.x, y - p.y); }
    P operator*(T d) const { return P(x * d, y * d); }
    P operator/(T d) const { return P(x / d, y / d); }
    T dot(P p) const { return x * p.x + y * p.y; }
    T cross(P p) const { return x * p.y - y * p.x; }
    T cross(P a, P b) const { return (a - *this).cross(b - *this); }
    T dist2() const { return x * x + y * y; }
    double dist() const { return sqrt((double)dist2()); }
    // angle to x􀀀axis in interval [􀀀pi , pi ]
    double angle() const { return atan2(y, x); }
    P unit() const { return *this / dist(); } // makes dist ()=1
    P perp() const { return P(-y, x); }       // rotates +90 degrees
    P normal() const { return perp().unit(); }
    // returns point rotated 'a ' radians ccw around the origin
    P rotate(double a) const
    {
        return P(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a));
    }
    friend ostream &operator<<(ostream &os, P p)
    {
        return os << "(" << p.x << "," << p.y << ")";
    }
};

typedef Point<double> P;
double ccRadius(const P &A, const P &B, const P &C)
{
    return (B - A).dist() * (C - B).dist() * (A - C).dist() /
           abs((B - A).cross(C - A)) / 2;
}
P ccCenter(const P &A, const P &B, const P &C)
{
    P b = C - A, c = B - A;
    return A + (b * c.dist2() - c * b.dist2()).perp() / b.cross(c) / 2;
}

pair<P, double> mec(vector<P> ps)
{
    shuffle(all(ps), mt19937(time(0)));
    P o = ps[0];
    double r = 0, EPS = 1 + 1e-8;
    rep(i, 0, sz(ps)) if ((o - ps[i]).dist() > r * EPS)
    {
        o = ps[i], r = 0;
        rep(j, 0, i) if ((o - ps[j]).dist() > r * EPS)
        {
            o = (ps[i] + ps[j]) / 2;
            r = (o - ps[i]).dist();
            rep(k, 0, j) if ((o - ps[k]).dist() > r * EPS)
            {
                o = ccCenter(ps[i], ps[j], ps[k]);
                r = (o - ps[i]).dist();
            }
        }
    }
    return {o, r};
}

int main()
{
    int n, i, j, t;
    vector<P> v;
    cin>>n;
    rep(i,0,n)
    {
        int x,y;
        cin>>x>>y;
        P pt(x,y);
        v.push_back(pt);
    }
    pair<P, double> res=mec(v);
    cout<<fixed << setprecision(9)<<res.second;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

// Robot is a struct.
type Robot struct {
	X   int64
	L   int64
	Min int64
	Max int64
}

// Robots is robots.
type Robots []Robot

func (r Robots) Less(i, j int) bool { return r[i].Max < r[j].Max }
func (r Robots) Len() int           { return len(r) }
func (r Robots) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }

func main() {
	var N int
	fmt.Scanf("%d", &N)
	robots := make(Robots, N)
	for i := 0; i < N; i++ {
		r := Robot{}
		fmt.Scanf("%d %d", &r.X, &r.L)
		r.Min = r.X - r.L
		r.Max = r.X + r.L
		robots[i] = r
	}
	sort.Sort(robots)
	count := 0
	var max int64
	max = math.MinInt64
	for _, r := range robots {
		if max > r.Min {
			continue
		}
		count++
		max = r.Max
	}
	fmt.Println(count)
}


Measured memory_bytes: 7680
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>

using namespace std;
bool IsPrime[105000];
vector<int> Prime;

void calc()
{
	memset(IsPrime, 1, sizeof(IsPrime));
	for(int i = 2; i < 105000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 105000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int N, P;
	while(cin >> N >> P)
	{
		if(N == -1 && P == -1)
		{
			break;
		}
		int pos = 0;
		while(Prime[pos] <= N)
		{
			pos++;
		}
		vector<int> Sum;
		for(int i = pos; i < pos + 100; ++i)
		{
			for(int j = i; j < pos + 100; ++j)
			{
				Sum.push_back(Prime[i] + Prime[j]);
			}
		}
		sort(Sum.begin(), Sum.end());
		cout << Sum[P - 1] << endl;
	}
}

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

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

int main(void){
  int a,b,c; cin >> a >> b >> c;
  int ans;

  if(b>=c*a) ans = c;
  else ans = b/a;

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


Measured memory_bytes: 256
n,m,X,Y=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

for i in range(Y-X):
    z=X+1+i
    s="no_war"
    for j in range(n):
        if x[j]>=z:
            s="war"
            break
    for j in range(m):
        if y[j]<z:
            s="war"
            break
    if s=="no_war":
        print("No War")
        exit()
print("War")

Measured memory_bytes: 9152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author P.Alizadeh
 */

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

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll,ll>     pll;

#define all(x)          x.begin(),x.end()
#define Sort(x)         sort(all(x))
#define trace(x)        cerr << #x << " = " << x << endl;
#define X               first
#define Y               second
#define sep             " "
#define endl            "\n"
#define fastio          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define ld_io           cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll pw(ll a, ll b, ll md) {
    if (!b)
        return 1;
    if (b & 1)
        return a * pw(a * a % md, b / 2, md) % md;
    return pw(a * a % md, b / 2, md) % md;
}

const ll MAXN = 2e5 + 10,
         INF  = 8e18,
         MOD  = 1e9 + 7;
//const ld PI   = acos(-1);

ll n, a[MAXN], b[MAXN], c[MAXN], dp[3], tmp[3], sum;

int main()
{
    fastio;
    //ld_io;

    cin >> n;
    for (ll i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    sum = 0;
    for (ll i = 1; i <= n; i++) {
        tmp[0] = max(dp[1], dp[2]) + a[i];
        tmp[1] = max(dp[0], dp[2]) + b[i];
        tmp[2] = max(dp[1], dp[0]) + c[i];
        dp[0] = tmp[0];
        dp[1] = tmp[1];
        dp[2] = tmp[2];
    }

    cout << max(tmp[0], max(tmp[1], tmp[2])) << endl;


    return 0;
}



Measured memory_bytes: 3584
switch_num, light_num = gets.chomp.split(" ").map {|item| item.to_i }

light_targets = []
light_num.times do |index|
    k, *target_swiches = gets.chomp.split(" ").map {|item| item.to_i }
    light_targets.push(target_swiches)
end
amari_list = gets.chomp.split(" ").map {|item| item.to_i }

c = 0
(2 ** switch_num).times do |n|
    flag = true
    swich_pattern = n.to_s(2).rjust(switch_num, '0').split("").map{|c| c.to_i}
    light_targets.each_with_index do |target_swiches, i|
        on_num = 0
        target_swiches.each do |target|
            if swich_pattern[target-1] == 1
                on_num += 1
            end
        end
        if on_num % 2 == amari_list[i]

        else
            flag = false
            break
        end
    end
    if flag == true
        c += 1
    end
end
puts c

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

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll n; cin >> n;
  priority_queue<ll> num; map<ll,ll> count;
  num.push(0); num.push(0);
  
  rep(i,n){
    ll x; cin >> x;
    count[x]++;
    if(count[x] % 2 == 0) num.push(x);
  }
  
  ll max = 0; ll secmax = 0;
  
  max = num.top();
  num.pop();
  secmax = num.top();
  
  cout << max * secmax << endl;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int digitsum(int n) {
	int ret = 0;
	while (n > 0) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	if (N % digitsum(N) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int k;
    cin>>k;
    for(int i=0;i<n;++i)
    {
        if(s[i]!=s[k-1])
        {
            s[i] = '*';
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
S = input()
L = [chr(i) for i in range(97, 97+26)]
if S[0] == "A":
  c = 0
  for i in range(2,len(S)-1):
    if S[i] == "C":
      c +=1
      k = i
  if c == 1:
    T = "AC"
    for j in range(1,len(S)):
      if j != k:
        if not S[j] in L:
          T = "WA"
          break
    print(T)
  else:
      print("WA")
else:
  print("WA")

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	while(a!=0 || b!=0){
		if(a>b){
			printf("%d %d\n", b, a);
		}
		else{
			printf("%d %d\n", a, b);
		}
		scanf("%d %d", &a, &b);
	}
	
	return 0;
}

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

using namespace std;

typedef long long lint;

const int MOD = (1e9) + 7;

int v[60009];

int putere(int a, int b)
{
    lint ca = a;
    lint rez = 1;
    for(int i = 0; (1 << i) <= b; i ++)
    {
        if(((1 << i) & b) != 0)
        {
            rez *= ca;
            rez %= MOD;
        }

        ca *= ca;
        ca %= MOD;
    }

    return (int)rez;
}

int main()
{
    int s, i;
    cin >> s;

    lint rez = 0;
    lint px = 9;
    lint sum = 0;
    rez = 0;
    for(i = 1; i <= 8; i ++)
    {
        lint c = px * 10;
        sum = 0;

        for(int j = i + 1; j <= 8; j ++)
        {
            lint rest = s - sum;

            if(rest <= 0)
                break;

            for(int h = 1; h * j < rest && h <= c; h ++)
            {
                if((rest - h * j) % i == 0 && (rest - h * j) / i <= px)
                    rez ++;
            }

            sum += c * j;
            c *= 10;
        }

        if(s % i == 0 && s / i <= px)
            rez += px - s / i + 1;

        px *= 10;
    }

    rez %= MOD;
    px %= MOD;

    int j, k = 0;
    for(i = 1; i * i <= s; i ++)
    {
        v[++ k] = i - 1;
        v[++ k] = i;
        v[++ k] = i + 1;

        v[++ k] = s / i - 1;
        v[++ k] = s / i;
        v[++ k] = s / i + 1;
    }

    sort(v + 1, v + k + 1);

    for(j = 1; j <= k ; j ++)
    {
        if(v[j] > 8 && v[j] != v[j - 1])
        {
            int i = v[j];
            lint px = putere(10, i - 1) * 9LL % MOD;
            int nr = (s / i + ((s % i) != 0)) * i;
            int rest = nr % s;
            int cate = nr / i - rest;

            if(cate > 0 && rest != 0)
            {
                rez ++;
                if(rez >= MOD)
                    rez -= MOD;
            }


            if(cate / (i - 1) > 0)
            {
                rez += cate / (i - 1) - ((cate % (i - 1)) == 0);
            }

            if(rez >= MOD)
                rez -= MOD;

            if(rest == 0)
            {
                rez += px - s / i + 1;
                if(rez < 0)
                    rez += MOD;
                if(rez >= MOD)
                    rez -= MOD;
            }
        }
    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  while(1){
    if(is_prime(N)){
      Out(N);
      break;
    }
    N++;
  }
}

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

int main(){
  int N;
  cin>>N;
  int temp=0,G=0,Q=0,K=0;
  for(int i=0;i<N;i++){
    cin >> temp;
    if(temp%4==0){
      Q++;
    }
    else if (temp%2==0){
      G++;
    }
    else K++;
  }
  if((Q>=N/2)||(K<=Q)){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v;
    set<int> s;
    int t, a, b, c, cnt=0;
    string st1;
    string st2;
    cin >> st1;
    cin >> st2;

    reverse(st1.begin(), st1.end());

    if(st1.compare(st2) == 0){
    	YES;
    }else{
    	NO;
    }

   bye;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, h;
	cin >> h >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	for(auto& x : a) {
		h -= x;
		if( h <= 0 ) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

//ユークリッドの互除法 O(log a)
LL gcd(LL a, LL b){
	if(b > a) swap(a, b);
	LL tmp;
	while(b != 0){
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	LL ans;
	cin >> ans;
	for(int i=1; i<N; i++){
		LL tmp;
		cin >> tmp;
		LL g = gcd(ans,tmp);
		ans = (ans / g) * tmp;
	}
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main()
{
	char tile[100][100];
	int n;
	while(1)
	{
		int r,c;
		std::cin>>r>>c;
		std::cin.ignore();
		if(r==0&&c==0)break;
		
		for(int i=0;i<r;i++)
		{
			char buf[101];
			std::cin.getline(buf,101);
			for(int j=0;j<c;j++)
			{
				tile[i][j]=buf[j];
			}
		}
		
		int x=0,y=0;
		bool moving=true;
		while(moving)
		{
			switch(tile[y][x])
			{
			case '.':
				std::cout<<x<<' '<<y<<std::endl;
				moving=false;
				break;
			case '>':
				tile[y][x]='1';
				x++;
				break;
			case '<':
				tile[y][x]='1';
				x--;
				break;
			case '^':
				tile[y][x]='1';
				y--;
				break;
			case 'v':
				tile[y][x]='1';
				y++;
				break;
			case '1':
				std::cout<<"LOOP"<<std::endl;
				moving=false;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<vector>
#include<cmath>

using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a.size()==b.size()){  
    for(int i=0;i<b.size();i++){
      cout<<a[i]<<b[i];  
    }
  }
  else{
    for(int i=0;i<b.size();i++){
      cout<<a[i]<<b[i];
    }
    cout<<a[a.size()-1];
  }
  
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    
    let n: usize = {
        let mut n = String::new();
        stdin.read_line(&mut n).unwrap();
        n.trim().parse::<usize>().unwrap()
    };

    let h: Vec<i32> = {
        let mut input = String::new();
        stdin.read_line(&mut input).unwrap();
        let input = input.trim().split_whitespace();

        input.map(|s| s.parse::<i32>().unwrap()).collect()
    };

    let mut value = h[n-1];

    
    for item in h.iter().rev().skip(1) {
        if *item < value+1 {
            value = *item;
        } else if *item > value+1 {
            println!("No");
            return;
        }
    }
    
    println!("Yes");
}


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

int main() {
  int A, B, T;
  cin >> A >> B >> T;
  int counter = 0;
  int t = A;
  while(t <= T + 0.5){
    counter += B;
    t += A;
  }
  cout << counter << endl;
}


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++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

int main(void) {
  string s;
  cin >> s;
  cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

const double pi = M_PI;

vector<pair<int, int> > q;
int f[222222];
int n;
int xs, ys, xt, yt;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d%d%d%d",&xs,&ys,&xt,&yt,&n);
	if (xs > xt) swap(xs, xt), swap(ys, yt);
	for(int i = 1; i <= n; ++i){
		int xx, yy;
		scanf("%d%d",&xx,&yy);
		if (xs == xt && xx == xs && min(ys, yt) < yy && yy < max(ys, yt)){
			printf("%.15lf", abs(ys - yt) * 100.0 + pi * 10 - 20);
			return 0;
		}
		if (ys == yt && yy == ys && min(xs, xt) < xx && xx < max(xs, xt)){
			printf("%.15lf", abs(xs - xt) * 100.0 + pi * 10 - 20);
			return 0;			
		}
		if (xs <= xx && xx <= xt){
			if ((ys <= yy && yy <= yt) || (ys >= yy && yy >= yt))
				q.pb(mp(xx, yy));
		}
	}
	if (ys > yt){
		for(int i = 0; i < q.size(); ++i)
			q[i].second *= -1;
	}
	sort(q.begin(), q.end());
	int an = 0;
	for(int i = 0; i < q.size(); ++i){
		if (an == 0 || q[i].second > f[an]) f[++an] = q[i].second;
		else if (q[i].second < f[1]) f[1] = q[i].second;
		else{
			int l = 1, r = an;
			while (l <= r){
				int md = (l + r) >> 1;
				if (q[i].second < f[md]) r = md - 1;
				else l = md + 1;
			}
			f[l] = q[i].second;
		}
	}
	double lst = abs(xs - xt) * 100.0 + abs(ys - yt) * 100.0 - 1.0 * an * (20 - pi * 5);
	if (an == min(abs(xs - xt), abs(ys - yt)) + 1) lst += pi * 5;
	printf("%.15lf", lst);
	return 0;
}

Measured memory_bytes: 2672
n,a,b = map(int,input().split())
s = input()
count_a = 0
count_b = 0 

for i in range(n):
    if s[i] == 'a':
        if count_a + count_b < a + b:
            count_a += 1
            print('Yes')
        else:
            print('No')
            
    elif s[i] == 'b':
        if count_a + count_b < a + b and count_b < b:
            count_b += 1
            print('Yes')
        else:
            print('No')
    
    else:
        print('No')
    

Measured memory_bytes: 4016
#include <string>
#include <cctype>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	string W,T;
	int ans = 0;
	cin >> W;
	while (1) {
		cin >> T;
		if (T == "END_OF_TEXT") break;
		transform(T.begin(), T.end(), T.begin(), ::tolower);
		if (T == W) ans++;
	}
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int Bitnum(const string& s) {
	int i, ans = 0;
	rep(i, s.size()) {
		if (s[i] == '1')
			ans++;
	}
	return ans;
}

int Bitnum(ll n) {
	int ans = 0;
	while (n) {
		if (n & 1)
			ans++;
		n >>= 1;
	}
	return ans;
}

int Search(vector<int>& d, int n) {
	if (d[n] || n == 0)
		return d[n];
	return d[n] = Search(d, n % Bitnum(n)) + 1;
}

int Init(string& s, int k) {
	if (k <= 0)
		return 0;
	int i, ans = 0;
	rep(i, s.size()) {
		ans <<= 1;
		if (s[i] == '1')
			ans++;
		ans %= k;
	}
	return ans;
}

ll Pow(ll n, ll k, const ll mod){
	if (mod <= 0)
		return 0;
	ll ans = 1, a = n % mod;
	while (k > 0) {
		if (k & 1) {
			ans *= a;
			ans %= mod;
		}
		a *= a;
		a %= mod;
		k >>= 1;
	}
	return ans;
}

int main(void) {
	int num, i, a, b, k, ans;
	string s;
	cin >> num >> s;
	vector<int> d(num + 1, 0);
	k = Bitnum(s);
	a = Init(s, k - 1);
	b = Init(s, k + 1);
	rep(i, num) {
		if (s[i] == '1') {
			if (k == 1) {
				printf("0\n");
				continue;
			}
			ll n = a - Pow(2, num - i - 1, k - 1);
			if (n < 0)
				n += k - 1;
			ans = Search(d, n) + 1;
		}
		else {
			ll n = b + Pow(2, num - i - 1, k + 1);
			n %= k + 1;
			ans = Search(d, n) + 1;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 4432
import sys
input = sys.stdin.readline

#Sから暗証番号Vを作るのではなく、VからSを作れるかを判定する
n = int(input())
s = input()
ans = 0
for i in range(1000):
    t = str(i).zfill(3)
    ti = 0
    for si in range(n):
        if s[si] == t[ti]:
            ti += 1
            if ti == 3:
                break
    if ti == 3:
        ans += 1
print(ans)

Measured memory_bytes: 41052
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define f(a, b, c) for(ull a=b; a<c; a++)
#define fo(a, b, c) for(ull a=b; a<=c; a++)

using namespace std;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ull t;
    cin>>t;
    // while(t--){
    ull min=LONG_LONG_MAX; 
    ull sum=min;
    fo(i, 1, sqrt(t)){
        if(t%i == 0){
            sum = (t/i)+i;
            if(min>sum){
                min=sum;
            }
        }
    }
    cout<<sum-2<<endl;
    // }
    return 0;
}

Measured memory_bytes: 256
N_Y = list(map(int,input().split()))

goal = N_Y[1]/1000 - N_Y[0]
counter = 0

for i in range(N_Y[0]+1):
    if counter == 1:
        break
    number = [[j, N_Y[0]-i-j] for j in range(N_Y[0]-i +1)]
    
    for k in number:
        if 9*k[0] + 4*k[1] == goal:
            counter += 1
            print(k[0], k[1], int(N_Y[0]-k[0]-k[1]))
            break
            
if counter == 0:
    print(-1,-1,-1)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 1000000007
#define INF 0x3fffffff
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 3005
int i2=(mod+1)/2;
int f[N][N];
int a[N];
signed main()
{
	int n=read(),Q=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++) f[i][j]=a[i]>a[j];
	}
	int Mul=1;
	while(Q--)
	{
		Mul=add(Mul,Mul);
		int u=read(),v=read();
		f[u][v]=f[v][u]=mul(add(f[u][v],f[v][u]),i2);
		for(int i=1;i<=n;i++)
		{
			if(i==u||i==v) continue;
			f[i][u]=f[i][v]=mul(add(f[i][u],f[i][v]),i2);
			f[u][i]=f[v][i]=mul(add(f[u][i],f[v][i]),i2);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++) ans=add(ans,f[i][j]);
	}
	cout<<mul(ans,Mul)<<endl;
	return 0;
}



Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //

int main() {
	in(ll, N);
	in(string, A, B, C);
	ll ans = 0;
	loop(i, N) {
		if (A[i] == B[i] && B[i] == C[i])
			continue;
		else if (A[i] != B[i] && B[i] != C[i] && C[i] != A[i])
			ans += 2;
		else
			ans += 1;
	}
	out(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (200010)
#define P ()
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,a[N],pos[N],T[N],f[N];
int main(){
	read(n); for(int i=1;i<=n;i++)read(a[i]),pos[a[i]]=i;
	for(int i=n-1;i;i--){
		if(T[i+1]==0){
			if(pos[i]>pos[i+1])T[i]=1,f[i]=i+1;
			else T[i]=0;
		}
		else{
			int s=(pos[f[i+1]]<pos[i])+(pos[i]<pos[i+1])+(pos[i+1]<pos[f[i+1]]);
			if(s==2)T[i]=T[i+1],f[i]=f[i+1];
			else T[i]=T[i+1]+1,f[i]=i+1;
		}
	}
	cout<<T[1]<<endl;
}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	for(ll a = -1000; a <= 1000; ++a){
		for(ll b = -1000; b <= 1000; ++b){
			ll y = pow(a,5) - pow(b,5);
			if(x == y){
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4096
N,M = map(int,input().split())

L =[]
R =[]

for i in range(M):
    l,r = [int(i) for i in input().split()]
    L.append(l)
    R.append(r)

if max(L) > min(R):
    ans = 0
else :
    ans= min(R)-max(L)+1
    
print(ans)

Measured memory_bytes: 10996
#include <iostream>

using namespace std;

int main() 
{
	int n,a,b,c;
	cin>>n;
	int arr[n][4];
	for(int i=0;i<n;i++)
	{
	    cin>>a>>b>>c;
	    arr[i][1]=a;
	    arr[i][2]=b;
	    arr[i][3]=c;
	}
	int cost[n][4];
	for(int i=1;i<=3;i++)
	cost[0][i]=arr[0][i];
	
	for(int i=1;i<n;i++)
	{
	    cost[i][1]=arr[i][1]+max(cost[i-1][2],cost[i-1][3]);
	    cost[i][2]=arr[i][2]+max(cost[i-1][1],cost[i-1][3]);
	    cost[i][3]=arr[i][3]+max(cost[i-1][2],cost[i-1][1]);
	}
	cout<<max(cost[n-1][3],max(cost[n-1][2],cost[n-1][1]));
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    bool a = true;
    for(int i =0;i<S.size()/2;i++){
        if(S.at(i)!=S.at(S.size()-i-1)) a = false;   
    }
    for(int i = 0;i<S.size()/4;i++){
        if(S.at(i) != S.at(S.size()/2-i-1)) a = false;
    }
    for(int i = 0;i<S.size()/4;i++){
        if(S.at((S.size()+3)/2+i-1) != S.at(S.size()-i-1)) a = false;
    }
    if(a==true) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),ed=(b);i<=ed;++i)
#define DREP(i,a,b) for(int i=(a),ed=(b);i>=ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x; 
}

const int N=2e5+10;
int n,a[N],s[N],len[2],stk[2][N],mx[2][N],sum[2],maxn[N],sufsum[N];

int tr[N*50],ch[N*50][2],cnt;
struct SegmentTree{
    int rt[N];
    inline void pushup(int x){tr[x]=max(tr[ch[x][0]],tr[ch[x][1]]);}
    inline void Insert(int &p,int pre,int l,int r,int pos,int v){
	p=++cnt;if(l==r){tr[p]=max(tr[p],v);return;}
	int mid=(l+r)>>1;
	if(pos<=mid){ch[p][1]=ch[pre][1];Insert(ch[p][0],ch[pre][0],l,mid,pos,v);}
	else{ch[p][0]=ch[pre][0];Insert(ch[p][1],ch[pre][1],mid+1,r,pos,v);}
	pushup(p);
    }
    inline int Query(int p,int l,int r,int L,int R){
	if(!p||L>R)return 0;
	if(L<=l&&r<=R)return tr[p];
	int mid=(l+r)>>1,res=0;
	if(L<=mid)res=max(res,Query(ch[p][0],l,mid,L,R));
	if(mid<R)res=max(res,Query(ch[p][1],mid+1,r,L,R));
	return res;
    }
}T[2];

inline bool check(int op,int i){
    int ned=sum[op]+sufsum[i+1]-sum[op^1];
    if(ned<0)return 0;
    return T[ned&1].Query(T[ned&1].rt[i+1],1,n,mx[op^1][len[op^1]]+1,n)>=ned;
}

int main(){
//    freopen("in.in","r",stdin);freopen("out.out","w",stdout);
    n=read();REP(i,1,n)a[i]=read(),maxn[i]=max(maxn[i-1],a[i]);
    DREP(i,n,1)sufsum[i]=sufsum[i+1]+(a[i]==maxn[i]);
    DREP(i,n,1){
	int t0=T[0].Query(T[0].rt[i+1],1,n,a[i]+1,n),t1=T[1].Query(T[1].rt[i+1],1,n,a[i]+1,n);
//	cout<<t0<<' '<<t1<<endl;
	if(a[i]==maxn[i]){
	    T[0].Insert(T[0].rt[i],T[0].rt[i+1],1,n,a[i],t0+2);
	    if(t1)T[1].Insert(T[1].rt[i],T[1].rt[i+1],1,n,a[i],t1+2);
	    else T[1].rt[i]=T[1].rt[i+1];
	}
	else{
	    T[1].Insert(T[1].rt[i],T[1].rt[i+1],1,n,a[i],t0+1);
	    if(t1)T[0].Insert(T[0].rt[i],T[0].rt[i+1],1,n,a[i],t1+1);
	    else T[0].rt[i]=T[0].rt[i+1];
	}
    }
    REP(i,1,n){
	s[i]=-1;
	REP(j,0,1){
	    stk[j][++len[j]]=a[i];
	    mx[j][len[j]]=max(mx[j][len[j]-1],a[i]);
	    sum[j]+=(mx[j][len[j]]==a[i]);
	    if(check(0,i)){s[i]=j;break;}
	    if(check(1,i)){s[i]=j;break;}
	    sum[j]-=(mx[j][len[j]]==a[i]);
	    --len[j];
	}
	if(!~s[i]){puts("-1");return 0;}
    }
    REP(i,1,n)printf("%d",s[i]);
    puts("");
    return 0;
}


Measured memory_bytes: 102912
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define f first
#define s second

using namespace std;
typedef long long ll;

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

	int n;
	cin >> n;
	vector<int> ar(n);
	for(int &it : ar){
		cin >> it;
	}
	int res = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(ar[i] != ar[j] && ar[j] != ar[k] && ar[i] != ar[k]){
					if(ar[i]+ar[j] > ar[k] && ar[i]+ar[k] > ar[j] && ar[j]+ar[k] > ar[i]){
						res++;
					}
				}
			}
		}
	}
	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3636
main :: IO()
main = do
    n <- getLine
    ls <- map read . words <$> getLine
    print $ solve ls

solve :: [Int] -> Int
solve ls 
    | ls == []							= 0
    | canShow (last ls) (init ls)		= 1 + (solve $ init ls)
    | otherwise							= solve $ init ls

canShow :: Int -> [Int] -> Bool
canShow myBld otherBld
    | otherBld == []			= True
    | myBld >= head otherBld	= canShow myBld (tail otherBld)
    | otherwise					= False

Measured memory_bytes: 636
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,u,v,ans=1;
vector<int> g[maxn];
int deg[maxn];
pii edge[maxn];
map<pii,int> m;
bool vis[maxn];
void dfs(int cur,int fa,int col){
	if(vis[cur]) return;
	vis[cur] = 1;
	sort(all(g[cur]));
	for(int i = 0;i < g[cur].size();i++){
		int v = g[cur][i];
//		cout << cur << " " << v << endl;
		if(v == fa) continue;
		m[mp(cur,v)] = (col + i) % ans;
		m[mp(v,cur)] = (col + i) % ans;
		dfs(v,cur,(col + i) % ans);
	}
	return;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	rep(i,0,n-2){
		cin >> u >> v;
		g[u].pb(v); g[v].pb(u);
		edge[i] = mp(u,v);
		deg[u]++; deg[v]++;
		ans = max(ans,max(deg[u],deg[v]));
	}
//	rep(i,1,n) sort(all(g[i]));
	cout << ans << endl;
	dfs(1,-1,0);
	rep(i,0,n-2){
		pii now = edge[i];
		cout << m[now]+1 << endl;
	}
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

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

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

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    vector<int> As = A, Bs = B;
    sort(As.begin(), As.end());
    sort(Bs.begin(), Bs.end());
    for (int i = 0; i < N; i++) {
        if (As[i] > Bs[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 0; i < N - 1; i++) {
        if (As[i] == As[i+1] || As[i+1] <= Bs[i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    vector<pair<int, int>> AB(N);
    for (int i = 0; i < N; i++) AB[i] = {A[i], B[i]};
    sort(AB.begin(), AB.end(), [](auto& p1, auto& p2) { return p1.second < p2.second; });
    vector<pair<int, int>> p(N);
    for (int i = 0; i < N; i++) p[i] = {AB[i].first, i};
    sort(p.begin(), p.end());

    vector<bool> visited(N);
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int size = 0;
        int j = i;
        while (!visited[j]) {
            visited[j] = true;
            j = p[j].second;
            size++;
        }
        if (size) cnt += size - 1;
    }
    cout << (cnt <= N - 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 6344
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println((in.nextInt() + in.nextInt()) * in.nextInt() / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main()
{
    int N;
    int A;
    int B;
    int sum_money;
    
    cin >> N >> A >> B;
    
    sum_money = N*A;
    
    if(sum_money <= B)
    {
        cout << sum_money << endl;
    }
    else
    {
        cout << B << endl;
    }
}

Measured memory_bytes: 256
s = input()
t = input()

s = sorted(s)
t = sorted(t)

# print(s,t)
if s[0] < t[-1]:
    print('Yes')
    exit()
elif s[0] > t[-1]:
    print('No')
    exit()
elif len(set(s)) ==1 and len(set(t)) ==1 and len(s) < len(t):
    print('Yes')
    exit()
else:
    print('No')


Measured memory_bytes: 3188
n, a, b, c, d = map(int,input().split())
s = input()

flag = False

if c < d:
  if s[a-1:c].count('##') == 0 and s[b-1:d].count('##') == 0:
    flag = True
else:
  if s[a-1:c].count('##') == 0 and s[b-2:d+1].count('...') >= 1:
    flag = True

if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3572
n, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
a = [i for i in range(n+1)]  # 1~nまで
ans = 0
mod = pow(10, 9)+7
sum_min = sum(a[:k])  # 前からkコの和
sum_max = sum(a[-k:])  # 後ろからkコ
for i in range(k, n+1):
    ans += sum_max-sum_min+1
    ans %= mod
    sum_min += a[i]  # 足してく
    sum_max += a[-i-1]
ans += 1  # 全部選んだ時
print(ans % mod)


Measured memory_bytes: 80700
from collections import deque

K=int(input())

todo=deque(list(map(str,range(1,10))))

count=0

while todo:
    num=todo.popleft()
    count+=1

    if count==K:
        print(num)
        exit()
    
    base=int(num[-1])
    n1=base-1
    if n1!=-1:
        todo.append(num+str(n1))
    
    n2=base
    todo.append(num+str(n2))

    n3=base+1

    if n3!=10:
        todo.append(num+str(n3))

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

using ll = long long;
using ld = long double;

int main()
{
    int n,a,b, ans=0;
    cin >> n>>a>>b;
    
    for(int i = 1; i <= n; i++)
    {
        int now = i;
        int cnt = 0;
        while(now>0){
            cnt += now%10;
            now/=10;
        }
        if(a<=cnt && cnt <=b) 
        {
            ans +=i;
        }
        
    }
    

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
 
#ifdef LUCARIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
 
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define f first 
#define s second 
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define mp make_pair    
#define endl "\n"
 
#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = b - 1; i >= a; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define trans(a,b) trasform(a.begin(),a.end(),a.begin(),b)
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)
 
#define infll (ll)1e15
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-10

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int n;
int a[22][22];
int dp[22][1<<22];

int solve(int i, int mask){
    if(i == n)return (mask == 0);
    int &r = dp[i][mask];
    if(~r)return r;
    r = 0;
    fore(j,0,n){
        if((mask & (a[i][j]<<j)))
        r  = (r + solve(i+1,mask^(a[i][j]<<j)))%mod;
    }
    return r;
}

int32_t main(int32_t argc, char const *argv[]){
    FIN;
    mm(dp,-1);
    cin>>n;
    fore(i,0,n)fore(j,0,n)cin>>a[i][j];
    cout<<solve(0,(1<<n)-1);


    return 0;
}





































































































































































































































































































































































//formulas 
//cero = r/k  -(l/k + (l%k!=0)) +1; cantidad de numeros divisibles por k en el intervalo [l r]
//upper_bound primer elemento mayot estricto
//lower_bound primer elemento mayo o igual
//al hacer bfs con distancia recordar simpre antes de visitar preguntar si ya llegue antes co
//un peso menor
//setprecision(15)




//PROGRAMADO POR xXLucarioXx    


Measured memory_bytes: 721280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m;
	cin>>n>>m;
	vvi cost(n,vi(n,inf));
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		cost[a][b]=c;
	}
	vvi dp(1<<n,vi(n,inf));
	dp[(1<<n)-1][0]=0;
	for(int i=(1<<n)-2;i>=0;i--)rep(j,n){
		rep(k,n)if((i&1<<k)==0){
			dp[i][j]=min(dp[i][j],dp[i|1<<k][k]+cost[j][k]);
		}
	}
	if(dp[0][0]!=inf)cout<<dp[0][0]<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 4436