akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0) :x(x% mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int> rec;
	rep(i, n) {
		if (s[i] == t[i]) rec.push_back(1);
		else rec.push_back(2), ++i;
	}
	mint ans = 1;
	if (rec.front() == 2) ans *= 6;
	else ans *= 3;
	int sz = rec.size();
	rrep(i, sz) {
		if (rec[i] == 1) {
			if (rec[i - 1] == 1) {
				ans *= 2;
			}
		}
		else {
			if (rec[i - 1] == 1) {
				ans *= 2;
			}
			else ans *= 3;
		}
	}
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, ii>, vector<pair<int, ii>>, greater<pair<int, ii>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int dx[] = {0, 0, 1, -1}, dy[]={1, -1, 0, 0};
int32_t main(void)
{
	IOS;
	string s; cin>>s; int n = s.length();
	int dp[n][2];
	dp[0][0]=1; dp[0][1]=0;
	dp[1][0] = (s[0]==s[1]?0:2);
	dp[1][1] = 1;
	if(s[0]==s[1] || s[1]==s[2]) {
		dp[2][0]=2; dp[2][1]=2;
	}
	else {
		dp[2][0]=3; dp[2][1]=2;
	}
	for(int i = 3; i < n; i++) {
		if(s[i]==s[i-1])
			dp[i][0]=dp[i-1][1]+1;
		else
			dp[i][0]=max(dp[i-1][0]+1, dp[i-1][1]+1);
		if(s[i-3]==s[i-1] && s[i-2]==s[i])
			dp[i][1]=dp[i-2][0]+1;
		else
			dp[i][1]=max(dp[i-2][0], dp[i-2][1])+1;
	}
	cout<<max(dp[n-1][0], dp[n-1][1])<<endl;
	time();	
	return 0;
}

Measured memory_bytes: 3732
nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);
s = input();

hukou = 0;
for i in range(n-1) :
	if s[i] == 'R' and s[i+1] == 'L' :
		hukou += 2;

edge = 0;
if s[0] == 'L' :
	edge += 1;
if s[n-1] == 'R' :
	edge += 1;

while hukou > 0 and k > 0 :
	hukou -= 2;
	k -= 1;

while edge > 1 and k > 0 :
	edge -= 1;
	k -= 1;

ans = n-edge-hukou;
if ans > n-1 :
	ans = n-1

print(ans);

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

int main() {
  ll n;
  cin >> n;
  ll ans=0;
  vector<ll> v(n);
  vector<ll> c(n);
  for(ll i=0;i<n;i++) {
    cin >> v[i];
  }
  for(ll i=0;i<n;i++) {
    cin >> c[i];
  }
  for(ll i=0;i<n;i++) {
    ans=max(ans,ans+v[i]-c[i]);
  }
  cout << ans << endl;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    int c = stoi(a + b);
    for(int i = 1; i <= c; i++) {
        if(i * i == c) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;


int qmi(int a, int k, int p)
{
    int res = 1;
    while (k)
    {
        if (k & 1) res = (LL)res * a % p;
        a = (LL)a * a % p;
        k >>= 1;
    }
    return res;
}


int C(int a, int b, int p)
{
    if (b > a) return 0;

    int res = 1;
    for (int i = 1, j = a; i <= b; i ++, j -- )
    {
        res = (LL)res * j % p;
        res = (LL)res * qmi(i, p - 2, p) % p;
    }
    return res;
}


int lucas(LL a, LL b, int p)
{
    if (a < p && b < p) return C(a, b, p);
    return (LL)C(a % p, b % p, p) * lucas(a / p, b / p, p) % p;
}


int main()
{
    int n;
    cin >> n;
    LL a, b;
    cin >> a >> b;
    LL p = 1e9 + 7;
    if (n == 2 && a == 1 && b == 2) {
        cout << 0 << endl;
        return 0;
    } else {
        LL res = (p+p + qmi(2, n, p) - 1 - lucas(n, a, p) - lucas(n, b, p)) % p;
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 384
// https://atcoder.jp/contests/abc106/tasks/abc106_b
#include <iostream>
#include <vector>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int_fast32_t i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int_fast32_t i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

vector<int> a = {105, 135, 165, 189, 195};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if (N >= 195) {
        cout << "5\n";
    } else if (N >= 189) {
        cout << "4\n";
    } else if (N >= 165) {
        cout << "3\n";
    } else if (N >= 135) {
        cout << "2\n";
    } else if (N >= 105) {
        cout << "1\n";
    } else {
        cout << "0\n";
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> weight(N);
  for(int i = 0; i < N; i++){
    cin >> weight.at(i);
  }
  
  int min = 1000000;
  for(int i = 0; i < N; i++){
  	int a = 0;
    int b = 0;
    for(int j = 0; j < N; j++){
      if(j <= i){
        a += weight.at(j);
      }else{
        b += weight.at(j);
        
      }
    }
    int result = std::abs(a - b);
    if(result < min)
      min = result;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10;
/*
struct Segment_tree{
	int tag[maxn<<2],Max[maxn<<2];
	inline void push_down(int x){
		if(tag[x]){
			tag[x<<1]+=tag[x],tag[x<<1|1]+=tag[x];
			Max[x<<1]+=tag[x],Max[x<<1|1]+=tag[x];
			tag[x]=0;
		}
	}
	inline void push_up(int x){
		Max[x]=max(Max[x<<1]+Max[x<<1|1]);
	}
	void add(int x,int L,int R,int ql,int qr,int v){
		if(ql<=L && R<=qr){
			tag[x]+=v;
			Max[x]+=v;
			return;
		}
		int Mid=(L+R)>>1;
		push_down(x);
		if(ql<=Mid) update(x<<1,L,Mid,ql,qr,v);
		if(qr>Mid) update(x<<1|1,Mid+1,R,ql,qr,v);
		push_up(x);
	}
	void update(int x,int L,int R,int q,int v){
		if(L==R){Max[x]=v,tag[x]=0;return;}
		int Mid=(L+R)>>1;
		push_down(x);
		if(q<=Mid) update(x<<1,L,Mid,q,v);
		else update(x<<1|1,Mid+1,R,q,v);
		push_up(x);
	}
}Seg;
*/
ll pre[maxn],suf[maxn];
struct point{
	ll x,v;
}a[maxn];
int main(){
	int n=read();ll C=readll();
	REP(i,1,n) a[i].x=readll(),a[i].v=readll();
	ll ans1=0,res=0,ans2=0;
	REP(i,1,n){
		res+=a[i].v;
		ans1=max(ans1,res-a[i].x*2);
		pre[i+1]=ans1;
	}
	res=0;
	DREP(i,n,1){
		res+=a[i].v;
		ans2=max(ans2,res-(C-a[i].x)*2);
		suf[i-1]=ans2;
	}
	res=0;ll ans=0;
	REP(i,1,n){
		res+=a[i].v;
		ans=max(ans,res-a[i].x+suf[i]);
	}
	res=0;
	DREP(i,n,1){
		res+=a[i].v;
		ans=max(ans,res-(C-a[i].x)+pre[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;
const int INF = INT_MAX/2;

int n;
int diam1,diam2,curmax;

vector <int> adjlist[maxn];
vector <int> leafs[maxn];
vector <int> diam;
vector <int> ans1,ans2;

void fail() {
	cout << -1;
	exit(0);
}

void dfsf(int x, int p,int d) {
	for (auto i: adjlist[x]) if (i != p) {
		dfsf(i,x,d+1);
	}
	if (d > curmax) {
		diam1 = x;
		curmax = d;
	}
}

void dfss(int x, int p,int d) {
	for (auto i: adjlist[x]) if (i != p) {
		dfss(i,x,d+1);
	}
	if (d > curmax) {
		diam2 = x;
		curmax = d;
	}
}

bool dfs(int x, int p) {
	int ondiam = 0;
	for (auto i: adjlist[x]) if (i != p) {
		int res = dfs(i,x);
		if (res == 1) ondiam = 1;
		else {
			leafs[x].push_back(i);
		}
	}
	
	if (x == diam2 or ondiam) {
		diam.push_back(x);
		return 1;
	} else {
		if ((int)adjlist[x].size() != 1) fail();
		return 0;
	}
}
 
int32_t main() {
	FAST
	cin >> n;
	for (int i =0;i<n-1;i++) {
		int a,b; cin >> a >> b;
		adjlist[a].push_back(b);
		adjlist[b].push_back(a);
	}
	dfsf(1,-1,0);
	curmax = 0;
	dfss(diam1,-1,0);
	dfs(diam1,-1);
	
	//cout << diam1 << "\n";
	//for (auto i: diam) cout << i << " ";
	//cout << "\n";
	//for (int i =1;i<=n;i++) {
		//for (auto j: leafs[i]) {
			//cout << i << " " << j << "\n";
		//}
	//}
	
	
	int co = 1;
	for (int i =0;i< (int) diam.size();i++) {
		int x = diam[i];
		int curdiam = co++;
		for (int j=0;j<(int)leafs[x].size();j++) {
			ans1.push_back(co);
			co++;
		}
		ans1.push_back(curdiam);
	}
	
	reverse(diam.begin(),diam.end());
	co = 1;
	for (int i =0;i< (int) diam.size();i++) {
		int x = diam[i];
		int curdiam = co++;
		for (int j=0;j<(int)leafs[x].size();j++) {
			ans2.push_back(co);
			co++;
		}
		ans2.push_back(curdiam);
		
	}
	
	int flip = 1;
	for (int i = 0; i< (int)ans1.size();i++) {
		if (ans1[i] < ans2[i]) flip = 1;
		else if (ans2[i] < ans1[i]) flip = 2;
		if (ans1[i] != ans2[i]) break;
	}

	if (flip == 1) {
		for (auto i: ans1) cout << i << " ";
	} else {
		for (auto i: ans2) cout << i << " ";
	}
}







Measured memory_bytes: 18932
costs = [2,5,5,4,5,6,3,7,6]

N, M = map(int, input().split())
A = list(map(int, input().split()))
neginf = -1 * 1e20
D = [neginf]*(N+1)

def dp(n_match):
    D[0] = 0
    for n in range(1,n_match+1):
        arr = [D[n-costs[a-1]] if n-costs[a-1]>=0 else neginf for a in A]
        D[n] = max(arr)+1

def main():
    dp(N)
    n = N
    ans = ''
    while n>1:
        arr = [ a for a in A if  n-costs[a-1]>=0 and D[n-costs[a-1]]==D[n]-1 ]
        if len(arr)>0:
            a = max(arr)
            ans += str(a)
            n -= costs[a-1]
        else:
            break
    print(ans)

main()

Measured memory_bytes: 43228
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

int
main(int argc, char *argv[])
{
    unsigned int K, N;

    scanf("%u %u", &K, &N);

    unsigned int *hs = malloc(sizeof(unsigned int) * N);
    if (hs == NULL) {
        return EXIT_FAILURE;
    }

    for (int i = 0; i < N; i++) {
        unsigned int a;
        scanf("%u", &a);
        hs[i] = a;
    }

    unsigned int max = hs[0] + K - hs[N - 1];
    int start = 0;
    fprintf(stderr, "max = %u start = %d\n", max, start);
    for (int i = 0; i < N - 1; i++) {
        unsigned int delta = hs[i + 1] - hs[i];
        if (delta > max) {
            max = delta;
            start = i + 1;
            fprintf(stderr, "max = %u start = %d\n", max, start);
        }
    }

    unsigned int distance;
    if (start > 0) {
        distance = (K - hs[start]) + hs[start - 1];
    }
    else {
        distance = hs[N - 1] - hs[0];
    }

    printf("%u \n", distance);

    return EXIT_SUCCESS;
}


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

#define F first
#define S second
#define mp make_pair
#define pb push_back
typedef long long int ll;
const ll N = 1e6+3,inf = 998244353;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll a,b,c;cin>>a>>b>>c;
    ll p = a+b;
    ll res = 0;
    if(p>=c-1)res += (b+c);
    else res += (a+1+2*b);
    cout<<res<< "\n";






    return 0;
}



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

int main() {
  
  int N; cin >> N; int count = 0, anyColor = 0;
  
  vector<bool> vec(8, false);
  
  for (int i = 0; i < N; i++) {
    
    int a; cin >> a;
    
    int tmp = a / 400;
    
    if (tmp < 8) vec[tmp] = true;
    
    else anyColor++;
    
  }
  
  for (bool flag : vec) if (flag) count++;
  
  cout << max(count, 1) << " " << count + anyColor << endl;
  
}

Measured memory_bytes: 3628
n = input()
digit_num = len(n)
if digit_num == 1:
    print(n)

else:
    first_digit = int(n[0])
    last_digit = int(n[-1])
    n = int(n)
    count = 0
    
    for i in range(1, 10):
        for j in range(i, 10):
            ci = 0
            cj = 0
            
            if i == j:
                if i < first_digit:
                    for k in range(digit_num - 1):
                        ci += 10 ** k
                    ci += 1
                
                elif i == first_digit:
                    for k in range(digit_num - 2):
                        ci += 10 ** k
                    ci += 1
                    ci += (n % (10 ** (digit_num-1))) // 10
                    if last_digit >= i:
                        ci += 1
                
                else:
                    for k in range(digit_num - 2):
                        ci += 10 ** k
                    ci += 1
            
                count += ci ** 2
            
            else:
                if j < first_digit:
                    for k in range(digit_num - 1):
                        ci += 10 ** k
                    cj = ci
                
                elif j == first_digit:
                    for k in range(digit_num - 1):
                        ci += 10 ** k
                    for k in range(digit_num - 2):
                        cj += 10 ** k
                    cj += (n % (10 ** (digit_num-1))) // 10
                    if last_digit >= i:
                        cj += 1
                
                elif i < first_digit and j > first_digit:
                    for k in range(digit_num - 1):
                        ci += 10 ** k
                    for k in range(digit_num - 2):
                        cj += 10 ** k
                
                elif i == first_digit:
                    for k in range(digit_num - 2):
                        ci += 10 ** k
                    ci += (n % (10 ** (digit_num-1))) // 10
                    if last_digit >= j:
                        ci += 1
                    
                    for k in range(digit_num - 2):
                        cj += 10 ** k
                    
                else:
                    for k in range(digit_num - 2):
                        ci += 10 ** k
                    cj = ci
                    
                count += ci * cj * 2

    print(count)

Measured memory_bytes: 3188
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)

n=int(input())
s=["".join(sorted(input())) for _ in range(n)]
t=Counter(s).values()
ans=0
for i in t:
    ans+=sum(range(1,i))
print(ans)

Measured memory_bytes: 68696
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <math.h>
#include <iomanip>
using namespace std;
//using ll = long long;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
int n,q;
int par[10005],depth[10005];
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        depth[i] = 0;
    }
}
int find(int x){
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (depth[x] < depth[y]){
        par[x] = y;
    } else {
        par[y] = x;
        if (depth[x] == depth[y]) depth[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}

int main(){
    vector<int> ans(0);
    cin >> n >> q;
    init(n);
    for(int i = 0; i < q; i++){
        int c,x,y; cin >> c >> x >> y;
        if (c == 0){
            if(same(x,y)) continue;
            unite(x,y);
        } else if (c == 1){
            if (same(x,y)){
                ans.push_back(1);
            } else {
                ans.push_back(0);
            }
        }
    }
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}
  




Measured memory_bytes: 3372
s = input()
t = 1
kisuulist = ["R", "U", "D"]
guusuulist = ["L", "U", "D"]
for i in s:
  if(t%2==0):
    if i not in guusuulist:
      print("No")
      exit()
  else:
    if i not in kisuulist:
      print("No")
      exit()
  t+=1
print("Yes")
  

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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  while(a[0] != a[n-1]){
    for(int i = 1; i < n; i++){
      a[i] %= a[0];
      if(a[i] == 0) a[i] = a[0];
    }
    sort(a.begin(), a.end());
  }
  cout << a[0] << endl;

  
  
  
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		Integer n = sc.nextInt();
		Integer m = sc.nextInt();
		if (n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 21332
import java.util.*;                                                                                  

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

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);

        line = sc.nextLine();
        String[] l = line.split(" ");

        int[] a = new int[n];
        int min = Integer.parseInt(l[0]);
        int max = Integer.parseInt(l[0]);
        long sum = 0;
        for(int i = 0; i < n; i++) {
          a[i] = Integer.parseInt(l[i]);
          if(min > a[i]) {
            min = a[i];
          }   
          if(a[i] > max) {
            max = a[i];
          }   
          sum = sum + a[i];
        }   

        System.out.println(min + " " + max + " " + sum);
    }   
}

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

int main()
{
    int n,k;
    std::cin>>n>>k;
    long long ans = 0;

    ans = std::pow((long long)n/k,3);

    if(k%2==0){
        int cnt = 0;
        for(int i=0;i<=n;i++){
            if(i % k == k/2)cnt++;
        }
        ans += std::pow((long long)cnt,3);
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <list>

using namespace std;

const double pi = 3.14159265358979323846;
const int mod = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i = 0; i < N; i++){
    cin >> D[i];
  }
  sort(D.begin(), D.end());

  int M;
  cin >> M;
  vector<int> T(M);
  for(int i = 0; i < M; i++){
    cin >> T[i];
  }
  sort(T.begin(), T.end());

  int idx = 0;
  for(int i=0; i < M; i++){
    while(D[idx] != T[i]){
      //cout << D[idx] << " " << T[i] << endl;
      idx++;
      if(idx >= N){
        cout << "NO" << endl;
        return 0;
      }
    }
    idx++;
    if(idx >= N && i != M-1){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int count = 0;

		for (int i = 1; i <= N; i++) {
			if (String.valueOf(i).length() % 2 == 1) {
				count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 28480
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
inline int gi() {
  char ch=getchar(); int q=0,x=0;
  while(ch<'0'||ch>'9') q=(ch=='-'?1:q),ch=getchar();
  while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int a[N];
int main(){
  int n=gi(),k=gi(),ans=2e9;
  for (int i=1; i<=n; ++i) a[i]=gi();
  for (int i=1; i<=n-k+1; ++i){
    ans=min(ans,abs(a[i])+a[i+k-1]-a[i]);
    ans=min(ans,abs(a[i+k-1])+a[i+k-1]-a[i]);
  }
  cout<<ans;
  return 0;
}

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

int main() {
  int A , B , C , D ;
  cin >> A >> B >> C >> D ;
  int L = A + B , R = C + D ;
if ( L > R ) {
  cout << "Left" << endl;
  }
else if ( L == R ) {
  cout << "Balanced" << endl;
  }
else {
  cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

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

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}




int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> ac(n, 0);
	vector<int> wa(n, 0);
	int c = 0;
	int w = 0;
	rep(i,m){
		int p;
		string s;
		cin >> p >> s;
		p--;
		if (ac[p] == 0){
			if (s == "AC"){
				ac[p] = 1;
			}
			else{
				wa[p]++;
			}
		}
	}
	rep(i,n){
		c += ac[i];
		if (ac[i] == 1)
			w += wa[i];
	}
	cout << c << " " << w << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int S[100000];
    int T[50000];
    int n, q, i, count = 0;
    int low, high, mid;

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

    scanf("%d",&q);
    for(i = 0; i < q; i++){
      scanf("%d",&T[i]);
    }
    
    //excution
    for(i = 0; i < q; i++){
      
      low = 0;
      high = n-1;
      
      while(low <= high){
	
	mid = (low + high) / 2;
	if (S[mid] == T[i]) {
	  count++;
	  break;
	}
	else if (S[mid] < T[i]){
	  low = ++mid;
	}
	else high = --mid;
    
      }
      
    }
    
    //output
    printf("%d\n",count);

    return 0;
}



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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define REP(i,n) for(int i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;

const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  while(1){
    int n;
    cin >> n;
    if(n == 0) return 0;
    vi s(n);
    double sum = 0;
    rep(i,n){
      cin >> s[i];
      sum += s[i];
    }
    double m = sum / n;
    double a = 0;
    rep(i,n){
      a += pow(s[i]-m, 2);
    }
    a /= n;
    double ans = sqrt(a);
    printf("%.10lf\n", ans);
  }
}


Measured memory_bytes: 3244
using System;

class Program {
    static void Main (string[] args) {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine ().Split (' ');
        int N = int.Parse (input[0]);
        int X = int.Parse (input[1]);
        int T = int.Parse (input[2]);

        //出力
        Console.WriteLine (Math.Ceiling ((double) N / X) * T);
    }
}

Measured memory_bytes: 27444
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, A, B, C, inputs):
    bamboos = [int(i) for i in inputs]

    def cost(cursor, a, b, c):
        if cursor == N:
            if min(a, b, c) > 0:
                return abs(A-a) + abs(B-b) + abs(C-c) - 30
            else:
                return 1000000000

        t = bamboos[cursor]
        results = []
        results.append(cost(cursor+1, a, b, c))
        results.append(cost(cursor+1, a + t, b, c) + 10)
        results.append(cost(cursor+1, a, b + t, c) + 10)
        results.append(cost(cursor+1, a, b, c + t) + 10)

        return min(results)

    return cost(0, 0, 0, 0)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, A, B, C] = string_to_int(input())
    ret = solve(N, A, B, C, inputs(N))
    print(ret)


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

long long int big_mod(long long  b, long long  p, long long m)
{
    long long int power=b%m,re=1;
    while(p!=0)
    {
        if(p%2==1) re=(power*re)%m;
        power=(power*power)%m;
        p/=2;
    }
    return re;
}

int main()
{
    long long int n,ten,eight,nine,re;
    cin >>n;
    ten= big_mod(10,n,1000000007);
    nine= big_mod(9,n,1000000007);
    eight= big_mod(8,n,1000000007);
    re=((ten-((2*nine)%1000000007)+ eight)%1000000007);
    if(re<0) re+=1000000007;
    cout << re;
}


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

int main(void) {
	int n;
	cin >> n;
	vector<int> p(n);
	int sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> p[i];
		sum += p[i];
	}

	sort(p.begin(), p.end());

	cout << sum - p[n-1]/2 << endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string S1, S2;
  cin >> S1 >> S2;
  bool ans = true;
  if(S1[0] != S2[2]) ans = false;
  if(S1[1] != S2[1]) ans = false;
  if(S1[2] != S2[0]) ans = false;
  if(ans){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


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

int main() { 
    string s;
    cin >> s;

     vector<char> v;
     for (int i = 0; i < 3; i++) {
         v.push_back(s[i]);
     }
     sort(v.begin(), v.end());
     if (v == vector<char> {'a', 'b', 'c'}) {
         cout << "Yes" << endl;
     } else {
         cout << "No" << endl;
     }
}

Measured memory_bytes: 256
M,D = map(int,input().split())
count=0
for m in range(1,M+1):
    for d in range(1,D+1):
        if d > 9 and d < 100:
            d1 = d%10
            if d1 >= 2:
                d10 = int(d/10)%10
                if d10 >= 2:
                    if m == d1*d10:
                        count+=1
print(count)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int w, h, n;
int x1[1000],x2[1000],y1[1000],y2[1000];
bool mp[3000][3000];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
int main() {
    while (scanf("%d%d",&w,&h)) {
        if (!w&&!h) break;
        scanf("%d",&n);
        vector<int> x, y;
        for (int i=0; i<n; i++) {
            scanf("%d%d%d%d",&x1[i],&y1[i],&x2[i],&y2[i]);
            x.push_back(x1[i]); x.push_back(x2[i]);
            y.push_back(y1[i]); y.push_back(y2[i]);
        }
        x.push_back(0); x.push_back(w);
        y.push_back(0); y.push_back(h);
        sort(x.begin(), x.end());
        sort(y.begin(), y.end());
        x.erase(unique(x.begin(),x.end()), x.end());
        y.erase(unique(y.begin(),y.end()), y.end());
        int X=x.size(), Y=y.size();
        for (int i=0; i<n; i++) {
            x1[i]=lower_bound(x.begin(),x.end(),x1[i])-x.begin();
            x2[i]=lower_bound(x.begin(),x.end(),x2[i])-x.begin();
            y1[i]=lower_bound(y.begin(),y.end(),y1[i])-y.begin();
            y2[i]=lower_bound(y.begin(),y.end(),y2[i])-y.begin();
        }
        for (int i=0; i<Y; i++) for (int j=0; j<X; j++) mp[i][j]=i==Y-1||j==X-1;
        for (int i=0; i<n; i++) {
            for (int j=x1[i]; j<x2[i]; j++) {
                for (int k=y1[i]; k<y2[i]; k++) mp[k][j]=1;
            }
        }
        // for (int i=0; i<Y; i++) for (int j=0; j<X; j++) printf("%d%c",mp[i][j]?1:0,j==X-1?'\n':' ');
        int ans=0;
        for (int i=0; i<Y; i++) {
            for (int j=0; j<X; j++) {
                if (mp[i][j]) continue;
                ans++;
                mp[i][j]=1;
                queue<P> que;
                que.push(P(i,j));
                while (!que.empty()) {
                    int a=que.front().first, b=que.front().second; que.pop();
                    // printf("%d %d\n",a,b);
                    for (int k=0; k<4; k++) {
                        int nx=b+dx[k], ny=a+dy[k];
                        if (nx<0||nx>=X-1||ny<0||ny>=Y-1||mp[ny][nx]) continue;
                        mp[ny][nx]=1;
                        que.push(P(ny,nx));
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
}

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

int main() {
  int i, N;
  long long int sum=1;
  
  cin >> N;
  
  for(i=1; i<=N; i++) {
    sum *= i;
    sum %= (long long)(pow(10,9)+7);
    //cout << sum << endl;
  }
  
  cout << sum << endl;

  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

int main(){
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> score(N, K - Q);
  rep(i, Q) {
    int A; cin >> A; A--;
    score[A]++;
  }
  rep(i, N) {
    if (score[i] > 0) cout << YES << endl;
    else cout << NO << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, h[100000];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> h[i];
	int pre = INT_MAX, cur = 0, mx = 0;
	for(int i = 0; i < n; i++){
		if(h[i] <= pre) cur++, mx = max(cur, mx);
		else cur = 1;
		pre = h[i];
	}
	cout << mx - 1 << "\n";
	return 0;
}

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

int main() {
    ll X; cin >> X;
    vector<ll> V(150);
    
    rep(i, 150){
        V[i] = pow(i, 5); 
    }

    rep(i, 150){
        for (int j = 0; j <= i; j++){
            if (V[i] - V[j] == X){
                cout << i << " " << j << endl;
                return 0;
            } else if (V[i] + V[j] == X){
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

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

constexpr long long Inf = numeric_limits<long long>::max() / 4;

namespace flow_algorithm
{
  template<class Flow>
  struct edge
  {
    int to;
    Flow cap, rev;
  };
  /*
  template<class Flow>
  using edges = vector<edge<Flow>>;
  
  template<class Flow>
  using graph = vector<edges<Flow>>;
  */
  
  typedef vector<edge<long long>> edges;
  typedef vector<edges> graph;
  
  template<class Flow>
  class dinic
  {
  private:
    int V;
    //    graph<Flow> g;
    graph g;
    vector<int> level;
    vector<int> iter;
    
  public:
    
    //    Flow static constexpr Inf = numeric_limits<Flow>::max() / 4;
    
  private:
    
    void bfs(int s)
    {
      rep(i, V) level[i] = -1;
      queue<int> q;
      q.push(s);
      level[s] = 0;
      while(!q.empty()) {
        int curr = q.front(); q.pop();
        rep(i, g[curr].size()) {
          edge<Flow>& e = g[curr][i];
          if(level[e.to] != -1) { continue; }
          if(e.cap <= 0) { continue; }
          level[e.to] = level[curr] + 1;
          q.push(e.to);
        }
      }
    }
    
    Flow dfs(int curr, int tar, Flow flow)
    {
      if(curr == tar) { return flow; }
      for(int &i = iter[curr]; i<(int)g[curr].size(); i++) {
        edge<Flow>& e = g[curr][i];
        if(e.cap <= 0) { continue; }
        if(level[curr] >= level[e.to]) { continue; }
        Flow d = dfs(e.to, tar, min(flow, e.cap));
        if(d <= 0) { continue; }
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
      return 0;
    }
    
  public:
    
    dinic(int V_)
    {
      V = V_;
      g.resize(V);
      level.resize(V);
      iter.resize(V);
    }
    
    void add_edge(int from, int to, Flow cap)
    {
      g[from].push_back({to, cap, (Flow)g[to].size()});
      g[to].push_back({from, 0, (Flow)g[from].size()-1});
    }
    
    Flow max_flow(int src, int dest)
    {
      Flow flow = 0;
      for(;;) {
        bfs(src);
        if(level[dest] < 0) { return flow; }
        rep(i, V) iter[i] = 0;
        Flow f;
        while((f = dfs(src, dest, Inf)) > 0) {
          flow += f;
        }
      }
    }
    
  };
  
  
}

typedef long long ll;

int const SBASE = 10;
int const SRC = 150, SINK = 151;

int main() {
  
  map<string, int> mp = {
    {"Monday",0},
    {"Tuesday", 1},
    {"Wednesday", 2},
    {"Thursday", 3},
    {"Friday", 4},
    {"Saturday", 5},
    {"Sunday", 6}
  };
  
  int N; ll W;
  while(cin >> N >> W && (N|W)) {
    flow_algorithm::dinic<ll> dn(200);
    
    rep(i, 7) dn.add_edge(SRC, i, W);
    
    ll need = 0;
    
    rep(i, N) {
      ll t; int c; cin >> t >> c;
      need += t;
      rep(j, c) {
        string s; cin >> s;
        //        dn.add_edge(mp[s], SBASE+i, flow_algorithm::dinic<ll>::Inf);
        dn.add_edge(mp[s], SBASE+i, Inf);
      }
      dn.add_edge(SBASE+i, SINK, t);
    }
    
    cout << ( dn.max_flow(SRC, SINK) == need ? "Yes" : "No" ) << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1292
n=input()
global ans
def saiki(s,a,m):
    if m==len(n):
#        print(s)
        if 7==eval(s):
            global ans
            ans=s+'=7'
    else:
        for x in a:
            t=s
            s=s+x+n[m]
            saiki(s,a,m+1)
            s=t 

saiki(n[0],['-','+'],1)
print(ans)

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

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

int main() {
    int n;
    cin >> n;
    double sum = 0;
    double a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        a[i] = 1/a[i];
        sum += a[i];
    }
    printf("%.8lf", 1/sum);


    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    repl(i, a, b + 1) {
        string s = to_string(i);
        reverse(begin(s), end(s));
        if (i == stoi(s)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int t = 1;
  bool f = true;
  for(int i = 0 ; s[i] != '\0' ;i++)
  {
    if(t == 1 && s[i] == 'L')
    {
      f = false;
    }
    if(t == 0 && s[i] == 'R')
    {
      f = false;
    }
    if(f == false) break;
    t = 1 - t;
  }
  if(f){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int j,n,m,d,i,o,sum,res=0;
    char map[101][101]={0};
    scanf("%d %d %d",&n,&m,&d);
    for(i=0;i<n;i++)
        scanf("%s",map[i]);
    for(i=0;i<n;i++){
        for(o=0;o<m;o++){
            if(map[i][o] == '.'){
                for(sum=1,j=1;;j++){
                    if(map[i][o+j] == '#' || !map[i][o+j])
                        break;
                    else if(map[i][o+j] == '.')
                        sum++;
                    if(sum == d){
                        res++;
                        break;
                    }
                }
                for(sum=1,j=1;;j++){
                    if(map[i+j][o] == '#' || !map[i+j][o])
                        break;
                    else if(map[i+j][o] == '.')
                        sum++;
                    if(sum == d){
                        res++;
                        break;
                    }
                }
            }
        }
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define LL long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

const int mn=1e5+7;

int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	int f=0;
	rep(i,a,b) if(i%n==0) f=1;
	puts(f?"OK":"NG");
}

Measured memory_bytes: 3764
/*
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;
mt19937 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());

void solve() {
  int n;
  cin >> n;
  vector <int> a(n), b(n), c(n);
  for(int &i : a)
    cin >> i;
  for(int &i : b)
    cin >> i;
  reverse(b.begin(), b.end());
  int l = 0, r = n - 1;
  for(int i = 0; i < n; i++) {
    if(a[i] == b[i]) {
      if(l < n  && b[l] != a[i] && b[i] != a[l]) {
        swap(b[l], b[i]);
        l++;
      }
      else if(r >= 0 && b[r] != a[i] && b[i] != a[r]) {
        swap(b[r], b[i]);
        r--;
      }
      else { 
        cout << "No\n";
        exit(0);
      }
    }
  }
  cout << "Yes\n";
  for(int &i : b)
    cout << i << " ";
  cout << "\n";
}
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}

Measured memory_bytes: 8288
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
const int MAX = (int)1e5 + 5;

char s[MAX];
bool dp[MAX];

bool comp(string w, char *si) {
    for (char c : w) if (c != *si++) return false;
    return true;
}

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);

    dp[0] = true;
    for (int i = 1; i <= n; i++) {
        for (string w : {"dream", "dreamer", "erase", "eraser"}) {
            int len = w.length();
            if (i >= len && comp(w, &s[i - len + 1])) dp[i] |= dp[i - len];
        }
    }

    puts(dp[n] ? "YES" : "NO");

    return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int h[n];
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    vector<vector<int>> edge(n);
    bool check[n];
    fill(check,check+n,true);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a>> b;
        a--; b--;
        if(h[a]<h[b]) check[a] = false;
        else if(h[a]==h[b]){
            check[a] = false;
            check[b] = false;
        }
        else check[b] = false;
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(check[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6160
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll a,b,c,x,y;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>a>>b>>c>>x>>y;
  ll cnt = 0;
  if((a+b) > c * 2) {
    cnt += 2*c*MIN(x,y);
    // cout<<cnt<<endl;
    if(x > y) cnt+= a*abs(x-y);
    else cnt += b * abs(x-y);
  } else {
    cnt += a*x+b*y;
  }
  ll l = MAX(x,y);
  if(l*c*2 < cnt) cout<<l*c*2<<endl;
  else cout<<cnt<<endl;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    // ????????°???????????¨?????????????????????
    public static void main(String[] args) {
        // ??\???????????????????????????
        Scanner sc = new Scanner(System.in);
        // 3????????°??????????????????
        int intN = sc.nextInt();
        int intM = sc.nextInt();
        int intL = sc.nextInt();
        // ???????????£?????°?????§??????????????????
        // A?????????
        int[][] gyoua = new int[intN][intM];
        // B?????????
        int[][] gyoub = new int[intM][intL];
        // C?????????
        long[][] gyouc = new long[intN][intL];
        // ??°??????A??????????????°????????????
        for (int i = 0; i < intN; i++) {
            for (int j = 0; j < intM; j++) {
                gyoua[i][j] = sc.nextInt();
            }
        }
        // B??????????????°??°??????????????????
        for (int i = 0; i < intM; i++) {
            for (int j = 0; j < intL; j++) {
                gyoub[i][j] = sc.nextInt();
            }
        }
        // ?¨????
        for (int i = 0; i < intN; i++) {
            for (int j = 0; j < intL; j++) {
 
                for (int k = 0; k < intM; k++) {
                    // C?????????????¨???????????????\????????????
                    gyouc[i][j] += gyoua[i][k] * gyoub[k][j];
                }
                System.out.print(gyouc[i][j]);
                if (j != intL - 1) {
                    // ??????
                    System.out.print(" ");
                }
            }
            // ??????
            System.out.println();
        }
 
    }
}

Measured memory_bytes: 54136
$month = [0, 31, [28, 29], 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
$count = 0

def leap(y)
  if y % 400 == 0
    1
  elsif y % 100 == 0
    0
  elsif y % 4 == 0
    1
  else
    0
  end
end

def add_day(y, m, y1, m1, d1, y2, m2, d2)
  if y1 == y2 && m1 == m2
    d2 - d1
  elsif m == m1 && y == y1
    if m == 2
      $month[2][leap(y)] - d1 + 1
    else
      $month[m] - d1 + 1
    end
  elsif m == m2 && y == y2
    d2 - 1
  else
    if m == 2
      $month[2][leap(y)]
    else
      $month[m]
    end
  end
end

def adding(first, last, y, data)
  first.upto(last) { |m| $count += add_day(y, m, *data) }
end

loop do
  data = gets.chomp.split.map(&:to_i)
  break if data.all?{ |x| x == -1 }

  y1, m1, d1, y2, m2, d2 = data
  $count = 0
  
  y1.upto(y2) do |y|
    if y1 == y2
      adding m1, m2, y, data
    elsif y == y1
      adding m1, 12, y, data
    elsif y == y2
      adding 1, m2, y, data
    else
      adding 1, 12, y, data
    end
  end
  puts $count
end

Measured memory_bytes: 6120
#include <iostream>

int main() {
    long N, H, W, res=0;
    std::cin >> N >> H >> W;
    for (int i=0; i<N; ++i) {
        long a, b;
        std::cin >> a >> b;
        if ( H <= a && W <= b ) ++res;
    }
    std::cout << res << std::endl;
    return 0;
}


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

/*
・公差の候補はO(n^2)
・v0 v2 v4... vm
・v2 v4...は見なくていい
 */

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    vector<vector<int>> use(N,vector<int>(N,0));
    map<int,int> m;
    for(int i=0;i<N;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0;i<N;i++) m[v[i]] = i;    
    int ans = 0;
    for(int i=0;i<N-1;i++) for(int j=i+1;j<N;j++){
        if(use[i][j]) continue;
        int d = v[j]-v[i];
        use[i][j] = 1;
        int len = 2,id = j;
        while(m.count(v[id]+d)){
            len++;
            use[id][m[v[id]+d]] = 1;
            id = m[v[id]+d];
        }
        ans = max(ans,len);
    }
    cout << ans << endl;
}


Measured memory_bytes: 101084
#include<stdio.h>

int main(void){
int H,W,i,I,j;
for(j=0;j<10000;j++){
	scanf("%d %d",&H,&W);
	if(H!=0){
	for(i=0;i<H;i++){
		for(I=0;I<W;I++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}else{
	break;
}
}
return 0;

}


Measured memory_bytes: 2620