akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, x, cnt[55], pa[55];
int solve(int a,int b) {
	if (a == 0)return 1;
	else if (b == 1)return 0;
	else if (b <= (cnt[a] - 3) / 2 + 1)return solve(a - 1, b - 1);
	else if (b == 2 + cnt[a - 1])return 1 + pa[a - 1];
	else if (b <= cnt[a] - 1)return pa[a - 1] + 1 + solve(a - 1, b - 2 - cnt[a - 1]);
	else return pa[a];
}
signed main() {
	cin >> n >> x;
	cnt[0] = 1, pa[0] = 1;
	for (int i = 1; i <= 50; i++) {
		cnt[i] = cnt[i - 1] * 2 + 3;
		pa[i] = pa[i - 1] * 2 + 1;
	}
	cout << solve(n, x) << endl;
	endre;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ps = readln.split.to!(int[]);

    int[] as, bs;
    as.length = N;
    bs.length = N;
    foreach (int i; 0..N) {
        as[i] = i+1;
        bs[N-i-1] = i+1;
    }
    foreach (dd, p; ps) {
        if (!dd) continue;
        auto d = dd.to!int;
        foreach (i; 0..N) {
            if (i >= p-1) as[i] += d;
            if (i <= p-1) bs[i] += d;
        }
    }

    writeln(as.to!(string[]).join(" "));
    writeln(bs.to!(string[]).join(" "));
}

Measured memory_bytes: 4732
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

ll combi(ll n, ll k)
{
	if (k >= n || k <= 0)
		return 1;
	ll r = 1;
	for (ll i = 1; i <= k; i++, n--)
		r *= n, r /= i;
	return r;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

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

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	ll h;
	cin >> h;
	ll r = 0;
	while (h > 0)
		r++, h /= 2;
	ll re = 1;
	for (ll i = 0; i < r; i++)
		re *= 2;
	re--;
	printf("%lld", re);


	return 0;
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void)
{
    int n;
    cin>>n;
    int num[n];
    for(int i=0;i<n;i++)
    {
        cin>>num[i];
    }
    for(int i=0;i<n;i++)
    {
        if(i==n-1)
        {
            cout<<num[i]<<endl;
        }
        else cout<<num[i]<<' ';
    }
    for(int i=1;i<n;i++)
    {
        int j=i-1,temp=num[i],k=i-1;
        while(j>=0&&num[j]>=num[i])j--;
        while(k>j)
        {
            num[k+1]=num[k];
            k--;
        }
        num[j+1]=temp;
        for(k=0;k<n;k++)
        {
            if(k==n-1)cout<<num[k]<<endl;
            else cout<<num[k]<<' ';
        }
    }
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  int x;
  cin >> x;
  if (x >= 1200) P("ARC");
  else P("ABC");
  return 0;
}

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

int main(){
    int n,m; cin >> n >> m;
    vector<ll> a(n);
    priority_queue<ll> pq;
    rep(i,n){
        ll a; cin >> a;
        pq.push(a);
    }
    rep(i,m){
        ll tmp = pq.top();
        pq.pop();
        tmp/=2;
        pq.push(tmp);
    }
    ll sum = 0;
    rep(i,n){
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 2168
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    byte a = sc.nextByte();
    byte b = sc.nextByte();
    double c = a/0.08;
    double d = (a+1)/0.08;
    double e = b/0.1;
    double f = (b+1)/0.1;
    double max = Math.max(c,e);
    double min = Math.min(d,f);
    if(c >= f || e >= d){
      System.out.println(-1);
    }else if(Math.ceil(max)<min){
      System.out.println((int)Math.ceil(max));
    }else{
      System.out.println(-1);
    }
  }
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr ll INF=1e18;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

template<typename C>
vl calc(int n,vi a,C comp)
{
	map<int,int,C> f;
	ll sum=0;
	rep(i,n){
		f[a[i]]++;
		sum+=a[i];
	}
	vl res={sum};
	rep(i,n){
		if(comp(begin(f)->first,a[n+i])){
			sum=sum+a[n+i]-begin(f)->first;
			if(--begin(f)->second==0)
				f.erase(begin(f));
			f[a[n+i]]++;
		}
		res.push_back(sum);
	}
	return res;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vi a(3*n);
		rep(i,3*n) cin>>a[i];

		vl pre=calc(n,a,less<int>());
		reverse(all(a));
		vl suf=calc(n,a,greater<int>());

		ll res=-INF;
		rep(i,n+1)
			res=max(res,pre[i]-suf[n-i]);
		cout<<res<<endl;
	}
}


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

using namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   cout << max({a+b,a-b,a*b}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int sum=0;
	for(int i=0;i<s.size();i++){
		while(s[i]==s[i+1]){
			i++;
		}
		sum++;
	}
	cout<<sum;
}


Measured memory_bytes: 512
def gcd(m,n)
	n,m = m,n if m > n
	
	loop do
		r = n % m
		break if r == 0
		n,m = m,r
	end
	m
end

def lcm(m,n)
	n,m = m,n if m > n
	r = 1
	loop do
		return m * r if (m * r) % n == 0
		r += 1
	end
end

while gets
	a,b = $_.split.map(&:to_i)
	puts "#{gcd(a,b)} #{lcm(a,b)}"
end

Measured memory_bytes: 6100
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n << endl;
	}
	else {
		cout << 2 * n << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a;
void solve()
{
    int i,tag=0;
    for (i=0;i<2;i++)
        if (a[i]!=a[i+1]) {tag=1;break;}
    if (!tag) cout<<a;
    else
    {
        if (a[0]>a[1])
        {
            for (i=0;i<3;i++)
                cout<<(char)a[0];
        }
        else if (a[0]<a[1])
        {
            for (i=0;i<3;i++)
                cout<<(char)(a[0]+1);
        }
        else if (a[1]<a[2])
        {
            for (i=0;i<3;i++)
                cout<<(char)(a[0]+1);
        }
        else if (a[1]>a[2])
        {
            for (i=0;i<3;i++)
                cout<<(char)a[0];
        }
    }
    cout<<endl;
}
int main()
{
    while(cin>>a)
        solve();
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int parent(int);
int left(int);
int right(int);

int main(){
  int h,i,A[MAX+1];

  scanf("%d",&h);

  for(i=1;i<=h;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i)<=h){
      printf("left key = %d, ",A[left(i)]); 
    }
    if(right(i)<=h){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }

  return 0;
}

int parent(int x){
  return x/2;
}

int left(int x){
  return 2*x;
}

int right(int x){
  return 2*x+1;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x) for( int i=0;i<(x);i++)
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{ 
      ll k;
      cin>>k;
        string s;
        cin>>s;
        ll h=0,b=0,p=0;
        ll  n=s.size();
        if(n<=k)
        {
            cout<<s<<endl;
        }
        else{
            
    
        for (int i = k; i <k+3 ; i++) 
        {
          s[i]='.';
        }
        for (int i = 0; i <k+3; i++)
        {
            cout<<s[i];
        }
      
        }
       return 0;
       
}

Measured memory_bytes: 3624
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, bCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isNumber = (x: unknown): x is number => typeof x === "number";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isBigint = (x: unknown): x is bigint => typeof x === "bigint";
type NumberOrBigintOrElse<T> = number | bigint extends T
  ? undefined
  : T extends number
  ? number
  : T extends bigint
  ? bigint
  : undefined;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const max = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.max(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc >= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const min = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.min(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc <= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const abs = <T extends number | bigint>(t: T) =>
  (isNumber(t)
    ? Math.abs(t)
    : isBigint(t)
    ? t >= 0n
      ? t
      : -t
    : undefined) as NumberOrBigintOrElse<T>;

/**
 * Program
 */

const P = 10n ** 9n + 7n;
const addP = (x: bigint, y: bigint) => ((x % P) + (y % P)) % P;
const subP = (x: bigint, y: bigint) => ((x % P) - (y % P) + P) % P;
const prodP = (x: bigint, y: bigint) => ((x % P) * (y % P)) % P;
const pow = (x: bigint, n: bigint): bigint => {
  let tmpN = n;
  const isEvens: boolean[] = [];
  while (tmpN !== 1n) {
    isEvens.push(tmpN % 2n === 0n);
    tmpN /= 2n;
  }
  return isEvens.reduceRight((acc, b) => {
    const tmp = prodP(acc, acc);
    return b ? tmp : prodP(x, tmp);
  }, x);
};
const getAns = (N: bigint): string =>
  addP(subP(pow(10n, N), prodP(2n, pow(9n, N))), pow(8n, N)).toString();
{
  const N = bCin();
  const ans = getAns(N);
  console.log(ans);
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll K;

    cin >> K;

    if( K % 2 == 0 ){
        cout << -1 << endl;
        return 0;
    }

    ll i = 1;
    ll m = 7;

    unordered_set<ll> seen;
    seen.insert(m);

    while(true){
        if( m % K == 0 ){
            break;
        }
        m = m % K;
        m = m*10 + 7;
        if( seen.find(m) != seen.end() ){
            cout << -1 << endl;
            return 0;
        }
        seen.insert(m);
        i++;
    }

    cout << i << endl;
}


Measured memory_bytes: 42696
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=302;
const int mod=998244353;
int don[M][M],bor[M][M],dp[M][M];
void compute()
{
	for(int j=300;j>=0;j--)
		for(int k=300;k>=0;k--)
			bor[j][k] = (dp[j][k] + bor[j+1][k+1])%mod;
	for(int j=0;j<=300;j++)
	{
		for(int k=0;k<=300;k++)
		{
			don[j][k] = dp[j][k];
			if(j)
				don[j][k] = (don[j][k]+don[j-1][k])%mod;
		}
	}			
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	int K;
	cin>>K;
	if(s[sz(s)-1]!='0')
		s=s+"0";
	std::vector<int> v;
	int c=0;
	for(int i=0;i<sz(s);i++)
	{
		if(s[i]=='0')
		{
			v.pb(c);
			c=0;
		}
		else
			c++;
	}
	for(int i=0;i<=min(K,300);i++)
		dp[0][i] = 1;
	compute();
	for(int i=sz(v)-1;i>=0;i--)
	{
		for(int j=0;j<=300;j++)
		{
			for(int k=0;k<=300;k++)
			{
				// borrow
				int a = bor[j+1][k+1];
				// donate
				int x = v[i];
				int b = don[j][k];
				if(j>x)
					b = (b-don[j-x-1][k]+mod)%mod;
				dp[j][k] = (a+b)%mod;
			}
		}
		compute();
	}
	cout<<dp[0][0]<<"\n";
	return 0;
}

Measured memory_bytes: 4704
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, m;
    scan(n, m);

    auto adj = new int[][](n, 0);
    foreach (i ; 0 .. m) {
        int ai, bi;
        scan(ai, bi);
        adj[ai - 1] ~= bi - 1;
        adj[bi - 1] ~= ai - 1;
    }

    bool nibu = true;
    int[2] cnt;
    auto c = new int[](n);
    c[] = -1;

    void dfs(int v, int col) {
        c[v] = col;
        cnt[col]++;

        foreach (u ; adj[v]) {
            if (c[u] == -1) {
                dfs(u, col ^ 1);
                continue;
            }
            if (c[u] != (col ^ 1)) {
                nibu = false;
                return;
            }
        }
    }

    dfs(0, 0);

    long ans = nibu ? 1L * cnt[0] * cnt[1] - m : 1L * n * (n - 1) / 2 - m;

    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 10364
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long N= sc.nextLong();
		long M = sc.nextLong();
		long t = N % M;
		long mae = t;
		while(true) {
		    if(mae < Math.abs(mae-M)) {
				break;
			 }else {
				mae = Math.abs(mae-M);
		     }
		}	
		
		System.out.println(mae);
		
	}
	

}


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

using namespace std;


int N, a[1000010], p[1000010], sum[1000010], eo;

char s[1000010];

bool flag = false;


int main() {
	cin >> N;
	scanf("%s", s);
	for (int i = 0; i < N; i++) a[i] = s[i] - '1', flag |= (a[i] == 1);
	if (!flag) {
		for (int i = 0; i < N; i++) a[i] >>= 1;
	}
	for (int i = 1; i < N; i++) {
		p[i] = ((i & 1) ? 0 : p[i >> 1] + 1);
		sum[i] = sum[i - 1] + p[i];
		//cout << sum[i] << "--------\n";
	}
	for (int i = 0; i < N; i++) if (a[i] & 1) eo ^= ((sum[N - 1] - sum[i] - sum[N - 1 - i]) == 0);
	if (eo & 1) return puts(flag ? "1" : "2") & 0;
	return puts("0") & 0;
} 


Measured memory_bytes: 12928
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#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(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}


class CDubiousDocument2 {
public:
	int solve(std::istream& cin, std::ostream& cout) {
          string S;
          string T;
          cin>>S>>T;
          int ind = -1;
          rep(i, S.size()-T.size()+1){
            rep(j, T.size()){
              if (S[i+j] != T[j] && S[i+j] != '?'){
                break;
              }else if (j == T.size()-1){
                ind = i;
              }
            }
          }
          if(ind == -1){
            cout<<"UNRESTORABLE"<<endl;
          }else{
            rep(i, T.size()){
              S[i+ind] = T[i];
            }
            rep(i, S.size()){
              if (S[i] == '?'){
                S[i] = 'a';
              }
            }
            cout<<S<<endl;
          }
	}
};


signed main() {
	CDubiousDocument2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

const int MOD = 1e9+7;

using mint = ModInt<MOD>;

int main(){
    int h, w;
    cin >> h >> w;
    vector<mint> tmp(w+1, 0);
    vector<vector<mint>> dp(h+1, tmp);
    vector<string> a;
    rep(i, h){
        string s;
        cin >> s;
        a.push_back(s);
    }

    dp[0][1] = 1;
    rep2(i, 1, h+1){
        rep2(j, 1, w+1){
            if(a[i-1][j-1]=='.'){
              dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            }
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 8572
l = [x for x in input()]

r = len(l)

l1 = []
l2 = []

c1 = 0
c2 = 0

for i in range(r):
	if i % 2 == 0:
		l1.append('0')
		l2.append('1')
	else:
		l1.append('1')
		l2.append('0')

for i in range(r):
	if l[i] != l1[i]:
		c1 += 1
	if l[i] != l2[i]:
		c2 += 1

if(c1>c2):
  print(c2)
else:
  print(c1)

Measured memory_bytes: 5528
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;
	private int n,count;
	private int[] A;



	public void mainrun() {
		scan = new Scanner(System.in);

		n = scan.nextInt();
		A = new int[n];
		count = 0;
		for(int i = 0;i < n ; i++) {
			A[i] = scan.nextInt();
		}

		serectionSort();

		for(int i = 0;i < n;i++) {
			String s = Integer.toString(A[i]);
			if(i != n - 1) {
				s += " ";
			}else {
				s += "\n";
			}
			System.out.print(s);
		}

		System.out.println(count);
	}

	public void serectionSort() {
		for(int i = 0; i < n;i++) {
			int minj = i;
			for(int j = i;j < n;j++) {
				if(A[j] < A[minj]) {
					minj = j;
				}

			}

			if(i != minj) {
				int tmp = A[i];
				A[i] = A[minj];
				A[minj] = tmp;
				count++;
			}

		}
	}


}


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

const int MN = 18;
vector <int> vec[MN];
bool good[MN];
int n;

vector <int> solve(int xr) {
//	cerr << xr << endl;
	vector <int> all, nic;
	for (int i = 0; i < n; i++)
		if (good[i])
			all.push_back(i);
	for (int i = 0; i < n; i++)
		if (xr >> i & 1)
			nic.push_back(i);
	if (nic.size() % 2 == 0)
		cout << "NO", exit(0);
//	for (int i = 0; i < n; i++)
//		cerr << (xr >> i & 1);
//	cerr << endl;
//	cerr << nic.size() << endl;
	int gd = all.size();
	if (nic.size() == 1) {
		int i = nic[0];		
		int st = 0;
		for (int j = 1; j < vec[gd].size(); j++) {
			int v = vec[gd][j], u = vec[gd][j - 1];
//			cerr << v << ' ' << u << endl;
//			cerr << (u ^ v) << ' ' << (1 << i) << endl;;
			if ((u ^ v) == (1 << i))
				st = j;
//			cerr << st << endl;
		}
//		for (int x: vec[gd])
//			cerr << x << ' ';
//		cerr << endl;
//		cerr << "st = " << st << endl;
//		cerr << vec[gd].size() << endl;
		vector <int> res = {0};
		for (int i = (st + 1) % (1 << gd); i != st; i++, i %= (1 << gd)) {
			int x = vec[gd][i] ^ vec[gd][st], y = 0;
			for (int j = 0; j < gd; j++) 
				if (x >> j & 1)
					y ^= 1 << all[j];
			res.push_back(y);
//			cerr << i << ' ';
		}
		return res;
	}
	int x = nic.back(), y = nic[0];
	vector <int> vec1, vec2;
	good[x] = false;
	vec1 = solve(xr ^ (1 << x) ^ (1 << y));
	vec2 = solve(1 << y);
	good[x] = true;
	for (int &i: vec2)
		i ^= (1 << x) ^ (vec1.back()); 
	//cerr << ((1 << x) ^ (vec1.back())) << '!' << endl;
	vec1.insert(vec1.end(), vec2.begin(), vec2.end());
	return vec1;
}

int main() {
	int A, B;
	cin >> n >> A >> B;
	vec[0] = {0};
	for (int i = 0; i < MN - 1; i++) {
		vec[i + 1] = vec[i];
		reverse(vec[i].begin(), vec[i].end());
		for (int v: vec[i])
			vec[i + 1].push_back(v ^ (1 << i));
		reverse(vec[i].begin(), vec[i].end());
	}
	for (int i = 0; i < n; i++)
		good[i] = true;
	vector <int> res = solve(A ^ B);
	cout << "YES\n";
	for (int u: res)
		cout << (u ^ A) << ' ';
	cerr << endl;
}


Measured memory_bytes: 2812
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
string s[10000];
main()
{
    int a=1e9,b=1e9,c=1e9;
    cin>>n;
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)
    {
        if(i==j)continue;
        int n=stoi(s[i]+s[j]);
        if(a>n)
        {
            c=b;b=a;a=n;
        }
        else if(b>n)
        {
            c=b;b=n;
        }
        else if(c>n)
        {
            c=n;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3624
import math
import random
import sys
import heapq
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, UserString
from functools import lru_cache, cmp_to_key, reduce
from itertools import (chain, combinations, combinations_with_replacement,
                       permutations, product)

sys.setrecursionlimit(10**7)
MAX_INT = 2**62-1

input = sys.stdin.buffer.readline

@lru_cache(None)
def gcd(a, b):
    if not b:
        return a
    return gcd(b, a % b)

if __name__ == "__main__":
    n = int(input())
    ans = (n + 1) * n // 2

    for i in range(1, n+1):
        for j in range(i+1, n+1):
            ans += gcd(j, i) * 6
            for k in range(j+1, n+1):
                ans += gcd(i, gcd(j, k)) * 6
    print(ans)


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

using namespace std;
int main(){
    int n;
    cin>>n;
    long long sum=0;
    for (int i = 1; i <=n; ++i) {
        for (int j = 1; j <=n; ++j) {
            for (int k = 1; k <=n; ++k) {
                sum=sum+__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3596
# 	i+=1


a,b,c,d=(map(int,input().split()))

cer=b//c-a//c
der=b//d-a//d
if(a%c==0):
	cer+=1
if(a%d==0):
	der+=1
def gcd(a,b):
	if(b==0):
		return a
	else:
		return gcd(b,a%b)
newno=int((c*d)/gcd(c,d))
newer=b//newno-a//newno
if(a%newno==0):
	newer+=1
print(b-a+1-cer-der+newer)

Measured memory_bytes: 3064
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())

for i in range(n):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if b==a[j][k]:
        a[j][k]=0

if a[0][0]==a[0][1]==a[0][2] or a[1][0]==a[1][1]==a[1][2] or a[2][0]==a[2][1]==a[2][2]\
or a[0][0]==a[1][0]==a[2][0] or a[0][1]==a[1][1]==a[2][1] or a[0][2]==a[1][2]==a[2][2]\
or a[0][0]==a[1][1]==a[2][2] or a[2][0]==a[1][1]==a[0][2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int arr[] = new int[1000];
        for(int i = 1; i <= 1000; i++) {
            if((a % i == 0) && (b % i == 0)) {
                arr[i] = i;
            }
        }
        int count = 0;
        for(int i = 999; i >= 0; i--) {
            if(arr[i] > 0) {
                count++;
            }
            if(count == k) {
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int X = scanner.nextInt();
		    int A = scanner.nextInt();
		    int B = scanner.nextInt();
		    
			System.out.println( (X - A ) % B );
		    scanner.close(); }
		  }

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    pair<string,int> index[1000];
    int cnt;
    for(cnt=0;cin>>index[cnt].first>>index[cnt].second;cnt++);
    sort(index,index+cnt);
    cout << index[0].first << endl << index[0].second;
    rep(i,cnt){
        if(i == 0) continue;
        if(index[i].first == index[i-1].first) cout << " " << index[i].second;
        else cout << endl << index[i].first << endl << index[i].second;
    }
    cout << endl;
    return 0;
}


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

int main(){
     string S,R;
     cin >> S;
     cin >> R;
     int count=0;
     for (int i=0;i<3;i++){
          if(S[i]==R[i]){
               count ++;
          }
     }
     cout << count <<endl;
}


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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if((A==B && A!=C) || (B==C && A!=C) || (A==C && A!=B)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
l = input()
s = [int(i) for i in l]
l1 = len(l)
l2 = l[int(l1) - 1]
if int(l2) == 3:
  print("bon")
elif int(l2) == 0:
  print("pon")
elif int(l2) == 1:
  print("pon")
elif int(l2) == 6:
  print("pon")
elif int(l2) == 8:
  print("pon")
else:
  print("hon")

Measured memory_bytes: 9144
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	long N;
	List<Integer> list;

	Main(BufferedReader in) throws IOException {
		N = Long.parseLong(in.readLine()) - 1;
		list = new ArrayList<>();
	}

	void calc() {
		if (N == 0) {
			list.add(0);
			return;
		}
		while (N >= 0) {
			list.add((int) (N % 26));
			N /= 26;
			N -= 1;
		}
		Collections.reverse(list);

	}

	char conv(int i) {
		return (char) (i + 97);
	}

	void showResult() {
		char[] chars = new char[list.size()];
		for (int i = 0; i < list.size(); ++i) {
			chars[i] = conv(list.get(i));
		}
		for (int i = 0; i < list.size(); ++i) {
			System.out.print(chars[i]);
		}
		System.out.println("");
	}
}

Measured memory_bytes: 32560
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   ll l,r;
   cin>>l>>r;
   ll ans=2019;
   if(r-l>=2019){
       cout<<0<<endl;
   }else{
       for(ll i=l;i<r;i++){
           for(ll j=i+1;j<=r;j++){
               ll tmp=(i*j)%2019;
               ans=min(ans,tmp);
           }
       }
       cout<<ans<<endl;
   }
   return 0;
}

Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
function main()
  V=zeros(Int,3010,3010)
  dp=zeros(Int,3010,3010,4)
  R,C,K=parse.(Int,split(readline()))
  for i=1:K
    r,c,v=parse.(Int,split(readline()))
    V[r,c]=v
  end
  for i=1:R
    for j=1:C
      for k=1:3
        dp[i+1,j+1,k+1]=max(dp[i+1,j+1,k+1],dp[i+1,j,k+1],max(dp[i,j+1,4],dp[i+1,j,k])+V[i,j])
      end
    end
  end
  println(dp[R+1,C+1,4])
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 571060
card = [list(map(int,list(input().split()))) for i in range(3)]
n = n=int(input())
s=[int(input()) for i in range(n)]
ans = "No"

for i in card:
    for j in i:
        if j in s:
            location = i.index(j)
            i[location] = -1

if card[0][0] == card[1][0] == card[2][0] == -1 or card[0][1] == card[1][1]== card[2][1] == -1 or card[0][2] == card[1][2] == card[2][2] == -1:
    ans = "Yes"
    
if card[0] == [-1, -1, -1]:
    ans = "Yes"
if card[1] == [-1, -1, -1]:
    ans = "Yes"
if card[2] == [-1, -1, -1]:
    ans = "Yes"

if card[0][0] == card[1][1] == card[2][2] == -1 or card[0][2] == card[1][1]== card[2][0] == -1:
    ans = "Yes"

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String x = scan.next();
		String y = scan.next();

		int numx  = Integer.parseInt(x, 16);
		int numy = Integer.parseInt(y, 16);
		
		if(numx<numy){
			System.out.println("<");
		}else if(numx>numy){
			System.out.println(">");
		}else{
			System.out.println("=");
		}

	}

}


Measured memory_bytes: 22612
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n=int(input())
    s=set()
    for i in range(n):
        s.add(input())
    print(len(s))



if __name__ == "__main__":

    main()

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

long A = 0;

double B = 0.0f;

long long result = 0;

int main(){
  cin>>A;
  cin>>B;
  
  B = (int)(B*100.0f + 0.1f);
  
  if(A==0){
    cout<<0;
    return 0;
  }
  
  result = (A*(int)B)/100;
  
    cout<<result;

  return 0;
}


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

int dp[100005];
int n;
string S;
string nex[] = { "dream",
                 "dreamer",
                 "erase",
                 "eraser" };

bool check(int i,int d){
  if(i+nex[d].size()>n) return false;
  for(int j=0;j<nex[d].size();j++)
    if( S[i+j] != nex[d][j] ) return false;
  return true;
}

int solve(){
  n = S.size();
  dp[0] = 1;
  for(int i=0;i<n;i++){
    for(int d=0;d<4;d++){
      if( check( i, d ) )
        dp[i+nex[d].size()] = dp[i];
    }
  }
  return dp[n];
}
int main(){
  cin >> S;
  if( solve() ) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 1e5 + 5;

vector<ll>ys[maxn];
vector<ll>gy[maxn];
ll comps = 0;
bool used[maxn];
vector<ll>compy[maxn];

void dfs(ll y) {
	used[y] = 1;
	compy[comps].push_back(y);
	for (ll yy : gy[y]) {
		if (used[yy]) continue;
		dfs(yy);
	}
}

bool lol[maxn];
vector<ll>xs[maxn];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	vector<pair<ll, ll>>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i].X >> a[i].Y;
		lol[a[i].Y] = 1;
		xs[a[i].Y].push_back(a[i].X);
		ys[a[i].X].push_back(a[i].Y);
	}
	for (ll x = 1; x < maxn; x++) {
		if ((ll)ys[x].size() >= 2) {
			for (ll i = 0; i + 1 < ys[x].size(); i++) {
				gy[ys[x][i]].push_back(ys[x][i + 1]);
				gy[ys[x][i + 1]].push_back(ys[x][i]);
			}
		}
	}
	long long ans = 0;
	for (ll y = 1; y < maxn; y++) {
		if (!lol[y]) continue;
		if(!used[y]) dfs(y);
		unordered_set<ll>st;
		for (ll yy : compy[comps]) {
			for (ll x : xs[yy]) {
				st.insert(x);
			}
		}
		ll cnt = st.size();
		ans += (ll)compy[comps].size() * cnt;
		comps++;
	}

	cout << ans - n;
	return 0;
}
/*

*/

Measured memory_bytes: 20860
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long
#define trace(x) cerr << #x << " = " << x << endl
using namespace std;

int main()
{
   /* #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("ouput.txt","w",stdout);
    #endif*/ 

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while(t--){
            int k;
	    cin>>k;
	    int curr = 7%k, ans = 1;
	    if(k%2==0  or  k%5==0){
		    return cout<<-1<<endl,0;
	    }
	    else{
		  
                   while(curr!=0){
			   curr = curr*10 + 7;
			   curr%=k;
                           ans++;
		   }
	    }
	    cout<<ans<<endl;
      } 
    return 0;
} 


Measured memory_bytes: 3660
N = int(input())
A = [int(input()) for _ in range(N)]
dic = {}
for i in range(N):
    data = A[i]
    if data in dic:  dic[data] += 1
    else:  dic[data] = 1
ans = 0
for i in dic:
    if dic[i] % 2:  ans += 1
print(ans)

Measured memory_bytes: 94484
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

ll func(ll num){
    if(num == 0) return 0;
    else if(num <= 6) return 1;
    else return 2;
}

int main(){
    ll x;
    cin >> x;
    ll a, b;
    a = x / 11;
    b = x % 11;
    ll ans = a * 2 + func(b);
    cout << ans << endl;
    return 0;
}

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

int main()
{
  set<int>ans;
  int N,K;
  int m,b;
  int R;
  int p,q;
  cin>>N>>K;
  vector< set<int> >boat(K);
  for(int i=0;i<K;i++){
    cin>>m;
    for(int j=0;j<m;j++){
      cin>>b;
      boat[i].insert(b);
    }
  }
  cin>>R;
  for(int i=0;i<R;i++){
    cin>>p>>q;
    for(int j=0;j<K;j++){
      if(boat[j].find(p)==boat[j].end())continue;
      if(boat[j].find(q)==boat[j].end())continue;
      ans.insert(p);
      ans.insert(q);
    }
  }
  cout<<ans.size()<<endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e3 + 10;
const int MOD=1e9 + 7;
int n,m,dp[MAX][MAX];
string S[MAX];
bool vis[MAX];
bool valid(int i,int j)
{
    return i>=0&&i<n&&j>=0&&j<m;
}
int dfs(int x,int y)
{
    if(valid(x,y)==0 || S[x][y]=='#')return 0;
    if(x==n-1&&y==m-1)return 1;
    if(dp[x][y]!=-1)return dp[x][y];
    int ans=0;
    ans+=dfs(x+1,y)%MOD;
    ans+=dfs(x,y+1)%MOD;
    return dp[x][y]=ans%MOD;
}
int main ()
{
    memset(dp,-1,sizeof dp);
    cin >> n >> m;
    for(int i=0;i<n;i++)cin>>S[i];

    cout<<dfs(0,0);
    return 0;
}



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

bool b[10];

bool hoge(ll x){
    while(x>0){
        ll a=x%10;
        x/=10;
        if(!b[a]){
            return false;
        }
    }
    return true;
}

int main(){
    ll n,k;cin>>n>>k;
    ll d[k];rep(i,0,k-1)cin>>d[i];
    rep(i,0,9)b[i]=true;
    rep(i,0,k-1)b[d[i]]=false;
    rep(i,n,1000000){
        if(hoge(i)){
            cout<<i<<endl;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CGreenBin {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<string> v(N);
        REP(i, N) {
            string s;
            cin >> s;
            sort(s.begin(), s.end());
            v[i] = s;
        }
        sort(v.begin(), v.end());

        int res = 0;
        string prev = "";
        int tmp = 0;
        REP(i, N) {
            string s = v[i];
            if (s == prev) {
                tmp++;
            } else {
                prev = s;
                if (tmp > 1) {
                    res += tmp * (tmp - 1) / 2;
                }
                tmp = 1;
            }
        }
        if (tmp > 1) {
            res += tmp * (tmp - 1) / 2;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CGreenBin solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 5760
import sys
sys.setrecursionlimit(1000000000)
n,k = map(int,input().split())
G = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

mod = 1000000007
def perm(n,k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n]*finv[n-k]%mod
fac = [1]*(k+1)
finv = [1]*(k+1)
for i in range(1,k+1):
    fac[i] = fac[i-1]*i%mod
    finv[i] = pow(fac[i],mod-2,mod)

def dfs(cur,prev=-1):
    nxtcnt = 0
    res = 1
    for nxt in G[cur]:
        if nxt == prev: continue
        nxtcnt += 1
        res = res*dfs(nxt,cur)%mod
    colors = k-1 if cur == 0 else k-2
    res = res*perm(colors,nxtcnt)%mod
    return res
  
ans = k*dfs(0)%mod
print(ans)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
  double N, K; cin >> N >> K;
  vector<int> A(N); REP(i, N) cin >> A[i];

  double a = (N - 1) / (K - 1);
  cout << ceil(a) << endl;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi x(N), y(N), h(N);
    REP(i, N) cin >> x[i] >> y[i] >> h[i];
    REP(Cx, 101)
    {
        REP(Cy, 101)
        {
            int Ch;
            REP(i, N)
            {
                if(h[i] != 0)
                {
                    Ch = h[i] + abs(x[i] - Cx) + abs(y[i] - Cy);
                    break;
                }
            }
            int i = 0;
            for(; i < N; i++)
            {
                if(max(Ch - abs(x[i]-Cx) - abs(y[i]-Cy), 0) != h[i]) break;
            }
            if(i == N)
            {
                cout << Cx << " " << Cy << " " << Ch << endl;
            }
        }
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256