akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		HashSet<String> hs = new HashSet<>();
		int i;
		String temp = "";
		String bef ="";
		boolean f = true;
		for(i = 0; i < n; i++) {
			temp = scan.next();
			if(i != 0) {
				if(hs.contains(temp))
					f = false;
				if(!temp.startsWith(bef.substring(bef.length() - 1, bef.length())))
					f = false;
			}
			hs.add(temp);
			bef = new String(temp);
		}
		if(f)
			out.print("Yes");
		else
			out.print("No");
		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[200005];
ll B[200005];

int main()
{
    ll K, N;
    cin >> N >> K;
    int n = 0;
    REP(i, N)
    {
        cin >> A[i];
        A[i]--;
        if (B[A[i]]++ == 0)
            n++;
    }
    sort(B, B + N);
    ll sum = 0;
    for (int i = 0; n > K; ++i)
    {
        sum += B[i];
        if (B[i] > 0)
            n--;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int cnt[2][2];
char s[100005];

int main() {
	scanf("%s", s);
	
	int l = strlen(s);
	
	for (int i = 0; i < l; i++) {
		if (i & 1) {
			if (s[i] == '0') cnt[0][0]++;
			if (s[i] == '1') cnt[1][0]++;
		}
		else {
			if (s[i] == '1') cnt[0][1]++;
			if (s[i] == '0') cnt[1][1]++;
		}
	}
	
	printf("%d\n", min(cnt[0][0] + cnt[0][1], cnt[1][0] + cnt[1][1]));
}


Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	ll x;
	cin >> k >> x;
	ll left = x - k + 1;
	if (left < -1000000) {
		left = -1000000;
	}
	ll right = x + k - 1;
	if (right > 1000000) {
		left = 1000000;
	}
	for (ll i = left; i <= right; i++) {
		if (i == right) {
			cout << i << endl;
			return 0;
		}
		cout << i << " ";
	}
}



Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].add(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

n,m,k=map(int,input().split())

fri=[[] for i in range(n)]
blk=[set() for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].add(d)
    blk[d-1].add(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append(set())
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(unii&blk[j-1])-1
        seq[j-1]=cj

print(*seq)

Measured memory_bytes: 83724
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
A,B = parseMap(split(readline()))    
for i in 1:1000000
    if Int(floor(i * 0.08)) == A && Int(floor(i * 0.1)) == B
        return i
        break
    end
end
return -1
end

println(main())

Measured memory_bytes: 168236
import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)


Measured memory_bytes: 28796
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;

const int Maxn=60;

const long double g=9.8;
const long double eps= 1e-8;

int N; long double V,X,Y;

long double L[Maxn],B[Maxn],R[Maxn],T[Maxn];

long double Calcy(long double vy,long double t){return vy*t-0.5*g*t*t;}
long double Calcx(long double vx,long double t){return vx*t;}

int cmp(long double lb,long double ub,long double a)
{
  return a<lb+eps ? -1 : a>ub-eps ? 1 : 0;
}

bool Check(long double x,long double y) // ????????????(x,y) 
{
  long double a=0.25*g*g; long double b=g*y-V*V; long double c=x*x+y*y;
  long double delta= b*b-4*a*c;
  if(delta < 0 && delta > -eps) delta=0.0;
  else if(delta < 0) return 0;
  for(int op=-1;op<=1;op+=2)
  {
    long double t=sqrt((-b+sqrt(delta)*op)/(2.0*a));
    if(t<=0) continue;
    long double vx=x/t; long double vy=(y+0.5*g*t*t)/t; //?????????
    long double yt=Calcy(vy,X/vx); //???????¨?????????????
   	if(yt < Y-eps) continue;
   	bool ok=1;
   	for(int i=1;i<=N;i++)
   	{
   	  if(L[i] >= X) continue;
   	  if(R[i] == X && yt >= T[i] && B[i] >= Y){ok=0; break;}
   	  int yL=cmp(B[i],T[i],Calcy(vy,L[i]/vx));
   	  int yR=cmp(B[i],T[i],Calcy(vy,R[i]/vx));
   	  int xH=cmp(L[i],R[i],Calcx(vx,vy/g));
   	  int yH=cmp(B[i],T[i],Calcy(vy,vy/g));
   	  if( xH == 0 && yH >= 0 && yL<=0){ok=0; break;}
   	  if(yL * yR <=0){ok=0; break;}
   	}
   	if(ok) return 1;
  } 
  return 0;
}

int main()
{

  cin >> N >> V >> X >> Y;
  for(int i=1;i<=N;i++) cin >> L[i] >> B[i] >> R[i] >> T[i];

  for(int i=1;i<=N;i++) R[i]=min(R[i],X);

  bool ok=0;
  ok=Check(X,Y);

  for(int i=1;i<=N;i++)
  {
    ok|=Check(L[i],T[i]);
    ok|=Check(R[i],T[i]);
  }

  puts(ok ? "Yes" : "No");

  return 0;
}

Measured memory_bytes: 3232
s = input()


def solve(query):
    while 1:
        for frag in ("erase", "eraser", "dream", "dreamer"):
            if query.endswith(frag):
                query = query[:-len(frag)]
                break
        else:
            print("NO")
            break
        if not query:
            print("YES")
            break



solve(s)

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

int main() {
  string s, st = "keyence";
  cin >> s;
  int n = s.length();
  for (int i = 0; i <= 7; i++) {
    bool flag = true;
    for (int j = 0; j < i; j++)
      if (s[j] != st[j]) flag = false;
    for (int j = n + i - 7; j < n; j++)
      if (s[j] != st[j - n + 7]) flag = false;
    if (flag) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
  class Main{
      public static void main(String[] args){
      Scanner stdIn = new Scanner(System.in);
      int n=stdIn.nextInt();
      int m=stdIn.nextInt();
      Integer[] aa=new Integer[n];
      int sum=0;
      for(int l=0;l<n;l++){
          int j=stdIn.nextInt();
          aa[l]=j;
          sum+=j;
      }
      double k=sum/(4.0*m);

      Arrays.sort(aa, Collections.reverseOrder()); 
      if(aa[m-1]<k){
          System.out.println("No");
      }else{
          System.out.println("Yes");
      }   
      }
  }



Measured memory_bytes: 22740
#include <stdio.h>
int main() {
  int N, K, Q, i;
  scanf("%d%d%d", &N, &K, &Q);
  int A[Q];
  int count[N+1];
  for (i = 0; i < N+1; ++i) {
    count[i] = 0;
  }
  for (i = 0; i < Q; ++i) {
    scanf("%d", &A[i]);
    ++count[A[i]];
  }
  for (i = 1; i < N+1; ++i) {
    if (count[i] <= Q-K) {
      printf("No\n");
    } else {
      printf("Yes\n");
    }
  }
  return 0;
}

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

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

int a[5];

int main()
{
    _FastIO;
    cin >> a[0] >> a[1] >> a[2];
    sort(a , a + 3);
    reverse(a , a + 3);
    cout << a[0] * 10 + a[1] + a[2] << endl;
    return 0;
}


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

int main()
{
  float a,b;
  int ans;
  cin>>a>>b;
  if(b==1)
    ans=0;
  else 
    ans =ceil((b-1)/(a-1));
  
  
  cout<<ans;
  return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 50 + 5;
const ll INF = 1e17 + 7 , mod = 1e9 + 7;
const double eps = 1e-9 , PI = acos(-1);


int n , m;

int dep[N];
int p[N];
int w[N];
ii a[N];
vii adj[N];

ll cost[N][N];

void dfs(int u , int pr , int d){
    p[u] = pr;
    w[u] = d;
    dep[u] = 1 + dep[pr];

    for(ii A : adj[u]){
            if(A.second != pr){
                    dfs(A.second , u , A.first);
            }
    }

}

int get_lca(int u , int v){

    while(u != v){
            if(dep[u] < dep[v])swap(u , v);

            if(dep[u] == dep[v]){
                    u = p[u] , v = p[v];
            }
            else u = p[u];
    }

    return u;
}

ll calc(int u , int v){
    int lca = get_lca(u , v);

    ll mask = 0;
    while(u != lca){
            mask |= 1ll << w[u];
            u = p[u];
    }
    while(v != lca){
            mask |= 1ll << w[v];
            v = p[v];
    }

    return mask;
}

void solve(int testCase){

    scanf("%d" , &n);

    for(int i = 0 ; i < n-1 ; i ++){
            int u , v; scanf("%d %d" , &u , &v);

            adj[u].push_back({i , v});
            adj[v].push_back({i , u});
    }

    dfs(1 , 0 , 0);

    scanf("%d" , &m);
    for(int i = 0 ; i < m ; i ++){
            scanf("%d %d" , &a[i].first , &a[i].second);

            cost[ a[i].first ][ a[i].second ] = cost[ a[i].second ][ a[i].first ] = calc(a[i].first , a[i].second);
    }

    ll ans = 0;
    for(int mask = 1 ; mask < (1 << m) ; mask ++){

            ll edges = 0ll;
            for(int i = 0 ; i < m ; i ++){
                    if(mask & (1 << i)){
                            edges |= cost[a[i].first][a[i].second];
                    }
            }

            ll num = __builtin_popcountll(edges);
            if(__builtin_popcount(mask)&1){
                    ans += (1ll << (1ll * (n - 1 - num)));
            }
            else {
                    ans -= (1ll << (1ll * (n - 1 - num)));
            }
    }


    printf("%lld\n" , (1ll << (1ll * (n-1))) - ans);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)
 
int n;
char color[200010];
int id, tmp, ans;
int r[200010];
inline void solve(int T) {
    cin >> n;
    cin >> color + 1;
    id = tmp = ans = 0;
    rep(i, 1, n) if(color[i] == 'R') r[++id] = i;
    rep(i, 1, n) {
        if(i >= r[id]) break;
        if(color[i] == 'W') {
            ans++;
            id--;
        }
    }
    cout << ans << endl;
}   
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
 
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
    // system("pause");
}

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

static const int inf=1e9;
struct Node
{
    int data;
    Node *l,*r;
};
int m;
int total;

///此处必须定义二级指针 或者指针的引用 或者返回Node *才能返回修改后的p
void add_point(Node *&p,int x)
{
    if(p==NULL)
    {
        p=(Node *)malloc(sizeof(Node));
        p->data=x;
        p->l=NULL;
        p->r=NULL;
        return;
    }
    if(x < p->data)
        add_point(p->l,x);
    else
        add_point(p->r,x);
}

bool find_point(const Node *p,int x)
{
    if(p==NULL)
        return false;
    if(p->data==x)
        return true;
    else if(x<=p->data)
        return find_point(p->l,x);
    else
        return find_point(p->r,x);
}

void inorder(Node *p)
{
    if(p!=NULL)
    {
        inorder(p->l);
        printf(" %d",p->data);
        inorder(p->r);
    }
}

void preorder(Node *p)
{
    if(p!=NULL)
    {
        printf(" %d",p->data);
        preorder(p->l);
        preorder(p->r);
    }
}

int main()
{
    int i,x;
    char st[20];
    Node *tree=NULL;

    cin>>m;
    for(i=1;i<=m;i++)
    {
        scanf("%s",st);
        if(st[0]=='i')
        {
            scanf("%d\n",&x);
            add_point(tree,x);
        }else if(st[0]=='f')
        {
            scanf("%d\n",&x);
            if(find_point(tree,x))
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
        }else
        {
            inorder(tree);
            cout<<endl;
            preorder(tree);
            cout<<endl;
        }
    }
    return 0;
}



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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4

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

    int n, k;
    cin >> n >> k;
    vec x(n);
    init(x);

    int ans = INF;
    For(i, 0, n - k) {
        int l = x[i], r = x[i + k - 1];
        int candi;
        if (l * r >= 0)
            candi = max(abs(l), abs(r));
        else
            candi = min(abs(l) * 2 + abs(r), abs(r) * 2 + abs(l));
        ans = min(ans, candi);
    }
    print(ans);

    return 0;
}

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

int main() {
	int n, m; cin >> n >> m;
	int64_t a[n];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] >>= 1ll;
	}
	int64_t lcm = 1;
	set<int> st;
	for(int i = 0; i < n; ++i) {
		lcm = lcm / __gcd(lcm, a[i]) * a[i];
		if(lcm > m) {
			cout << 0 << '\n';
			return 0;
		}
		int64_t tmp = a[i];
		int cnt = 0;
		while(tmp % 2 == 0) {
			tmp >>= 1ll;
			++cnt;
		}
		cerr << cnt << '\n';
		st.insert(cnt);
	}
	if(st.size() != 1) {
		cout << 0 << '\n';
		return 0;
	}
	cout << m / lcm - m / (2 * lcm) << '\n';
	return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(s.substr(0,n/2)==s.substr(n/2,n/2) && (n%2==0))
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s;
    if (s.length() < 4){
        cout << "No" << endl;
        return 0;
    }
    if (s[0] == 'Y' && s[1] == 'A' && s[2]=='K' && s[3] == 'I')
        cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

vector<int> taro;
vector<int> hana;
int n,m,a;
int tarowa=0,hanawa=0;

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

int solve(){
  int exi,exj;
  int min = 100000;
  REP(i,m){
    REP(j,n){
      if(tarowa-taro[j]+hana[i] == hanawa -hana[i] + taro[j]){
	if(taro[j] + hana[i] < min){
	  min = taro[j] + hana[i];
	  exi = i;
	  exj = j;
	}
      }
    }
  }
  if(min != 100000)
    cout << taro[exj] << " " << hana[exi] << endl;
  else
    cout << -1 << endl;
  
  return 0;
}


int main(){
  while(true){
    cin >> n >> m;
    if(!n&&!m)break;

    taro.resize(n);
    hana.resize(m);
    
    REP(i,n){
      a=nextInt();
      taro[i] = a;
      tarowa += a;}
    REP(i,m){
      a=nextInt();
      hana[i] = a;
      hanawa += a;
    }
    
    solve();
    tarowa = 0;
    hanawa = 0;
    taro.clear();
    hana.clear();
  }
  return 0;
}

Measured memory_bytes: 3008
#include<bits/stdc++.h>
#define mp make_pair
#define eps 1e-8
using namespace std;
typedef pair<int, int> pii;
int main(){
  int a, b, d;
  while(cin >> a >> b >> d, a){
    int x = 0, y = 0;
    pii ans = mp(1e9, 1e9);
    for(int i = -(d/b) - 1 - b; i <= b; i++){
      x = i;
      if((a*x + d) % b != 0)continue;
      y = (a*x + d) / b;
      if(ans.first + ans.second > abs(x) + abs(y)){
	ans = mp(abs(x), abs(y));
      }else if(ans.first + ans.second == abs(x) + abs(y)){
	if(a*ans.first + b*ans.second > a*abs(x) + b*abs(y))
	ans = mp(abs(x), abs(y));
      }
    }
    cout << ans.first << " " << ans.second << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

void solve(){
    int n;
    cin >> n;
    ll s = 0;
    for(int i=1; i<=n; i++){
        if(i%3==0||i%5==0)
            continue;
        s += i;
    }
    cout << s;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1, i = 1;
    //cin >> t;
    while(t--){
        solve();
        ++i;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;



int main() {
	string s, t,a;
	string ans;
	int flag;
	ans = "";
	cin >> s >> t;
	if (SZ(s) < SZ(t)) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		REP(i, SZ(s) - SZ(t) + 1) {
			flag = 0;
			a = s;
			 REP(j,SZ(t)){
				 //cout << a << endl;
				 if (a[i+j] == t[j] ) {

				 }
				 else if (a[i+j] == '?') {
					 a[i+j] = t[j];
				 }
				 else {
					 flag = 0;
					 break;
				 }
			
				 if (j == SZ(t) - 1) flag = 1;
			 
			 }
			 if (flag == 1) {
				// a = s;
				 REP(i, SZ(a)) {
					 if (a[i] == '?') {
						 a[i] = 'a';
					 }
				 }
				 if (ans != "") {
					 if (!lexicographical_compare(ans.begin(), ans.end(), a.begin(), a.end())) {
						 ans = a;
					 }
				 }
				 else {
					 ans = a;
				 }
			 }
		
		
		}
		if (ans != "") {
			cout << ans << endl;
		}
		else {
			cout << "UNRESTORABLE" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int Maxn=100000;
const int Maxm=200000;
int fa[Maxn+5];
int find(int x){
	if(fa[x]==x){
		return x;
	}
	return fa[x]=find(fa[x]);
}
void merge(int x,int y){
	int fa_x=find(x),fa_y=find(y);
	if(fa_x==fa_y){
		return;
	}
	fa[fa_y]=fa_x;
}
int head[Maxn+5],arrive[Maxm<<1|5],nxt[Maxm<<1|5],val[Maxm<<1|5],tot;
void add_edge(int from,int to,int v){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	val[tot]=v;
	head[from]=tot;
}
struct Bomb{
	int a,b;
	friend bool operator <(Bomb p,Bomb q){
		return p.a<q.a;
	}
}a[Maxn+5];
int d[Maxn+5],d_len;
int n,m;
struct Segment{
	int l,r;
}b[Maxm+5];
int ans[Maxm+5];
int c[Maxn+5];
bool vis[Maxn+5];
int las[Maxn+5];
int use[Maxn+5];
void dfs(int u){
	vis[u]=1;
	use[u]=c[u];
	for(int i=head[u];i;i=nxt[i]){
		int v=arrive[i];
		if(vis[v]){
			continue;
		}
		las[v]=val[i];
		dfs(v);
		use[u]^=use[v];
	}
	ans[las[u]]^=use[u];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].a,&a[i].b);
		d[++d_len]=a[i].a;
	}
	for(int i=1;i<=n+1;i++){
		fa[i]=i;
	}
	sort(a+1,a+1+n);
	sort(d+1,d+1+d_len);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&b[i].l,&b[i].r);
		b[i].l=lower_bound(d+1,d+1+d_len,b[i].l)-d;
		b[i].r=upper_bound(d+1,d+1+d_len,b[i].r)-d-1;
		if(b[i].l>b[i].r){
			continue;
		}
		if(find(b[i].l)!=find(b[i].r+1)){
			merge(b[i].l,b[i].r+1);
			add_edge(b[i].l,b[i].r+1,i);
			add_edge(b[i].r+1,b[i].l,i);
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i].b){
			c[i]^=1;
			c[i+1]^=1;
		}
	}
	for(int i=1;i<=n+1;i++){
		if(!vis[i]){
			dfs(i);
			if(ans[0]){
				puts("-1");
				return 0;
			}
		}
	}
	int num=0;
	for(int i=1;i<=m;i++){
		if(ans[i]){
			num++;
		}
	}
	printf("%d\n",num);
	for(int i=1;i<=m;i++){
		if(ans[i]){
			printf("%d ",i);
		}
	}
	puts("");
	return 0;
}


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

int main() {
  int N;
  cin >> N;
 vector<int> A(N);
  for(int i = 0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  A.push_back(0);
  int count = 0;
  int c = 1;
for(int i = 0;i<N;i++){
  if(A[i] == A[i+1]) c++;
  else{
    if(c%2 != 0) count++;
    c = 1;
  }
}
cout << count << endl;

}

  
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[101];

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		a[t] = 1;
	}

	int t1 = 0;
	for (int i = x; i <= n; i++) {
		t1 += a[i];
	}
	int t2 = 0;
	for (int i = x; i >=0; i--) {
		t2+= a[i];
	}
    if(t1 > t2)
        cout << t2;
    else
        cout << t1;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;

ll n, h;
ll a[MAXN], b[MAXN];

void solve() {
  sort(a, a+n, greater<ll>());
  sort(b, b+n, greater<ll>());
  ll sum = 0;
  ll cnt = 0;
  for (int i=0;i<n;i++) {
    if (a[0] <= b[i] && sum < h) {
      sum += b[i];
      cnt++;
    } else {
      break;
    }
  }
  if (sum < h) {
    cnt += (h - sum + a[0] - 1) / a[0];
  }
  cout << cnt << endl;
}

int main() {
  cin >> n >> h;
  for (int i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  solve();
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int d;
    cin >> d;
    cout << "Christmas";
    rep(i, 25 - d) cout << " Eve";
    cout << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
require 'set'
require 'pp'
N, M = gets.chomp.split(" ").map(&:to_i)
p = gets.chomp.split(" ").map(&:to_i)
N.times do |i|
  p[i] -= 1
end
x = []
y = []
M.times do |i|
  a, b = gets.chomp.split(" ").map(&:to_i)
  x[i] = a - 1
  y[i] = b - 1
end

## union find tree

par = (0..N-1).to_a
def root(par, a)
  if par[a] == a
    a
  else
    par[a] = root(par, par[a])
  end
end
def same_group?(par, x, y)
  root(par, x) == root(par, y)
end
def unite(par, a, b)
  a = root(par, a)
  b = root(par, b)
  return if a == b
  par[a] = b
end

M.times do |i|
  unite(par, x[i], y[i])
end

# pp par

##

index_hash = Hash.new { Set.new }
value_hash = Hash.new { Set.new }
N.times do |i|
  root = root(par, p[i])
  index_set = index_hash[root]
  value_set = value_hash[root]
  index_set << i
  value_set << p[i]
  index_hash[root] = index_set
  value_hash[root] = value_set
end

# pp index_hash
# pp value_hash

ans = 0
index_hash.each do |root, index_set|
  hash_set = value_hash[root]
  ans += index_set.intersection(hash_set).size
end

puts ans


Measured memory_bytes: 118864
import java.util.Scanner;

public class Main {
    static int result = 0;
     static int fibonanci(int n){
         result += n;
        if(n <= 1 ){
            return n;
        }
        return fibonanci(n-1);

    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n;
        n = in.nextInt();
        fibonanci(n);
        System.out.println(result);


    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,mp;
  cin>>n>>mp;
  long long int arr[n];
  map<int,int> h;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
      h[i+1]=arr[i];
  }
  map<int,vector<int>> m;
  while(mp--)
  {
      int u,v;
      cin>>u>>v;
      m[u].push_back(v);
      m[v].push_back(u);
  }
  int count=0,count2=0;
  for(auto it=m.begin();it!=m.end();it++)
  {
      int val=h[it->first];
      count2=0;
      for(int i=0;i<it->second.size();i++)
      {
          if(val>h[it->second[i]])
          {
              count2++;
              //break;
          }
          
      }
      if(count2==it->second.size())
      {
          count++;
      }
      
  }
  cout<<count+(n-m.size())<<endl;
  
}


Measured memory_bytes: 18684
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

const int MX=100005;

int main()
{
    int n;
    scanf("%d",&n);
    int x,y,z=0,m=0;
    for(int i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(x==y) z++;
        else z=0;
        m=max(m,z);
    }
    if(m>2) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3656
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e7+7;
int isPrime[N+1];

void sieve()
{
    
    rep(i,1,N)
    isPrime[i]=i;
    
    isPrime[1]=1;
    isPrime[0]=1;
    
    
    for(int i=2;i*i<=N;i++)
    {
        if(isPrime[i]==i)
        for(int j=i*i;j<=N;j+=i)
       { 
           if(isPrime[j]==j)
           isPrime[j]=i;
       }
    }
    
}

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


int main()
{
   
    int n,f=1;
    scf(n);
    
    int a[n];
    
    rep(i,0,n)
    scf(a[i]);
    
     map<int,int>m;
     
     sieve();
    
    
    for(int i=0;i<n;i++)
    {
            int x=a[i];
                
            while(x!=1)
            {
                int c=isPrime[x];
                
               while(x%c==0)
               x/=c;
               
                
                m[c]++;
                    
            }
            
    }
    
    
            
    
    int g=gcd(a[0],a[1]);
    
    for(auto it:m)
    {
        if(it.S>1)
        {  f=0;
        break;}
        
    }
    
 
    rep(i,2,n)
    g=gcd(g,a[i]);
    
    
    if(f)
    printf("pairwise coprime\n");
    
    else if(g==1)
    printf("setwise coprime\n");
    
    else
    printf("not coprime\n");
    
    
    
    

        
}

Measured memory_bytes: 50172
#include <bits/stdc++.h>
using namespace std;
int main(){
	int K, Q; cin >> K >> Q; 
	long long D[5010] = {}; 
	for(int i = 0; i < K; i++) cin >> D[i]; 
	long long R[5010] = {}; 
	long long S[5010] = {}; 
	long long E[5010] = {}; 
	while(Q--){
		long long N, X, M; 
		cin >> N >> X >> M; 
		for(int i = 0; i < K; i++){
			R[i] = D[i] % M; 
			if(i == 0) S[0] = R[0]; 
			else S[i] = S[i-1] + R[i]; 
			if(i == 0 && R[i] == 0) E[0] = 1; 
			else E[i] = E[i-1] + (R[i] == 0); 
		}
		long long final = X + (N - 2) / K * S[K-1] + S[(N - 2) % K]; 
		long long jump = final / M - X / M; 
		long long equal = (N - 2) / K * E[K-1] + E[(N - 2) % K]; 
		cout << N - 1 - jump - equal << endl;  
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

ll a[100010];

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

  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;

  rep(i, n) {
    rep(j, i + 1, n) {
      // 抜け道を使った場合の距離
      // 1から5まで歩いた
      int dist = abs(i - j);

      // 抜け道Xを使った場合の距離
      // 1からx まで歩く + 1 + yから5まで歩く
      int distx = abs(x - i) + 1 + abs(y - j);

      // 抜け道Yを使った場合の距離
      // 1からyまで歩く + 1 + xから5まで歩く
      int disty = abs(y - i) + 1 + abs(x - j);

      dist = min(dist, distx);
      dist = min(dist, disty);
      a[dist]++;
    }
  }

  rep(i, 1, n) {
    cout << a[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
function main(input) {
  let args = input.split(/\n|\s/);
  const isUpperCase = c => {
  return /^[A-Z]+$/g.test(c)
}
  if (isUpperCase(args[0])) {
    console.log('A');
  } else {
    console.log('a');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL N, A, B;
	cin >> N >> A >> B;
	LL counter[3] = {0, 0, 0};
	REP(i, N) {
		LL p;
		cin >> p;

		if (p <= A) {
			counter[0]++;
		}
		else if (p <= B) {
			counter[1]++;
		}
		else {
			counter[2]++;
		}
	}

	cout << min(counter[0], min(counter[1], counter[2])) << endl;

	return 0;
}


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

using namespace std;

int solve(int N, const vector<int>& A, int i, bool even)
{
	if (i == N) {
		return even ? 1 : 0;
	}

	int ans = 0;
	for (int x = A[i] - 1; x <= A[i] + 1; ++x) {
		ans += solve(N, A, i + 1, even || x % 2 == 0);
	}
	return ans;
}

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) {
		cin >> x;
	}
	cout << solve(N, A, 0, false) << endl;
}



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

int main(){
  int N;
  cin >> N;
  char C;
  
  for(int i = 0; i <N ; i++){
    cin >> C;
      if(i == N-1){
          cout << "Three" << endl;
      }
    if(C == 'Y'){
        cout << "Four" << endl;
        break;
    }
    
    else {
        continue;
    }
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int n, k, lr[20];
ll mod = 998244353, sum, dp[200005];
void pluse(int p, ll s) {
    if (p > n) return;
    dp[p] += s;
    return;
}
void dfs() {
    for (int i = 1; i < n; i++) {
        sum += dp[i];
        ll tl = 0;
        if (i == 1) tl = 1;
        sum = sum % mod;
        for (int j = 0; j < k; j++) {
            pluse(lr[j * 2] + i, sum + tl);
            pluse(lr[j * 2 + 1] + 1 + i, -sum - tl);
        }
        //cout << sum << endl;
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> k;
    memset(dp, 0, sizeof(dp));
    dp[1] = 0;
    sum = 0;
    for (int i = 0; i < k; i++) {
        cin >> lr[i * 2] >> lr[i * 2 + 1];
    }
    dfs();
    ll res = (sum + dp[n]) % mod;
    while (res < 0) res += mod;
    cout << res << endl;
}

Measured memory_bytes: 5208
#include<iostream>
#include<iomanip>
#include<vector>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<unordered_set>
using namespace std;

int main() {
	int H, W;
	int table[26] = { 0 };

	int s = 0;
	int d = 0;
	int q = 0;
	int cnt = 0;

	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char a;
			cin >> a;
			table[a - 'a']++;
		}
	}

	if (H & 1 && W & 1) {
		s = 1;
		d = H + W - 2;
	}
	else if (H & 1) {
		d = W;
	}
	else if (W & 1) {
		d = H;
	}

	q = H * W - s - d;

	for (int i = 0; i < 26; i++) {
		while (table[i] >= 4 && q >= 4) {
			table[i] -= 4;
			q -= 4;
		}
	}
	for (int i = 0; i < 26; i++) {
		while (table[i] >= 2 && d >= 2) {
			table[i] -= 2;
			d -= 2;
		}
	}

	for (int i = 0; i < 26; i++) {
		cnt += table[i];
	}

	if (cnt <= s)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a.at(i);
    vector<ll> b(n);
    rep(i,n) cin >> b.at(i);
    ll ans=0;
    rep(i,n){
        ll left=min(a.at(i),b.at(i));
        ans+=left;
        a.at(i)-=left;
        b.at(i)-=left;
        ll left2=min(a.at(i+1),b.at(i));
        ans+=left2;
        a.at(i+1)-=left2;
    }
    cout << ans << endl;
}
   


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
//mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9+7, N = 2e5+5;

int  n, m, k;/*
int f[1000003];
void fac(){
	f[0] = 1;
	f[1] = 1;
	for(int i=2;i<=1000003;i++){
		f[i] = i*f[i-1];
		f[i]%=mod;
	}
}
int binpow(int a, int b){
	if(b==0)return 1;
	int temp = binpow(a,b/2);
	temp*=temp;
	temp%=mod;
	if(b%2==1)temp*=a;
	return temp%mod;
}
 
int moddiv(int a, int b){
	int temp = binpow(b, mod-2);
	return a*temp;
}*/
void solve(int test_case){
	int i, j;
	cin >> n;
	if(n == 1){
		cout << 0;
		return;
	}if(n == 2){
		cout << 2;
		return;
	}
	int on=1, to=1, s=1;
	for(i=0;i<n;i++){
		on *= 10;
		on %= mod;
	}
	for(i=0;i<n;i++){
		to *= 9;
		to %= mod;
	}to*= 2;
	to %= mod;
	
	for(i=0;i<n;i++){
		s *= 8;
		s %= mod;
	}
	int ans = ((on-to)+mod)%mod+s;ans %= mod;
	cout << ans << '\n';
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}



Measured memory_bytes: 3640
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
 
using namespace std; 
 
#define MP make_pair
typedef unsigned long long ULL;
 

int main(){
 
    ios::sync_with_stdio(false);
    string s;
 
    while(cin>>s,s!="#"){
 
 
        set<string> ss1,ss2;
        vector<string> ans;
        int n=s.size()/2;
        int m=s.size()-n;
        ULL N=(1ULL<<n);
        ULL M=(1ULL<<m);
        for(ULL state=0;state<N;++state){
            string str=s.substr(0,n);
            for(char i=0;i<n;++i){
                if((1<<i)&state && str[i]!='z') str[i]++;
            }
  
            ss1.insert(str);
        }
 
        for(ULL state=0;state<M;++state){
            string str=s.substr(n);
            for(char i=0;i<m;++i){
                if((1<<i)&state && str[i]!='z') str[i]++;
            }
 
            ss2.insert(str);
        }
 
        for(auto it1=ss1.begin();it1!=ss1.end();++it1){
            for(auto it2=ss2.begin();it2!=ss2.end();it2++){
//              if(enc(str1+(*it2))==s) ans.push_back(str1+(*it2)+"\n");
                string str=(*it1)+(*it2);
                bool app[26]={false};
                for(char i=0;i<n+m;++i){
                    char c=str[i]-'a';
                    if(!app[c] && c!=0){
                        --str[i];
                        app[c]=true;
                    }
                }
 
                if(str==s) ans.push_back((*it1)+(*it2)+"\n");
 
            }
        }
 
        const ULL sz=ans.size();
        cout<<sz<<endl;
 
        if(sz<=10){
            for(char i=0;i<sz;i++)
                cout<<ans[i];
        }else{
            cout<<ans[0]+ans[1]+ans[2]+ans[3]+ans[4]
            +ans[sz-5]+ans[sz-4]+ans[sz-3]+ans[sz-2]+ans[sz-1];
        }
 
 
    }
 
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

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

  int n, r; cin >> n >> r;

  if(n >= 10) cout << r << endl;
  else cout << r + 100 * (10 - n) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long r, d, x;
	cin >> r >> d >> x;
	for(int i=0;i<10;i++) {
		x = x * r - d;
		cout << x <<" ";
	}
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;

template<typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll g = gcd(n, m);
    ll ans = m * n / g;
    for(int i = 0; i < g; i++){
        if(s[i*n/g] != t[i*m/g]){
            ans = -1;
            break;
        }
    }

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


Measured memory_bytes: 640
#include <stdio.h>
int main(){
	int n,now=-1,temp,a[100000];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		if(a[i]<=a[n-1]){
			now++;
			temp=a[i];
			a[i]=a[now];
			a[now]=temp;
		}
	}
	for(int i=0;i<now;i++)printf("%d ",a[i]);
	printf("[%d]",a[now]);
	for(int i=now+1;i<n;i++)printf(" %d",a[i]);
	printf("\n");
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout<<"No" << endl;
    else
    {
        cout << "Yes" << endl;
    }
    
    
    
}




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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    string s;
    cin >> n >> s;

    int rez = 0, dp[n];
    for (int ctr1 = 1; ctr1 <= n; ++ctr1) {
        memset(dp, 0, sizeof(dp));
        for (int ctr2 = n - ctr1 - 1; ctr2 >= 0; --ctr2) {
            if (s[ctr2] != s[ctr2 + ctr1]) dp[ctr2] = 0;
            else dp[ctr2] = min(dp[ctr2 + 1] + 1, ctr1);
            rez = max(rez, dp[ctr2]);
        }
    }
    
    cout << rez << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int64_t N, K;
    cin >> N >> K;

    N %= K;
    cout << min(N, K-N) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int i, j;
	int data[10][10];
	int sum_v[11];
	int sum_h = 0;
	
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < 11; i++){
			sum_v[i] = 0;
		}
		
		
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				scanf("%5d", &data[i][j]);
			}
		}
		
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				sum_v[j] += data[i][j];
				sum_h += data[i][j];
				
				printf("%5d", data[i][j]);
			}
			sum_v[10] += sum_h;
			printf("%5d\n", sum_h);
			sum_h = 0;
		}
		
		for (i = 0; i < n; i++){
			printf("%5d", sum_v[i]);
		}
		printf("%5d", sum_v[10]);
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 620
#include "bits/stdc++.h"
using namespace std;


const int N = 105;
const int inf = 1e8;
int c[N][N], edge[N][N];
int dist[N];
vector< int > conn[N];
bool inpath[1005];
int n;

void dijkstra(int u) {
    fill_n(dist, N, inf);
    vector< bool> processed(N, false);
    vector< int> parent(N, -1);

    dist[u] = 0;
    priority_queue< pair< int, int> > pq;
    pq.emplace(0, u);

    while (!pq.empty()) {
        int u = pq.top().second;
        pq.pop();
        if (processed[u]) continue;
        processed[u] = true;
        for (int v : conn[u]) {
            if (dist[v] > dist[u] + c[u][v]) {
                dist[v] = dist[u] + c[u][v];
                parent[v] = u;
                pq.emplace(-dist[v], v);
            }
        }
    }

    for (int i = 1; i <= n; ++i) {
        if (i == u) continue;
        int x = i;
        while (1) {
            int p = parent[x];
            if (p == -1) break;
            inpath[edge[p][x]] = true;
            x = p;
        }
    }
}

int main() {
    int m;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);
        c[u][v] = c[v][u] = w;
        edge[u][v] = edge[v][u] = i;
        conn[u].emplace_back(v);
        conn[v].emplace_back(u);
    }

    for (int i = 1; i <= n; ++i) {
        dijkstra(i);
    }

    int res = 0;
    for (int i = 1; i <= m; ++i) if (!inpath[i]) res++;
    cout << res << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int aa = a%10;
  if(aa==0){
    a -=10;
    aa = 10;
  }
  int bb = b%10;
  if(bb==0){
    b -=10;
    bb = 10;
  }
  int cc = c%10;
  if(cc==0){
    c -=10;
    cc = 10;
  }
  int dd = d%10;
  if(dd==0){
    d -=10;
    dd = 10;
  }
  int ee = e%10;
  if(ee==0){
    e -=10;
    ee = 10;
  }
  int last = min({aa,bb,cc,dd,ee});
  int cnt = a/10*10+b/10*10+c/10*10+d/10*10+e/10*10+last+40;
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 256