akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <set>
#define x first
#define y second
using namespace std;
typedef pair <double,double> pii;
int N;
pii points[55];
double error = 0.0000001;

double distanceSquare(double ax, double ay, double bx, double by){
    double distx = ax-bx;
    double disty = ay-by;
    return distx*distx+disty*disty;
}

bool works(double rad){
    set <pii> intersect;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            pii mid;
            mid.x = (points[i].x + points[j].x) / 2;
            mid.y = (points[i].y + points[j].y) / 2;
            double distx = mid.x - points[i].x;
            double disty = mid.y - points[i].y;
            double leg = rad * rad - distx * distx - disty * disty;
            if (0 - leg > error * error) {
                intersect.clear();
                return false;
            }
            leg = sqrt(abs(leg));
            double mag = sqrt(distx*distx+disty*disty);
            pii normal = {-disty / mag, distx / mag};
            pii vect = {normal.x*leg, normal.y*leg};
            intersect.insert({mid.x+vect.x, mid.y+vect.y});
            intersect.insert({mid.x-vect.x, mid.y-vect.y});
        }
    }

    bool ok = false;
    for (auto it: intersect){
        bool indeed = true;
        for (int i=0; i<N; i++){
            if (distanceSquare(it.x, it.y, points[i].x, points[i].y) - rad*rad > error) {
                indeed = false;
            }
        }
        if (indeed) ok = true;
    }
    intersect.clear();
    return ok;
}

int main() {
    cin >> N;
    for (int i=0; i<N; i++){
        scanf("%lf %lf", &points[i].x, &points[i].y);
    }

    double l = 0, r = 1500, m = 0;
    while (l+error < r) {
        m = (l+r)/2;
        if (works(m)) r = m;
        else l = m;
    }
    printf("%.7lf\n", m);
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();

        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = in.nextInt();
        }

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n - k + 1; i++) {
            int l = 0;
            l += x[i + k - 1] - x[i];
            l += Math.min(Math.abs(x[i + k - 1]), Math.abs(x[i]));

            ans = Math.min(ans, l);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 59344
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll Powb(ll b,ll n,ll m);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l=0,r=0,a=0,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    string s;
    cin >> s;
    n = s.size();
    for(i=0;i<n;i++)
        if(i%2==0)
        cout << s[i];
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 3696
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n;
    cin>>n;
    int a[n];
    int c=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        if(!a[i])
            c++;
    }
    if(c)
    {
        cout<<0;
        exit(0);
    }
    int res = a[0];
    for(int i  = 1 ; i<n ;i++)
    {
            int dum;
         if(__builtin_smulll_overflow (res,  a[i], &dum))
         {
            cout<<-1;
            exit(0);
         }
         else
            res*=a[i];
    }
    if(res>INF)
        cout<<-1<<endl;
    else
        cout<<res;

    printclock;
    return 0;
}


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

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

ll N, M;
typedef vector<vector<ll>> G;
G graph;
ll color[100050];

bool dfs(ll v, ll c) {
    color[v] = c; // 頂点v を cで塗る
    for (ll i = 0; i < graph[v].size(); i++) {
        // 隣接している頂点が同じ色なら false
        if (color[graph[v][i]] == c) return false;

        if (color[graph[v][i]] == 0 && !dfs(graph[v][i], -c)) return false;
    }

    // 全ての頂点をぬれた
    return true;
}


int main() {
    cin >> N >> M;
    graph = G(N);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    ll b = 0, w = 0;
    if (dfs(0, 1)) {
        rep(i, N) {
            if (color[i] == 1) {
                b++;
            } else if (color[i] == -1) {
                w++;
            }
        }
        cout << b * w - M << endl;
    } else {
        // 二部グラフではない場合
        cout << N * (N - 1) / 2 - M << endl;
    }
}

Measured memory_bytes: 7424
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

struct Mod {
    static uint64_t PRIME;
    uint64_t value = 0;
    Mod()
    : value(0) {}
    Mod(ll v) {
        if (v >= 0) {
            value = v % PRIME;
        } else {
            value = PRIME - (-v) % PRIME;
        }
    }
    Mod operator+(const Mod& rhs) const { return Mod(*this) += rhs; }
    Mod& operator+=(const Mod& rhs) {
        value += rhs.value;
        if (value >= PRIME) {
            value -= PRIME;
        }
        return *this;
    }
    Mod operator-(const Mod& rhs) const { return Mod(*this) -= rhs; }
    Mod& operator-=(const Mod& rhs) {
        if (value < rhs.value) {
            value += PRIME;
        }
        value -= rhs.value;
        return *this;
    }
    Mod operator*(const Mod& rhs) const { return Mod(*this) *= rhs; }
    Mod& operator*=(const Mod& rhs) {
        value = (value * rhs.value) % PRIME;
        return *this;
    }
    Mod inv() const { return power(*this, PRIME - 2); }
    Mod operator/(const Mod& rhs) const { return Mod(*this) /= rhs; }
    Mod& operator/=(const Mod& rhs) {
        *this *= rhs.inv();
        return *this;
    }
    static Mod power(Mod rhs, ll exp) {
        Mod ans = 1;
        while (exp > 0) {
            if (exp % 2) {
                ans *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return ans;
    }
};
uint64_t Mod::PRIME = 1000000007;

vector<Mod> fact;
vector<Mod> fact_inv;

Mod binom(ll n, ll r) {
    if (!(0 <= n && 0 <= r && r <= n)) {
        return 0;
    } else {
        return fact[n] * fact_inv[r] * fact_inv[n-r];
    }
}

int main() {
    ll H, W;
    cin >> H >> W;
    ll A, B;
    cin >> A >> B;
    fact.resize(W+H+1, 1);
    fact_inv.resize(W+H+1, 1);
    rep(n,1,W+H+1) {
        fact[n] = fact[n-1] * n;
        fact_inv[n] = fact_inv[n-1] / n;
    }
    Mod ans = 0;
    rep(y,0,H-A) {
        ans += binom(B+y, y) * binom(W-(B+1)-1 + H-y-1, H-y-1);
    }
    ans += binom(B+1-1 + H-A-1, H-A-1) * binom(A-1+W-B-1, A-1);
    cout << ans.value << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int temp = 1;
    vector<ll> acc;
    for (int i = 0; i < n; i++)
    {
        if (i == 0 & s[i] == '0')
        {
            acc.push_back(0);
        }
        if (i == n - 1)
        {
            acc.push_back(temp);
            if (s[i] == '0')
            {
                acc.push_back(0);
            }
            continue;
        }
        if (s[i] == s[i + 1])
        {
            temp++;
        }
        else
        {
            acc.push_back(temp);
            temp = 1;
        }
    }

    vector<ll> acc2(acc.size() + 1);
    for (int i = 0; i < acc.size(); i++)
    {
        acc2[i + 1] = acc[i] + acc2[i];
    }
    ll ans = -1;
    for (int i = 0; i < acc2.size(); i += 2)
    {
        int right = min(i + 2 * k + 1, int(acc2.size() - 1));
        ans = max(ans, acc2[right] - acc2[i]);
    }
    cout << ans << endl;
    return 0;
}

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

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

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#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 (ll i = m; i < n; i++)

int n,k;
int s[15];
set<int> st;
bool used[15]{};

void dfs(int i, int t){
    if(i==0){
        st.insert(t);
    }
    REP(j,n){
        if(used[j])continue;
        used[j] = true;
        dfs(i-1,t*(s[j]>9?100:10)+s[j]);
        used[j] = false;
    }
}

int main() {
    while(1){
        cin >> n >> k;
        if(n==0)break;
        REP(i,n)cin >> s[i];
        st.clear();
        fill(used,used+15,false);
        dfs(k,0);
        cout << st.size() << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    int sum = 0;
    int count = 0;
    int total;
    for(int i = 1;i <= N - 1;i++){
        sum += N - i;
    }
    for(int i = 1;i <= M -1;i++){
        count += M - i;
    }
    total = sum + count;
    cout << total << endl;
}

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

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    int n,l;
    cin>>n;
    l=n%1000;
    if(l==0)cout<<0<<endl;
    else cout<<1000-l<<endl;
}




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

INF = 10**14

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

maxd = 0
Q = int(input())
Query = []
Color = []
for _ in range(Q):
    v, d, c = map(int, input().split())
    if d > maxd:
        maxd = d
    Query.append((v-1, d))
    Color.append(c)

Query = Query[::-1]
Color = Color[::-1]

dp = [[INF]*(maxd+1) for _ in range(N)]
for i, (v, d) in enumerate(Query):
    if i < dp[v][d]:
        dp[v][d] = i

for d in reversed(range(maxd)):
    for v in range(N):
        if dp[v][d+1] < dp[v][d]:
            dp[v][d] = dp[v][d+1]
        for nv in graph[v]:
            if dp[v][d+1] < dp[nv][d]:
                dp[nv][d] = dp[v][d+1]

for v in range(N):
    seq = dp[v][0]
    if seq == INF:
        print(0)
    else:
        print(Color[seq])


Measured memory_bytes: 97584
N,K = map(int,input().split())
ans = 1
res = 0
for i in range(N):
    ans = i + 1
    aro = 1
    while ans < K:
        ans *= 2
        aro += 1
#     print(aro)
    res += 0.5**(aro-1)
print(res/N)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define debug(x) cerr << #x << ": " << (x) << endl
#define debug2(x, y) cerr << #x << ": " << (x) << " " << #y << ": " << y << endl;
#define int long long
using namespace std;
using II = pair<int, int>;
using VII = vector<II>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;
double EPS = 1e-5;

signed main() {
  int N; cin >> N;
  vector<double> a(N);
  double to = 0;
  REP (i, N) {
    cin >>a[i];
    to += a[i];
  }
  to /= N;
  int in = -1;
  double mi = 1e10;
  REP (i, N) {
    if (abs(a[i] - to) < mi) {
      in = i;
      mi = abs(a[i] - to);
    }
  }
  cout << in << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
bool a[509][509];
vector<P>idx;

int main(){
  int h,w;
  cin>>h>>w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      int b;
      cin>>b;
      a[i][j]=b%2;
    }
  }
  bool f=0;
  for(int i=0;i<=h;i++){
    if(i%2){
      for(int j=1;j<=w;j++){
        if(a[i][j]==1){
          if(f==0){
            f=1;
            idx.push_back(P(i,j));
          }
          else{
            f=0;
            idx.push_back(P(i,j));
          }
        }
        else if(f==1){
          idx.push_back(P(i,j));
          idx.push_back(P(i,j));
        }
      }
    }
    else{
      for(int j=w;j>=1;j--){
        if(a[i][j]==1){
          if(f==0){
            f=1;
            idx.push_back(P(i,j));
          }
          else{
            f=0;
            idx.push_back(P(i,j));
          }
        }
        else if(f==1){
          idx.push_back(P(i,j));
          idx.push_back(P(i,j));
        }
      }
    }
  }
  cout<<idx.size()/2<<endl;
  for(int i=1;i<idx.size();i+=2){
    cout<<idx[i-1].first<<' '<<idx[i-1].second<<' ';
    cout<<idx[i].first<<' '<<idx[i].second<<endl;
  }
  return(0);
}

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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
//#define int ll
const int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


int h, w;
vector<string> grid(50);
int d[50][50];
typedef pair<int, int> Vec2;

int dfs() {
	rep(i, 50) {
		rep(j, 50) {
			d[i][j] = INF;
		}
	}
	queue<Vec2> Q;
	Q.push({ 0,0 });
	d[0][0] = 0;
	while (!Q.empty()) {
		int x = Q.front().first;
		int y = Q.front().second;
		Q.pop();
		if (x == w-1 and y == h-1) return d[x][y];
		rep(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx >= 0 and nx < w and ny >= 0 and ny < h and grid[ny][nx] == '.') {
				if (d[nx][ny] == INF) {
					d[nx][ny] = d[x][y] + 1;
					Q.push({ nx,ny });
				}
			}
		}
	}
	return -1;
}

signed main() {
	ios::sync_with_stdio(true);
	cin >> h >> w;
	int score = 0;
	rep(i, h)
		cin >> grid[i];
	int dist = dfs();
	if (dist == -1) {
		cout << -1 << endl;
	}
	else {
		int nw = 0;
		rep(i, h) {
			rep(j, w) {
				if (grid[i][j] == '.')
					nw++;
			}
		}
		cout << nw - (dist + 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def main(): 
    n = input()
    digit = len(n)

    ans = 0

    if digit == 1:
        ans+= int(n)
    elif digit == 2:
        ans+= 9
    elif digit == 3:
        ans+= 9 + int(n) - 99
    elif digit == 4:
        ans+= 9 + 900
    elif digit == 5:
        ans+= 9 + 900 + int(n) - 9999
    elif digit == 6:
        ans+= 9 + 900 + 90000

    print(ans)


if __name__ == "__main__":
    main() 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define int int64_t
#define pb push_back
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};
typedef gp_hash_table<int, int, chash> ht;
const int MOD = 1e9 + 7;
const int N = 1e5 + 3;
int dp[N][3],d[N][3],n;
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 0 ; j < 3 ; j ++){
			dp[i][j] = -LLONG_MAX;
			cin >> d[i][j];
		}
		
	for(int i = 0 ; i < n ; i ++)
		for(int j = 0 ; j < 3 ; j ++)
			for(int k = 0 ; k < 3 ; k ++)
				if(k != j) dp[i+1][k] = max(dp[i+1][k],dp[i][j] + d[i+1][k]);
				
	cout << *max_element(dp[n] , dp[n] + 3);
}




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

long long ans = 0;
int march[10];
void rec(long long now, int i, int j) {
    if (i == 3) {
        ans += now;
        return;
    }
    if (j == 5) {
        return;
    }
    if (march[j]) {
        rec(now * march[j], i + 1, j + 1);
    }
    rec(now, i, j + 1);
}

int main() {
    int n;
    cin >> n;
    memset(march, 0, sizeof(march));
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        char c = s[0];
        for (int j = 0; j < 5; j++) {
            if (c == "MARCH"[j])
                march[j]++;
        }
    }
    int kind = 0;
    for (int i = 0; i < 5; i++) {
        if (march[i]) {
            kind++;
        }
    }
    if (kind < 3) {
        cout << 0;
        return 0;
    }
    rec(1, 0, 0);

    cout << ans;
}

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

using namespace std;

typedef long long ll;


int main(int, char**)
{
	ll n, m;
	cin >> n >> m;

	vector<ll> rem;
	rem.resize(m);
	for (int i = 0; i < m; ++i)
		rem[i] = 0;

	for (int i = 0; i < n; ++i) {
		ll k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			ll y;
			cin >> y;
			rem[y - 1]++;
		}
	}
	ll ans = 0;
	for (int i = 0; i < m; ++i)
		if (rem[i] >= n)
			ans++;

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


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
long long int lis[3010][3010];
long long int fie[3010][3010][5][2];
int main(){
    long long int R,C,K;
    cin>>R>>C>>K;
    for(int i=0;i<K;i++){
        int a,b,c;
        cin>>a>>b>>c;
        lis[a][b]=c;
    }
    //for(int i=0;i<4;i++){
        for(int j=1;j<=R;j++){
            for(int k=1;k<=C;k++){
                for(int l=0;l<4;l++){
                    for(int m=0;m<2;m++){
                        fie[j+1][k][0][0]=max(fie[j][k][l][m],fie[j+1][k][0][0]);
                        fie[j][k+1][l][0]=max(fie[j][k][l][m],fie[j][k+1][l][0]);
                        if(l!=3&&m==0)fie[j][k][l+1][1]=max(fie[j][k][l][m]+lis[j][k],fie[j][k][l+1][1]);
                    }
                }
            }
        }
    //}
    long long int ans=0;
    for(int i=0;i<=3;i++){
        for(int j=0;j<2;j++){
            ans=max(ans,fie[R][C][i][j]);
        }
    }
    cout<<ans<<endl;

    /*
    for(int i=0;i<=3;i++){
        for(int j=1;j<=2;j++){
            for(int k=1;k<=2;k++){
                printf("[%lld]",fie[i][k][l]);
            }
            puts("");
        }
        puts("==========");
    }
*/

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int>data(n);
  float sumd = 0;
  int sum = 0;
  for(int i = 0;i < n;i++){
    cin >> data[i];
    sum += data[i];
    sumd += data[i];
  }
  if(sumd/n-sum/n >= 0.5){
    int a = sum/n+1;
    int ans = 0;
    for(int i = 0;i < n;i++){
      ans += (data[i]-a)*(data[i]-a);
    }
    cout << ans << endl;
    return 0;
  }
  else{
    int a = sum/n;
    int ans = 0;
    for(int i = 0;i < n;i++){
      ans += (data[i]-a)*(data[i]-a);
    }
    cout << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 256
<?php
    $inArray = [];
    while (!feof(STDIN) ) {
        foreach(str_split(trim(fgets(STDIN))) as $a){
            $inArray[] = $a;
        }
    }
        
    $searchArray = range("a", "z");
    foreach($searchArray as $searchVal){
        $count = 0;
        foreach($inArray as $inVal){
            if($searchVal == $inVal){
                $count = $count + 1; 
            }
            if(strtoupper($searchVal) == $inVal){
                $count = $count + 1; 
            }
        }
        echo $searchVal." : ".$count.PHP_EOL;
    }


Measured memory_bytes: 9380
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
    mp::cpp_int ans=0;
    ll n;
    
    mp::cpp_int souwa=0;
cin>>n;
vector<mp::cpp_int> a(n);
for (int i = 0; i < n; i++)
{
    cin>>a.at(i);
    souwa+=a.at(i);
}
for (int i = 0; i < n; i++)
{
    ans+=a.at(i)*souwa;
    ans-=a.at(i)*a.at(i);
}
ans/=2;
ans=ans%1000000007;
cout<<ans<<endl;





    return 0;
}

Measured memory_bytes: 9632
#include<bits/stdc++.h>
using namespace std;
const int maxn=2005;
const int maxs=20;
struct Circle
{
	double x,y,z,r;
	Circle(double X=0,double Y=0,double Z=0,double R=0)
	{
		x=X;y=Y;z=Z;r=R;
	}
	Circle operator -(const Circle &p)
	{
		return Circle(x-p.x,y-p.y,z-p.z,0);
	}
}cir[maxn],sor[maxs],o;
bitset<maxn> sp[maxs],now;
#define sqr(v) ((v)*(v))
const double eps=1e-8;
bool cross(int i,int j)
{
	Circle vec=o-sor[i];
	double a=sqr(vec.x)+sqr(vec.y)+sqr(vec.z);
	double b=2*vec.x*(sor[i].x-cir[j].x)+2*vec.y*(sor[i].y-cir[j].y)+2*vec.z*(sor[i].z-cir[j].z);
	double c=sqr(sor[i].x-cir[j].x)+sqr(sor[i].y-cir[j].y)+sqr(sor[i].z-cir[j].z)-sqr(cir[j].r);
	double delta=b*b-4*a*c;
	if(delta<-eps)return false;
	if(delta<eps)
	{
		double t=-b/(2*a);
		if(-eps<t&&t<1+eps)return true;
	}
	else
	{
		double t1=(-b+sqrt(delta))/(2*a);
		if(-eps<t1&&t1<1+eps)return true;
		double t2=(-b-sqrt(delta))/(2*a);
		if(-eps<t2&&t2<1+eps)return true;
	}
	return false;
}
int main()
{
	int n,m,r,i,j;
	double tmp,res;
	while(scanf("%d%d%d",&n,&m,&r)!=EOF)
	{
		if(!n&&!m&&!r)break;
		for(i=0;i<n;++i)
			scanf("%lf%lf%lf%lf",&cir[i].x,&cir[i].y,&cir[i].z,&cir[i].r);
		for(i=0;i<m;++i)
		{
			sp[i].reset();
			scanf("%lf%lf%lf%lf",&sor[i].x,&sor[i].y,&sor[i].z,&sor[i].r);
		}
		scanf("%lf%lf%lf",&o.x,&o.y,&o.z);
		for(i=0;i<m;++i)
			for(j=0;j<n;++j)
				if(cross(i,j))
				{
					//cout <<i<<" "<<j<<endl;
					sp[i][j]=1;
				}
		res=0;
		for(i=0;i<(1<<m);++i)
		{
			tmp=0;
			now.reset();
			for(j=0;(1<<j)<=i;++j)
				if(i&(1<<j))
				{
					now|=sp[j];
					tmp+=sor[j].r/(sqr(sor[j].x-o.x)+sqr(sor[j].y-o.y)+sqr(sor[j].z-o.z));
				}
			if(now.count()<=r&&tmp>res)res=tmp;
		}
		printf("%.9f\n",res);
	}
	return 0;
}

Measured memory_bytes: 1320
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, std::vector<long long> A){

    if(A[0]!=0){
        cout<<-1<<endl;
        return;
    }

    lli ans = A[N-1];
    for(lli i=N-2;i>=0;i--){
        if(A[i+1]-A[i] == 1)continue;
        if(A[i+1]-A[i]>1){
            cout<<-1<<endl;
            return;
        } 
        ans += A[i];
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
import java.awt.geom.*;
import java.util.*;
public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			String abstr = ("" + ((double)a / b));
			String [] ab =  abstr.split("\\.");
			int sum = 0;
			int len = Math.min(n, ab[1].length());
			for(int i = 0; i < len; i++){
				sum += ab[1].charAt(i) - '0';
			}
			System.out.println(sum);
		}
	}
	
	public static void main(String [] args){
		new Main().doit();
	}
}

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

int main(){

  int N;
 
  cin>>N;
  
  int min=300000;

  int now=0;
  int count=0;
  
  for(int i=0;i<N;i++){
    cin>>now;
	if(min>now){min=now;count++;}
    else continue;
  }

  cout<<count;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 610;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int px[N*N],py[N*N],f[N][N],n,in[N][N];
void solve(int x,int y){
	for(int k=0;k<4;k++){
		int tx=x+dx[k],ty=y+dy[k];
		if(tx<1||ty<1||tx>n||ty>n) continue;
		if(f[x][y]+in[x][y]<f[tx][ty]){
			f[tx][ty]=f[x][y]+in[x][y];
			solve(tx,ty);
		}
	}
}
int main(){
	read(n);
	for(int i=1;i<=n*n;i++){
		int x;read(x);
		px[i]=(x-1)/n+1;
		py[i]=(x-1)%n+1;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			f[i][j]=min(i-1,min(n-i,min(j-1,n-j))),in[i][j]=1;
	ll ans=0;
	for(int i=1;i<=n*n;i++){
		ans+=f[px[i]][py[i]];
		in[px[i]][py[i]]=0;
		for(int k=0;k<4;k++){
			int tx=px[i]+dx[k],ty=py[i]+dy[k];
			if(tx<1||ty<1||tx>n||ty>n) continue;
			if(f[px[i]][py[i]]<f[tx][ty]){
				f[tx][ty]=f[px[i]][py[i]];
				solve(tx,ty);
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}



Measured memory_bytes: 23284
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  ll k=s.size();
  ll count=0;
  rep(i,k){
    if(s[i]=='o')count++;
  }
  if(count+(15-k)>=8){
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int n, m;
  cin >> n >> m;
  int p = pow(2, m);
  int x = 0;
  x += (1900 * m + (n - m) * 100) * p;
  cout << x << endl;
}


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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long gcd(long long x, long long y){
    if(x < y) swap(x, y);
    return (x % y ? gcd(y, x % y) : y);
}

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

    long long a, b;
    cin >> a >> b;

    long long g = gcd(a, b);
    
    vector<pair<long long, long long>> p = prime_factorize(g);
    cout << p.size() + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
 
string s;
int a[30];
 
int main()
{
	cin>>s;
	for(int i=0; i<s.length(); i++) a[s[i]-'a']=1;
	for(int i=0; i<26; i++)
		if(a[i]==0){ cout<<(char)(i+'a')<<endl; return 0; }
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define eb emplace_back
#define mp make_pair
using namespace std;
const int MAX_N=3e5+10;
const int mod=1e9+7;
ll a[MAX_N],b[70],c[70],d[70],n;

int main(){
    b[0]=1;
    for(int i=1;i<=60;i++){
        b[i]=b[i-1]*2LL%mod;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<=60;j++){
            if(((a[i]>>j)&1)){
                (ans+=d[j]*b[j]%mod)%=mod;
            }else{
                (ans+=c[j]*b[j]%mod)%=mod;
            }
        }
        for(int j=0;j<=60;j++){
            if(((a[i]>>j)&1)){
                c[j]++;
            }else{
                d[j]++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b;
    cin>>a>>b;
    ll sum=0;
    for(int i=0;i<b;i++){
        int x;cin>>x;
        sum+=x;
    }
    if(sum>=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
def cost(a, b):
    tmp = a - b
    if tmp < 0:
        tmp = -1*tmp
    return tmp

N = int(input())
h = list(map(int, input().split()))

min_cost = [0]*N
min_cost[0] = 0
min_cost[1] = cost(h[0], h[1])


for i in range(2, N):
    min_cost[i] = min(min_cost[i - 2]+cost(h[i-2], h[i]), min_cost[i-1]+cost(h[i-1], h[i]))

print(min_cost[-1])

Measured memory_bytes: 13980
N = int(input())
a = map(int, input().split())

counts = [0] * (10**5 + 2)
for a_i in a:
    counts[a_i + 1] += 1

counts_all = [0] * (10**5)
for i in range(10**5):
    counts_all[i] += (counts[i] + counts[i + 1] + counts[i + 2])

print(max(counts_all))

Measured memory_bytes: 10580
#include<iostream>
#include <iomanip>
#include <limits>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	double L;
	cin >> L;
	cout << fixed << setprecision(12) << (L * L * L) / 27 << endl;
	
	return 0;
}

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

int main() {
  ll k;
  cin>>k;
  ll a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout<<a[k-1]<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main() {

	int N = 0;
	std::cin >> N;
	std::vector<std::string> names(N);
	std::vector<float> maneies(N);

	float sum = 0.0;
	for(int i = 0; i < N; i++) {
		float maney = 0.0;
		std::cin >> maney;
		maneies[i] = maney;
		std::cin >> names[i];
		if (names[i] == "BTC") {
			maneies[i] *= 380000.0;
		}
		sum += maneies[i];
	}

	std::cout << sum << std::endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

  public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int q = s.nextInt();

    int[] outputs = new int[q];

    String str = s.next();

    int[] acs = new int[n];
    acs[0] = 0;

    for (int i = 1; i < n; i ++) {
      if (str.substring(i - 1, i + 1).equals("AC"))
        acs[i] = acs[i - 1] + 1;
      else
        acs[i] = acs[i - 1];
    }

    for (int i = 0; i < q; i ++) {
      int l = s.nextInt();
      int r = s.nextInt();
      outputs[i] = acs[r - 1] - acs[l - 1];
    }

    for (int i : outputs)
      System.out.println(i);

  }

}

Measured memory_bytes: 81492
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    string s; cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
  int A,B,C,D,ab,cd,max;
  scanf("%d¥n",&A);
  scanf("%d¥n",&B);
  scanf("%d¥n",&C);
  scanf("%d¥n",&D);
  ab = A*B;
  cd = C*D;
  if(ab<=cd){
    max = cd;
  }else if(ab>cd){
    max = ab;
  }
  printf("%d",max);
  return 0;
}
    
    


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

int main() {
	ll a,b;
	cin >> a >>b;
	bool k=0;
	for(ll i=1;i<=10000000;i++)
	{
	    if(floor(i*0.08)==a && floor(i*0.1)==b) {cout << i << endl;k=1;break;}
	}
	if(k==0) cout << "-1" << endl;
 
	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int k;
string s;

int main()
{
    _FastIO;

    cin >> k;
    int a = k / 2;
    int b = a + k % 2;
    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 510000;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


ll k;


int main() {

	cin >> k;

	queue<ll> q;

	rrep(i, 9) q.push(i);

	int i = 1;
	while (i < k) {
		ll tmp;
		tmp = q.front(); q.pop();

		if (tmp % 10 != 0)q.push(tmp * 10 + ((tmp % 10) - 1));
		q.push(tmp * 10 + (tmp % 10));
		if (tmp % 10 != 9)q.push(tmp * 10 + ((tmp % 10) + 1));
		i++;
	}

	cout << q.front() << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main()
{
    int N, K; cin >> N >> K;
    vector<int> v(N);
    for(int i=0; i<N; i++){
        cin >> v[i];
        if(v[i] == K){
            cout << "POSSIBLE";
            return 0;
        }
    }
    sort(all(v));
    if(v[N-1] < K){
        cout << "IMPOSSIBLE";
        return 0;
    }
    int t, dv;
    dv = 2000000000;
    for(int i=1; i<N; i++){
        t = v[i] - v[i-1];
        if(t > 0)   dv = min(dv,t);   
    }
    for(int i=0; i<N; i++){
        if(v[i]%dv != 0){
            cout << "POSSIBLE";
            return 0;
        }
    }
    if(K%dv == 0)   cout << "POSSIBLE";
    else    cout << "IMPOSSIBLE";
}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

const int N = 500005, MX = 1 << 20, MOD = 1E9 + 7;

int n, u, cur, su[N];
long long ans = 0;
vector<int> ve[MX];

long long solve(int u, bool fi)
{
    long long add = 0, tot = 0;
    for (int i = 0; i < (int)ve[u].size(); i++)
    {
        int occ = su[ve[u][i]] - (i == 0 ? 0 : su[ve[u][i - 1]]);
        (add += tot * occ) %= MOD;
        (tot += add + 1) %= MOD;
    }
    return fi ? tot : (add + 1) % MOD;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> u;
        cur ^= u;
        su[i] = su[i - 1] + (cur == 0);
        if (cur > 0)
            ve[cur].push_back(i);
    }
    if (cur > 0)
        ans = solve(cur, false);
    else
    {
        for (int i = 1; i < MX; i++)
            (ans += solve(i, true)) %= MOD;
        int pw = 1;
        for (int i = 1; i < su[n]; i++)
            (pw *= 2) %= MOD;
        (ans += pw) %= MOD;
    }
    cout << ans;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define loop(a,b)            for(ll i=a;i<=b;i++)
#define sci(n)               scanf("%d",&n)
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define srt(g)               sort(g.begin(),g.end())
#define rvs(g)               reverse(g.begin(),g.end())
#define pl                   pair<long long,long long>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define f first
#define s second
int main()
{
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << "\n";
    else cout << "ABC\n";
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////


int main(){
    ll n,ma,mb;cin>>n>>ma>>mb;
    ll a[n+1],b[n+1],c[n+1];
    rep(i,1,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n+1][500][500];
    rep(i,0,n){
        rep(j,0,450){
            rep(k,0,450){
                dp[i][j][k]=inf;
            }
        }
    }
    dp[0][0][0]=0;
    rep(i,1,n){
        rep(j,0,440){
            rep(k,0,440){
                if(j-a[i]<0 || k-b[i]<0){
                    dp[i][j][k]=dp[i-1][j][k];
                    continue;
                }
                dp[i][j][k]=min(dp[i-1][j-a[i]][k-b[i]]+c[i],dp[i-1][j][k]);
                continue;
            }
        }
    }
    ll ans=inf;
    ll cc=1;
    while(ma*cc<=410 && mb*cc<=410){
        ans=min(ans,dp[n][ma*cc][mb*cc]);
        cc++;
    }
    if(ans<inf){
        cout<<ans<<endl;
    }else{
        cout<<-1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 80384
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string a,b,c;cin>>a>>b>>c;
  string ans=a.substr(0,1)+b[0]+c[0];
  transform(ans.begin(),ans.end(),ans.begin(),::toupper);
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568