akhauriyash/Code-Regression huggingface dataset:
k = int(input())

from collections import deque

q = deque([1,2,3,4,5,6,7,8,9])

x = 0
while k:
    x = q.popleft()
    if x % 10 != 0:
        q.append(10*x+(x%10)-1)

    q.append(10*x+(x%10))

    if x % 10 != 9:
        q.append(10*x+(x%10)+1)
    k -= 1

print(x)

Measured memory_bytes: 40944
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
#include <cassert>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

map<LL, int> M;

int calc(int a) {
    int n = a;
    FOR(i, 1, n + 2) {
        if (a - i < 0) {
            return i - 1;
        }

        a -= i;
    }

    throw -1;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false); cin.tie(0);
    LL a;
    cin >> a;
    LL b = a;
    for (LL k = 2; k * k <= a; k++) {
        while (b % k == 0) {
            b /= k;
            M[k]++;
        }
    }

    if (b != 1) {
        M[b]++;
    }

    int ans = 0;
    for (auto it = M.begin(); it != M.end(); it++) {
        //cout << it -> second
        ans += calc(it->second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3664
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N = int(input())

    print(1000 - (N % 1000)) if N%1000 != 0 else print(0)

if __name__ == '__main__':
    main()

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

template<class T,class F>
struct segtree{
  int n;
  T e;
  F f;
  std::vector<T> dat;

  segtree(){}
  segtree(int sz,T _e,F _f):e(_e),f(_f){
    n = 1;
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
  }
  segtree(std::vector<T> const& v,T _e,F _f):e(_e),f(_f){
    build(v);
  }
  void build(std::vector<T> const& v){
    n = 1;
    int sz = v.size();
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
    for(int i=0;i<sz;++i){
      dat[i+n] = v[i];
    }
    for(int i=n-1;i>0;--i){
      dat[i] = f(dat[i<<1],dat[i<<1|1]);
    }
  }
  void set(int p,T v){
    for(dat[p+=n]=v;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  T query(int l,int r){
    T res = e;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
      if(l&1){
        res = f(res,dat[l]);
        l++;
      }
      if(r&1){
        r--;
        res = f(res,dat[r]);
      }
    }
    return res;
  }
  T operator[](int k){
    return query(k,k+1);
  }
};

int main(){

  ll n,d,a;
  cin>>n>>d>>a;
  vector<pll> xh(n);
  cin>>xh;

  auto sum = [](auto a,auto b){return a+b;};
  segtree<ll,decltype(sum)> seg1(n,0,sum);

  constexpr auto ceil = [](auto a,auto b){return (a-1)/b+1;};
  sort(xh.begin(),xh.end());
  ll ans = 0;

  rep(i,n){
    pll key = { xh[i].first-2*d,-1 };
    auto itr = lower_bound(xh.begin(),xh.end(),key);
    ll idx = itr-begin(xh);
    ll attacked = seg1.query(idx,i+1);
    ll damage = a*attacked;
    ll hp = xh[i].second-damage;
    if(hp<=0)continue;
    ll attack = ceil(hp,a);
    seg1.set(i,attack);
    ans += attack;
  }
  cout<<(ans)<<endl;

}


Measured memory_bytes: 7424
#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()
    
int main(){
    long long n,k;
    cin >> n >> k;

    vector <long long> fac(0);
    map <long long, long long> table;

    rep(i,n){
        int a,b;
        cin >> a >> b;
        fac.push_back(a);
        if(table.count(a)){
            table.at(a) += b;
        }
        else{
            table[a] = b;
        }
    }
    sort(all(fac));
    fac.erase(unique(all(fac)), fac.end());

    long long cnt = 0;
    for(auto x:fac){
        cnt += table.at(x);
        if(cnt >= k){
            cout << x << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 7976
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n,m;
    cin >> n >>m;
    vector< pair<int64_t ,int64_t> > p(n); //(int,int)のpair型の配列pを作る
    for(int i = 0;i< n; i++){
        cin >> p.at(i).first >> p.at(i).second;
    }
    //first円でsecond本ある
    sort(p.begin(),p.end()); //値段が安い順にソート
    /*for(int i = 0;i< n; i++){
        cout << p.at(i).first <<" "<< p.at(i).second<<endl;
    }
    */
   int64_t am=0;
   int64_t ans=0;
   int64_t k;
   for(int i=0;i<n;i++){
           am += p[i].second;
           ans += p[i].first*p[i].second;
           //cout <<ans <<endl;
           if(am>=m){
               k=i;
               break;
           }
       
   }
   //cout <<"k=" <<k<<endl;
   ans -= p[k].first * (am-m);
   //am -= m;
   //cout <<"am="<<am <<endl;
   cout  <<ans <<endl;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//templete
int main() {
	ll N,Q;
	cin>>N>>Q;
	vll A;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	ll tes[SIZE]={},ket[SIZE]={};	//累積和、右から偶数番目の累積和
	for(int i=0;i<N;i++){
		if((N-i)%2)
			ket[i]+=A[i];
		tes[i]+=A[i];
	}
	for(int i=1;i<N;i++){
		tes[i]+=tes[i-1];
		ket[i]+=ket[i-1];
	}
	while(Q--){
		ll x;
		cin>>x;
		ll ans=0;
		//青木くんが最初にとるカードより右のカードで、青木くんが取るものと高橋くんが取るものの境界を求める
		int aoki=0,takahashi=N;
		while(takahashi-aoki>1){
			ll idx=(aoki+takahashi)/2;
			if(A[idx]<x){
				aoki=idx;
				continue;
			}
			//高橋くんは、idx番目のカードをN-idx番目に取る
			//青木くんは、idx番目のカードをord番目に取る
			ll ord=upper_bound(A.begin(),A.end(),A[idx])-lower_bound(A.begin(),A.end(),x-(A[idx]-x));
			if(ord<N-idx)
				aoki=idx;
			else
				takahashi=idx;
		}
		ans+=tes[N-1]-tes[aoki];
		//aokiくんはaoki-(N-takahashi)番目まで取る
		ll und=aoki-(N-takahashi);
		if(und>=0)
			ans+=ket[und];
		//cout<<aoki<<" "<<takahashi<<" "<<und<<endl;
		cout<<ans<<endl;
	}
    return 0;
}


Measured memory_bytes: 5748
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  auto ab = abs(a-b);
  auto ac = abs(a-c);
  auto bc = abs(b-c);
  cout << ((ac <= d || (ab <= d && bc <= d)) ? "Yes" : "No")<< endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int x, y; std::cin >> x >> y;
  bool ans = false;
  for (int c = 0; c < x+1; ++c) {
    int l = c*2 + (x-c)*4;
    if (l == y) ans = true;
  }
  if (ans) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v=0; v<n; v++){
    if(M[u][v] == 0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;

  for(u=0; u<n; u++) color[u] = WHITE;
  tt = 0;

  for(u=0; u<n; u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u=0; u<n; u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++) M[i][j] = 0;
  }

  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0; j<k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}



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

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

int a=0,un=0;

int flg=1;
for(int i=0;i<n;i++){
	string s;
	cin>>s;
	
	if(s=="A"){
		a++;
		}
	else {
		un++;
		if(a<un)flg=0;
		}	
	}

if(flg==1&&a==un)cout<<"YES"<<endl;
else cout<<"NO"<<endl;

return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i,n) for(int i=0;i<(int)(n);i++)
#define repd(i,n) for(int i=(int)(n);i>=0;i--)

int main()
{
    int A,B;
    cin >> A >> B;
    if(A<9 && B<9){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> a=new ArrayList<>();

		while(scan.hasNext()) {
			Integer Nb = scan.nextInt();
			a.add(Nb);			
		}
		
		int[] b =new int[a.size()];
		
		for(int i=0;i<a.size();i++) {
			b[i]=a.get(i);
		}

		for(int i=0;i<a.size();i++) {
			int minj=i;
			for(int j=i;j<a.size();j++) {
				if(b[j]<b[minj]) {
					minj=j;
				}
			}
			int v=b[i];
			b[i]=b[minj];
			b[minj]=v;
			
		}
		
		int result=0;
		int tmp=0;
		for(int i=0;i<a.size()-1;i++) {
			tmp=b[i+1]-b[i];
			result=tmp+result;
			
		}
		
		
		System.out.println(result);

	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  if (std::abs(a-x) < std::abs(b-x)) cout << "A" << endl;
  else cout << "B" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {                                                                
    double speed;                                                               
    int floor;                                                                  
                                                                                
    while (scanf("%lf", &speed) != EOF) {                                       
        double t = speed / 9.8;                                                 
        double y = 4.9 * t * t;                                                 
        floor = (y + 5) / 5 + 1;                                                
        printf("%d\n", floor);                                                  
    }                                                                           
    return 0;                                                                   
}

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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  if(N%(A+B)==0) cout <<  N/(A+B)*A << endl;
  else cout << N/(A+B)*A+min(N%(A+B), A) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int cnt=0;
    char tmp=' ';
    for(int i=0; i<(int) S.size(); i++){
        if(tmp!=S[i]){
            cnt++;
            tmp=S[i];
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <map>
using namespace std;

char buf1[1024], buf2[64], buf3[64];

int main(){
	map<string,int> sub;
	sub["yotta"] = 24;
	sub["zetta"] = 21;
	sub["exa"] = 18;
	sub["peta"] = 15;
	sub["tera"] = 12;
	sub["giga"] = 9;
	sub["mega"] = 6;
	sub["kilo"] = 3;
	sub["hecto"] = 2;
	sub["deca"] = 1;
	sub["deci"] = -1;
	sub["centi"] = -2;
	sub["milli"] = -3;
	sub["micro"] = -6;
	sub["nano"] = -9;
	sub["pico"] = -12;
	sub["femto"] = -15;
	sub["ato"] = -18;
	sub["zepto"] = -21;
	sub["yocto"] = -24;

	int T;
	cin >> T;
	cin.get();
	string s, t;
	while(T--){
		getline(cin, s);
		int d;
		const char *unit;
		if(sscanf(s.c_str(), "%s %s %s", buf1, buf2, buf3) == 3){
			d = sub[buf2];
			unit = buf3;
		}
		else{
			d = 0;
			unit = buf2;
		}

		t = buf1;
		size_t top, dot;
		for(top = 0; t[top] == '.' || t[top] == '0'; ++top);

		dot = t.find('.');
		if(dot == string::npos){
			dot = t.size();
			t += '.';
		}
		else if(dot < top){
			d -= t.size() - 2;
			t = t.substr(top);
			dot = t.size();
			t += '.';
			top = 0;
		}

		while(dot - 1 > top){
			t[dot] = t[dot - 1];
			++d;
			--dot;
		}
		t[dot] = '.';

		if(dot + 1 == t.size()){
			t.resize(dot);
		}

		printf("%s * 10^%d %s\n", t.c_str(), d, unit);
	}
}

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

int main(){
	int N;
	cin >> N;
	int count=1;
	int sum=1;
	while(sum<N){
		count++;
		sum+=count;
	}
	if(sum==N){
		for(int i=1;i<=count;i++){
			cout<<i<<endl;
		}
	}
	else{
		int dif=sum-N;
		for(int i=1;i<=count;i++){
			if(i!=dif){
				cout<<i<<endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct UnionFind {
  vector<lli> v;

  UnionFind(lli n = 0) : v(n) { iota(begin(v), end(v), 0); }
  lli root(lli i) { return i == v[i] ? i : v[i] = root(v[i]); }
  bool same(lli i, lli j) { return root(i) == root(j); }
  void unite(lli i, lli j) { v[root(i)] = root(j); }
};

struct Edge {
  lli u, v, c;
};

lli n;
lli px[100001], py[100001], pi[100001];
vector<Edge> e;
UnionFind uf;

int main() {
  cin >> n;
  for (lli i=0; i<n; ++i) {
    cin >> px[i] >> py[i];
    pi[i] = i;
  }

  uf = UnionFind(n);

  for (lli k=0; k<=1; ++k) {
    const auto& pz = k==0 ? px : py;
    sort(&pi[0], &pi[n], [&](lli i, lli j) { return pz[i] < pz[j]; });
    for (lli i=0; i<n-1; ++i) {
      lli u = pi[i], v = pi[i+1];
      e.push_back({u, v, pz[v] - pz[u]});
    }
  }

  sort(begin(e), end(e), [](Edge& f, Edge& g) { return f.c < g.c; });

  lli ans = 0;
  for (lli i=0; i<e.size(); ++i) {
    Edge& f = e[i];
    lli u = f.u, v = f.v, c = f.c;

    if (!uf.same(u, v)) {
      uf.unite(u, v);
      ans += c;
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11632
import sys
import numpy as np

read = sys.stdin.read
readline = sys.stdin.readline

N, *S = map(str, read().split())
S = np.array(list(map(list, S)), np.str)
N = int(N)
answer = 0
for y in range(N):
    for i in range(N):
        a = S[i, y:].tolist() + S[i, :y].tolist()
        b = S[:, (i + y) % N].tolist()
        if a != b:
            break
    else:
        answer += N

print(answer)


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

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

  VAR(int, N, M);

  bool exist[100010];
  vector<int> buff;
  vector<int> vec[100010];
  vector<int> p(M+5), y(M+5);
  rep(i, M) {
    IN(p[i], y[i]);
    vec[p[i]].emplace_back(y[i]);
    if (!exist[p[i]]) buff.emplace_back(p[i]);
    exist[p[i]] = true;
  }

  map<pii, i64> mp;
  rep(i, buff.size()) {
    int P = buff[i];
    sort(all(vec[P]));
    rep(j, vec[P].size()) {
      mp[make_pair(P, vec[P][j])] = j + 1;
    }
  }

  rep(i, M) {
    OUTN(setw(6), setfill('0'), p[i]);
    OUTN(setw(6), setfill('0'), mp[make_pair(p[i], y[i])], "\n");
  }

  return 0;
}


Measured memory_bytes: 14456
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int MAXN=100000+10;
int A[MAXN],n,ans;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
int main()
{
	read(n);
	for(register int i=1;i<=n;++i)read(A[i]);
	for(register int i=1;i<=n;++i)
		if(A[i]==i)
		{
			swap(A[i],i==n?A[i-1]:A[i+1]);
			ans++;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define rep(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define REP(i,a,b) for (int i = a;i < b;i ++)

#define _read(a,s,n) rep(i,s,n) scanf("%d",a + i);
#define _READ(a,s,n) REP(i,s,n) scanf("%d",a + i);

#define _read_ll(a,s,n) rep(i,s,n) scanf("%lld",a + i);
#define _READ_ll(a,s,n) REP(i,s,n) scanf("%lld",a + i);

#define _T_(T) int T;scanf("%d",&T);while (T --)

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    ll n;
    scanf("%lld",&n);
    ll cnt = 0;
//    ll i = 2;
    ll p = n;
    map<ll,int> all;
    for (ll i = 2;i * i <= n && p != 1;i ++) {
        while (p % i == 0) {
            p /= i;
            all[i] ++;
        }
    }
    if (p != 1) all[p] ++;
    
    int k;
    int x;
    for (auto i : all) {
//        printf("%lld: %d\n",i.first,i.second);
        k = i.second;
        x = sqrt(k * 2 + 0.25) - 0.5;
        cnt += x;
    }
    printf("%lld\n",cnt);
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<int,int> P;
#define Mod 1000000007


int main(){
    ll i,j;
    ll n,q;
    cin>>n>>q;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }

    ll bi[q+10];

    bi[0]=1;
    for(i=1;i<q+10;i++){
        bi[i]=2*bi[i-1];
        bi[i]%=Mod;
    }

    ll nq=bi[q];

    ll hal=(1+Mod)/2;

    ll cal[n][n];
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(a[i]>a[j]) cal[i][j]=nq;
            else cal[i][j]=0;
        }
    }

    for(j=0;j<q;j++){
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        for(i=0;i<n;i++){
            if(i!=x&&i!=y){
                ll mx=min(x,i);
                ll my=min(y,i);

                
                    ll calxi=cal[x][i];
                    ll calix=cal[i][x];
                    ll calyi=cal[y][i];
                    ll caliy=cal[i][y];

                    cal[x][i]=hal*(calxi+calyi);
                    cal[i][x]=hal*(calix+caliy);

                    cal[x][i]%=Mod;
                    cal[i][x]%=Mod;

                    cal[y][i]=hal*(calyi+calxi);
                    cal[i][y]=hal*(caliy+calix);

                    cal[y][i]%=Mod;
                    cal[i][y]%=Mod;
                
            }
        }
            ll calxy=cal[x][y];
            ll calyx=cal[y][x];

            cal[x][y]=hal*(calxy+calyx);
            cal[x][y]%=Mod;
            cal[y][x]=cal[x][y];



    }


    ll ans=0;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            ans+=cal[i][j];
            ans%=Mod;
        }
    }
    cout<<ans<<endl;






    return 0;
}

Measured memory_bytes: 70656
// Author: Jinhai Chen
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
int c[34];
bool ok() {
	for(int i=1;i<=4;i++) {
		if(c[i]>2) return false;
	}
	return true;
}

int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	ios::sync_with_stdio(false);
	ll k,a,b;
	cin>>k>>a>>b;
	if(b-a<=2) {
		cout<<k+1<<endl;
	}else {
		ll use=min(k,a-1);
		k-=use;
		ll time=k/2;
		ll ans=a+(b-a)*time;
		if(k&1) ans++;
		cout<<ans<<endl;
	}


	return 0;
}














Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

//rang add, get point
struct SegmentTree{
private:
  int N;
  vector<long long> node;
  long long identity=0;
public:
  SegmentTree(vector<long long> v){
    int SZ=(int)v.size();
    N=1;
    while(N<SZ) N*=2;
    node.resize(2*N-1,identity);

    for(int i=0;i<SZ;i++) node.at(i+N-1)=v.at(i);
    for(int i=N-2;i>=0;i--) node.at(i)=0;
  }

  long long getpoint(int i){
    i+=N-1;
    long long ans=node.at(i);
    while(i>0){
      i=(i-1)/2;
      ans+=node.at(i);
    }
    return ans;
  }

  void add(int a,int b,long long x,int k=0,int l=0,int r=-1){
    if(r==-1) r=N;
    if(r<=a || b<=l)  return;
    if(a<=l && r<=b){
      node.at(k)+=x;
      return;
    }
    add(a,b,x,2*k+1,l,(l+r)/2);
    add(a,b,x,2*k+2,(l+r)/2,r);
    return;
  }
};

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  ll D,A;
  cin >> N >> D >> A;
  vector<pair<ll,ll>> XH(N);
  for(int i=0;i<N;i++)  cin >> XH.at(i).fi >> XH.at(i).se;

  sort(all(XH));
  vector<ll> X(N),H(N);
  for(int i=0;i<N;i++){
    X.at(i)=XH.at(i).fi;
    H.at(i)=XH.at(i).se;
  }

  ll ans=0;
  SegmentTree seg(H);
  for(int i=0;i<N;i++){
    ll tmp=seg.getpoint(i);
    if(tmp<=0)  continue;
    ll cnt=(tmp+A-1)/A;
    int l=i;
    int r=upper_bound(X.begin(),X.end(),X.at(i)+2*D)-X.begin();
    ans+=cnt;
    seg.add(l,r,-cnt*A);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15084
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int main() {
    // source
    int d, n;
    cin >> d >> n;

    int ans;
    if (n != 100) {
        if (d == 0) {
            ans = n;
        } else if (d == 1) {
            ans = 100 * n;
        } else {
            ans = 10000 * n;
        }
    } else {
        if (d == 0) {
            ans = 101;
        } else if (d == 1) {
            ans = 100 * 101;
        } else {
            ans = 10000 * 101;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int k = tmp[0], x = tmp[1];
	int l = x - k + 1;
	int r = x + k - 1;

	for (int i = l; i < r; i++)
	{
	    Write($"{i} ");
	}
	WriteLine(r);
    }
}


Measured memory_bytes: 13396
def f(D, Y, Z):
    temp = 0
    for i in range(D):
        temp+= (Y[i]-Z[i])**2
    return temp**(1/2)

N, D = map(int, input().split())

axis = []
for n in range(N):
    axis.append(list(map(int, input().split())))

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        if f(D, axis[i], axis[j]).is_integer():
            cnt+=1

print(cnt)


Measured memory_bytes: 3188
from typing import List


def main():
    nums = [int(n) for n in input().split()]

    print('Yes') if si(nums) else print('No')


def si(nums: List[int]) -> bool:
    a, b, c = nums

    if 4 * a * b < (c - a - b) ** 2 and (c - a - b) > 0:
        return True

    return False


if __name__ == '__main__':
    main()


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

hoge = []
for i in range(0,M):
    a = [int(x) for x in input().split()]
    hoge.append(a)
    
s = min([x[1] for x in hoge]) - max([x[0] for x in hoge]) +1
if s <= 0:
	print(0)
else:
	print(s)

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int x,y; cin>>x>>y;
  int d =abs(x-y);
  if (d%2) out("IMPOSSIBLE");
  d=d/2;
  int ans = min(x,y)+d;
  cout<<ans;
  

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef pair<int, int> P;

/** Problem2263 : The First Acceptance **/
int main()
{
	int N;
	cin>>N;
	
	vector<P> p(N);
	rep(i, N) cin>>p[i].second>>p[i].first;
	
	sort(p.begin(), p.end());
	
	int a[1001][1001];
	fill(a[0], a[0]+1001*1001, INF);
	
	a[0][0] = 0;
	rep(i, N) {
		rep(j, N) {
			a[i+1][j] = min(a[i+1][j], a[i][j]);

			if (a[i][j]+p[i].second <= p[i].first)
				a[i+1][j+1] = min(a[i][j]+p[i].second, a[i][j+1]);
		}
	}
	
	int ans=0;
	rep(i, N+1)
		if (a[N][i] != INF) ans = i;
	
	cout << ans << endl;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;
    int n = sz(s);
    rep(i, n) s[i] = tolower(s[i]);

    if (s == "akihabara" || s == "kihabara" || s == "akihbara" || s == "akihabra" || s == "akihabar" ||
        s == "kihbara" || s == "kihabra" || s == "kihabar" || s == "akihbra" || s == "akihbar" || s == "akihabr" ||
        s == "kihbra" || s == "kihbar" || s == "kihabr" || s == "akihbr" || s == "kihbr") cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

int hurui(vector<bool>& isPrime, int n, int m){
	int ret=0;
	for(int i=m;i<=7368791+1;i++){
		if(isPrime[i]){
			ret++;
			if(ret==n+1){
				return i;
			}
			for(int j=i;j<7368791+1;j+=i){
				isPrime[j]=false;
			}
		}
	}
}

int main (){
	int m,n;
	while(cin>>m>>n && m && n){
		vector<bool> isPrime(7368791+1,true);
		cout<<hurui(isPrime,n,m)<<endl;
		// int count=0;
		// for(int i=m;;i++){
		// 	if(isPrime[i])count++;
		// 	if(count==n+1){
		// 		cout<<i<<endl;
		// 		break;
		// 	}
		// }
	}
}




Measured memory_bytes: 3984
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0515-input.txt"));
		while (true) {
			int n = scan.nextInt();
			int k = scan.nextInt();
			if (n == 0 & k == 0)
				break;

			boolean[] e = new boolean[n + 1];

			for (int i = 0; i < k; i++)
				e[scan.nextInt()] = true;

			List<Integer> contig = new ArrayList<Integer>();

			for (int i = 1; i <= n;) {
				int j = 1;
				for (; i + j <= n; j++)
					if (e[i + j] != e[i])
						break;
				if (e[i])
					contig.add(j);
				else
					contig.add(-1 * j);
				i += j;
			}

			int max = 0;
			for (int i = 0; i < contig.size(); i++)
				if (max < contig.get(i))
					max = contig.get(i);

			if (e[0]) {
				for (int i = 0; i < contig.size() - 1; i++)
					if (contig.get(i) > 0)
						if (contig.get(i + 1) == -1 && i < contig.size() - 2) {
							int len = contig.get(i) + 1 + contig.get(i + 2);
							if (len > max)
								max = len;
						} else {
							int len = contig.get(i) + 1;
							if (len > max)
								max = len;
						}
					else {
						int len = contig.get(i + 1) + 1;
						if (len > max)
							max = len;
					}
			}

			System.out.println(max);
		}

		scan.close();
		System.exit(0);
	}

}

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

using namespace std;

void solve(int N, int X, int T) {
  cout << T * ((N - 1) / X + 1) << endl;
}

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

  int N, X, T;
  cin >> N >> X >> T;

  solve(N, X, T);

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
using namespace std;
typedef long long ll;



int main(void) {
  ll N;
  cin >> N;
  vector<ll> a(N);
  ll i;
  
  for(i=0; i<N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  pt(a[N/2]-a[N/2-1]);
  
  
  
  
}








Measured memory_bytes: 1024
N=int(input())
A,B=map(int,input().split() )
P=list(map(int,input().split() ))
X1=sum( [p<=A for p in P])
X2=sum( [ (p>A and p<=B)  for p in P] )
X3=sum( [p>B  for p in P] )
print(min([X1,X2,X3]))

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll l = 0, r = 1e9;
    ll x = 0;
    while(r-l>1) {
        x = (l+r)/2;
        ll times = 0;
        rep(i,n) {
            times += (a[i]-1)/x;
        }
        if (times>k) l = x;
        else r = x;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4840
#include<iostream>
#include<bitset>
#include<vector>
using namespace std;

int main(){

    int n, k;
    cin >> n >> k;

    bitset<18> bs;
    
    for(int i = 0; i < (1 << n); i++){
        bs = i;
        if(bs.count() == k){
            cout << i << ":";            
            for(int j = 0; j < n; j++){
                if(bs[j]){
                    cout << ' ' <<  j;
                }
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
int main() {
	int N,M;
	cin>>N>>M;
	priority_queue<ll> que;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		que.push(a);
	}
	for(int i=0;i<M;i++){
		int a=que.top();
		que.pop();
		que.push(a/2);
	}
	ll ans=0;
	while(que.size()){
		ans+=que.top();
		que.pop();
	}
	cout<<ans<<endl;
	return 0;
}

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

inline int read() 
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
    return x * f;
}

inline void write(int x)
{
    if(x<0){
    	putchar('-');
		x=-x;
	}
    if(x>9) 
		write(x/10);
    putchar(x%10+'0');
}


int main()
{
	int n=read(),x=read(),t=read();
	if (n%x==0)
	{
		printf("%d",(n/x)*t);
		return 0;
	}
	int tmp=n/x+1;
	printf("%d",tmp*t);
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define ll long long int
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,n) for (int i = a; i < n; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
double PI=acos(-1.0);
using namespace std;
int mod = 1000000007;
int inf=INT_MAX;
int minf = INT_MIN;

/*int main()
{
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
}*/

/*int main()
{
    ll n,d;
    cin>>n>>d;
    int cnt=0;
    while(n--)
    {
        ll x,y;
        cin>>x>>y;
        ll temp=x*x+y*y;
        ll ans=ceil(sqrt(temp));
        //cout<<ans<<endl;
        if(ans<=d)
            cnt++;
    }
    cout<<cnt;
}*/

int main()
{
    int k;
    cin>>k;
    if(k%2==0 || k%5==0)
    {
        cout<<"-1";
        return 0;
    }
    int first=7,cnt=1;
    while(k>first)
    {
        first=first*10+7;
        cnt++;
    }
    while(first>0)
    {
        first=first%k;
        if(first>0)
        {
            first=first*10+7;
            cnt++;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 3644
# -*- coding: utf-8 -*-

def rec(x):
    if x == 1:
        return 1

    return 2 * rec(x // 2) + 1


def main():
    from sys import setrecursionlimit

    setrecursionlimit(10 ** 7)

    n = int(input())
    print(rec(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import math
n = int(input())
c = sorted(list(map(int, input().split())),reverse=True)
a = 0
for i in range(n):
  a += c[i]*(i+2)
  a = a%(10**9+7)
a = (a*pow(2,2*n-2,10**9+7))%(10**9+7)
print(a)

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

// ABC130A - Rounding
// 
void ABC130A() {
	int X, A;
	cin >> X >> A;

	if (X < A) {
		cout << 0  << endl;
	}
	else {
		cout << 10 << endl;
	}
}

int main() {
	ABC130A();

	return 0;
}




Measured memory_bytes: 256
import sys

N = int(input())

lis = [0] * (10 ** 5 + 10)

D = list(map(int,input().split()))
maxi = 0

if D[0] != 0:
    print (0)
    sys.exit()

for i in D:
    maxi = max(maxi,i)
    lis[i] += 1

ans = 1
for i in range(maxi + 1):

    if i == 0 and lis[i] != 1:
        ans = 0
        print (0)
        sys.exit()
    elif i != 0:
        #print (ans,lis[i-1],lis[i])
        ans = ans * ( lis[i-1] ** lis[i] ) 
        ans %= 998244353

#print (lis)
print (ans % 998244353)


Measured memory_bytes: 53616
/**
 *   Author: praveen_ojha
 *   Created: 17 January 2019
 *   Time: 11:50:41
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
int n,a[100005],dp[100005];
int solve(int ind){
	if(ind==n-2){
		return abs(a[n-1]-a[n-2]);
	}
	if(ind==n-1){
		return 0;
	}
	if(dp[ind]!=-1)
		return dp[ind];
	int ans1,ans2;
	dp[ind+1]=solve(ind+1);
	dp[ind+2]=solve(ind+2);
	ans1=abs(a[ind]-a[ind+1])+dp[ind+1];
	ans2=abs(a[ind]-a[ind+2])+dp[ind+2];
	dp[ind]=min(ans1,ans2);
	return dp[ind];

}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
    	cin>>a[i];
    cout<<solve(0);
return 0;
}

Measured memory_bytes: 4224
#!/usr/bin/env python3

n, a, b = list(map(int, input().split()))

ans = 10**18+1

if a > b:
    a, b = b, a

# print(a, b)
ans = []
ans.append(max(a-1, b-1))
ans.append(max(n-a, n-b))

if abs(a-b) % 2 == 0:
    ans.append(abs(a-b)//2)
else:
    a_tmp, b_tmp = 1, b-a
    ans.append(a + abs(b_tmp-a_tmp)//2)

    a_tmp, b_tmp = a+(n-b)+1, n
    ans.append(n-b+1 + abs(b_tmp-a_tmp)//2)
# print(ans)
print(min(ans))


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


int main() {
  string S; cin >> S;
  int ans = 700;

  for(int i=0; i<=S.size(); i++){
    if(S[i] == 'o') ans += 100;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int a,b,c; cin >> a >> b >> c;
	if(b-a==c-b) cout << "YES" << endl;
	else cout << "NO" << endl;
} 

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

int memo[100010];

int main(){
	int N;
	cin >> N;
	for(int i = 0 ; i < N ; i++){
		int a,b;
		cin >> a >> b;
		memo[a-1]++;
		memo[b]--;
	}
	int sum = 0;
	for(int i = 1 ; i <= 100001 ; i++){
		memo[i] += memo[i-1];
		//if( i < 10 ) cout << memo[i] << " ";
		
		if( i <= memo[i] ) sum = max(sum,i);
	}
	cout << sum << endl;
	
}

Measured memory_bytes: 1552
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> P2;
const ll INF=100000000000000001;
int dp[100001]={};
bool d[100001]={};
vector<P> v[100001];
int main() {
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;++i){
		int l1,r1,d1;
		cin>>l1>>r1>>d1;
		v[l1].push_back(P(r1,d1));
		v[r1].push_back(P(l1,-d1));
	}
	queue<P> que;
	for(int i=1;i<n+1;++i){
		if(!d[i])que.push(P(i,0));
		while(!que.empty()){
			P p1=que.front();que.pop();
			int to=p1.first;
			int cost=p1.second;
			if(d[to]){
				if(dp[to]!=cost){
					cout<<"No"<<endl;
					return 0;
				}
			}else{
				d[to]=true;
				dp[to]=cost;
				for(auto it:v[to]){
					int to2=it.first;
					int co2=it.second;
					que.push(P(to2,cost+co2));
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 11252
#include <iostream>

int main() {
    int S;
    std::cin >> S;

    int h, m, s;
    s = S % 60;
    S /= 60;
    m = S % 60;
    S /= 60;
    h = S;

    printf("%d:%d:%d\n", h, m, s);
}



Measured memory_bytes: 3220
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] cnt = new int[m];

        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int a = sc.nextInt();
                cnt[a-1]++;
            }
        }

        long res = Arrays.stream(cnt).filter(v -> v == n).count();

        System.out.println(res);

        sc.close();
    }
}

Measured memory_bytes: 27476
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N; scanf("%d", &N);
	int ret = 0;
	for (int i = 1; i <= N; i++){
		if (1 <= i&&i <= 9){
			ret++;
		}
		else if (100 <= i&&i <= 999){
			ret++;
		}
		else if (10000 <= i&&i<=99999){
			ret++;
		}
	}

	printf("%d", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
#define FORk(N) for(int k=0;k<N;++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll A,B,C;
  cin>>A>>B>>C;
  ll min_=min(A+B,B+C);
  min_ = min(min_,A+C);  
  cout<<min_<<endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    for (ll i = 1; i <= n; ++i) {
        ll sum = 0;

        for (ll x = 1; x * x <= i; ++x) {
            for (ll y = x; x * x + y * y <= i; ++y) {
                for (ll z = y; x * x + y * y + z * z <= i; ++z) {
                    if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
                        set<ll> se;
                        se.insert(x);
                        se.insert(y);
                        se.insert(z);

                        if (se.size() == 1) {
                            sum += 1;
                        } else if (se.size() == 2) {
                            sum += 3;
                        } else {
                            sum += 6;
                        }
                    }
                }
            }
        }

        cout << sum << endl;
    }
}

Measured memory_bytes: 3512