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

Measured memory_bytes: 1160
/*  3_3
    Y_Aizaki    */

#include <stdio.h>

int main(void){
    int date, base; // 数値、進数

    scanf("%d%d", &date, &base);

    int digit = 1; // 桁数
    while (date / base > 0)
    {
        date /= base;
        digit += 1;
    }
    printf("%d\n", digit);

    return 0;
    
}

Measured memory_bytes: 128
#include<iostream>

constexpr size_t cnt_digit(size_t n){
    size_t cnt = 0;

    while(n != 0){
        n /= 10;
        cnt++;
    }

    return cnt;
}

int main(){

    size_t n;
    size_t cnt = 0;

    std::cin >> n;

    for(size_t i = 1; i <= n; i++){
        if(cnt_digit(i) % 2 == 1) cnt++;
    }

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


Measured memory_bytes: 256
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

h,w = mi()
cs = [input() for i in range(h)]

for i in range(h):
    for k in range(2):
        for j in range(w):
            print(cs[i][j],end="")
        print("")

Measured memory_bytes: 4468
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,k,ans,dep[maxn],mx[maxn],V[maxn],X[maxn];
vector <int> mp[maxn];

inline void dfs(int u,int fa)
{
	for(int i=0;i<mp[u].size();i++)
	{
		int v=mp[u][i]; if(v==fa) continue;
		dep[v]=dep[u]+1; mx[v]=dep[v]; dfs(v,u);
		if(!V[v]) mx[u]=max(mx[u],mx[v]);
	}
	if(mx[u]-dep[u]==k-1&&!X[u]&&!V[u]) ans++,V[u]=1;
}

int main()
{
	n=read(); k=read(); X[1]=1;
	rep(i,1,n)
	{
		int x=read(); if(x==1) X[i]=1;
		if(i!=1) mp[i].pb(x),mp[x].pb(i);
		else if(x!=1) ans++;
	}
	dfs(1,0); cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 38016
#include<stdio.h>

int main()
{
	char s[16];
	scanf("%s",s);
	int cnt=0;
	for(int i = 0;i<16;i++){
		if(s[i] == 'x')cnt++;
	}
	if(cnt>=8){
		printf("NO\n");
	}else
		printf("YES\n");
}

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

int main() {
    string s;
    cin >> s;
    if(s.at(2)==s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	rep(i,0,n){
		int a; cin>>a;
		if(a%2==0){
			if(a%3!=0 && a%5!=0){
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	
	return 0;
}

Measured memory_bytes: 3616
from itertools import combinations

H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

cnt = 0
for rh in range(H):
    for rw in range(W):
        for h in combinations(range(H), rh):
            for w in combinations(range(W), rw):
                T = [c[:] for c in C]
                for hi in h:
                    T[hi] = list("." * W)
                for wj in w:
                    for i in range(H):
                        T[i][wj] = "."
                if K == sum(t.count("#") for t in T):
                    cnt += 1

print(cnt)

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DPairCards {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;

        vector<int> X(N);
        REP(i, N) cin >> X[i];

        vector<vector<int>> d(M);
        REP(i, N) {
            d[X[i] % M].push_back(X[i]);
        }

        int res = 0;
        for (int i = 0; i <= M / 2; i++) {
            auto& l = d[i];
            auto& r = d[M - i];

            if (i == 0 || i + i == M) {
                res += l.size() / 2;
                continue;
            }

            if (l.size() < r.size()) {
                swap(l, r);
            }

            int cur = l.size();
            int prev = -1;
            sort(l.begin(), l.end());
            REP(j, l.size()) {
                if (cur <= r.size() + 1) break;
                if (l[j] == prev) {
                    res += 1;
                    cur -= 2;
                    prev = -1;
                    continue;
                }
                prev = l[j];
            }
            res += r.size();
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DPairCards solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6528
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let ab :Vec<String>= read_vec();
    let s = ab.concat();
    let sq = s.parse::<f64>().unwrap().sqrt();
    let ans = if sq.floor().powi(2) == s.parse().unwrap() {
        "Yes".to_string()
    } else{
        "No".to_string()
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e5 + 10;
int n , a[N] , b[N];

int main(){
    scanf("%d",&n);
    per(i,0,n) scanf("%d",a + i);
    int l=0,r=n-1;
    rep(i,0,n) {
        if(i&1) b[r--]=a[i];
        else b[l++]=a[i];
    }
    rep(i,0,n) printf("%d%c",b[i]," \n"[i+1==n]);
    return 0;
}


Measured memory_bytes: 3712
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
//        out.flush();
        System.out.println(main.solve());
    }
    long solve() throws IOException{
        int k = sc.nextInt();
        long ans = 0;
        for(int a=1;a<=k;a++){
            for(int b=1;b<=k;b++){
                for(int c=1;c<=k;c++){
                    ans += gcd(gcd(a,b),c);
                }
            }
        }
        return ans;
    }
    int gcd(int a, int b){
        if(a<b){
            int c = a; a=b;b=c;
        }
        while(a%b!=0){
            int c = b; b=a%b;a=c;
        }
        return b;
    }
}



Measured memory_bytes: 35764
#include<stdio.h>
#include<string.h>

int saikoro1(int a[7],char b[101]) {
	unsigned int x,i;
	for (i = 0; i < strlen(b); i++) {
		if (b[i] == 'N') {
			x = a[0];
			a[0] = a[1];
			a[1] = a[5];
			a[5] = a[4];
			a[4] = x;
		}else if (b[i] == 'E') {
			x = a[0];
			a[0] = a[3];
			a[3] = a[5];
			a[5] = a[2];
			a[2] = x;
		}
		else if (b[i] == 'S') {
			x = a[0];
			a[0] = a[4];
			a[4] = a[5];
			a[5] = a[1];
			a[1] = x;
		}
		else if (b[i] == 'W') {
			x = a[0];
			a[0] = a[2];
			a[2] = a[5];
			a[5] = a[3];
			a[3] = x;
		}
	}
	return a[0];
}

int saikoro2(int a[7],int b,int c){
	int i=0, j=0,k=0;
	if (a[0] == b && a[1] == c) {
		return 0;
	}
	for (i = 0; i < 4; i++) {
		saikoro1(a, "N");
		if (a[0] == b && a[1] == c) break;
		for (j = 0; j < 4; j++) {
			saikoro1(a, "E");
			if (a[0] == b && a[1] == c) break;
			for (k = 0; k < 4; k++) {
				saikoro1(a, "N");
				if (a[0] == b && a[1] == c) break;
			}
			if (a[0] == b && a[1] == c) break;
		}
		if (a[0] == b && a[1] == c) break;
	}

	return 0;
}

int saikoro3(int a[7], int b[7]) {
	int x;
	if (a[0] == b[0] && a[1]==b[1]&&a[2] == b[2] && a[3] == b[3] && a[4] == b[4] && a[5] == b[5]) {
		x = 1;
	}
	else {
		x = 0;
	}
	return x;
}

struct dice {
	int men[7];
};

int main() {
	int i,j,n,x=0;
	struct dice d[101] = {0};

	scanf("%d", &n);


	for (i = 0; i < n; i++) {
		for (j = 0; j < 6; j++) {
			scanf("%d", &d[i].men[j]);
		}
	}
	
	for (i = 0; i < n; i++) {
		for (j = i+1; j < n; j++) {
			saikoro2(d[j].men, d[i].men[0], d[i].men[1]);

			x += saikoro3(d[i].men, d[j].men);
		}
		
	}
	
	if (x > 0) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    int A, B;
    in >> A, B;

    out << std::max(0, A - 2 * B);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n,k;cin>>n>>k;
  vector<ll> x(n);
  rep(i,n){
    cin>>x[i];
  }
  ll ans=0;
  rep(i,n){
    ans+=2*min(abs(x[i]-0),abs(x[i]-k));
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, c = MII()
    for i in range(1,b):
        if (a*i)%b == c:
            print('YES')
            return None
    print('NO')

if __name__ == '__main__':
    main()

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

int main() {
	int n;
	int field[2][100];
	cin >> n;
	for(int i=0; i<2; i++) {
		for(int j=0; j<n; j++) {
			cin >> field[i][j];
		}
	}
	int res = 0;
	for(int k=0; k<n; k++) {
		int cnt = 0;
		for(int x=0; x<=k; x++) {
			cnt += field[0][x];
		}
		for(int x=k; x<n; x++) {
			cnt += field[1][x];
		}
		if( res < cnt ) {
			res = cnt;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max({a * c, a * d, b * c, b * d});
  if(a <= 0 && b >= 0) {
    ans = max(ans, (ll)0);
  }
  if(c <= 0 && d >= 0) {
    ans = max(ans, (ll)0);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]
t=[int(input()) for _ in range(D)]

points=0
day_last=[0]*26

def minus(day):
    return sum([c[i]*(day+1-day_last[i]) for i in range(26)])

def plus(day,contest_number):
    return s[day][contest_number-1]

for day,contest_number in enumerate(t):
    day_last[contest_number-1]=day+1
    points=points+plus(day,contest_number)-minus(day)
    print(points)

Measured memory_bytes: 9244
# Aizu Problem 0228: Seven Segments

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


digits = [63, 6, 91, 79, 102, 109, 125, 39, 127, 111]

while True:
    n = int(input())
    if n == -1:
        break
    e = 0
    for i in range(n):
        a = digits[int(input())]
        print("{:07b}".format(a^e))
        e = a

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

int main() {
  int k;
  string s;
  cin>>k;
  cin>>s;
  if (k>=s.length()) cout<<s<<endl;
  else {
    for (int i=0;i<k;i++){
      cout<<s[i];
    }
    cout<<"..."<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
def rem(n, a):
    if a == 0:
        return 0
    ans=0
    for i in n:
        ans*=2
        ans+=i
        ans%=a
    return ans
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c
    
n, x = int(input()), list(map(int,input()))

p = x.count(1)
m = [0] * n
q = p - 1
if q!=0:
    m[0] = 1
    for i in range(1, n):
        m[i] = 2 * m[i - 1] % q

w = p + 1
k = [0] * n
k[0] = 1
for i in range(1, n):
    k[i] = 2 * k[i - 1] % w

s = rem(x, q)
t = rem(x, w)
for i in range(n):
    if x[i] == 0:
        a = (t + k[n - i - 1]) % w
        
    else:
        if q == 0:
            print(0)
            continue
        # if i == 3:
        #     print(s,k[n-i-1])
        a = (s - m[n - i - 1]) % q

    cnt = 1
    b = popcnt(a)
    # if i == 3:
    #     print(a,b)
    while b:
        a %= b
        b = popcnt(a)
        cnt += 1
    print(cnt)

Measured memory_bytes: 79348
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

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

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

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


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  string s,t;
  	cin>>s>>t;
  cout<<t<<s<<"\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int a,b;
	int diff;

	int thou=1000;
	int fif =500;
	int hnd =100;

	int tsuri[3];

	int i1;

	while(1){
		cin>>a>>b;
		if(a+b==0) break;

		diff=b-a;
		for(i1=0;i1<3;i1++) tsuri[i1]=0;

		if(diff>=thou) {
			tsuri[2]=diff/thou;
			diff-=(diff/thou)*thou;
		}
		if(diff>=fif){
			tsuri[1]=diff/fif;
			diff-=(diff/fif)*fif;
		}
		if(diff>=hnd){
			tsuri[0]=diff/hnd;
			diff-=(diff/hnd)*hnd;
		}

		for(i1=0;i1<3;i1++){
			if(i1!=0) cout<<" ";
			cout<<tsuri[i1];
		}
		cout<<endl;

	}
	return 0;
}

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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> vec(N+1, 0);
    
    for (int i=0; i < M; i++) {
        int j;
        cin >> j;
        vec.at(j) = 1;
    }
    
    int A = 0;
    int B = 0;
    for (int i = 0; i < X; i++) {
        if (vec.at(i) == 1) {
            A++;
        }
    }
    for (int i = X + 1; i <= N; i++) {
        if (vec.at(i) == 1) {
            B++;
        }
    }
    
    if (A <= B) {
        cout << A << endl;
    }
    else if (A > B) {
        cout << B << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n - 1];
		int count = 0;
		int tmp = -1;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			count += b[a[i] - 1];
			if (tmp + 1 == a[i]) {
				count += c[a[i] - 2];
			}
			tmp = a[i];

		}

		System.out.print(count);

	}
}

Measured memory_bytes: 22608
#include<stdio.h>
int main()
{
    int i,j,k,a,b,s=0,s2=0;
    scanf("%d %d",&a,&b);
    int col[102][102];
    int c=0,sum[102][102];
    int sum2[102][102];

    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b;j++)
        {
            scanf("%d",&col[i][j]);
            c=c+col[i][j];

        }
        sum[i][j]= c;
        c=0;

    }
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b;j++)
        {
           printf("%d ",col[i][j]);
        }
        printf("%d\n",sum[i][j]);
        s2=s2+sum[i][j];
    }


  for(i=1;i<=b;i++)
    {
        for(j=1;j<=a;j++)
        {
          s=s+col[j][i];

        }
        sum2[j][i]=s;
        s=0;
        printf("%d ",sum2[j][i]);
    }
    printf("%d\n",s2);
return 0;
}




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

int main(){
  int a,b;
  cin >> a >> b;
  //cin >> t;
  if(13<=a)cout << b << endl;
  else if(6<=a&&a<=12)cout << b/2 << endl;
  else cout << 0 << endl;
  //cout << b*(int)((t+0.5)/a) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define ld          long double
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = int(2e5) + 7;
typedef pair<int, int> pii;

int a[N], n, Max;
ll res, sum;
set<int> s;
vector<int> v;

struct BIT {
   ll t[N];
   void Update(int x, int val) {for(; x > 0; x -= (x & -x)) t[x] += val;}
   ll Get(int x) {ll res = 0; for(x = max(x, 1); x < N; x += (x & -x)) res += t[x]; return res;}
} bit1, bit2;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i], v.pb(a[i]);
    sort(v.begin(), v.end());
    for(int i = n; i >= 1; --i) {
        sum += a[i];
        a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
        bit1.Update(a[i], 1); bit2.Update(a[i], v[a[i] - 1]);
    }
    for(int i = 1; i <= n; ++i) {
        if(Max >= a[i]) cout << "0\n";
        else {
            s.insert(a[i]); res = 0;
            auto p = s.lower_bound(a[i]);
            int x;
            if(p == s.begin()) x = 0;
            else p = prev(p), x = (*p);
            int upper = bit1.Get(a[i]);
            res += 1ll * v[a[i] - 1] * upper;
            res += bit2.Get(x + 1) - bit2.Get(a[i]);
            if(x) {
                res -= 1ll * (bit1.Get(x + 1) - bit1.Get(a[i])) * v[x - 1];
                res -= 1ll * v[x - 1] * upper;
            }
            cout << res << '\n';
            Max = a[i];
        }
        sum -= a[i]; bit1.Update(a[i], -1); bit2.Update(a[i], -v[a[i] - 1]);
    }
}


Measured memory_bytes: 8056
#include<stdio.h>
int m(int);
int z[100000],a[100000];
int main()
{
	int n;
	int i,x,y;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<n;i++) z[i]=1000000000;
	z[0]=0;
	for(i=0;i<n;i++){
		x=a[i]-a[i+1];
		y=a[i]-a[i+2];
		if(x<0) x=-x;
		if(y<0) y=-y;
		if(i+1<n){
			if(x+z[i]<z[i+1]) z[i+1]=x+z[i];
		}
		if(i+2<n){
			if(y+z[i]<z[i+2]) z[i+2]=y+z[i];
		}
	}
	printf("%d\n",z[n-1]);
	return 0;
}

Measured memory_bytes: 2488
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, ans, h[N], k;
vector<int> gr[N];
void dfs(int v, int par = 0) {
	for (auto u : gr[v]) {
		if (u != par) {
			dfs(u, v);
			h[v] = max(h[v], h[u] + 1);
		}
	}
	if (h[v] == k - 1 && par != 0)
		ans++, h[v] = -1;
//	cout << "v = " << v << " : " << h[v] << endl;
	return;
}
int main() {
	ios_base::sync_with_stdio (false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		if (i == 0) {
			if (x != 0)
				ans++;
		}
		else {
			gr[i].push_back(x);
			gr[x].push_back(i);
		}
	}
	dfs(0);
	cout << ans;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

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

int main()
{
  int n = in();
  int sum[128][128] = {};
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= n; j++){
      sum[i][j] = in();
    }
  }
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= n; j++){
      sum[i][j] += sum[i][j - 1];
    }
  }

  int maxi = -(1 << 29);
  for (int sx = 1; sx <= n; sx++){
    for (int ex = sx; ex <= n; ex++){
      int s = 0;
      for (int y = 1; y <= n; y++){
        s += sum[y][ex] - sum[y][sx - 1];
        maxi = max(maxi, s);
        s = max(s, 0);
      }
    }
  }
  printf("%d\n", maxi);
  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

Measured memory_bytes: 1244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

priority_queue<pair<int, int> > q;

int main() {
	int n, t;
	cin >> n >> t;
	int a[n];
	FOR (i, n)
		cin >> a[i];
	int mm = a[n - 1], profit = -1;
	for (int i = n - 1; i > -1; i--) {
		mm = max(mm, a[i]);
		profit = max(profit, mm - a[i]);
	}
	int ret = 0;
	for (int i = n - 1; i > -1; i--) {
		q.push(make_pair(a[i], i));
		while (q.top().first - a[i] == profit) {
			ret++;
			pair<int, int> el = q.top();
			q.pop();
			el.first--;
			q.push(el);
		}
	}
	
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string n;
    cin >> n;
    int sum = 0, int_n;
    int_n = stoi(n);
    for (int i = 0; i < n.size(); i++) {
        sum += n[i] - '0';    
    }
    string ans;
    if (int_n % sum == 0)  ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fir first
#define sec second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

bool check(int a){
	for (int i = 1; i < 130; i++){
		int d = i*i;
		if(a==d) return true;
	}
	return false;
}

int main(){
	int l, r;
	cin >> l >> r;
	if(r-l >= 2018) {
		cout << 0 << endl;
		return 0;
	}
	r %= 2019, l %= 2019;
	int ans = INF;
	if(r==l){
		cout << r*r % 2019 << endl;
		return 0;
	}
	if(r<l) r += 2019;
	for (int i = l; i < r; i++) {
		for (int j = i+1; j <= r; j++) {
			chmin(ans, i*j%2019);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
const int INF = (1<<30);
struct FlowGraph{
	struct edge{
		int to, cap, flow;
		edge *nxt, *rev;
	}edges[20*MAXN + 5], *adj[4*MAXN + 5], *cur[4*MAXN + 5], *ecnt;
	FlowGraph() {ecnt = &edges[0];}
	void addedge(int u, int v, int c1, int c2) {
		edge *p = (++ecnt), *q = (++ecnt);
		p->to = v, p->cap = c1, p->flow = 0;
		p->nxt = adj[u], adj[u] = p;
		q->to = u, q->cap = c2, q->flow = 0;
		q->nxt = adj[v], adj[v] = q;
		p->rev = q, q->rev = p;
//		printf("! %d %d %d %d\n", u, v, c1, c2);
	}
	int dis[4*MAXN + 5];
	int s, t;
	bool relabel() {
		for(int i=0;i<=t;i++)
			dis[i] = INF, cur[i] = adj[i];
		queue<int>que; que.push(t), dis[t] = 0;
		while( !que.empty() ) {
			int f = que.front(); que.pop();
			for(edge *p=adj[f];p;p=p->nxt)
				if( p->rev->cap > p->rev->flow )
					if( dis[f] + 1 < dis[p->to] )
						que.push(p->to), dis[p->to] = dis[f] + 1;
		}
		return !(dis[s] == INF);
	}
	int aug(int x, int tot) {
		if( x == t ) return tot;
		int sum = 0;
		for(edge *&p=cur[x];p;p=p->nxt) {
			if( p->cap > p->flow && dis[p->to] + 1 == dis[x] ) {
				int del = aug(p->to, min(p->cap - p->flow, tot - sum));
				sum += del, p->flow += del, p->rev->flow -= del;
				if( sum == tot ) break;
			}
		}
		return sum;
	}
	int max_flow(int _s, int _t) {
		int flow = 0; s = _s, t = _t;
		while( relabel() )
			flow += aug(s, INF);
		return flow;
	}
}G;
int P[MAXN + 5], Q[MAXN + 5];
bool tag[MAXN + 5];
int main() {
	int N, cnt; scanf("%d", &N), cnt = 2*N;
	for(int i=1;i<=N;i++)
		scanf("%d", &P[i]), P[i]++, tag[i] = false;
	for(int i=1;i<=N;i++)
		if( !tag[i] ) {
			int p = i; cnt++;
			do {
				tag[p] = true;
				p = P[p];
				G.addedge(cnt, p, INF, INF);
			}while( p != i );
		}
	for(int i=1;i<=N;i++)
		scanf("%d", &Q[i]), Q[i]++, tag[i] = false;
	for(int i=1;i<=N;i++)
		if( !tag[i] ) {
			int p = i; cnt++;
			do {
				tag[p] = true;
				p = Q[p];
				G.addedge(cnt, p + N, INF, INF);
			}while( p != i );
		}
	int s = 0, t = cnt + 1;
	for(int i=1;i<=N;i++) {
		if( i == P[i] && i == Q[i] && P[i] == Q[i] )// a = c = 1
			G.addedge(s, i, 1, 0), G.addedge(i, t, 1, 0);
		if( i == P[i] && i != Q[i] && P[i] != Q[i] )// b = 1
			G.addedge(s, i + N, 1, 0);
		if( i != P[i] && i == Q[i] && P[i] != Q[i] )// c = 1
			G.addedge(i, t, 1, 0);
		if( i != P[i] && i != Q[i] && P[i] == Q[i] )// e = f = 1
			G.addedge(i, i + N, 1, 1);
		if( i != P[i] && i != Q[i] && P[i] != Q[i] )// f = 1
			G.addedge(i, i + N, 1, 0);
	}//s -> i(a), s -> i+N(b), i -> t(c), i+N -> t(d), i+N -> i(e), i -> i+N(f)
	printf("%d\n", N - G.max_flow(s, t));
}

Measured memory_bytes: 35456
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<cmath>
#include<numeric>
#include<ctime>
#include<locale>
//freopen("std.in","r",stdin);freopen("stdout.out","w",stdout);
using namespace std;
long long a[55];
int main()
{
    long long n;
    long long s;
    cin>>n;
    for(long i=0;i<n;i++)scanf("%lld",&a[i]);
    s=0;
    for(long i=0;i<n;)
    {
        if(a[i]>=n)
        {
            if((a[i])/n>=n)
            {
            long long x,y;
            x=a[i]-(a[i]/(n+1)*n);
            y=a[i]/(n+1);
            s+=a[i]/(n+1);
            s+=n*(y-n+1);
            x-=y-n+1;
            if(x>n)
            {
                s+=n+1;
                for(long j=0;j<n;j++)
                {
                    if(i!=j)a[j]+=n-1;
                }
                a[i]=x-n-1;
            }
            else if(x==n)
            {
                s+=n;
                for(long j=0;j<n;j++)
                {
                    if(i!=j)a[j]+=n-2;
                }
                a[i]=n-1;
            }
            else
            {
                for(long j=0;j<n;j++)
                {
                    if(i!=j)a[j]+=n-1;
                }
                a[i]=n-1;
            }
            i=0;
            }
            else
            {
                s+=a[i]/n;
                for(long j=0;j<n;j++)
                {
                    if(i!=j)a[j]+=a[i]/n;
                }
                a[i]%=n;
                i=0;
            }
        }
        else i++;
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 888888
int n,k; char s[SZ];
int ps[SZ],*h=ps,*t;
int main()
{
	scanf("%d%d%s",&n,&k,s); t=h+n-1;
	for(int i=0;i<n;++i) *(h+i)=(s[i]-'A')^(i&1);
	if(k>=n+n) k=n+n+(k-n-n)%2;
	for(int i=1;i<=k;++i)
	{
		if(*h==0) *h^=1;
		else *(++t)=(n-1)&1, ++h;
	}
	for(int i=0;i<n;++i)
		putchar((*(h+i)^(i&1))+'A');
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
     
int main(){
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if(N <= K){
    cout << N * X << endl;
  }
  else{
    cout << K * X + (N - K) * Y << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def run():
    N = int(sysread())
    A = list(map(int, sysread().split()))
    B = list(map(int, sysread().split()))
    list_A = defaultdict(lambda:[])
    for i in range(N):
        list_A[A[i]].append(i)

    list_B = defaultdict(lambda:[])
    for i in range(N):
        list_B[B[i]].append(i)

    cnt = [0] * (N+1)
    for v in A + B:
        cnt[v] += 1
        if cnt[v] > N:
            print('No')
            return
    q = [set() for _ in range(N+1)]
    for i in range(1, N+1):
        q[cnt[i]].add(i)
    #print(q)

    arr = [-1] * N
    for i in range(N):
        #print(list_A)
        #print(list_B)
        v = q[N-i]
        #print(i, '--------------')
        #print(q)
        if len(v) == 0:
            for alpha in list_A.keys():
                j = cnt[alpha]
                q[j].remove(alpha)
                q[j - 1].add(alpha)
                cnt[alpha] -= 1
                break

            for beta in list_B.keys():
                if alpha == beta :continue
                j = cnt[beta]
                q[j].remove(beta)
                q[j - 1].add(beta)
                cnt[beta] -= 1
                break

            arr[list_A[alpha].pop()] = beta
            list_B[beta].pop()

        elif len(v) == 1:
            alpha,  = v
            q[N-i].remove(alpha)
            mem = alpha
            #print(list_A)
            #print(list_B)
            if not list_A[alpha]:
                beta = alpha

                for alpha in list_A.keys():
                    if beta == alpha:continue
                    j = cnt[alpha]
                    q[j].remove(alpha)
                    q[j - 1].add(alpha)
                    cnt[alpha] -= 1
                    break

            else:
                for beta in list_B.keys():
                    if beta == alpha:continue
                    j = cnt[beta]
                    q[j].remove(beta)
                    q[j - 1].add(beta)
                    cnt[beta] -= 1
                    break

            arr[list_A[alpha].pop()] = beta
            list_B[beta].pop()
            q[N - i - 1].add(mem)
        else:
            alpha, beta = list(v)
            q[N-i].remove(alpha)
            q[N-i].remove(beta)
            if not list_A[alpha]:
                alpha, beta = beta, alpha
            arr[list_A[alpha].pop()] = beta
            list_B[beta].pop()
            q[N-i-1].add(alpha)
            q[N - i - 1].add(beta)

        if not len(list_A[alpha]):del list_A[alpha]
        if not len(list_B[beta]): del list_B[beta]
    print('Yes')
    print(' '.join([str(s) for s in arr]))
if __name__ == "__main__":
    run()


Measured memory_bytes: 207872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, k, n) for(int i = (int)(k);i < (int)(n);i++)
int main() {
  int N;cin >> N;
  vector<int> dp(N), c(N);
  rep(i, 0, N) cin >> c[i];
  dp[0] = 0, dp[1] = abs(c[1]-c[0]);
  rep(i, 2, N) dp[i] = min(dp[i-1]+abs(c[i-1]-c[i]), dp[i-2]+abs(c[i-2]-c[i]));
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 4036
#include<iostream>

using namespace std;

int bubbleSort(int a[],int n){
  int cnt=0;
  bool swapped = true;
  while(swapped){
    swapped = false;
    for(int i=0;i<n-1;i++){
      if(a[i] > a[i+1]){
        int temp = a[i];
        a[i] = a[i+1];
        a[i+1] = temp;
        swapped = true;
        cnt++;
      }
    }
  }
  return cnt;
}

int main(){
  int n,a[100],cnt;
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  cnt = bubbleSort(a,n);
  for(int i=0;i<n;i++)if(i==0)cout << a[i]; else cout << " " << a[i];
  cout << endl;
  cout << cnt << endl;
}

Measured memory_bytes: 1160
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    int n, x;
    cin >> n >> x;
    int A[n];
    REP(i, n) cin >> A[i];

    long long ans = 0, s;
    for(int i = 1; i < n; i++){
        s = A[i] + A[i - 1];
        if(s > x){
            ans += s - x;
            if(A[i] < s - x){
                A[i] = 0;
                A[i - 1] -= A[i - 1] - x;
            }else{
                A[i] -= s - x;
            }
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef pair<string, int> f_pair;

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

	vector<f_pair> a;
	string s;
	while (cin >> s)
	{
		int n;
		bool exist = false;

		for (int i = 0; i < a.size(); ++i)
			if (s == a[i].first)
			{
				exist = true, n = i;
				break;
			}

		if (exist)
			a[n].second++;
		else
			a.push_back(f_pair(s, 1));
	}

	int lMax = a[0].first.size();
	int fMax = a[0].second;
	int n = 0, m = 0;
	for (int i = 1; i < a.size(); ++i)
	{
		if (a[i].second > fMax)
			fMax = a[i].second, n = i;

		if (a[i].first.size() > lMax)
			lMax = a[i].first.size(), m = i;
	}

	cout << a[n].first << " " << a[m].first << endl;

	return 0;
}

Measured memory_bytes: 1200
from collections import defaultdict
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
ans = "YES"
d = defaultdict(lambda : 0)
for i in range(N):
    d[D[i]] += 1
for j in range(M):
    if d[T[j]] == 0:
        ans = "NO"
        break
    d[T[j]] -= 1
print(ans)

Measured memory_bytes: 41700
k, s = map(int, input().split())

cnt = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - (x + y)
        if z >= 0 and z <= k:
            cnt = cnt + 1
#        for z in range(k+1):
#            if x + y + z == s:
#                cnt = cnt + 1

print(cnt)

Measured memory_bytes: 2940
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;

    ll n = s.size();

    vector<ll> imos(n+1, 0);
    REP(i, n) {
        imos[i+1] = imos[i] ^ (1LL << s[i] - 'a');
    }
    
    // dp[i] := i文字まで見て最小の分割数
    vector<int> dp(n+1, 999999); dp[0] = 0;
    // dp2[i] := imos == i になったところの最小の分割数
    vector<int> dp2(1LL << 26, 999999);
    dp2[0] = 0;
    RANGE(i, 1, n) {
        chmin(dp[i], dp2[imos[i]] + 1);
        REP(j, 26) {
            ll mask = imos[i] ^ (1LL << j);
            chmin(dp[i], dp2[mask] + 1);
        }
        chmin(dp2[imos[i]], dp[i]);
    }
    // DUMPALL(dp);
    cout << dp[n] << endl;
    
}

Measured memory_bytes: 265236
while True:
    m,f,r= map(int, input().split())
    if m==f==r==-1:
        break

    if m==-1 or f==-1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5592