akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
string s;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>s;
  rep(i,s.size()-8) cout<<s[i];
  cout<<""<<endl;

}

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


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();

        int h,m,s;

        h = num/3600;
        m = num%3600;
        s = m%60;
        m = m/60;

        System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26260
import java.util.Scanner;
class Main {
   public static void main(String[] args){
   Scanner scan = new Scanner(System.in);
 
   int a = scan.nextInt();
   int b = scan.nextInt();
   int c = scan.nextInt();
   int tmp;
 
   if(a > b){tmp = a;
             a = b;
             b = tmp;}
 
    if(a > c){tmp = a;
              a = c;
              c = tmp;}
  
    if(b > c){tmp = b;
              b = c;
              c = tmp;}
 
     System.out.println(a + " " + b + " " + c);
    }
}
 

Measured memory_bytes: 26216
s = input()
n = (len(s) - 1)

ans_lst = []
for i in range(2**n):
    op = ["+"] * n 
    for j in range(n):
        if ((i >> j) & 1):
            op[n-j-1] = ""
    formula = ""
    for num,opp in zip(s, op + [""]):
        formula += (num + opp)
    ans_lst = ans_lst + [eval(formula)]

print(sum(ans_lst))

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

int main(){

  int a,b;

  cin >> a >> b;

  int ans = 0;

  for(int i=a; i<=b; i++){
    stringstream ss;
    ss << i;
    string s;
    ss >> s;
    if(s[0] == s[4] && s[1] == s[3]){
       ans++;
    }
  }
 
  cout << ans << endl;
  
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

struct Timer {
    chrono::system_clock::time_point start;
    int ms;
    Timer(int ms) : start(chrono::system_clock::now()), ms(ms) {}
    bool stop() {
        chrono::system_clock::time_point curr = chrono::system_clock::now();
        double t = static_cast<double>(chrono::duration_cast<chrono::microseconds>(curr - start).count() / 1000.0);
        return t > ms;
    }
};

using ulint = unsigned long long;
struct RandomNumberGenerator {
    mt19937_64 mt;
    RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}
    ulint operator()(ulint a, ulint b) { // [a, b)
        uniform_int_distribution<ulint> dist(a, b - 1);
        return dist(mt);
    }
    ulint operator()(ulint b) { // [0, b)
        return (*this)(0, b);
    }
    ulint operator()() { return mt(); }
};

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

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

    Timer t(1950);
    RandomNumberGenerator r;

    int d;
    cin >> d;
    vector<lint> c(26);
    for (int i = 0; i < 26; ++i) {
        cin >> c[i];
    }
    vector<vector<lint>> s(d, vector<lint>(26));
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }
    vector<lint> ret(d, -1);
    for (int i = 0; i < d; ++i) {
        cin >> ret[i];
        ret[i]--;
    }
    lint score = 0;
    vector<lint> last(26, 0);
    for (int i = 0; i < d; ++i) {
        score += s[i][ret[i]];
        last[ret[i]] = i + 1;
        for (int j = 0; j < 26; ++j) {
            score -= c[j] * (i + 1 - last[j]);
        }
        cout << score << "\n";
    }
    return 0;
}

Measured memory_bytes: 3736
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int a[8];
int b[8];
int main() {
  cin >> N;
  rep(i, N){
    cin >> a[i];
  }  
  rep(i, N){
    cin >> b[i];
  }
  vector<int> vec;
  rep(i, N){
    vec.push_back(i+1);
  }
  int index = 0;
  do{
    bool flag1 = true, flag2 = true;
    rep(i, N){
      flag1 &= (vec[i] == a[i]);
      flag2 &= (vec[i] == b[i]);
    }
    if(flag1) Q = index;
    if(flag2) R = index;
    index++;
  }while(next_permutation(vec.begin(), vec.end()));
  cout << abs(Q - R);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S;
  cin>>S;
  int ans;
  int j;
  j=1;
 vector<int> vec(15);
  vector<int> vec2(15);
  for (int i = 0; i < S.size(); i++) {
  if(S.at(i)!='A'&&S.at(i)!='G'&&S.at(i)!='C'&&S.at(i)!='T'){
    vec.at(j)=i+1;
    ++j;
  }
    vec.at(j)=S.size()+1;
  }
  for (int i = 0; i < S.size(); i++){
  vec2.at(i)=vec.at(i+1)-vec.at(i)-1;
  }
  sort(vec2.begin(), vec2.end(), greater<int>());

  cout<<vec2.at(0)<<endl;

}

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;
int main(){
    set<long long >s;
    map<long long ,int>mp;
    long x,t;
    cin>>x;
    for(int i=0;i<x;i++) {
       cin>>t;
       s.insert(t);
       mp[t]++;   
    }
    vector<long long>A;
    for(auto t:s){
       if(mp[t]>=4){
        A.push_back(t);
                A.push_back(t);
       }
       else if(mp[t]>=2)
                  A.push_back(t);

    } 
    //for(int i=0;i<
//    sort(A.begin(),A.end());
    if(A.size()>=2)
        cout<<(A[A.size()-1]*A[A.size()-2]);
    else 
        cout<<"0";  
  return 0;
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double R1 = sc.nextDouble();
		double R2 = sc.nextDouble();
		double d1 = (double)1 / R1;
		double d2 = (double)1/ R2;
		double d3 = 1 / (d1 + d2);
		System.out.println(d3);
	}
}


Measured memory_bytes: 11856
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

pair<double, int> dp[(1<<15) + 10][25];

int num[25], dist[25], v[25];

int w[(1<<15) + 10];

int main(){
	int n = in.nextInt();
	rep(i, n){
		num[i] = in.nextInt(), dist[i] = in.nextInt(), v[i] = in.nextInt();
	}
	rep(i, 1<<n) {
		int sum = 0;
		rep(j, n){
			dp[i][j] = mp(1e18, -1);
			if((i & (1<<j)) != 0) sum += v[j];
		}
		w[i] = sum * 20;
	}

	rep(i, n) dp[1<<i][i].fi = 0.0;
	rep(i, 1<< n){
		rep(now, n){
			if((i & (1<<now)) == 0) continue;
			rep(nxt, n){
				if((i & (1<<nxt)) != 0) continue;
				dp[i | (1<<nxt)][nxt] = min(dp[i | (1<<nxt)][nxt], 
					mp(dp[i][now].fi + (abs(dist[now] - dist[nxt]) * (70.0+w[i])/ 2000.0), now));
			}
		}
	}
	vi ans;
	int idx = 0, last = (1<<n) -1;
	for(int i = 1; i < n; i++){
		if(dp[last][i] < dp[last][idx]) idx = i;
	}
	int prv = last;

	// for(int i = 0; i < 1<<n; i++){
	// 	for(int j = 0; j < n; j++){
	// 		printf(" (%3d, %3d) : ", i, j);
	// 		cout<<dp[i][j].fi<<endl;
	// 	}
	// }

	while(idx != -1){
		ans.pb(num[idx]);
		int tmp = dp[prv][idx].se;
		prv -= (1<<idx);
		
		idx = tmp;
	}
	reverse(all(ans));
	
	rep(i, n) {
		if(i != 0) cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
}

Measured memory_bytes: 16076
n, a, b, c = list(map(int, input().split()))
lll = [int(input()) for _ in range(n)]

ans = 10 ** 9
for i in range(4 ** n):
    ta, tb, tc = 0, 0, 0
    tmp = 0
    for j in range(n):
        k = (i >> (2 * j)) & 3
        if k == 1:
            if ta > 0:
                tmp += 10
            ta += lll[j]
        elif k == 2:
            if tb > 0:
                tmp += 10
            tb += lll[j]
        elif k == 3:
            if tc > 0:
                tmp += 10
            tc += lll[j]
    if ta == 0 or tb == 0 or tc == 0:
        continue
    tmp += abs(a - ta) + abs(b - tb) + abs(c - tc)
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 46060
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int y, x;
	while (1) {
		cin >> y >> x;
		if (y == 0 && x == 0)break;
		for (size_t i = 0; i < y; i++)
		{
			for (size_t i = 0; i < x; i++)
			{
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;
struct edge {ll from, to, cost;};

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, m, a, b, c, d[1000];
edge es[2000];
bool nega = false;	// 負の閉路がある場合true

void BellmanFord(int s) {
	fill(d, d+n, linf);
	d[s] = 0;
	
	for (int j = 0; j < n*2; ++j) {
		bool updatebf = false;
		for (int i = 0; i < m; ++i) {
			edge e = es[i];
			if (d[e.from] != linf && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				updatebf = true;
				// n-1までの道のりに負の閉路がなければたかだかn-1周でd[n-1]は確定する
				if (j>=n-1 && e.to==n-1) nega = true;
			}
		}
		if (!updatebf) break;
	}
}

int main() {
	cin >> n >> m;
	rep(i,m) {
		cin >> a >> b >> c;
		a--, b--, c=-c;
		es[i] = edge{a, b, c};
	}
	BellmanFord(0);
	if (nega) cout << "inf" << ln;
	else cout << -d[n-1] << ln;
}

Measured memory_bytes: 256
# include <cstdio>
# include <iostream>
# include <cstring>
# include <algorithm>
# include <queue>
# define N 100001
# define M 200001
# define _cin ios::sync_with_stdio(false)
# define Inf 0x7f7f7f7f
using namespace std;
struct ege
{
	int next;
	int to;
	int w;
}e[M<<1];
int n;//人数 
int m;//信息数 
int book[N+1];
int head[N+1];
int dis[N+1];
bool vis[N+1];
bool spfa(int x);
int main()
{
	_cin;
	
	int u,v,w;
	cin>>n>>m;
	memset(head,-1,sizeof(head));
	for(int i=1;i<=m;i++)	
	{
		cin>>u>>v>>w;
		//建立双向边 
		/*e[i].next=head[u];
		e[i].to=v;
		e[i].w=w;
		head[u]=i;
		e[i+m].next=head[v];
		e[i+m].to=u;
		e[i+m].w=-w;
		head[v]=i+m;
		*/
		e[i]=(ege){head[u],v,w};head[u]=i;
		e[m+i]=(ege){head[v],u,-w};head[v]=m+i;		
	}
	memset(book,0,sizeof(book));
	memset(dis,0x7f,sizeof(dis));
	for(int i=1;i<=n;i++)
	if(!vis[i])//表示两点连通
	{
		vis[i]=1;//连通就变成真值 
		if(spfa(i)==false)	{cout<<"No"<<endl;return 0;}
	} 
	cout<<"Yes"<<endl;
	return 0;
}
bool spfa(int x)
{
	queue <int>q;
	dis[x]=0;
	q.push(x);book[x]=1;//标记已经进队列的点 
	while(q.size()>0)
	{
		int k=q.front();//取头元素
		q.pop();//头元素出队列
		book[k]=0;
		for(int i=head[k]; i!=-1; i=e[i].next)
		{
			if(dis[e[i].to]==Inf && dis[k]<Inf)
			{
				dis[e[i].to]=dis[k]+e[i].w;
				//如果下一个点没有被标记，将这个点标记，进队列 
				if(book[e[i].to]==0)	{q.push(e[i].to);book[e[i].to]=1;}
				vis[e[i].to]=1;
			} 
			//与已知矛盾，即任意两点的距离都不能有两个值 
			//表示k点已被改变值，下一个点也已经改变值，但是新值与旧值不等 
			else if(dis[k]<Inf && dis[e[i].to]<Inf && dis[e[i].to]!=dis[k]+e[i].w) return false;
		} 
	}
	return true;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
map<char,int>mp;
map<char,int>::iterator it;
int main()
{
    string s[1000];
    int h,w,n,m;
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        cin>>s[i];
    }
    n=h+2;
    m=w+2;

    for(int i=0;i<n;i++)
    {
        if(i==0||i==n-1){
            for(int j=0;j<m;j++)
            {
                cout<<"#";
            }
            cout<<endl;
        }
        else
        {
            for(int j=0;j<3;j++)
            {
                if(j==0||j==2){cout<<"#";}
                else{cout<<s[i-1];}
            }
            cout<<endl;
        }
    }
}


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

using namespace std;


int main(int argc, char **argv) {

    int N;
    cin>>N;
    vector<long long> v(N);
    for(int c=0;c<N;c++) cin>>v[c];
    sort(v.rbegin(),v.rend());
    long long res = v[0];
    priority_queue<tuple<int,int,int> > q;
    q.push(make_tuple(v[1],0,1));
    q.push(make_tuple(v[1],1,0));

    for(int c=2;c<N;c++) {
        tuple<int,int,int> top = q.top();
        q.pop();
        res += get<0>(top);
        q.push(make_tuple(v[c],get<1>(top),c));
        q.push(make_tuple(v[c],c,get<2>(top)));
    }
    cout<<res;
}


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

using namespace std;

string s;
int has[30];
int pos[30];

int main() {
    // freopen("inp.txt", "r", stdin);

    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        has[s[i] - 'a']++;
    }

    int found = -1;
    for (int i = 0; i < 26; i++) {
        if (!has[i]) {
            found = i;
            break;
        }
    }

    if (~found) {
        char c = found + 'a';
        s = s + c;
        cout << s;
    }
    else {
        for (int i = 0; i < s.size(); i++) {
            pos[i] = s[i] - 'a';
        }

        int t = next_permutation(pos, pos + 26);

        if (!t) {
            cout << -1;
            return 0;
        }

        for (int i = 0; i < s.size(); i++) {
            char c = pos[i] + 'a';
            cout << c;
            if (c != s[i]) return 0;
        }
    }

    return 0;
}

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

pii q[100001];
ll parent[100001];
ll ans[100001];

int Find(int x) {
    if (parent[x] < 0) return x;
    else return parent[x] = Find(parent[x]);
}

void Union(int x, int y) {
    x = Find(x); y = Find(y);
    if (x == y) return;
    parent[x] += parent[y];
    parent[y] = x;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    memset(parent, -1, sizeof(parent));
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> q[i].first >> q[i].second;
    }
    
    ll comp = n;
    ans[m - 1] = comp * (comp - 1) / 2;
    for (int i = m - 2; i >= 0; i--) {
        int a = q[i + 1].first, b = q[i + 1].second;
        
        if (Find(a) != Find(b)) {
            ans[i] = ans[i + 1] - parent[Find(a)] * parent[Find(b)];
            Union(a, b);
            
        } else {
            ans[i] = ans[i + 1];
        }
    }
    
    for (int i = 0; i < m; i++) {
        cout << ans[i] << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>


using namespace std;

int main(){

    int a,b,k;
    cin >> a >> b >> k;

    if(2*k >= b-a+1){
        for(int i=a;i<=b;i++) cout << i << endl;
    }else{
        for(int i=0;i<k;i++) cout << a + i << endl;
        for(int i=b-k+1;i<=b;i++) cout << i << endl;

    }




    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(D: int, T: int, S: int):
    if T >= D/S:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(D, T, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
import queue
K = int(input())

lunlun_queue = queue.Queue()

for i in range(1, 10):
    lunlun_queue.put(i)

for i in range(K):
    ans = lunlun_queue.get()

    if(ans % 10 != 0):
        lunlun_queue.put(ans * 10 + ans % 10 - 1)
    
    lunlun_queue.put(ans * 10 + ans % 10)

    if(ans % 10 != 9):
        lunlun_queue.put(ans * 10 + ans % 10 + 1)
'''
while not lunlun_queue.empty():
    print(lunlun_queue.get())
'''
print(ans)

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  operator ll() const { return v; }
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return (mint)0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

mint mfact(int n) { // n! (mod MOD)
  static vector<mint> fact(1, 1);
  int pn = fact.size();
  if (pn < n + 1) {
    fact.resize(n + 1);
    for (int i = pn; i <= n; i++) fact[i] = fact[i - 1] * (mint)i;
  }
  return fact[n];
}
mint nPk(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k == 0) return 1;
  return mfact(n) * mfact(n - k).inv();
}
mint nCk(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k == 0) return 1;
  return mfact(n) * mfact(k).inv() * mfact(n - k).inv();
}

mint f(int n, int a) {
  mint a1 = 1;
  mint a2 = 1;
  dump(n, a);
  rep(i, a) {
    a1 *= (mint)(n - i);
    a2 *= (mint)(i + 1);
  }
  dump(a1, a2);
  return a1 / a2;
}

void solve() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = 2;
  ans = ans.pow(n) - (mint)1;
  dump(ans);
  // dump(f(n,a));
  // dump(f(n,b));
  ans -= f(n, a);
  ans -= f(n, b);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
l = [0] * n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        l[a[j] - 1] = 1
ans = 0
for i in range(n):
    if l[i] == 0:
        ans += 1
print (ans)


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

using namespace std;

typedef long long LL;

const int N = 1010;

string a, b;

int main()
{
    cin >> a >> b;

    string s = a + b;

    int n = 0;


    for(int i = 0; i < s.size(); i++)
        n = n * 10 + s[i] - '0';

    for(int i = 1; i <= n / i; i++)
        if(i * i == n)
        {
            puts("Yes");
            return 0;
        }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
typedef long long ll;


using namespace std;


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22){
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		int max = Math.max(a + b, a - b);

		System.out.println(Math.max(max, a * b));

	}
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

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

    int n;
    while(cin>>n,n)
    {   
        int cnt=0;
        for(int a=1;a*a<=n;a++) if(a*a==n) cnt++;
        
        for(int a=1;a*a<n;a++)
        for(int b=a;a*a+b*b<=n;b++) if(a*a+b*b==n) cnt++;
        
        for(int a=1;a*a<n;a++)
        for(int b=a;a*a+b*b<n;b++)
        for(int c=b;a*a+b*b+c*c<=n;c++) if(a*a+b*b+c*c==n) cnt++;
        
        for(int a=1;a*a<n;a++)
        for(int b=a;a*a+b*b<n;b++)
        for(int c=b;a*a+b*b+c*c<n;c++) 
        for(int d=c;a*a+b*b+c*c+d*d<=n;d++) if(a*a+b*b+c*c+d*d==n) cnt++;
        cout<<cnt<<endl;
    }
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  if(n==1) {
    cout << "Hello World" << endl;
  }
  else {
    ll a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
bool ok(int x) {
    int p = x/2;
    for(int i = 0, j = p + 1; i < p; i++, j++) {
        if(s[i] != s[j]) return false;
    }
    return true;
}
int main()
{
    int ln;
    cin>>s;
    ln = s.size();
    for(int i = ln-2; i >= 2; i -= 2) {
        if(ok(i-1)) {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};


int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	lint k;
	in(k);
	lint now=7;
	int ans=1;
	int flg=0;
	if(k%7==0){
		flg=1;
		now=1;
		k=k/7;
	}
	rep(i,10000000){
		now%=k;
		if(now==0){
			out(ans);
			return 0;
		}
		if(flg)now=now*10+1;
		else now=now*10+7;
		ans++;
	}
	out(-1);
	return 0;
}


Measured memory_bytes: 3624
/**
 *    author:  tourist
 *    created: 12.01.2020 10:22:24       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  cout << min((2 * n + m) / 4, m / 2) << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N=sc.nextInt(),L[]=new int[N],res=0;
      	for(int i=0;i<N;i++){
          	L[i]=sc.nextInt();
        }
        for(int i=0;i<N-2;i++){
            for(int j=i+1;j<N-1;j++){
                for(int k=j+1;k<N;k++){
                    if(L[i]+L[j]>L[k]&&L[i]+L[k]>L[j]&&L[k]+L[j]>L[i]&&L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]){
                        res++;
                    }
                }
            }
        }
        System.out.println(res);
        /*long X=sc.nextLong(),K=sc.nextLong(),D=sc.nextLong(),end=0,endl=0;
        if(K>X/D){
            if(Math.abs((X/D)*D)<Math.abs(((X/D)+1)*D)){
                end=Math.abs(X-(X/D)*D);
                endl=Math.abs(X-((X/D)+1)*D);
                if((K-X/D)%2==0){
                    System.out.println(end);
                }else{
                    System.out.println(endl);
                }
            }else{
                endl=Math.abs(X-(X/D)*D);
                end=Math.abs(X-((X/D)+1)*D);
                if((K-X/D)%2==0){
                    System.out.println(end);
                }else{
                    System.out.println(endl);
                }
            }
        }
        else{
            System.out.println(Math.abs(X-D*K)<Math.abs(X+D*K)?X-D*K:X+D*K);
        }*/
    }
}


Measured memory_bytes: 36556
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void N(int a[], int t) {
	t = a[1];
	a[1] = a[2];
	a[2] = a[6];
	a[6] = a[5];
	a[5] = t;
}

void S(int a[], int t) {
	t = a[1];
	a[1] = a[5];
	a[5] = a[6];
	a[6] = a[2];
	a[2] = t;
}

void E(int a[], int t) {
	t = a[1];
	a[1] = a[4];
	a[4] = a[6];
	a[6] = a[3];
	a[3] = t;
}

void W(int a[], int t) {
	t = a[1];
	a[1] = a[3];
	a[3] = a[6];
	a[6] = a[4];
	a[4] = t;
}

int main(void) {
	int a[10],b[10],t=0,p=0,c=0;
	char NEWS[100];
	a[0] = 0;
	b[0] = 0;
	for (int i = 1; i <= 6; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= 6; i++) {
		scanf("%d", &b[i]);
	}
		while ((a[1] != b[1]) || (a[2] != b[2])) {
			
			p = rand() % 4 + 1;
			if (p == 1) {
				N(a, t);
			}
			else if (p == 2) {
				E(a, t);
			}
			else if (p == 3) {
				W(a, t);
			}
			else if (p == 4) {
				S(a, t);
			}
		}
		if ((a[3] == b[3]) && (a[4] == b[4])) {
			printf("Yes\n");
		}else{
			printf("No\n");
		}
}


Measured memory_bytes: 2704
s = input()
findex = 0
eindex = len(s) - 1
cnt = 0
ftmp = 0
if len(s) == 1:
    print(0)
    exit()
while eindex - findex > 0:

    if s[findex] == s[eindex]:
        findex += 1
        eindex -= 1
        continue

    else:
        if s[eindex] != 'x' and s[findex] == 'x':
            findex += 1
            cnt += 1
        elif s[findex] != 'x' and s[eindex] == 'x':
            eindex -= 1
            cnt += 1
        else:
            cnt = -1
            break

print(cnt)

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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pb emplace_back
#define pf emplace_front
#define mp make_pair
#define ld long double
#define all(x) x.begin(), x.end()
#define uniq(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())

const int maxn = 100;
int cnt1[maxn][maxn];
int cnt2[maxn][maxn];
int cnt3[maxn][maxn];
int cnt4[maxn][maxn];
int n;

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        int x = 0, y = 1, fl = 0;
        for (int e = 0; e < (int)s.size(); e++)
        {
            if (s[e] == '.')
            {
                fl = 1;
                continue;
            }
            x = x * 10 + (s[e] - '0');
            if (fl)
                y *= 10;
        }
        int gcd = __gcd(x, y);
        x /= gcd;
        y /= gcd;
        if (y == 1)
        {
            ans++;
            int k1 = 0, k2 = 0;
            int xx = x;
            while (xx % 2 == 0)
            {
                k1++;
                xx /= 2;
            }
            while (xx % 5 == 0)
            {
                k2++;
                xx /= 5;
            }
            cnt1[k1][k2]++;
//            cout << k1 << " " << k2 << "\n";
        }
        else
        {
            int k1 = 0, k2 = 0;
            int yy = y;
            while (yy % 2 == 0)
            {
                k1++;
                yy /= 2;
            }
            while (yy % 5 == 0)
            {
                k2++;
                yy /= 5;
            }
            cnt2[k1][k2]++;
            if (y % 2 != 0)
            {
                int k3 = 0;
                int xx = x;
                while (xx % 2 == 0)
                {
                    k3++;
                    xx /= 2;
                }
                cnt3[k3][k2]++;
            }
            else if (y % 5 != 0)
            {
                int k3 = 0;
                int xx = x;
                while (xx % 5 == 0)
                {
                    k3++;
                    xx /= 5;
                }
                cnt4[k1][k3]++;
            }
        }
    }
    ans = ans * (ans - 1) / 2;
    for (int i = 0; i < maxn; i++)
        for (int e = 0; e < maxn; e++)
    {
        cnt2[i][e] += (i ? cnt2[i - 1][e] : 0) + (e ? cnt2[i][e - 1] : 0) - ((i && e) ? cnt2[i - 1][e - 1] : 0);
        ans += cnt1[i][e] * cnt2[i][e];
    }
    for (int i = maxn - 1; i >= 0; i--)
        for (int e = 0; e < maxn; e++)
    {
        cnt3[i][e] += (i + 1 < maxn ? cnt3[i + 1][e] : 0) + (e ? cnt3[i][e - 1] : 0) - ((i + 1 < maxn && e) ? cnt3[i + 1][e - 1] : 0);
        ans += cnt4[i][e] * cnt3[i][e];
    }
    cout << ans;
}


Measured memory_bytes: 3812
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
          String[] input = br.readLine().split(" ");
          int[] result = new int[3];

          result[0] = Integer.parseInt(input[2]);
          result[1] = Integer.parseInt(input[0]);
          result[2] = Integer.parseInt(input[1]);

          System.out.println(result[0] + " " + result[1] + " " + result[2]);
        }
    }
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    string s;
    cin >> s;

    // 処理
    s[3] = '8';
    // 出力
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
bl = list(map(int, input().split()))

res = []
for i in range(n):
    b = bl[i]
    if i<b-1:
        print(-1)
        exit()
    res.insert(b-1,b)

for r in res:
    print(r)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <cstring>

using namespace std;

map<string,int> sound;
int n,m;
int stairs[50001];
int song[50001];

bool simulate(int s){
	for(int i=0;i<m;i++){
		if(i==m-1){
			int ns=s-1;
			if(ns==-1&&(stairs[s]+sound.size())%sound.size()==song[m-1-i]){
				return true;
			}
			ns=s-2;
			if(ns==-1&&(stairs[s]+1+sound.size())%sound.size()==song[m-1-i]){
				return true;
			}
			return false;
		}
		int ns=s+1;
		if(ns<n&&ns>=0&&(stairs[s]-1+sound.size())%sound.size()==song[m-1-i]){
			s=ns;
			continue;
		}
		ns=s-1;
		if(ns<n&&ns>=0&&(stairs[s]+sound.size())%sound.size()==song[m-1-i]){
			s=ns;
			continue;
		}
		ns=s-2;
		if(ns<n&&ns>=0&&(stairs[s]+1+sound.size())%sound.size()==song[m-1-i]){
			s=ns;
			continue;
		}
		return false;
	}
}

int main(){

	sound["C"]=0;
	sound["C#"]=1;
	sound["D"]=2;
	sound["D#"]=3;
	sound["E"]=4;
	sound["F"]=5;
	sound["F#"]=6;
	sound["G"]=7;
	sound["G#"]=8;
	sound["A"]=9;
	sound["A#"]=10;
	sound["B"]=11;
	int t;
	cin>>t;
	while(t--){
		cin>>n>>m;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			stairs[i]=sound[s];
		}
		for(int i=0;i<m;i++){
			string s;
			cin>>s;
			song[i]=sound[s];
		}
		if(simulate(n-1)||simulate(n-2))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Text;

namespace ConsoleApp3
{

	class Digit
	{


		public Digit()
		{
			Value = 0;
			Left = new Digit(1, null, this);
		}
		
		private Digit(int value,Digit left,Digit right)
		{
			if (value < 0 && value > 10) throw new ArgumentOutOfRangeException(nameof(value));
			Value = value;
			Left = left;
			Right = right;
		}

		public int Value { get; private set; }
		public Digit Left { get; private set; }
		public Digit Right { get; }


		private static void Reset(Digit d)
		{
			var piv = d;

			while (piv.Right != null)
			{
				if (piv.Value == 0) piv.Right.Value = 0;
				else piv.Right.Value = piv.Value - 1;

				piv = piv.Right;
			}

		}

		public void Next()
		{

			if (Left == null)
			{
				Left = new Digit(1, null, this);
				Reset(Left);
				return;
			}

			var tmp = Value + 1;

			if (Math.Abs(Left.Value - tmp) <= 1 && tmp < 10)
			{
				Value = tmp;
				Reset(this);
				return;
			}

			if (Left.Left == null && Left.Value < 9)
			{
				Left.Value += 1;
				Reset(Left);
				return;
			}



			Left.Next();
		}


		public override string ToString()
		{
			if (Right != null) throw new InvalidOperationException();
			var bld = new StringBuilder();

			var piv = this;


			while (piv.Left != null) piv = piv.Left;

			while (piv != null)
			{
				bld.Append(piv.Value);
				piv = piv.Right;
			}

			return bld.ToString();

		}
	}

	class Program
	{
		static void Main(string[] args)
		{
			var k = int.Parse(Console.ReadLine());

			if (k <= 10)
			{
				Console.WriteLine(k);
			}
			else
			{

				var hoge = new Digit();
				for (var i = 0; i < k - 10; i++)
				{
					hoge.Next();
				}

				Console.WriteLine(hoge);
			}
		}
	}
}


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

int main(){
   int a, b, c, x, y, am, bm, cm;
   cin >> a >> b >> c >> x >> y;
   am = x;
   bm = y;
   cm = 0;
   int q = (a*am)+(b*bm)+(c*cm);
   while(am > 0 || bm > 0){
     if (q > (a*am)+(b*bm)+(c*cm)) {
       q = (a*am)+(b*bm)+(c*cm);
     }
    if (am>0){am--;}
    if (bm>0){bm--;}
     cm += 2;
   }
   if (q > (a*am)+(b*bm)+(c*cm)) {
     q = (a*am)+(b*bm)+(c*cm);
   }
   cout << q << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	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;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

int main() {
	double A, B, C, D, E, F, max_c = -1,tmp_c;
	vll ans(2, 0), tmp(2);
	std::cin >> A >> B >> C >> D >> E >> F;
	A = 100 * A;
	B = 100 * B;
	E = 100 * E / (100 + E);

	vll cnt(4, 0);

	while (A * cnt[0] + B * cnt[1] + C * cnt[2] + D * cnt[3] <= F) {
		while (A * cnt[0] + B * cnt[1] + C * cnt[2] + D * cnt[3] <= F) {
			while (A * cnt[0] + B * cnt[1] + C * cnt[2] + D * cnt[3] <= F) {
				while (A * cnt[0] + B * cnt[1] + C * cnt[2] + D * cnt[3] <= F) {

					tmp[1] = C * cnt[2] + D * cnt[3];
					tmp[0] = A * cnt[0] + B * cnt[1] + tmp[1];
					if (tmp[0] == 2634) {
						tmp[0] = tmp[0];
					}
					if (tmp[0] > 0) {
						tmp_c = 100.0 * tmp[1] / tmp[0];
						if (tmp_c <= E && tmp_c>max_c) {
							max_c = tmp_c;
							ans[0] = tmp[0];
							ans[1] = tmp[1];
						}
					}
					cnt[0]++;
				}
				cnt[0] = 0;
				cnt[1]++;
			}
			cnt[1] = 0;
			cnt[2]++;
		}
		cnt[2] = 0;
		cnt[3]++;
	}

	std::cout << ans[0] << " " << ans[1] << endl;
	return 0;

}


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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int, int>
#define sz size()

const int mod = 1e9 + 7;

void add(int &x, int y)
{
	x += y;
	if(x >= mod)
		x -= mod;
}

signed main()
{
	ios::sync_with_stdio(0);
	int i, j, n, d;
	string k;

	cin >> k >> d;
	n = k.sz;

	vector<vector<int>> dp(d, vector<int>(2));
	dp[0][0] = 1;

	for(i=0;i<n;++i)
	{
		vector<vector<int>> newdp(d, vector<int>(2));
		for(int rem=0;rem<d;++rem)
		{
			// can == true
			for(int dig=0;dig<=9;++dig)
				add(newdp[(rem+dig)%d][1], dp[rem][1]);

			// can == false
			for(int dig=0;dig<k[i]-'0';++dig)
				add(newdp[(rem+dig)%d][1], dp[rem][0]);
			add(newdp[(rem+k[i]-'0')%d][0], dp[rem][0]);
		}

		dp = newdp;
	}

	int ans = (dp[0][0] + dp[0][1]) % mod;
	ans--;
	if(ans == -1)
		ans = mod - 1;
	
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };
bool so[100000];
int sum[100000];
int main() {
	so[0] = so[1] = true;
	FOR(i, 2, 100000) {
		if (so[i] == false) {
			for (int j = i * 2; j < 100000; j += i) {
				so[j] = true;
			}
		}
	}
	
	for (int i = 3; i < 100000; i += 2) {
		if (!so[i] && !so[(i + 1) / 2]) {
			sum[i] = sum[i - 2] + 1;
		}
		else {
			sum[i] = sum[i - 2];
		}

	}
	int n;
	cin >> n;
	REP(i, n) {
		int l,r;
		cin >> l >> r;
		cout << sum[r] - sum[l] + ((!so[l] && !so[(l + 1) / 2]) ? 1 : 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli N;
	cin >> N;

	lli gcd;
	cin >> gcd;

	for (int i = 0; i < N - 1; i++) {
		lli x, y, z;
		cin >> z;
		gcd = ::extgcd<lli>(gcd, z, x, y);
	}

	COUT(gcd);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,d,e,f,g,h,i,j,k,l,n,o;
     o=0;
    scanf("%d %d",&a,&b);
    int c[a][b];
    int m[b];
    for(d=0;d<a;d++){
        for(e=0;e<b;e++){
            scanf("%d",&c[d][e]);
        }
    }for(f=0;f<a;f++){
        i=0;
        for(g=0;g<b;g++){
         printf("%d ",c[f][g]);
        }for(h=0;h<b;h++){
            i=i+c[f][h];
        }printf("%d\n",i);
    }for(j=o;j<b;j++){
        k=0;
    for(l=0;l<a;l++){
        k=k+c[l][j];
    }printf("%d ",k);
    m[j]=k;
          }for(n=0;n<b;n++){
            o=o+m[n];
          }printf("%d\n",o);

return 0;
}

Measured memory_bytes: 636