akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define OUT(a) cout << (a) << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n, m;
    ll h[200010];
    ll q[200010];
    string s;

    cin >> n >> m;
    REP(i, n){
        cin >> h[i];
    }

    REP(j, m){
        ll a, b;
        cin >> a >> b;
        if (h[a-1] == h[b-1]){
            q[a-1] = -1;
            q[b-1] = -1;
        }
        else if (h[a-1] < h[b-1]){
            q[a-1] = -1;
            if (q[b-1] != -1){
                q[b-1] = 1;
            }
        } else {
            if (q[a-1] != -1){
                q[a-1] = 1;
            }
            q[b-1] = -1;
        }
    }

    ll ans = 0;
    REP(l, n){
        if (q[l] != -1){
            ans++;
        }
    }
  
  	cout << ans << endl;

    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    int x;
    cin >> x;
    cout << x / 500 * 1000 + x % 500 / 5 * 5;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 250005
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long rc[2], a[2], b[2], ch[2], data[2][3][2] = {0},
                                    cost = 0, ans = 0;
long long solve();
long long calc(int x, int y);
long long setd(int x);

int main() {
  smodfact();
  cin >> rc[0] >> rc[1] >> a[0] >> a[1] >> b[0] >> b[1];
  ans = solve();
  cout << cost << " " << ans << endl;
  return 0;
}

long long solve() {
  long long xy[2], ans = 0, nowx, nowy;
  for(int i = 0; i < 2; ++i) xy[i] = setd(i);
  cost = xy[0] + xy[1];
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j < 3; ++j) {
      nowx = data[0][i][0];
      nowy = data[1][j][0];
      if(xy[0] == nowx && xy[1] == nowy) {
        ans += calc(i, j);
        ans %= N;
      }
    }
  return ans;
}

long long setd(int x) {
  long long minn;
  data[x][0][0] = max(a[x] - b[x], b[x] - a[x]);
  minn = data[x][0][0];
  data[x][1][0] = b[x] + 1;
  data[x][1][1] = 1;
  minn = min(minn, data[x][1][0]);
  data[x][2][0] = rc[x] - b[x];
  data[x][2][1] = 1;
  minn = min(minn, data[x][2][0]);
  return minn;
}
long long calc(int x, int y) {
  long long ans = 0;
  if(x == 0 && x == y)
    return factorial[data[0][0][0] + data[1][0][0]] *
           finverse[data[0][0][0]] % N *
           finverse[data[1][0][0]] % N;
  if(x != 0) {
    for(int i = 0; i <= data[1][y][0]; ++i) {
      ans +=
          factorial[data[0][x][0] + data[1][y][0] - i - 1] *
          finverse[data[0][x][0] - 1] % N *
          finverse[data[1][y][0] - i] % N;
      ans %= N;
    }
  }
  else if(y != 0) {
    for(int i = 0; i <= data[0][x][0]; ++i) {
      ans +=
          factorial[data[0][x][0] + data[1][y][0] - i - 1] *
          finverse[data[0][x][0] - i] % N *
          finverse[data[1][y][0] - 1] % N;
      ans %= N;
    }
  }
  while(ans < 0) ans += N;
  return ans;
}


Measured memory_bytes: 8964
import copy
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

B = copy.copy(A)
maxx = max(A)
A.pop(A.index(maxx))
second_max = max(A)

for i in range(N):
    if(B[i] == maxx):
        print(second_max)
    else:
        print(maxx)


Measured memory_bytes: 14560
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

 
const int MAXN = 1e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	int n;
	cin >> n;
	vector<int> a(n);
	forn(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	int ans = a[n - 1];
	int lft = n - 2;
	int j = n - 2;
	while (lft > 0) {
		ans += a[j] * 2;
		lft -= 2;
		if (lft < 0) {
			ans -= a[j];
			lft++;
		}
		j--;
	}
	cout << ans << "\n";
 	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

int main() {
	int n, m;
	int dis[20][20];
	
	cin >> n >> m;
	
	fill(dis[0], dis[20], INF);
	REP(i, n) dis[i][i] = 0;
	REP(i, m) {
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		a--; b--;
		dis[a][b] = c;
		dis[b][a] = d;
	}
	
	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	x1--; x2--;
	
	REP(k, n) REP(i, n) REP(j, n) {
		dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
	}
	
	int ans = y1 - y2 - (dis[x1][x2] + dis[x2][x1]);
	cout << ans << endl;
	
	return 0;
}

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

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

  vector<ll> p(n+1);
  p[0] = 1;
  ll total = 1;
  for (int i = 1; i <= n; i++) {
    p[i] = p[i - 1] * 2 + 1;
    total = total * 2 + 3;
  }

  ll l = 0;
  ll r = total;
  int k = n;
  ll ans = 0;
  while (l <= r) {
    ll mid = (r + l + 1) / 2;
    if (mid == x) {
      ans += (p[k] + 1) / 2;
      break;
    }

    if (mid > x) {
      l++;
      r = mid - 1;
      k--;
      continue;
    }

    if (mid < x) {
      ans += (p[k] + 1) / 2;
      l = mid + 1;
      r--;
      k--;
      continue;
    }
  }

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

Measured memory_bytes: 256
K,N=map(int,input().split())
A=list(map(int,input().split()))
lis=[]
for i in range(N-1):
    L=A[i+1]-A[i]
    lis.append(L)
lis.append(K-A[N-1]+A[0])
lis_sort=sorted(lis,reverse=True)
print(sum(lis_sort)-lis_sort[0])

Measured memory_bytes: 32392
#include<cstdio>
#include<cstring>
using namespace std;
const int N=22,M=1e6+1e5;
int f[N][2*M],d[N],g[M],Ans[N],n,K;char s[M];bool bk[N][M];
int main()
{
	scanf("%d%d",&n,&K);
	d[0]=1;for(int i=1;i<=n+1;i++) d[i]=d[i-1]*2;
	for(int i=0;i<=n;i++){
		scanf("%s",s+1);
		for(int j=0;j<d[i];j++)
			if(s[j+1]=='1') bk[i][j]=true;
	}
	memset(f,0,sizeof(f));
	for(int i=1;i<=n;i++)
		for(int j=d[i]-1;j<d[i+1]-1;j++)
			if(bk[i][j-d[i]+1]) f[i][j]=1;
	for(int i=n;i>=1;i--)
		for(int j=i;j>0;j--)
			for(int k=0;k<=d[i]-1;k++){
				int t=k%d[j],t0=k/d[j],t1=0,t2=0;
				for(int l=j;l>=1;l--)
					if(k/d[l-1]%2==0) {t1=l;break;}
				for(int l=j;l>=1;l--)
					if(k/d[l-1]%2==1) {t2=l;break;}
				if(t1){
					int t3=(t0*2)*d[t1-1]+k%d[t1-1];
					f[t1-1][t3+d[i-j+t1]-1]+=f[j][k+d[i]-1];
				}
				if(t2){
					int t3=(t0*2+1)*d[t2-1]+k%d[t2-1];
					f[t2-1][t3+d[i-j+t2]-1]+=f[j][k+d[i]-1];
				}
			}
	for(int i=n;i>=1;i--)
		for(int j=0;j<d[i];j++){
			int Sum=0;
			for(int k=0;k<=n-i;k++)
				for(int l=0;l<d[k];l++){
					int t=j*d[k]+l+d[i+k]-1;
					Sum+=f[k][t];
				}
			if(Sum>=K){
				for(int p=1;p<=i;p++) Ans[p]=j%2,j/=2;
				for(int p=i;p>=1;p--) printf("%d",Ans[p]);
				printf("\n");
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 193924
CHARS = ['A', 'G', 'C', 'T']
PROHIBITED = ['AGC', 'ACG', 'GAC', 'ACGC', 'AGGC', 'ATGC', 'AGAC', 'AGGC', 'AGTC']
MOD = 10**9 + 7
N = gets.to_i

def accept(last4)
  !PROHIBITED.any?{|word| last4.include? word }
end

MEMO = []
def patterns(len, last3)
  return MEMO[len][last3] if !MEMO[len].nil? && MEMO[len][last3]
  return 1 if len == N
  result = 0
  CHARS.each do |char|
    last4 = last3 + char
    next if !accept(last4)
    result = (result + patterns(len+1, last4[1,3])) % MOD
  end
  MEMO[len] = {} if MEMO[len].nil?
  MEMO[len][last3] = result
  result
end

puts patterns(0, 'xxx')


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

int main()
{
    string N;
    cin >> N;
    if (N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7')
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }       
}

Measured memory_bytes: 3596
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

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

// main関数
int main(void) {
	int n, a[20], b[20], c[20];
	cin >> n;
	int i;
	rpt(i, n) {
		cin >> a[i];
	}
	rpt(i, n) {
		cin >> b[i];
	}
	rpt(i, n - 1) {
		cin >> c[i];
	}
	int sum = 0;
	rpt(i, n) {	
		sum += b[a[i] - 1];
		if (a[i] + 1 == a[i + 1]) {
			sum += c[a[i] - 1];
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int min = 1000;
    for(int i = 0;i < s.size() - 2;i++)
    {
        int x = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        if(fabs(753 - x) < min)
        {
            min = fabs(753 - x);
        }
    }
    cout << min;

    return 0;
}

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

string S;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> S;
  ll even0 = 0;
  ll even1 = 0;
  ll odd0 = 0;
  ll odd1 = 0;
  for (ll i = 0; i < (ll) S.size(); i++) {
    if (i % 2 == 0) {
      if (S.at(i) == '0') {
	even0++;
      }else {
	even1++;
      }
    }else {
      if (S.at(i) == '0') {
	odd0++;
      }else {
	odd1++;
      }
    }
  }
  cout << min(even0 + odd1, even1 + odd0) << endl;

  return 0;
}



Measured memory_bytes: 768
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
list = list(map(int, input().split()))
chk = True

for i in range(0, 10**9):
    for i in range(n):
        if list[i]%2==0:
            list[i] = list[i]//2
        else:
            chk = False

    if chk == True:
        ans += 1
    else:
        break

print(ans)

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

int main(){
    int n;
    cin>>n;
    int a[n];
    int ans[100000+1]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans[a[i]]++;
    }    
    sort(a,a+n);
    ll val=0;
    for(int i=1;i<100000;i++){
        ll temp=ans[i]+ans[i+1]+ans[i-1];
        if(temp>val)val=temp;
    }
    if(n==1)cout<<1;
    else if(n==2){
        if(a[1]-a[0]==1)cout<<2;
        else cout<<1;
    }else cout<<val;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
int d,a,b,i2,pos,dp[102],res,tmp[102];
char k[10002];
int main()
{
    scanf("%s",&k);
    for(; k[pos]!=0; ++pos) a+=k[pos]-'0';
    scanf("%d",&d);
    dp[0]=1;
    a%=d;
    if(a==0) ++res;
    while(--pos>=0){
        if(k[pos]!='0'){
            b=k[pos]-'0';
            a-=b;
            while(a<0) a+=d;
            if(a) i2=d-a; else i2=0;
            for(int i=0; i<b; ++i){
                res+=dp[i2--];
                if(i2<0) i2+=d;
                if(res>=MOD) res-=MOD;
            }
        }
        tmp[0]=0;
        i2=d-1;
        for(int i=0; i<9; ++i){
            tmp[0]+=dp[i2--];
            if(i2<0) i2+=d;
            if(tmp[0]>=MOD) tmp[0]-=MOD;
        }
        for(int i=1; i<d; ++i){
           tmp[i]=tmp[i-1]+dp[i-1]-dp[++i2%d];
           if(tmp[i]>=MOD) tmp[i]-=MOD;
           else if(tmp[i]<0) tmp[i]+=MOD;
        }
        for(int i=0; i<d; ++i){
           dp[i]=dp[i]+tmp[i];
           if(dp[i]>=MOD) dp[i]-=MOD;
        }
    }
    if(--res<0) res+=MOD;
    printf("%d",res);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b,c=0,d=0;
    scanf("%d %d",&a,&b);
    int e = b;
    int f = a;
    int n;
    for(n = 1;n<=e;n++){
        c += a;
        a *= 10;
    }
    //printf("c;%d\n",c);/**/
    for(n = 1;n<=f;n++){
        d += b;
        b *= 10;
    }
    //printf("d;%d\n",d);/**/
    if(c>=d){
        printf("%d\n",c);
    }else{
        printf("%d\n",d);
    }
    return 0;
}

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

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

  int K, A, B;
  cin >> K >> A >> B;
  for (int k = K; k < 10000; k += K) {
    if (A <= k && k <= B) {
      cout << "OK\n";
      return 0;
    }
  }
  
  cout << "NG\n";
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

#define V 100000

signed main(){

    int N, W; cin >> N >> W;
    vec w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];
    mat dp(N + 1, vec(V + 1, INF));
    dp[0][0] = 0;
    REP(i, N){
        REP(j, V + 1){
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if(j + v[i] <= V) dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
        }
    }
    int ans = 0;
    REP(j, V + 1) if(dp[N][j] <= W) ans = j;
    cout << ans;
    
    return 0;
}

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j].value < A[j - 1].value) {
                Card t = A[j];
                A[j] = A[j - 1];
                A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        int minj = i;
        
        for (int j = i; j < N; j++) {
            if (A[j].value < A[minj].value) {
                minj = j;
            }
         }
         
         Card t = A[i];
         A[i] = A[minj];
         A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        
        cout << A[i].suit << A[i].value;
    }
    
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i =  0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) {
            return false;
        }
    }
    
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i < N; i++) {
        C2[i] = C1[i];
    }
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    
    cout << "Stable" << endl;
    
    print(C2, N);
    
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3088
n=int(input())
v = list(input().split())
v = sorted([int(i) for i in v], reverse=True)

for i in range(1, n):
  x=float(sum(v[-2:])/2)
  #print(x)
  del v[-2:]
  v.append(x)

print(sum(v))
  
  

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

int power(int a, int b)
{
    int s = 1;
    while (b--) {
        s = s * a;
    }
    return s;
}

int main( )
{
    int n, k;
    cin >> n >> k;
    cout << k * power((k - 1), (n - 1)) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	char b;
	cin >> b;
	
	if (b == 'A') {
		cout << 'T';
	}else if (b == 'T') {
		cout << 'A';
	}
	else if (b == 'C') {
		cout << 'G';
	}
	else {
		cout << 'C';
	}

	return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> p(N);
  REP(i, N){
    int a; cin >> a;
    p[a-1] = i;
  }

  REP(i, N){
    cout << N*(i+1)+p[i]; SPBR(i, N);
  }
  REP(i, N){
    cout << N*(N-i); SPBR(i, N);
  }

  return 0;
}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(new Program().Solve());
    }

    string Solve()
    {
        var mk = ReadLongArray();
        var m = mk[0];
        var k = mk[1];

        var z = (long)Math.Pow(2, m);

        if (z <= k) return "-1";

        if (m == 0) return "0 0";
        if (m == 1 && k == 0) return "0 0 1 1";
        if (m == 1 && k == 1) return "-1";

        var list = new List<long>();

        for (var i = 0L; i < z; i++)
        {
            if (i != k) list.Add(i);
        }

        list.Add(k);

        for (var i = z - 1; i >= 0; i--)
        {
            if (i != k) list.Add(i);
        }

        list.Add(k);

        return string.Join(" ", list);
    }

    #region Console.Read 関係
    long[] ReadLongArray() => (from x in Console.ReadLine().Split(' ') select long.Parse(x)).ToArray();
    #endregion
}


Measured memory_bytes: 30424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll INF = 1e15;
typedef vector<vector<ll>> Matrix;
void warshall_floyd(Matrix& d) {
  ll n = SZ(d);
  REP(i, n) REP(j, n) REP(k, n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  vector<vector<ll>> to(n, vector<ll>(n, INF));
  REP(i, n) to[i][i] = 0;
  REP(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    to[a][b] = c;
    to[b][a] = c;
  }
  warshall_floyd(to);
  REP(i, n) REP(j, n) {
    if (to[i][j] <= l)
      to[i][j] = 1;
    else
      to[i][j] = INF;
  }
  REP(i, n) to[i][i] = 0;
  warshall_floyd(to);
  ll q;
  cin >> q;
  REP(i, q) {
    ll s, t;
    cin >> s >> t;
    s--;
    t--;
    if (to[s][t] == INF)
      cout << -1 << endl;
    else
      cout << to[s][t] - 1 << endl;
  }
}

Measured memory_bytes: 1280
#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<vector<int>> candy(2, vector<int>(n));
    rep(i, 2)
    {
        rep(j, n)
        {
            cin >> candy[i][j];
        }
    }
    int ans = 0;
    rep(i, n)
    {
        int x = 0;
        int sum = 0;
        rep(y, n)
        {
            sum += candy[x][y];
            if (i == y)
            {
                x++;
                sum += candy[x][y];
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
s = list(str(input()))
sm = [1 if s[i] == 'B' else 0 for i in range(len(s))]
smr = list(reversed(sm))
t =[]
for i in range(len(s)):
    if smr[i] == 1:
        t.append(i)
u = [i for i in range(len(t))]
v = [t[i] - u[i] for i in range(len(t))]
ans = sum(v)
print(ans)


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

int main()
{
    int N, K;
    cin >> N >> K;
    int ans = 1;

    for (int i = 0; i<N; ++i){
        ans = min(ans * 2, ans + K);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	int A1 = N/100;
	int A2 = N%10;
	if( A1 == A2 ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll bottom_up(std::vector<int> wt,std::vector<int> value,int n,int W)
{
    ll dp[n+1][W+1] = {0};
    for(int i=0;i<=n;i++)
    {
        for(int w=0;w<=W;w++)
        {
            if(i==0||w==0)
            {
                dp[i][w] = 0;
            }
            else if(wt[i-1]<=w)
            {
               dp[i][w] = max(value[i-1] + dp[i-1][w-wt[i-1]],dp[i-1][w]); 
            }
            else
            {
                dp[i][w] = dp[i-1][w];
            }
        }
    } 

    return dp[n][W];
}
int knapsack(std::vector<int> wt,std::vector<int> value,int n,int W)
{
    if(n==0||W==0)
    {
        return 0;
    }

    if(wt[n-1]>W)
    {
        return knapsack(wt,value,n-1,W);
    }
    else
    {
        int ans1 = knapsack(wt,value,n-1,W);
        int ans2 = value[n-1] + knapsack(wt,value,n-1,W-wt[n-1]);
        return max(ans1,ans2);
    }
}
int main()
{
    ll n;
    ll W;
    cin>>n>>W;
    std::vector<int> wt;
    std::vector<int> value;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        wt.push_back(a);
        value.push_back(b);
    }

    ll ans = bottom_up(wt,value,n,W);
    cout<<ans<<endl;
}

Measured memory_bytes: 82408
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let B: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    const INF: usize = 1_000_000_000;
    let res = (0..(1 << N))
        .map(|p| {
            let mut X = vec![];
            for i in 0..N {
                X.push((i, 1));
            }
            let mut Y = vec![];
            for i in 0..N {
                if (p >> i) & 1 == 1 {
                    Y.push(A[i]);
                } else {
                    Y.push(B[i]);
                }
            }
            let mut cost = 0;
            // println!("p={}", p);
            for i in 0..N {
                // println!("{:?}", X);
                // println!("{:?}", Y);
                let l = (i..N)
                    .find(|&l| ((l - i) + X[l].1) % 2 == (p >> X[l].0) & 1)
                    .unwrap_or(INF);
                if l == INF {
                    cost = INF;
                    break;
                }
                let mut k = l;
                for j in l..N {
                    if Y[j] < Y[k] && ((j - i) + X[j].1) % 2 == (p >> X[j].0) & 1 {
                        k = j;
                    }
                }
                // println!("l={}, k={}", l, k);
                for r in (i..k).rev() {
                    let tmp = X[r + 1];
                    X[r + 1] = (X[r].0, 1 - X[r].1);
                    X[r] = (tmp.0, 1 - tmp.1);
                    let tmp2 = Y[r + 1];
                    Y[r + 1] = Y[r];
                    Y[r] = tmp2;
                    cost += 1;
                }
            }
            if (1..N).any(|i| Y[i - 1] > Y[i]) {
                cost = INF;
            }
            // println!("{}", cost);
            cost
        })
        .min()
        .unwrap();
    let ans = if res >= INF { -1 } else { res as i64 };

    println!("{}", ans);
}


Measured memory_bytes: 4352
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [N, M] = r.nn()

    return N === M ? 'Yes' : 'No'
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<long long> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  
  long long ans = 0;
  
  if(n>k){
    sort(h.begin(),h.end());
    for(int i=0; i<n-k; i++){
      ans += h[i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, char *argv[]){
  int i;
  char a,b,c,d;
  scanf("%c%c%c%c", &a,&b,&c,&d);
  if(a == b || b == c || c == d){
    printf("Bad");
  }else{
    printf("Good");
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;

int main(void){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 1;
    for (int i = 1; i < n; i++)
    {
        if(s[i] != s[i-1]) ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

int N, K;
int x[105];
int ans;

void solve() {
    for (int i = 0; i < N; i++) {
        int a = x[i] - 0;
        int b = K - x[i];
        ans += min(a, b) * 2;
    }
    cout << ans << endl;
}

int main() {
    cin >> N;
    cin >> K;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
a = x2 - x1
b = y2 - y1

x3 = x2 - b
y3 = y2 + a
x4 = x3 - a
y4 = y3 - b

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int n;
    cin >> n;
    vi arr(n);
    garr(arr);
    int xval = 0;
    for (auto a : arr)
        xval ^= a;
    for (auto a : arr)
        cns(a ^ xval);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 4784
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if not s in dic.keys():
        dic[s]=1
    else:
        dic[s]+=1
maxv = max(dic.values())
ls = [i for i in dic if dic[i] == maxv]
for key in sorted(ls):
    print(key)

Measured memory_bytes: 33112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   string s1,s2; cin>>s1; cin>>s2;
   if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
}


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

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    char c;
    cin>>c;


    if(c>'Z')
        cout<<"a";
    else
        cout<<"A";


    printclock;
    return 0;
}

Measured memory_bytes: 3800
import math

N = int(input())
A = sorted(list(map(int,input().split())))

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

M = A[-1]
P = [1,M]
for k in range(2,math.ceil(math.sqrt(M))+1):
    if M % k == 0:
        P.append(k)
        P.append(M//k)
M = A[-2]
P.append(M)
for k in range(2,math.ceil(math.sqrt(M))+1):
    if M % k == 0:
        P.append(k)
        P.append(M//k)
P = set(list(P))
ans = 1
for p in P:
    t = 0
    for k in range(N):
        if A[k]%p != 0:
            t += 1
        if t == 2:
            break
    if t <= 1:
        ans = max(ans,p)

print(ans)


Measured memory_bytes: 14588
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        int ball[15]={0};
        int A=0,B=0;
        int x=0,y=0;
        bool flg=0;
        for(int i=0;i<10;i++){
            cin>>ball[i];
        }
        for(int i=0;i<10;i++){
            if(x<ball[i])x=ball[i];
            else if(y<ball[i])y=ball[i];
            else{
                cout<<"NO"<<endl;
                flg=1;
                break;
            }
        }
        if(flg==0)cout<<"YES"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;

int main()
{
  int n;
  cin >> n;
  ll a[100100], b[100100];
  ll sum[100100];
  vector<pll> p;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i] >> b[i];
    sum[i] = a[i] + b[i];
    p.push_back(make_pair(sum[i], a[i]));
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());

  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    if (i % 2 == 0)
    {
      ans += p[i].second;
    }
    else
    {
      ans -= p[i].first - p[i].second;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3444
c, n = gets.split.map(&:to_i)
a = (1..n).map { gets.split("").map(&:to_i) }

d = 0
hdiff = Array.new(n).map { Array.new(n, 0) }
vdiff = Array.new(n).map { Array.new(n, 0) }
(0..n-1).each do |i|
    (0..n-1).each do |j|
        if a[i][j] != a[i][n-j-1]
            hdiff[i][j] = 1
            d += 1
        end
        if a[i][j] != a[n-i-1][j]
            vdiff[i][j] = 1
            d += 1
        end
    end
end

k = (d == 0 ? 1 : 0)
(c - 1).times do
    gets.to_i.times do
        i, j = gets.split.map(&:to_i)
        i -= 1
        j -= 1
        if hdiff[i][j] == 1
            hdiff[i][j] = hdiff[i][n-j-1] = 0
            d -= 2
        else
            hdiff[i][j] = hdiff[i][n-j-1] = 1
            d += 2
        end
        if vdiff[i][j] == 1
            vdiff[i][j] = vdiff[n-i-1][j] = 0
            d -= 2
        else
            vdiff[i][j] = vdiff[n-i-1][j] = 1
            d += 2
        end
    end
    k += 1 if d == 0
end
p k




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

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

    int s;
    cin >> s;

    int tail = s % 100;
    int head = s / 100;

    string res;
    if (1 <= tail && tail <= 12 && 1 <= head && head <= 12) {
        res = "AMBIGUOUS";
    }
    else if (1 <= tail && tail <= 12) {
        res = "YYMM";
    }
    else if (1 <= head && head <= 12) {
        res = "MMYY";
    }
    else {
        res = "NA";
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main() {
  
  int N,M;
  cin >> N >> M;

  int sum = 0;
  vector<int> A(N);
  for(int i = 0;i< N;i++) {
    cin >> A[i];
    sum += A[i];
  }
  
  double s = (double)1/(4*M)*sum;
  int num = 0;
  for(int i = 0;i < N;i++) {
    if(A[i] >= s) num++;
  }

  if(num >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 384
n, k = map(int, input().split())
mod = 10**9+7

k = min([k, n-1])


ans = 0
key = 1

for i in range(k+1):
    ans += key
    ans %= mod
    key = (((key*(n-i)%mod)*(n-i-1)%mod)*pow(pow(i+1, mod-2, mod), 2, mod))%mod
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
    int n,i,y;
    int a[100];
    double D1=0,D2=0,D3=0,Di=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&y);
        y= abs(a[i]-y);
        D1+=y;
        D2+=y*y;
        D3+=y*y*y;
        if(Di<y){
            Di=y;
        }
    }
    printf("%f\n%f\n%f\n%f\n",D1,sqrt(D2),pow(D3,1.0/3.0),Di);
    
        return 0;
}

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

int main()
{
    char a, b;
    cin >> a >> b;
    bool A, B;
    A = (a == 'H');
    B = (b == 'H');
    if (!(A xor B))
    {
        cout << "H";
    }
    else
    {
        cout << "D";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,c;
    cin>>n;
    string s;
    cin>>s;
    char x;
    x=s[0];
    c=1;
    for(i=1;i<n;i++)
    {
        if(s[i]==x)
        {
            
        }
        else
        {
            c++;
            x=s[i];
        }
    }
    cout<<c<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

template<int mod> struct modint {
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = (i64) x * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
  #define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  #define op(o) bool operator o(modint that) const { return x o that.x; }
    op(==) op(!=) op(<) op(<=) op(>) op(>=)
  #undef op
};

using mint = modint<1000000007>;

struct mcalc {
  vector<mint> fac, finv;
  mcalc(int max) {
    fac = vector<mint>(max + 1);
    finv = vector<mint>(max + 1);
    fac[0] = 1;
    reps(i, max) fac[i] = fac[i - 1] * i;
    finv[max] = (mint) 1 / fac[max];
    rreps(i, max) finv[i - 1] = finv[i] * i;
  }
  mint com(int a, int b) {
    if (a < 0) return 0;
    if (b < 0 || b > a) return 0;
    return fac[a] * finv[a - b] * finv[b];
  }
  mint hom(int a, int b) {
    return com(a + b - 1, b);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i32 n, m = 0;
  cin >> n;
  vi32 a(n + 1), b;
  rep(i, n + 1) cin >> a[i];
  b = a;
  sort(all(b));
  {
    i32 prev = b[0];
    reps(i, n) if (b[i] == prev) break; else prev = b[i];
    rep(i, n + 1) if (a[i] == prev) break; else m++;
    rrep(i, n + 1) if (a[i] == prev) break; else m++;
  }
  auto mc = mcalc(100010);
  reps(k, n + 1) {
    cout << mc.com(n + 1, k) - mc.com(m, k - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 2816
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define NUM 100000

using namespace std;

struct Info{
	Info(){
		from_down = from_left = right_up = up_right = 0;
	}
	int from_down,from_left,right_up,up_right;
};

void func(int W,int H){


	Info table[H][W];

	for(int i = 0; i < W;i++)table[0][i].from_down = 1;
	for(int i = 0; i < H;i++)table[i][0].from_left = 1;

	table[1][1].right_up = 1;
	table[1][1].up_right = 1;

	for(int i = 2; i < W; i++){
		table[1][i].right_up = 1;
		table[1][i].from_left = 1;
	}

	for(int i = 2; i < H; i++){
		table[i][1].up_right = 1;
		table[i][1].from_down = 1;
	}


	for(int i = 2; i < H; i++){
		for(int k = 2; k < W; k++){
			table[i][k].from_left = table[i][k-2].from_left + table[i][k-2].from_down + table[i][k-2].up_right;
			table[i][k].from_left %= NUM;
			table[i][k].from_down = table[i-2][k].from_left + table[i-2][k].from_down + table[i-2][k].right_up;
			table[i][k].from_down %= NUM;
			table[i][k].up_right = table[i-1][k-1].from_down + table[i-1][k-1].right_up;
			table[i][k].up_right %= NUM;
			table[i][k].right_up = table[i-1][k-1].from_left + table[i-1][k-1].up_right;
			table[i][k].right_up %= NUM;
		}
	}

	printf("%d\n",(table[H-1][W-1].from_left+table[H-1][W-1].from_down+table[H-1][W-1].right_up+table[H-1][W-1].up_right)%NUM);
}


int main(){

	int W,H;
	while(true){
		scanf("%d %d",&W,&H);
		if(W == 0 && H == 0)break;

		func(W,H);
	}
	return 0;
}

Measured memory_bytes: 2728
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s=readln.chomp.to!(char[]);

  s[3]='8';
  writeln(s);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv, std.exception;
  auto l=readln.split;
  enforce(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,X[100],m=100,M=0,res=1000000,sum;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>X[i];
		m=min(m,X[i]);
		M=max(M,X[i]);
	}
	for(int i=m;i<=M;i++){
		sum=0;
		for(int j=0;j<N;j++){
			sum+=(X[j]-i)*(X[j]-i);
		}
		res=min(sum,res);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

Int Y[100050], S[100050];

struct edge {
  int src, dst, yen, snk;
  edge(int src, int dst, int yen, int snk) : src(src), dst(dst), yen(yen), snk(snk) { }
};
typedef vector<edge> edges;
typedef vector<edges> graph;

struct info {
  int pos;
  Int d;
  info(int p, Int d) : pos(p), d(d) { }
  bool operator< (const info& e) const { return d > e.d; }
};

void dijkstra(const graph& g, int s, bool yen, Int* res) {
  const int n = g.size();
  fill(res, res + n, INFLL);

  priority_queue<info> Q;
  Q.emplace(s, 0);
  res[s] = 0;

  while (!Q.empty()) {
    const info c = Q.top(); Q.pop();
    if (res[c.pos] != c.d) continue;
    for (const edge& e : g[c.pos]) {
      Int cost = (yen ? e.yen : e.snk);
      if (res[e.dst] > c.d + cost) {
        res[e.dst] = c.d + cost;
        Q.emplace(e.dst, res[e.dst]);
      }
    }
  }
}

int main() {
  int N = in();
  int M = in();
  int st = in() - 1;
  int gl = in() - 1;

  graph G(N);
  for (int i = 0; i < M; ++i) {
    int u = in() - 1;
    int v = in() - 1;
    int a = in();
    int b = in();
    G[u].emplace_back(u, v, a, b);
    G[v].emplace_back(v, u, a, b);
  }

  dijkstra(G, st, true, Y);
  dijkstra(G, gl, false, S);

  vector<Int> U;
  for (int i = 0; i < N; ++i) {
    U.push_back(Y[i] + S[i]);
  }
  for (int i = N - 2; i >= 0; --i) {
    chmin(U[i], U[i + 1]);
  }
  for (int i = 0; i < N; ++i) {
    printf("%lld\n", 1000000000000000LL - U[i]);
  }

  return 0;
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
template<typename T> istream &operator>>(istream &is, vector<T> &vec)
                                        { for (auto &v : vec) is >> v; return is; }

const int  MOD=1000000007;
const int N=2*100005;

void solve(){
	long n;
	cin>>n;
	vector<long> a(n+1),b(n+1),c(n+1),cntA(n+1,0),cntB(n+1,0);
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	cin>>b[i];
	for(int i=1;i<=n;i++)	cntA[a[i]]=i;
	for(int i=n;i>=1;i--)	cntB[b[i]]=i;
	long ans=0;
	for(int i=1;i<=n;i++){
		if(cntA[i] && cntB[i])
			ans=max(ans,cntA[i]-cntB[i]+1);
	}
	for(int i=1;i<=n;i++)
		c[(i+ans)>n ? i+ans-n : i+ans ]=b[i];
	
	bool ok=true;
	for(int i=1;i<=n;i++){
		if(a[i]==c[i])
			ok=false;
	}
	if(!ok){
		cout<<"No\n";
	} else {
		cout<<"Yes\n";
		for(int i=1;i<=n;i++)
			cout<<c[i]<<" ";
	}
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11100