akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] a = new int[10];
			for (int i = 0; i < n; i++) {
				int b = scanner.nextInt();
				a[b]++;
			}
			int sum = 0;
			for (int i = 1; i < 5; i++) {
				int c = Math.min(a[i], a[10 - i]);
				sum += c;
				a[i] -= c;
				a[10 - i] -= c;
			}
			sum += a[5] / 2;
			a[5] %= 2;
			if(a[1]<2)
				a[8] =0;
			a[9] = 0;
			ans = 0;
			dfs(1, 0, a, 0);
			System.out.println(sum + ans);
		}

	}

	int ans;

	private void dfs(int i, int sum, int[] a, int now) {
		int rem = sum;
		int max = 0;
		for (int j = 1; j < 10; j++) {
			rem += a[j] * j;
			if(a[j]!=0)
				max=j;
		}
		if (now + rem / 10 <= ans)
			return;
		ans = Math.max(ans, now);
		if (sum == 10) {
			dfs(1, 0, a, now + 1);
			return;
		}
		if (i > max)
			return;
		dfs(i + 1, sum, a, now);
		if (a[i] > 0 && sum + i <= 10) {
			a[i]--;
			dfs(i, sum + i, a, now);
			a[i]++;
		}
	}
}

Measured memory_bytes: 32680
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<queue>
#include<unordered_map>
#include<map>
#include<stack>
#include<bits/stdc++.h>
#include<string.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define f first
#define s second
#define respr(fir,sec) for(int i=0;i<=fir;i++){for(int j=0;j<=sec;j++){cout << res[i][j] << " ";}cout << "\n";}
#define pb push_back
//#define INF (1LL<<31)
using namespace std;
using namespace __gnu_pbds;
const int mod = 1000000007;
const ll MAX = 1000000000000000000;
typedef pair<int,ll> pii;
typedef pair<ll,int> pi;
typedef tuple<long long,int> tp;
typedef tuple<int,int,long long> tu;
typedef multimap<pii , int> mpp;
typedef priority_queue< tp , vector<tp>, greater<tp>>  minheap;
typedef priority_queue<pii , vector<pii>> maxheap;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
 


int main()
{
	int n;
	cin >> n;
	vector<int> arr(n);
	vector<int> cost(n);
	for(int i=0;i<n;i++)
		cin >> arr[i];
	for(int i=0;i<n;i++)
		cin >> cost[i];
	vector<ll> res(n+1);
	
	ll base=1;
	while(base <=(ll)n)
		base *= 2;
	vector<ll> tree(2*base);
	
	for(int i=0;i<n;i++){
		ll stop = base + arr[i];
		ll best=0;
		while(stop>1){
			if(stop%2==1){
				best = max(best, tree[stop-1]);
			}
			stop /= 2;
		}
		
		res[arr[i]] = best+cost[i];
		
		for(ll base1=base+arr[i]; base1>=1;base1/=2)
			tree[base1] = max(tree[base1], res[arr[i]]);
	}
	ll ans=0;
	for(int i=0;i<=n;i++)
		ans= max(ans,res[i]);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 7424
n,a,b = [int(i) for i in input().split()]
ans = int(0)
#range(a,b,c)はstart:a,end:b-1,step:cである。注意。
for i in range(1,n+1):
    # h = i//100
    # l,m = divmod(i%100,10)
    # p = h+l+m
    p = sum(int(j) for j in str(i))
    if a <= p <= b:
        ans += i
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long  long 
#define ar array

using namespace std ;
const int N =1e7 +5 ;
int f[N] ;
                                                                                              
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int n ; 
	cin>>n;
	for(int i=1;i<N;i++)
		for(int j=i;j<N;j+=i) f[j]++; 
	int ans=0;
	for(int i=1;i<=n;i++) ans=ans+f[i]*i;
	cout<<ans<<endl;

}








Measured memory_bytes: 81784
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int h, n;
        cin >> h >> n;
        int x = 0;
        while(n--){
            int y; cin >> y ; x+=y;
        }

        if(x >= h)
            cout << "Yes\n";
        else
            cout << "No\n";
        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i, n) cin >> l.at(i);
  int d = 0;
  int num = 1;
  rep(i, n) {
    d += l.at(i);
    if(d <= x) num++;
  }
  cout << num << endl;
}


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


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

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

lli C[300005] = {};
lli D[300005] = {};
lli ruiseki1[300005] = {};
lli ruiseki2[300005] = {};
lli ans[300005] = {};


int main(void) {

	lli N;
	cin >> N;

	for (int i = 0; i < N; i++) {
		lli A;
		cin >> A;

		//Cがその数がいくつあるかの配列になる
		C[--A]++;
	}

	for (int i = 0; i < N; i++) {
		//Dが個数がkある数がいくつあるか？の配列
		D[C[i]]++;
	}

	for (int i = 0; i < N; i++) {
		ruiseki1[i + 1] = i * D[i] + ruiseki1[i];
	}

	for (int i = 1; i <= N; i++) {
		ruiseki2[i + 1] = D[i] + ruiseki2[i];
	}

	//K個(長さK)食べるとして、X回食べれる最大の長さは？
	//Xよりも個数が小さい数は、すべて使える。
	//X以上の個数が多い数は全ては使えない。最大使えてX。
	//鳩ノ巣理論的に同じところで選ばなければいけないから
	for (lli X = 1; X <= N; X++) {
		lli sum = 0;
		//ココが重いから累積和を使って高速化
		/*
		for (int i = 1; i < X; i++) {
			sum += i * D[i];
		}
		for (int i = X; i <= N; i++) {
			sum += X * D[i];
		}
		*/
		sum += ruiseki1[X];
		sum += (ruiseki2[N + 1] - ruiseki2[X]) * X;
		sum /= X;
		//COUT(sum);
		//長さにマッピングしなおす
		ans[sum] = std::max(ans[sum], X);
	}

	//長さiである個数食べれたならi-1でもその個数食べれるはず
	for (int i = N; i > 0; i--) {
		ans[i - 1] = std::max(ans[i - 1], ans[i]);
	}

	for (int i = 1; i <= N; i++) {
		COUT(ans[i]);
	}

	return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n,m;
    cin >> n >> m;
    ll res = 0;
    if(n <= m/2){
        res = n + (m-2*n)/4;
    }else{
       //Sccを作ることにおいて、S > 2*cならばそれより多くSを作ることは必要ない
       //だからc/2でいい
       res = m / 2;
    }
    cout << res << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    ll ans = 0, n = s.size();
    rep(x, 0, 1 << (n - 1)) {
        ll acc = 0;
        rep(i, 0, n) {
            acc *= 10;
            acc += s[i] - '0';
            if ((x & (1 << i)) == 0) {
                ans += acc;
                acc = 0;
            }
        }
        ans += acc;
    }
    cout << ans << endl;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a<b){
    for(int i=0;i<b;i++) cout<<a;
  }
  else{
    for(int i=0;i<a;i++) cout<<b;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[4];
cin >> s;
string ans = "Good";
REP(i,3) {
  if(s[i]==s[i+1]) ans="Bad";
}
cout << ans << endl;
return 0;
}


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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector<ll> pos, neg;
	ll curr = 0, i = 0, x;
	cin>>x;
	while(curr <= 100000000000)
	{
		pos.pb(curr);
		i++;
		curr= pow(i, 5);
	}
	int s = pos.size();
	for(int i = 1; i < s; i++)
	{
		neg.pb(pos[i]);
	}
	int s2 = neg.size();
	// for(int i = 0; i < pos.size(); i++)
	// {
	// 	cout<<pos[i]<<" ";
	// }
	// cout<<endl;
	// for(int i = 0; i < neg.size(); i++)
	// {
	// 	cout<<neg[i]<<" ";
	// }
	// cout<<endl;
	int f = 0;
	// for(int x = 1; x <= 100; x++)
	// {
	// 	cout<<x<<" ";
	// 	f = 0;
	for(int i = 0; i < s; i++)
	{
		for(int j = 0; j < s; j++)
		{
			if(pos[i]-pos[j]==x)
			{
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}

	for(int i = 0; i < s; i++)
	{
		for(int j = 0; j < s2; j++)
		{
			if(pos[i]+neg[j]==x)
			{
				cout<<i<<" "<<"-"<<j+1;
				return 0;
				// cout<<endl;
				f = 1;
				// break;
			}
		}

	}
	// for()

}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (c>=a&&c<=b)
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    int main(){
        long long N,K;cin>>N>>K;
        if(N==K){
            cout<<0<<endl;
            return 0;
        }
        if(N>K){
            N=N-(N/K)*K;
            if(N==0){cout<<0<<endl;
            return 0;
            }
        }
        long long mae=N;
        long long ima;
       ima=abs(mae-K);
        while(mae>ima){
            mae=ima;
            ima=abs(mae-K);
            
        }

        cout<<mae<<endl;
        return 0;
    }










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

int main()
{
	int n,m;
	cin>>n>>m;
	vector<string>a(n);
	for(int i=0;i<n;i++)
	{
			cin>>a[i]; 
		
	}
/*	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cout<<a[i][j];//<<" ";
		}
		cout<<endl;
	}
	*/
	vector<vector<int>>dp(n,vector<int>(m));
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(a[i][j]=='#') continue;
			if(i==0&&j==0) continue;
			if(i==0) dp[i][j]=dp[i][j-1];
			else if(j==0) dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]+=(dp[i][j-1]+dp[i-1][j])%1000000007;
			}
		}
	}
	cout<<dp[n-1][m-1]%1000000007<<endl;
	
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(ll i=0;i<(n);i++)
int main() {
	string s;
	cin >> s;
	ll cnt = 0;
	rep(i, 3)if (s[i] == 'o')cnt++;
	cout << 700 + cnt * 100 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;

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

	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n + 1; i++) ans += i * (n - i + 1) % mod + 1;
	cout << ans % mod << '\n';
}

Measured memory_bytes: 3636
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)
 
using namespace std;
const int N=2005,mod=1000000007;
typedef long long LL;
int n,k,ans;
LL flv[N*N],inv[N*N],f[N][N];

LL getmi(LL a,int x)
{
    LL rt=1;
    while(x)
    {
        if(x&1) rt=rt*a%mod;
        a=a*a%mod,x>>=1;
    }
    return rt;
}
 
LL C(int n,int m)
{
    return n<m?0:flv[n]*inv[m]%mod*inv[n-m]%mod;
}
 
void inc(LL &x,int y)
{
    if((x+=y)>=mod) x-=mod;
}
 
void task()
{
	if(k==1) {puts("1"); return;}
    flv[0]=1;
    rep(i,1,n*k) flv[i]=flv[i-1]*i%mod;
    inv[n*k]=getmi(flv[n*k],mod-2);
    repd(i,n*k,1) inv[i-1]=inv[i]*i%mod;
    f[0][0]=1;
    rep(i,1,n)
        rep(j,0,i)
        {
            f[i][j]=f[i-1][j];
            if(j) f[i][j]=(f[i][j]+f[i][j-1]*C(n-i+(k-1)*(n-j+1)-1,k-2))%mod;
        }
    printf("%lld\n",flv[n]*f[n][n]%mod);
}
 
int main()
{
    scanf("%d%d",&n,&k);
    task();
    return 0;
}

Measured memory_bytes: 92928
n = int(input())
a = list(int(i) for i in input().split())

dic = {}
for i in range(len(a)):
    if a[i] in dic:
        dic[a[i]]+=1
    else:
        dic[a[i]]=1

    if a[i]+1 in dic:
        dic[a[i]+1]+=1
    else:
        dic[a[i]+1]=1

    if a[i]-1 in dic:
        dic[a[i]-1]+=1
    else:
        dic[a[i]-1]=1

print(max(dic.values()))



Measured memory_bytes: 19772
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        String line1 = sc.nextLine();
        String[] line2 = line1.split(" ");
        int[] ary = new int[n];
        for(int i = 0; i < n; i++)
        ary[i] = Integer.parseInt(line2[i]);
        Arrays.sort(ary);
        if(ary[ary.length / 2] == ary[ary.length / 2 - 1])
        System.out.println(0);
        else
        System.out.println(ary[ary.length / 2] - ary[ary.length / 2 - 1]);
    }
}

Measured memory_bytes: 51012
# https://atcoder.jp/contests/agc002/tasks/agc002_a
a, b = map(int, input().split())

if a > 0 and b > 0:
    print('Positive')
elif a <= 0 and 0 <= b:
    print('Zero')
else:
    d = b - a
    if d % 2 == 0:
        print('Negative')
    else:
        print('Positive')

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll X;
    cin >>X;
    ll now=0;
    ll cnt=0;
    while(1){
        cnt++;
        now+=cnt;
        if(now>=X)break;
    }
    cout << cnt << endl;


    return 0;
    

}

Measured memory_bytes: 3608
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>


using namespace std;

//vector<double> a;


int main(){
	double a;
	while(cin>>a){
		double sum=a;
		for(int i=0; i<9; i++){
			if(i%2==0)a*=2;
			else a/=3;
			sum+=a;
		}
		//cout<<sum<<endl;
		printf("%.15lf\n", sum);
	}

}

Measured memory_bytes: 1236
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.*;

public class Main {

static int mod=(int)1e9+7;
 public static void main(String[] $) {

   Scanner sc=new Scanner(System.in);
   int k=sc.nextInt();
   
   String s="";
   for(int i=0;i<k;i++) {
     s+="ACL";
}
   System.out.println(s);

}
static int msb(int a){
   int k=(int)(Math.log(a)/Math.log(2));
   return k;
}


static long pow(long x,long y) {
  long res=1l;
  while(y!=0) {
    if(y%2==1) {
      res=x*res%mod;
    }
    y/=2;
    x=x*x%mod;
  }
  return res;
}

}
class pair{
  int x,y;
  pair(int x,int y){
    this.x=x;
    this.y=y;
  }
}

Measured memory_bytes: 38424
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int ans = 0;

int check(long long int n, int a, bool x3, bool x5, bool x7) {
	if (n > a) {
		return 0;
	}
	if (x3&&x5&&x7) {
		ans++;
	}
	check(n * 10 + 3, a, true, x5, x7);
	check(n * 10 + 5, a, x3, true, x7);
	check(n * 10 + 7, a, x3, x5, true);
}

int main() {
	int n;
	cin >> n;
	check(0, n, false, false, false);

	cout << ans << endl;

	return 0;
}

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2) ans*=a, ans%=(mod);
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,_;
	ll n;
	cin >> n;
	ll ans[n];
	init(ans,n,-1);
	vector<ll> a[n+1],b[n+1];
	priority_queue<pair<ll,ll> > pq,pq2;
	ll x,d[n];
	rep(i,0,n) {
		cin >> x;
		d[i] = x;
		a[x].pb(i);
	}
	ll c[n];
	rep(i,0,n) {
		cin >> x;
		c[i] = x;
		b[x].pb(i);
	}
	ll m[n];
	j = 0;
	rep(i,n/2,n) m[i] = c[j++];
	rep(i,0,n/2) m[i] = c[j++];
	rep(i,0,n) {
		if(d[i] == m[i]) break;
	}
	if(i == n) {
		cout << "Yes\n";
		rep(i,0,n) cout << m[i] << ' ';cout << endl;
		return;
	}
	rep(i,0,n+1) {
		if(a[i].size()) {
			pq.push({a[i].size(),i});
		}
		if(b[i].size()) pq2.push({b[i].size(),i});
	}
	while(!pq.empty()) {
		pll k = pq.top();
		pq.pop();
		pll j = pq2.top();
		pq2.pop();
		if(k.S == j.S) {
			if(pq2.size() == 0) break;
			pll j1 = pq2.top();
			pq2.pop();
			while(k.F && j1.F) {
				ans[a[k.S].back()] = b[j1.S].back();
				a[k.S].pop_back();
				b[j1.S].pop_back();
				k.F = a[k.S].size();
				j1.F = b[j1.S].size();
			}
			if(k.F) pq.push(k);
			if(j1.F) pq2.push(j1);
			pq2.push(j);
		}
		else {
			while(k.F && j.F) {
				ans[a[k.S].back()] = b[j.S].back();
				a[k.S].pop_back();
				b[j.S].pop_back();
				k.F = a[k.S].size();
				j.F = b[j.S].size();
			}
			if(k.F) pq.push(k);
			if(j.F) pq2.push(j);
		}
	}
	// rep(i,0,n) cout << ans[i] << " " ;cout << endl;

	rep(i,0,n) {
		if(ans[i] == -1) {
			cout << "No\n";
			return;
		}
	}
	cout << "Yes\n";
	for(auto i : ans) cout << c[i] << " ";
	cout << endl;
}

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




Measured memory_bytes: 31736
n,m,XX,YY=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
x.sort()
y.sort()
result=False
if x[-1]<=y[0]:
    for i in range(XX+1,YY+1):
        if i>x[-1] and i<=y[0]:
            result=True
if result==True:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
//lunchtime june Increasing and Decreasing
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <algorithm>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while(t--)

#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define pb push_back
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define double long double

using namespace std;
ll form(ll n){
return (n*(n+1))/2;
}
ll exponent(ll base, ll power){
   ll res = 1;
  ll m = 1000000007;
   while(power){
    if(power&1)
        res = (res*base)%m;
    base= (base*base)%m;
    power=power>>1;
   }
return res;}
bool count_one(ll n){
    ll cnt = 0;
    while(n>0){
            cnt+=1;
       n= n&(n-1);

    }
    if(cnt>1)
        return true;
    return false;
}
void solve()
{ll n;
 in n;
 ll check=0;
  for(ll i=1;i<=100000;i++){
    if(1000*i>=n){
        check=(1000*i)-n;
        break;
    }
  }
  out check<<en;
}




int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


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

#define ll long long
#define ld long double
//#define endl '\n'
#define With_the_name_of_Allah ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi double(acos(-1))

using namespace std;

long long mod ;
long long Fast_pow(long long a ,long long b)
{
    if(b==0)
        return 1;

    long long z=Fast_pow(a,b/2);


    if(b%2==0)return ((z%mod)*(z%mod))%mod; else return (((z*z)%mod)*a)%mod;
}



long long gcd(long long a, long long b)
{
    if(a==0)
        return b;
    else return gcd(b%a , a);
}


bool prime[1000001];

void sieve()
{
    memset(prime , true , sizeof prime);
    prime[0]=prime[1]=0;

    for(int i=2 ; i*i<=1000000; i++)
    {
        if(prime[i]==true)
        for(int j=i*i ; j<=100000 ; j+=i)
        prime[j]=false;
    }
}

ll lcm(ll a, ll b)
{
    return (a*b)/__gcd(a,b);
}
int res;
int ans[3*1001][3*1001];
string a, b , c;
int fn(int i , int j)
{
    if(i>=a.size() || j>=b.size())
        return 0;
    if(ans[i][j]!=-1)
    return ans[i][j];
    int res=0;


    if(a[i]==b[j])
        res=1+fn(i+1 , j+1) , c+=a[i];

    else
    {
        res=max(res , fn(i+1 , j));
        res=max(res , fn(i,j+1));
     }
    ans[i][j]=res;
    return res;
}

void pr(int i , int j)
{
    if(i>=a.size() || j>=b.size())
        return;

    else if(a[i]==b[j])
        cout<<a[i] , pr(i+1 , j+1);

    else
    {
        if(fn(i + 1, j)==ans[i][j])
            pr(i+1 , j) ;
        else
            pr(i , j+1);
    }
}

string ss, bb;
int f(int i , int j)
{
    if(i==a.size())
        return b.size()-j;
    else if(j==b.size())
        return a.size()-i;

    if(ans[i][j]!=-1)
        return ans[i][j];
    res=1e9;
    if(a[i]==b[j])
        res = f(i+1 , j+1);
    else
    {
        res=min(f(i+1 , j)+1 , f(i,j+1)+1);
        res=min(res , f(i+1 , j+1)+1);
     }
    ans[i][j]=res;
    return res;
}





int main()
{
    //------lcs------//

    cin>>a>>b;
    memset(ans , -1 , sizeof ans);
   /*fn(0,0);
    pr(0,0);
    */



    fn(0,0);
    pr(0, 0);
    return 0;
}


Measured memory_bytes: 40456
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    if(A+B>C+D){
      System.out.println("Left");
    }else if(A+B==C+D){
      System.out.println("Balanced");
    }else{
      System.out.println("Right");
    }
  }
}


Measured memory_bytes: 23636
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        String S = reader.next();
        for (int i=0; i<S.length(); i++) {
            char c = S.charAt(i);
            int  p = (c - 'A' + N) % 26;
            c = (char)((int)'A' + p);
            System.out.print(c);
        }
        System.out.println();
    }

    // Read Class
    static class FS {
        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() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); 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 int nextInt() {
            return (int)nextLong();
        }
        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();
            }
        }
    }
}



Measured memory_bytes: 23764
import itertools
N,M = map(int,input().split())
r = []
for _ in range(M):
    add = list(map(int,input().split()))
    r.append(add)
    r.append(add[::-1])
A = [i for i in range(2,N + 1)]
A = list(itertools.permutations(A,N - 1))
ans = 0
for check in A:
    q = 0
    p = [1] + list(check)
    for c in range(N - 1):
        if p[c:c + 2] in r:
            q += 1
    if q == N - 1:
        ans += 1
print(ans)

Measured memory_bytes: 3572
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range((n - 1) // 2 + 1):
    b.append(a[n - 1 - 2 * i])
for i in range(n // 2):
    b.append(a[2 * i + n % 2])
for i in range(n):
    print(b[i], end = " ")
print()

Measured memory_bytes: 96084
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    int k;
    cin >> n >> k;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++){
        if (i == k - 1){
            if (s[i] == 'A'){
                s[i] = 'a';
            }
            if (s[i] == 'B'){
                s[i] = 'b';
            }
            if (s[i] == 'C'){
                s[i] = 'c';
            }
        }
    }
    ctn(s);
    return 0;
}


Measured memory_bytes: 3604
from collections import deque

N,M,Q = map(int,input().split())
QUERY = [0]*Q
for i in range(Q):
    QUERY[i] = tuple(map(int,input().split()))

ans = 0
D = deque()
D.append((1,[1]))
dlen = 1
while dlen != 0:
    Alen,A = D.pop()
    dlen -= 1
    if Alen == N:
        e = 0
        for a,b,c,d in QUERY:
            a -= 1
            b -= 1
            if A[b] - A[a] == c:
                e += d
        ans = max(ans,e)
    else:
        for AA in range(A[-1],M+1):
            D.append((Alen+1,A+[AA]))
            dlen += 1

print(ans)


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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;cin>>s;
  vector<vector<int>> alp(26,vector<int>(0));
  rep(i,26)alp[i].emplace_back(-1);
  int i,j;
  rep(i,s.size())alp[s[i]-'a'].emplace_back(i);
  rep(i,26)alp[i].emplace_back(s.size());
  int ans=s.size()-1;
  rep(i,26)
  {
    int kmax=0;
    rep(j,alp[i].size()-1)
    {
      kmax=max(kmax,alp[i][j+1]-alp[i][j]-1);
    }
    if(kmax<ans)ans=kmax;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
    for(int i=0;i<4;i++){
        cin>>a[i];
    }
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]== 9){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}


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

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String[] temp = in.nextLine().trim().split("\\s");
        int n = Integer.parseInt(temp[0]);
        int w = Integer.parseInt(temp[1]);
        int[] warr = new int[n];
        int[] varr = new int[n];
        for(int i = 0; i < n; i++){
            temp = in.nextLine().trim().split("\\s");
            warr[i] = Integer.parseInt(temp[0]);
            varr[i] = Integer.parseInt(temp[1]);
        } 
        long[][] dp = new long[n+1][w+1];
        for(int i = 1; i <= n; i++){
            for(int j = 0; j <= w; j++){
                dp[i][j] = dp[i-1][j];
                if(j >= warr[i-1]){
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][j-warr[i-1]] + varr[i-1]);
                }
            }
        }
        
        System.out.println(dp[n][w]);
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S, T; cin >> S >> T;
  string ans = "Yes";
  for(int i = 0; i < S.size(); ++i) {
    if(S[i] != T[i]) ans = "No";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
from decimal import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

BLOCK = '#'
ROAD = '.'


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


def bfs(graph, initial, goal, H, W):
    options = [(1, 0), (0, 1)]
    q = deque([initial])
    dist = [[10**9 for i in range(W)] for i in range(H)]
    dist[initial[0]][initial[1]] = 0 if graph[initial[0]][initial[1]] == ROAD else 1

    while len(q) != 0:
        p = q.popleft()

        for d in options:
            i = p[0] + d[0]
            j = p[1] + d[1]

            if i >= 0 and i < H and j >= 0 and j < W:
                if dist[i][j] == 10**9 or dist[p[0]][p[1]] < dist[i][j]:
                    q.append((i, j))
                    if graph[p[0]][p[1]] != BLOCK and graph[i][j] == BLOCK:
                        dist[i][j] = dist[p[0]][p[1]] + 1
                    else:
                        dist[i][j] = dist[p[0]][p[1]]

    # print_matrix(dist)
    return dist[goal[0]][goal[1]]


def main():
    H, W = MI()
    graph = [None] * H

    for i in range(H):
        graph[i] = list(S())

    ret = bfs(graph, (0, 0), (H-1, W-1), H, W)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64620
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
int main(){
      int cntJ=0,cntO=0,cntI=0;
      string s;
      cin>>s;
      int ans=0,f=0,i=0,now;
      while(i<s.size()){
            now=i;
            cntJ=cntO=cntI=0;
            if(s[i]=='J'){
                  while(s[i]=='J'&&s.size()){
                        cntJ++;i++;
                  }
                  f=1;
            }
            if(f==1&&s[i]=='O'&&i<s.size()){
                  while(s[i]=='O'&&i<s.size()){
                        cntO++;i++;
                  }
                  if(cntJ>=cntO)f=2;
            }
            if(f==2&&s[i]=='I'&&i<s.size()){
                  while(s[i]=='I'&&i<s.size()){
                        i++;cntI++;
                  }
                  if(cntI>=cntO)ans=max(ans,cntO);
            }
            if(now==i)i++;
      }
      cout<<ans<<endl;
}

Measured memory_bytes: 2048
#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;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 1;
  rep(i,n-1){
    if(s[i]!=s[i+1]) cnt++;
  }
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long sum = 0;
        int i = 1;
        while (true) {
            sum += i;
            if (sum >= x) {
                System.out.println(i);
                return;
            }
            i++;
        }
    }

}


Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstring>
#include <map>
#include<cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ret = 0;
    int a, b;
    for(int i = 0; i < n; i ++){
        cin >> a >> b;
        ret += (b - a + 1);
    }
    cout << ret << endl;
    return 0;
}
//1234567894848
//1234567891011


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
int MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,n){
        int a;
        cin>>a;
        a--;
        ans+=a;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	cout << n * m << endl;
	return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10 + 1e8;
int main() 
{
	int Min = Max;
	int MAX = 0;
	int n, k;
	cin >> k >> n;
	vector<int> a(n);
	vector<int> sa(n);
	rep(i, n) cin >> a[i];
	rep(i, n-1) {
		sa[i] = a[i + 1] - a[i];
	}
	sa[n - 1] = a[0] + k - a[n - 1];
	rep(i, n) MAX = max(MAX, sa[i]);
	int ans = k - MAX;
	cout << ans;
}


Measured memory_bytes: 4836
(let* ((n (read))
    (l (make-array n))
    (ans 0))
    (loop for i below n do
        (setf (aref l i) (read))
    )
    (sort l #'<)
    (loop for i from 0 to (- n 3) do
        (loop for j from (+ i 1) to (- n 2) do
            (loop for k from (+ j 1) to (- n 1) do
                (if (not (or (= (aref l i) (aref l j)) (= (aref l j) (aref l k)) (= (aref l i) (aref l k))))
                    (if (and (> (+ (aref l i) (aref l j)) (aref l k)) (> (+ (aref l j) (aref l k)) (aref l i)) (> (+ (aref l k) (aref l i)) (aref l j)))
                        (incf ans)
                    )
                )
            )
        )
    )
    (princ ans)
)

Measured memory_bytes: 24444
a,b = [int(x) for x in input().split()]
sum_outlet = a
taps = 1
# A口ある電源タップを一個取り付けると、差込口はA-1個増える

if b == 1:
      print(0)
else:
      while(sum_outlet < b):
            #print(sum_outlet,taps)
            taps += 1
            sum_outlet += a-1
      print(taps)

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

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

    cout << (n + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var N string
  fmt.Scan(&N)
  var flg int

  for i := 0; i < len(N); i++{
    if flg == 0 && (string(N[i]) == "L" || string(N[i]) == "R" || string(N[i]) == "U" || string(N[i]) == "D"){
      if (i)%2 == 1 {
        if string(N[i]) == "R"{
          flg = 1
        }
      } else {
        if string(N[i]) == "L"{
          flg =1
        }
      }
    } else {
      flg =  1
    }
  }

  if flg ==  0 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}


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

using namespace std;

#define ll long long
#define INF 99999999999999
#define MOD 1000000007

const int MAX_N = 100000;

int a[MAX_N];

int main()
{
	int N,K,len=0;
	ll suma=0;
	ll white,black;
	ll maxa = 0;
	cin >> N;
	cin >> K;
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		if(a[i] > 0){
			suma += a[i];
		}
	}
	white = suma;
	black = suma;
	for(int i=0;i<K;i++){
		if(a[i] > 0){
				white -= a[i];
		}else{
			black += a[i];
		}
	}
	maxa = max(max(maxa,white),black);
	for(int i=0;i<=N-K;i++){
		if(a[i] > 0){
			white += a[i];
		}else{
			black -= a[i];
		}
		if(a[i+K] > 0){
			white -= a[i+K];
		}else{
			black += a[i+K];
		}
		maxa = max(max(maxa,white),black);
	}
	cout << maxa;
}

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

#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define REP(i, n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;


class BGridCompression {
public:
    ll H, W;
    char mat[100][100];
    bool hskip[100]{false};
    bool wskip[100]{false};

    void solve(std::istream& in, std::ostream& out) {
        in >> H >> W; in.ignore();
        string line;
        REP(i, H) {
            getline(in, line);
            REP(j, W) mat[i][j] = line[j];
        }

        for(;;) {
            REP(i, H) {
                if (row(i) && !hskip[i]) { hskip[i] = true; continue; }
            }
            REP(j, W) {
                if (col(j) && !wskip[j]) { wskip[j] = true; continue; }
            }
            break;
        }
        REP(i, H) {
            if (hskip[i]) continue;
            REP(j, W) {
                if (!wskip[j]) out << mat[i][j];
            }
            out << endl;
        }

    }

    bool row(int r) {
        char x;
        REP(i, W) {
            if (wskip[i]) continue;
            x = mat[r][i]; break;
        }
        if (x == '#') return false;
        REP(i, W) {
            if (wskip[i]) continue;
            if (x != mat[r][i]) return false;
        }
        return true;
    }

    bool col(int c) {
        char x;
        REP(i, H) {
            if (hskip[i]) continue;
            x = mat[i][c]; break;
        }
        if (x == '#') return false;
        REP(i, H) {
            if (hskip[i]) continue;
            if (x != mat[i][c]) return false;
        }
        return true;
    }
};


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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define pb(x) push_back(x)
#define eps 0.000000000001;
using namespace std;

int main(){
  double w,h,x,y;
  std::cin >> w>>h>>x>>y;
  double ans = w*h/2.0;
  double ans2 = 0;
  if(w == x*2 && h == y*2){
    ans2 = 1;
  }
  std::cout << ans <<" "<<ans2<< '\n';

  return 0;
}


Measured memory_bytes: 256
#! /usr/bin/python3
# ABC044_B
# B - 美しい文字列 / Beautiful Strings
"""
collectionsを使わないタイプ

制約
    1≤|w|≤100
    w は英小文字 (a-z) のみからなる文字列である。
"""

import collections
test_mode = False
use_Counter = True    # collections.Counter を使うかどうか


def judge_0(l):
    """
    collections.Counter を使うタイプ
    奇数会出現する要素があると False を返し、
    全ての要素が偶数回出現すると True を返す。
    """
    count_l = collections.Counter(l)    # l の各要素の出現回数をカウント

    if test_mode:
        print(count_l)

    for i in count_l:
        if count_l[i] % 2 == 1:
            if test_mode:
                print('break')
            return False

    return True


def judge_1(l):
    """
    collections.Counter を使わないタイプ
    奇数会出現する要素があると False を返し、
    全ての要素が偶数回出現すると True を返す。
    """

    for i in l:
        if test_mode:
            print('{}:'.format(i), l.count(i))
            if l.count(i) % 2 == 1:
                print('break')
        if l.count(i) % 2 == 1:
            return False

    return True



def main():
    """
    main関数
    """
    w = list(str(input()))  # 文字列をリストに変換
    if use_Counter:
        beautiful = judge_0(w)
    else:
        beautiful = judge_1(w)

    if beautiful:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>

void swap(int *a, int *b){
  int v;
  v=*a;
  *a=*b;
  *b=v;
}

int main(){
  int n,*A,i,j=0,k;
  
  scanf("%d",&n);
  A=(int *)malloc(n*sizeof(int));
  
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  for(i=0;i<n-1;i++)
    if(A[i]<=A[n-1])
      swap(&A[i], &A[j++]);
  swap(&A[j], &A[n-1]);

  for(i=0;i<n-1;i++){
    if(i!=j) printf("%d ",A[i]);
    else printf("[%d] ",A[i]);
  }
  printf("%d\n",A[i]);
  
  return 0;
}



Measured memory_bytes: 2248