akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int mod=1000000007;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORQ(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a)-1; i >= b; i--)
using vi = vector<int>;

bool isin(int x, int y){
  return (0 <= x) and (x < 8) and (0 <= y) and (y < 8);
}

vi dx = {1,0,-1,0,1,1,-1,-1}, dy = {0,1,0,-1,1,-1,1,-1};

int main(){
  vector<string> board(8);
  rep(i,8) cin >> board[i];
  bool ismami = true;
  int notchanged = 0;

  while(1){
    //cerr << ismami << endl;
    vector<string> prev = board; // 前の盤面を取っておくよう
    vector<string> next = board; // 数最大の候補
    int rnum = 0; // 最大のひっくり返せる数

    if(ismami){
      rep(i,8) rep(j,8){ // (i,j)に置くことを試す
	board = prev;
	int tmp = 0; // (i,j)に置くときにひっくり返せる数
	if(board[i][j] != '.') continue;
	rep(k,8) FORQ(l,1,8){
	  int nx = i + l * dx[k], ny = j + l * dy[k];
	  if(not isin(nx,ny)) break;
	  if(board[nx][ny] == 'x') continue;
	  if(board[nx][ny] == 'o'){
	    //cerr << i << "\t" << j << "\t" << l << endl;
	    tmp += l - 1;
	    FOR(m, 0, l) board[i+m*dx[k]][j+m*dy[k]] = 'o';
	    break;
	  }
	  if(board[nx][ny] == '.') break;
	}
	if(tmp > rnum){
	  //cerr << tmp << endl;
	  rnum = tmp;
	  next = board;
	}
      }
    }else{
      FORD(i,8,0) FORD(j,8,0){ // (i,j)に置くことを試す
	board = prev;
	int tmp = 0; // (i,j)に置くときにひっくり返せる数
	if(board[i][j] != '.') continue;
	rep(k,8) FORQ(l,1,8){
	  int nx = i + l * dx[k], ny = j + l * dy[k];
	  if(not isin(nx,ny)) break;
	  if(board[nx][ny] == 'o') continue;
	  if(board[nx][ny] == 'x'){
	    tmp += l - 1;
	    FOR(m, 0, l) board[i+m*dx[k]][j+m*dy[k]] = 'x';
	    break;
	  }
	  if(board[nx][ny] == '.') break;
	}
	if(tmp > rnum){
	  //cerr << tmp << endl;
	  rnum = tmp;
	  next = board;
	}
        
      }
    }

    board = next;
    ismami = not ismami;
    
    if(prev == next) notchanged++;
    else notchanged = 0;
    if(notchanged == 2) break;
    // rep(i,8){
    //   rep(j,8) cerr << board[i][j];
    //   cerr << endl;
    // }
  }
  rep(i,8){
    rep(j,8) cout << board[i][j];
    cout << endl;
  }
}



Measured memory_bytes: 3228
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:i64,
    }
    let mut ans = 0;
    for i in 1..=n {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
const int MAX_N = 100005;
int R,S,P;
char W[MAX_N];

char win(char t)
{
	if (t == 'r')
	{
		return 'p';
	}
	else if (t == 's')
	{
		return 'r';
	}
	else
	{
		return 's';
	}
}

int score(char w)
{
	if (w == 'r')
	{
		return R;
	}
	else if (w == 's')
	{
		return S;
	}
	else
	{
		return P;
	}
}

int main()
{
	int N,K,ans = 0;
	string T;
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;
	rep(i,N)
	{
		W[i] = win(T[i]);
		//cout << W[i];
		ans += score(W[i]);
	}

	//cout << ans << endl;

	rep(i,K)
	{
		int idx = i;
		while(idx+K < N)
		{
			//cout << "checking:" << idx << endl;
			if (W[idx] == W[idx+K])
			{
				//cout << "a" << endl;
				ans -= score(W[idx+K]);
				W[idx+K] = 'a';
			}
			idx += K;
		}
	}

	/*
	rep(i,N)
	{
		cout << W[i];
	}
	*/
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
lint dp[101][4][4][4];
bool cc(int a, int b, int c)
{
    return (a == 1 && b == 2 && c == 3);
}
int main()
{
    int n;
    cin >> n;
    dp[0][0][0][0] = 1;
    rep(i, n)
    {
        rep(a, 4)
        {
            rep(b, 4)
            {
                rep(c, 4)
                {
                    rep(d, 4)
                    {
                        if (cc(b, c, d) || cc(b, d, c) || cc(c, b, d))
                        {
                            continue;
                        }
                        else if (cc(a, c, d) || cc(a, b, d))
                        {
                            continue;
                        }
                        else
                        {
                            dp[i + 1][b][c][d] = (dp[i + 1][b][c][d] + dp[i][a][b][c]) % MOD;
                        }
                    }
                }
            }
        }
    }
    lint ans = 0;
    rep(a, 4)
    {
        rep(b, 4)
        {
            rep(c, 4)
            {
                ans = (ans + dp[n][a][b][c]) % MOD;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int H, W, N;
string S, T;

struct bds{int lr, ur, lc, uc;};

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

	cin >> H >> W >> N;

	int sr, sc;
	cin >> sr >> sc;

	cin >> S >> T;
	reverse(S.begin(), S.end());
	reverse(T.begin(), T.end());

	int lr = 1, ur = H;
	int lc = 1, uc = W;

	for(int i = 0; i < N; i++){
		if(T[i] == 'L'){
			uc = min(W, uc + 1);
		}else if(T[i] == 'R' ){
			lc = max(1, lc - 1);
		}else if(T[i] == 'U'){
			ur = min(H, ur + 1);
		}else{
			lr = max(1, lr - 1);
		}

		if(S[i] == 'L'){
			lc += 1;
		}else if(S[i] == 'R' ){
			uc -= 1;
		}else if(S[i] == 'U'){
			lr += 1;
		}else{
			ur -= 1;
		}

		if(uc < lc || ur < lr){
			cout << "NO" << endl;
			return 0;
		}

	}

	if(lr <= sr && sr <= ur && lc <= sc && sc <= uc){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


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

namespace PCK2015
{
	class Question03
	{
		static void Main()
		{
			int N = int.Parse(Console.ReadLine());
			for(int i= 0; i < N; i++)
			{
				List<int> buff = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
				int rocks = buff[0];
				int players = buff[1];
				Console.WriteLine(rocks % players == 0 ? players : rocks % players);
			}
		}
	}
}

Measured memory_bytes: 9468
#include <stdio.h>

int main(void){
	int n,a,i,min,max;
	long long sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		sum+=a;
		if(i==0){
			min=a;
			max=a;
		}else if(a>max){
			max=a;
		}else if(a<min){
			min=a;
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
digits = [int(c) for c in input()]
n = len(digits)
m = int(input())

dp = [[[0 for _ in range(2)] for _ in range(m + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for i, digit in enumerate(digits):
    for j in range(m + 1):
        for k in range(2):
            for d in range(10 if k else digit + 1):
                if j + (d > 0) <= m:
                    dp[i + 1][j + (d > 0)][k or (d < digit)] += dp[i][j][k]

print(sum(dp[n][m]))

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x,y;
	cin>>x>>y;
	if(y%2==0 && 2*x<=y && 4*x>=y)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(){
	int s,i;
	long long int a[2001];
	scanf("%d",&s);
	a[2]=0;a[1]=0;a[3]=1;	
	if (s==3) printf("1\n");
	else {
		for (i=4;i<=s;i++)
		{
			a[i]=a[i-1]+a[i-3];//завязано на свойстве коэффициентов бинома ньютона, надо жоко заметить 
				 	   //закономерность, она совсем неочевидна, на мой взгляд, и под общий случай 
					   //хз как подобрать, шагать назад на другие kонстанты наверно
			a[i]=a[i]%1000000007;
		}
		printf("%lld\n",a[s]);
	}
	return 0;
}


Measured memory_bytes: 1748
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;

ll ara[sz];
map<ll,pair<ll,ll> >mp;

int main()
{

    ll n,x,y,a,b,i,j,d,p;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>x>>y;
        mp[i]={x,y};
        ara[i]=i;
    }

    double s=0.0;

     p=1;

    for(i=1;i<=n;i++)p*=i;

    do
    {
         for(i=1;i<n;i++)
         {

             a=mp[ara[i]].first;
             b=mp[ara[i]].second;

             x=mp[ara[i+1]].first;
             y=mp[ara[i+1]].second;
             d=(a-x)*(a-x)+(b-y)*(b-y);
             double xx=sqrt(d*1.0);
             s+=xx;

         }

    }
    while(next_permutation(ara+1,ara+n+1));

    double ans=s/p*1.0;

    printf("%0.10lf\n",ans);

    return 0;
}



Measured memory_bytes: 764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
struct UnionFind {
  UnionFind(int n) : data(n, -1) {}

  int root(int ver) { return data[ver] < 0 ? ver : data[ver] = root(data[ver]); }

  void unite(int ver1, int ver2) {
    ver1 = root(ver1);
    ver2 = root(ver2);
    if (ver1 != ver2) {
      if (data[ver1] > data[ver2]) swap(ver1, ver2);
      data[ver1] += data[ver2];
      data[ver2] = ver1;
    }
  }

  bool same(int ver1, int ver2) { return root(ver1) == root(ver2); }

  int size(int ver) { return -data[root(ver)]; }

private:
  vector<int> data;
};

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<long long> x(n), y(n);
  map<pair<long long, long long>, int> mp;
  REP(i, n) {
    cin >> x[i] >> y[i];
    mp[{x[i], y[i]}] = i;
  }
  int ans = n;
  REP(i, n) FOR(j, i + 1, n) {
    long long p = x[j] - x[i], q = y[j] - y[i];
    UnionFind uf(n);
    REP(k, n) {
      long long xx = x[k] + p, yy = y[k] + q;
      if (mp.count({xx, yy}) == 1) uf.unite(k, mp[{xx, yy}]);
    }
    set<int> st;
    REP(k, n) st.emplace(uf.root(k));
    ans = min(ans, (int)st.size());
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
Q = 10**9 + 7

def main():
    N, K = map( int, input().split())
    A = list( map( int, input().split()))
    ans = 0

    for i in range(N):
        a = A[i]
        al = 0
        after = 0
        for i in range(i):
            if A[i] < a:
                al += 1
        for i in range(i+1, N):
            if A[i] < a:
                al += 1
                after += 1
        ans += K*(K-1)//2*al%Q + after*K%Q
        ans %= Q
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 41072
def calcb(lx,ly,rx,ry):
  if rx<0 or ry<0 or lx>rx or ly>ry:
    return 0
  ret=acum1[ry*2*k+rx]
  if lx!=0:
    ret-=acum1[ry*2*k+lx-1]
  if ly!=0:
    ret-=acum1[(ly-1)*2*k+rx]
  if lx!=0 and ly!=0:
    ret+=acum1[(ly-1)*2*k+lx-1]
  return ret

def calcw(lx,ly,rx,ry):
  if rx<0 or ry<0 or lx>rx or ly>ry:
    return 0
  ret=acum2[ry*2*k+rx]
  if lx!=0:
    ret-=acum2[ry*2*k+lx-1]
  if ly!=0:
    ret-=acum2[(ly-1)*2*k+rx]
  if lx!=0 and ly!=0:
    ret+=acum2[(ly-1)*2*k+lx-1]
  return ret

n,k=map(int,input().split())
board1=[0]*(4*k*k)
board2=[0]*(4*k*k)
acum1=[0]*(4*k*k)
acum2=[0]*(4*k*k)
for _ in range(n):
  x,y,c=input().split()
  x,y=int(x)%(2*k),int(y)%(2*k)
  if c=='B':
    board1[y*2*k+x]+=1
  if c=='W':
    board2[y*2*k+x]+=1
for i in range(2*k):
  for j in range(2*k):
    acum1[i*2*k+j]=board1[i*2*k+j]
    acum2[i*2*k+j]=board2[i*2*k+j]
    if i!=0:
      acum1[i*2*k+j]+=acum1[(i-1)*2*k+j]
      acum2[i*2*k+j]+=acum2[(i-1)*2*k+j]
    if j!=0:
      acum1[i*2*k+j]+=acum1[i*2*k+j-1]
      acum2[i*2*k+j]+=acum2[i*2*k+j-1]
    if i!=0 and j!=0:
      acum1[i*2*k+j]-=acum1[(i-1)*2*k+j-1]
      acum2[i*2*k+j]-=acum2[(i-1)*2*k+j-1]
ans=0
for i in range(k):
  for j in range(k):
    tmp1=0
    tmp2=0
    lx,ly=i,j
    rx,ry=lx+k-1,ly+k-1
    #1個目のマス
    tmp1+=calcb(lx,ly,rx,ry)
    tmp2+=calcw(lx,ly,rx,ry)
    #左上のマス
    tlx,tly=0,0
    trx,ttry=lx-1,ly-1
    tmp1+=calcb(tlx,tly,trx,ttry)
    tmp2+=calcw(tlx,tly,trx,ttry)
    #右上のマス
    tlx,tly=rx+1,0
    trx,ttry=2*k-1,ly-1
    tmp1+=calcb(tlx,tly,trx,ttry)
    tmp2+=calcw(tlx,tly,trx,ttry)
    #左下のマス
    tlx,tly=0,ry+1
    trx,ttry=lx-1,2*k-1
    tmp1+=calcb(tlx,tly,trx,ttry)
    tmp2+=calcw(tlx,tly,trx,ttry)
    #右下のマス
    tlx,tly=rx+1,ry+1
    trx,ttry=2*k-1,2*k-1
    tmp1+=calcb(tlx,tly,trx,ttry)
    tmp2+=calcw(tlx,tly,trx,ttry)
    #上のマス
    tlx,tly=lx,0
    trx,ttry=rx,ly-1
    tmp1+=calcw(tlx,tly,trx,ttry)
    tmp2+=calcb(tlx,tly,trx,ttry)
    #左のマス
    tlx,tly=0,ly
    trx,ttry=lx-1,ry
    tmp1+=calcw(tlx,tly,trx,ttry)
    tmp2+=calcb(tlx,tly,trx,ttry)
    #右のマス
    tlx,tly=rx+1,ly
    trx,ttry=2*k-1,ry
    tmp1+=calcw(tlx,tly,trx,ttry)
    tmp2+=calcb(tlx,tly,trx,ttry)
    #下のマス
    tlx,tly=lx,ry+1
    trx,ttry=rx,2*k-1
    tmp1+=calcw(tlx,tly,trx,ttry)
    tmp2+=calcb(tlx,tly,trx,ttry)
    ans=max(ans,tmp1,tmp2)
print(ans)

Measured memory_bytes: 199612
// luogu-judger-enable-o2
#include<bits/stdc++.h>

using namespace std;

const int N = 49;
const int MOD = 1e9 + 7;

int n, x, y, z;

long long ans;

long long f[N][1 << 19];

int main ( ) {
	scanf("%d%d%d%d", &n, &x, &y, &z);
	ans = 1;
	int haiku = ( 1 << ( x + z + y - 1) ) | ( 1 << ( x + y - 1) ) | ( 1 << ( x - 1 ) ) ;
	int ST = ( 1 << ( x + y + z ) ) ;
	for ( int i = 1 ; i <= n ; i ++ )
		ans = ( ans * 10 ) % MOD;
	f[0][0] = 1;
	for ( register int i = 0 ; i < n ; i ++ ) // 位数
		for ( register int st = 0 ; st < ST ; st ++ )  // 前面的位数
			for ( register int j = 1 ; j <= 10 ; j ++ ) {  //当前放的数 
					int now =  ( st << j ) | ( 1 << ( j - 1 ) ) ;
					now &= (ST - 1);
					if ( ( now & haiku ) == haiku )  continue ;
					f[ i + 1 ][now] = ( MOD + f[i + 1][now] + f[i][st] ) % MOD; // 不合法方案 
	}
	for ( int i = 0 ; i < ST ; i ++  )
		ans = ( ans - f[n][i] ) % MOD;
	cout << ( ans + MOD ) % MOD; 
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> x(N);
    vector<ll> y(N);
    rep(i, N) cin >> x[i] >> y[i];

    vector<ll> xminusy(N);
    vector<ll> xplusy(N);
    rep(i, N){
        xminusy[i] = x[i] - y[i];
        xplusy[i] = x[i] + y[i];
    }

    sort(xminusy.begin(), xminusy.end());
    sort(xplusy.begin(), xplusy.end());

    ll ans = xminusy[N-1] - xminusy[0];
    if (ans < xplusy[N-1] - xplusy[0]){
        ans = xplusy[N-1] - xplusy[0];
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;



int main() {




int N,ans,v,c;
cin>>N;

vector<int>V;
vector<int>C;

for(int i=0 ; i<N ; i++) {
cin>>v;
V.push_back(v);
}
for(int i=0 ; i<N ; i++) {
cin>>c;
C.push_back(c);
}
for(int i=0 ; i<N ; i++){
if(V[i]>C[i]) ans+=V[i]-C[i];
}

cout<<ans;

return 0;

}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1<<29;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

int dp[105][4][2];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int K;
    cin >> K;
    dp[0][0][0] = 1;

    rep(i,n)rep(j,4)rep(k,2) {
        int nd = s[i]-'0';
        rep(d,10){
            int ni = i+1, nj = j, nk = k;
            if(d!=0) nj++;
            if(nj>K) continue;
            if(k==0){
                if(d>nd) continue;
                if(d<nd) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int hitPoint = sc.nextInt();
    int attackCount = sc.nextInt();
    
    int list[] = new int[attackCount];
    int damage = 0;
    for(int i =0; i < attackCount; ++i){
      list[i] = sc.nextInt();
      damage  += list[i];      
    }
    
    if(hitPoint <= damage){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }   
  }  
}

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

int n;
int a[101], b[101];
vector<int> ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i) cin >> a[i];
	for(int i=0; i<n; ++i)
		b[i] = (i+1) - a[i];
//	for(int i=0; i<n; ++i)
//		cout << i << " " << b[i] << "\n";
	for(int i=0; i<n; ++i){
		int mi = 1e9;
		for(int j=0; j<n; ++j)
			mi = min(mi, b[j]);
		if(mi < 0){
			cout << -1 << "\n";
			return 0;
		}
		for(int j=n-1; j>=0; --j){
			if(b[j] == 0){
				b[j] = 1e9;
				ans.push_back(a[j]);
				for(int k=j+1; k<n; ++k)
					b[k]--;
				break;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	for(int i=0; i<n; ++i)
		cout << ans[i] << "\n";
}

Measured memory_bytes: 256
from math import gcd

K = int(input())
ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        ab = gcd(a, b)
        if ab == 1:
            ans += K
            continue
        for c in range(1, K + 1):
            ans += gcd(ab, c)

print(ans)

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

int main()
{
int L,A,B,C,D,a,b;
cin>>L;
cin>>A;
cin>>B;
cin>>C;
cin>>D;

a=A/C;
b=B/D;

if(A%C>0)
a++;
if(B%D>0)
b++;

if(a>b)
cout<<L-a<<'\n';
else
cout<<L-b<<'\n';

return 0;
}

Measured memory_bytes: 1160
let readInt () = stdin.ReadLine() |> int

Seq.initInfinite (fun x -> x |> int64 |> ((+) 1L))
|> Seq.take (readInt ())
|> Seq.filter (fun x -> x % 3L <> 0L && x % 5L <> 0L)
|> Seq.reduce (+)
|> printfn "%d"

Measured memory_bytes: 43300
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  bool ok = false;
  rep(i,100){
    rep(j,100){
      if(i*4 + j*7 == N) ok = true;
    }
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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


int main()
{
    uint d;
    cin >> d;
    switch (d) {
    case 25:
        cout << "Christmas";
        break;
    case 24:
        cout << "Christmas Eve";
        break;
    case 23:
        cout << "Christmas Eve Eve";
        break;
    case 22:
        cout << "Christmas Eve Eve Eve";
        break;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC120 {
    class A {
        static void Main() => CustomMain();

        static void Solve() {
            int a, b, c;
            ReadMulti(out a, out b, out c);

            var ans = b / a < c ? b / a : c;
            WriteAnswer(ans);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <list>
#include <stack>

using namespace std;
int a[11];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	int sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += a[i];
	}
	if (sum > a[n - 1]) {
		cout << "Yes" << '\n';
	}
	else {
		cout << "No" << '\n';
	}



}


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

int main() {
    int n, m;
    std::cin >> n >> m;

    valarray<valarray<int>> matrix(valarray<int>(m), n);
    valarray<int> vec(m);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> matrix[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        std::cin >> vec[i];
    }

    for (int i = 0; i < n; i++) {
        std::cout << (matrix[i] * vec).sum() << std::endl;
    }
}



Measured memory_bytes: 3180
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<set>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

struct Union_find{
    vector<int> par;
    vector<int> rank;
    Union_find(int p){
        par = vector<int>(p + 1);
        rank = vector<int>(p + 1);
        for(int i = 1; i <= p; i++){
            par[i] = i;
        }
    }
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    Union_find uf(n);
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        uf.unite(a, b);
    }
    set<int> st;
    for(int i = 1; i <= n; i++){
        st.insert(uf.find(i));
    }
    ans = st.size();
    cout << ans << endl;
    return 0;
}


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

int main() {

	int n; cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    vector<pair<double,double>> vp;
    int n;
    cin >> n;
    rep(i,n){
        double x,y;
        cin >> x >> y;
        vp.push_back({x,y});
    }
    sort(vp.begin(),vp.end());
    double ans = 0;
    do{
        double now = 0;
        rep(i,n-1){
            now += sqrt( pow(vp[i].first - vp[i+1].first,2) + pow(vp[i].second - vp[i+1].second,2 ));
        } 
        ans += now;
    }while(next_permutation(vp.begin(),vp.end()));
    double kai = 1;
    rep(i,n){
        kai *= (double)(i+1);
    }
    cout << ans / kai << endl;
    //N!の順列の全探索
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;


int main() {
    ll N, K;
    cin >> N >> K;
    K--;
    vector<pair<ll,ll>> A;
    for(int i = 0; i < N; i++){
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        A.push_back(make_pair(tmp1,tmp2));
    }
    sort(A.begin(),A.end());
    int i = 0;
    while(1){
        K -= A[i].second;
        if(K < 0){
            break;
        }
        i++;
    }
    cout << A[i].first << endl;
}

Measured memory_bytes: 5328
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  double  r;
  cin>>r;
  double ret = 2 * acos(-1) * r;
  printf("%.10f\n", ret);
  return 0;
}

Measured memory_bytes: 3780
S = list(input())
ans ="AC"
if S[0]!="A":
    ans ="WA"
if S.count("C") !=1:
    ans ="WA"
if S[2:-1].count("C")!=1:
    ans ="WA"
if S[0]==("A"):
    del S[0]
if S.count("C")>0:
    S.remove("C")
S = str(S)
for i in range(len(S)):
    if (S[i]).isupper():
        ans = "WA"
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int main(){
	char ch[100];
	int i=0;
	int j=0;
	while(scanf("%s",&ch)!=EOF){
		for(i=0;i<strlen(ch);i++){
			if(ch[i]!='@'&&ch[i-1]!='@'&&ch[i-2]!='@'){
				printf("%c",ch[i]);
			}else if(ch[i-1]=='@'){
				for(j=0;j<ch[i]-48;j++){
					printf("%c",ch[i+1]);
				}
			}
		}
		puts("");
	}
return 0;
}
		

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

int main()
{
    string s,t;
    cin >> s >> t;
    int n = s.length();
    int c = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] != t[i])
        {
            c++;
        }
    }
    cout << c;
}


Measured memory_bytes: 3856
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final char[] line = in.next().replaceAll("BC", "D").toCharArray();
        long result = 0;
        int aCount = 0;
        for (int i = 0; i < line.length; i++) {
            if (line[i] == 'B' || line[i] == 'C') {
                aCount = 0;
            }
            if (line[i] == 'D') {
                result += aCount;
            }
            if (line[i] == 'A') {
                aCount++;
            }
        }
        System.out.println(result);
    }

}


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
template<typename T> void comb(vector<vector<T> > &c){
  c[0][0] = 1;
  for(int k = 1; k < c.size(); k++){
    c[k][0] = 1;
    for(int j = 1; j < c.size(); j++){
      c[k][j] = (c[k-1][j-1] + c[k-1][j]) % MOD;
    }
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  VVL c(2000, VL(2000, 0));
  comb<ll>(c);
  FOR(i, 1, k + 1) out(c[k - 1][i - 1] * c[n - k - (i - 1) + i][i] % MOD);
  return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
  int n;
  cin >> n;
  vector<int> l(n,0);
  r(i,n) cin >> l[i];
  sort(ALL(l));
  int cnt=0;
  r(i,n-1){
    cnt += l[i];
  }
  if (cnt > l[n-1]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = map(int, input().split())

is_odd = 0
is_even = 0
is_4 = 0
ans = "Yes"
for a in A:
  if a % 4 == 0:
    is_4 += 1
  elif a % 2 == 0:
    is_even += 1
  else:
    is_odd += 1

if is_odd - is_4 > 1:
  ans = "No"
elif is_odd - is_4 == 1 and is_even > 0:
  ans = "No"

print(ans)




Measured memory_bytes: 11100
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll n;
    cin >> n;
    ll cnt = 0;

    if(n%2!=0)
    {
        cout << 0 << endl;
        return 0;
    } 
    else
    {

        // ll div = 10;
        ll div2 = 50;
        // int digit = 1;
        // while(1)
        // {
        //     if(n/div==0) break;
        //     cnt += (n/div)*digit;
        //     div *= 10;
        //     ++digit;
        // }
        while(1)
        {
            if(n/div2==0) break;
            // if(n/div==0) break;
            // cnt += (n/div);
            cnt += (n/div2);
            // div *= 10;
            div2 *= 5;
        }
        cnt += (n/10);
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
op = ""
while op != "?":
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(int(a / b))
    elif op == "?":
        break

Measured memory_bytes: 7636
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    vmax(a)        *max_element(all(a))
#define    vmin(a)        *min_element(all(a))
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"Yes"<<nn
#define    no             cout<<"No"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {ikarus_101

    ll n,m,i,j,k,x;

    string s , t;
    cin>>s>>t;
    n = s.size()-t.size()+1;
    ll ans = inf;
    rep(i,n)
    {
        string ss = s.substr(i,t.size());
        ll tot = 0;
        for(j=0;j<t.size();++j)
        {
            if(ss[j] != t[j])
                ++tot;
        }
        ans = min(ans,tot);
    }
    cout << ans << nn;














    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <cmath>

using namespace std;
int main (){
    int n;
    cin >> n;
    long long a=2;
    long long b=1;
    long long c=1;
    for (int i = 0; i < n-1; i++){
        c=a+b;
        a=b;
        b=c;
    }
    cout << c << "\n";
}

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

int N[4];
int main(){
	REP(i,4){
		cin>>N[i];
	}
	sort(N,N+4);
	cout<<((N[0]==1 && N[1]==4 && N[2]==7 && N[3]==9) ? "YES" : "NO")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

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

const int inf = 1e9 + 7;
const ll longinf = 1LL << 50;
const long long mod_const = 1e9+7;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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

using pll = pair<long long, long long>;

vector<ll> divisor(ll n) {
	vector<ll> vec;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			vec.push_back(i);
		}
	}
	return vec;
}

const double pi = 3.14159265358979323846;

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

	double a, b, x;
	cin >> a >> b >> x;

	double tan = 0.0;
	if (x <= b * a * a / 2) {
		tan = atan(2 * x / a / b / b) / pi * 180;
	}
	else {
		double h = 2 * b - 2 * x / a / a;
		tan = atan(a / h) / pi * 180;
	}

	cout << fixed << setprecision(10) << 90- tan << endl;

	return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  sort(rall(b));
  int memo=-1;
  int cnt=0;
  rep(i,n){
    if(a[i]==b[i]){
      memo=a[i];
      cnt++;
    }
  }
  if(cnt==0){
    cout<<"Yes"<<endl;
    out(b);
    return;
  }
  int kcnt=0;
  vec c;
  rep(i,n){
    if(a[i]!=memo && b[i]!=memo){
      kcnt++;
      c.pb(i);
    }
  }
  if(kcnt<cnt){
    cout<<"No"<<endl;
  }
  else{
    int idx=0;
    cout<<"Yes"<<endl;
    rep(i,n){
      if(a[i]==b[i]){
        swap(b[i],b[c[idx]]);
        idx++;
      }
    }
    out(b);
  }
  

  
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
  int repeat = 1;
  // cin >> repeat;
  while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp

./a.out

python3 expander.py code.cpp

*/

Measured memory_bytes: 13124
a, b, m = map(int, input().split())
aList = list(map(int, input().split()))
bList = list(map(int, input().split()))
minimum = min(aList) + min(bList)

for i in range(m):
  x, y, c = map(int, input().split())
  if minimum > aList[x-1] + bList[y-1] - c:
    minimum = aList[x-1] + bList[y-1] - c
print(minimum)

Measured memory_bytes: 18736
A11, A12, A13 = input().split(' ')
A21, A22, A23 = input().split(' ')
A31, A32, A33 = input().split(' ')
A11 = int(A11)
A12 = int(A12)
A13 = int(A13)
A21 = int(A21)
A22 = int(A22)
A23 = int(A23)
A31 = int(A31)
A32 = int(A32)
A33 = int(A33)
N = int(input())
b = []
for i in range(N):
  bi = int(input())
  b.append(bi)
if A11 in b and A12 in b and A13 in b:
  print('Yes')
elif A21 in b and A22 in b and A23 in b:
  print('Yes')
elif A31 in b and A32 in b and A33 in b:
  print('Yes')
elif A11 in b and A21 in b and A31 in b:
  print('Yes')
elif A12 in b and A22 in b and A32 in b:
  print('Yes')
elif A13 in b and A23 in b and A33 in b:
  print('Yes')
elif A11 in b and A22 in b and A33 in b:
  print('Yes')
elif A13 in b and A22 in b  and A31 in b:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9200
MOD=10**9+7
H,W,K=map(int,input().split())
dp=[[0]*W for i in range(H+1)]
dp[0][0]=1

for i in range(1,H+1):
    for k in range(W):
        l,c,r=0,0,0
        for bit in range(2**(W-1)):
            ok=True
            for t in range(W-2):
                if (bit>>t&1) and (bit>>(t+1)&1):
                    ok=False
                    break
            if not ok:
                continue
            if ((k>0 and not(bit>>(k-1)&1)) or k==0) and ((k<W-1 and not(bit>>k&1))or k==W-1):
                c+=1
            if (k>0):
                if ((k>1 and not(bit>>(k-2)&1)) or k==1) and ((k<W-1 and not(bit>>k&1))or k==W-1) and (bit>>(k-1)&1):
                    l+=1
            if (k<W-1):
                if ((k>0 and not(bit>>(k-1)&1)) or k==0) and ((k<W-2 and not (bit>>(k+1)&1))or k==W-2) and (bit>>k&1):
                    r+=1
        dp[i][k]=(dp[i][k]+dp[i-1][k]*c)%MOD
        if k>0:
            dp[i][k]=(dp[i][k]+dp[i-1][k-1]*l)%MOD
        if k<W-1:
            dp[i][k]=(dp[i][k]+dp[i-1][k+1]*r)%MOD
print(dp[H][K-1])

Measured memory_bytes: 9260
n = int(input())

def check_distance(move_distance, move_time):
  buf_result = False

  if move_time >= move_distance:
    buf_val = move_time - move_distance

    if buf_val % 2 == 0:
      buf_result = True

  return buf_result

current_posi = [0, 0]
next_posi = []

current_time = 0
next_time = 0

result = False

for i in range(n):
  input_i = list(map(int, input().split()))
  next_time = input_i[0]
  next_posi = [input_i[1], input_i[2]]

  move_distance = abs(current_posi[0] - next_posi[0]) + abs(current_posi[1] - next_posi[1])

  move_time = next_time - current_time

  result = check_distance(move_distance, move_time)

  if result == False:
    break
  else:
    current_time = input_i[0]
    current_posi = [input_i[1], input_i[2]]


if result == False:
  print("No")
else:
  print("Yes")

  

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main () {
int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};

int x , y ; cin >> x >> y ;
cout << ( a [ x ] == a [ y ] ? " Yes " : " No ") << endl ;
}

Measured memory_bytes: 256
// failed to generate code

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

int N;
vector<int> g[100010];
vector<int> ch[100010];
long long M;

int dp[100010];
int parent[100010];
int dp2[100010];

long long pos[100010];
vector<long long> le[100010];
vector<long long> ri[100010];


void build(int root, int p){
    parent[root] = p;
    for( auto i : g[root] ){
        if( p != i ){
            build(i, root);
            ch[root].push_back(i);
        }
    }
}


int dfs(int root){
    if( dp[root] != -1 ) return dp[root];

    if( ch[root].size() == 0 ){
        return 1;
    }

    long long ans = 1;
    for( auto i : ch[root] ){
        ans *= (dfs(i)+1);
        ans %= M;
    }
    return dp[root] = ans;
}

int dfs2(int root){
    if( dp2[root] != -1 ) return dp2[root];
    if( parent[root] == -1 ) return 1;

    long long ans = dfs2(parent[root]);


    int p = parent[root];
    if( ch[p].size() && le[p].size() == 0 ){
        le[p].push_back(1ll);
        for(int i = 0 ; i < ch[p].size() ; i++){
            le[p].push_back(le[p].back() * (dfs(ch[p][i])+1) % M);
            pos[ch[p][i]] = i;
        }
        ri[p].push_back(1ll);
        for(int i = (int) ch[p].size() - 1 ; i >= 0 ; i--){
            ri[p].push_back(ri[p].back() * (dfs(ch[p][i])+1) % M);
        }
        reverse(ri[p].begin(), ri[p].end());
    }

    // 2 3 4
    // 1  2 6 24
    // 24 12 4 1
//    for( auto i : ch[p]) cout << dfs(i) << " "; cout << endl;
//    for( auto i : le[p]) cout << i << " "; cout << endl;
//    for( auto i : ri[p]) cout << i << " "; cout << endl;

    ans *= le[p][pos[root]];
    ans %= M;
    ans *= ri[p][pos[root]+1];
    ans %= M;

//    for(auto c : ch[parent[root]]){
//        if( root != c){
//            ans *= (dfs(c)+1);
//            ans %= M;
//        }
//    }
    ans += 1;
    return dp2[root] = ans ;

}


int main(){
    memset(dp, -1, sizeof(dp));
    memset(dp2, -1, sizeof(dp2));
    memset(pos, -1, sizeof(pos));
    cin >> N >> M;
    for(int i = 0 ; i < N-1 ; i++){
        int x,y;
        cin >> x >> y;
        g[x-1].push_back(y-1);
        g[y-1].push_back(x-1);
    }

    build(0, -1);

    for(int i = 0 ; i < N ; i++){
        cout << 1ll * dfs(i) * dfs2(i) % M << endl;
    }


}

Measured memory_bytes: 29184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000005];
int main()
{
    set<int> s;
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];

    long long ans=0;
    long long sum=0;
    for(int i=0;i<k;i++)
        sum=sum+a[i]+1;
    ans=sum;
    for(int i=k;i<n;i++)
    {
        sum=sum-a[i-k];
        sum=sum+a[i];
        //cout<<sum<<'\n';
        ans=max(ans,sum);
    }
    cout<<ans/2;
    if(ans%2) cout<<".5";
}


Measured memory_bytes: 1024