akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const int maxn = 1e5 + 10 ;
int x[maxn] ;
ll dp[maxn] ;
int que[maxn], st, ed ;
int main() {
	int n, e, t ;
	scanf("%d%d%d", &n, &e, &t) ;
	for (int i = 1; i <= n; i ++)
		scanf("%d", &x[i]) ;
	memset (dp, 0x3f, sizeof dp) ;
	dp[0] = 0 ;
	ll mn_val = 1e18 ;
	st = 1; ed = 0 ;
	que[++ ed] = 0 ;
	for (int i = 1; i <= n; i ++) {
		/*for (int j = 0; j < i; j ++) {
			//dp[i] = x[j + 1] - x[j] + dp[j] - 3ll * x[j + 1] + 3ll * x[i] ;
			//dp[i] = dp[j] - x[j] + x[i] + t ;
			dp[i] = min (dp[i], x[j + 1] - x[j] + dp[j] + max (3ll * (x[i] - x[j + 1]), 1ll * x[i] - x[j + 1] + t)) ;
		}*/
		while (st <= ed && 3ll * (x[i] - x[que[st] + 1]) >= 1ll * x[i] - x[que[st] + 1] + t) {
			mn_val = min (mn_val, x[que[st] + 1] - x[que[st]] + dp[que[st]] - 3ll * x[que[st] + 1]) ;
			st ++ ;
		}
		dp[i] = min (dp[i], mn_val + 3ll * x[i]) ;
		if (st <= ed) dp[i] = min (dp[i], dp[que[st]] - x[que[st]] + x[i] + t) ;
		if (i == n) continue ;
		while (st <= ed && dp[i] - x[i] <= dp[que[ed]] - x[que[ed]]) {
			mn_val = min (mn_val, x[que[ed] + 1] - x[que[ed]] + dp[que[ed]] - 3ll * x[que[ed] + 1]) ;
			ed -- ;
		}
		que[++ ed] = i ;
	}
	printf("%lld\n", dp[n] + e - x[n]) ;
	return 0 ;
}

Measured memory_bytes: 5384
def f(m):
  if m%10 == 0:
    return 10
  else:
    return m%10

def g(m):
  if m%10 == 0:
    return m
  else:
    return 10*(m//10 + 1)
lis = []
for i in range(5):
  x = int(input())
  lis.append([f(x%10),g(x),x])

a = sorted(lis)
ans = 0
for i in reversed(range(1,5)):
  ans += a[i][1]

ans += a[0][2]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 1e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

ll dp[N];

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i <= n; i++){
        int w, v;
        cin >> w >> v;
        for (int j = N-1; j - v >= 0; j--){
            dp[j] = min(dp[j], dp[j-v]+w);
        }
    }
    int ans = 0;
    for (int i = 1; i < N; i++){
        if (dp[i] <= W){
            ans = i;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n, i, j, ans = 0;
    scanf("%d",&n);
    char c, *s = (char *)malloc(sizeof(char)*n);
    scanf("%s",s);
    for(i=0;i<n;i++)
    {
        c = s[i];
        while(c == s[i])
        {
            i++;
        }
        i--;
        ans+=1;

    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N, D;
int main() {
    while (cin >> N >> D) {
        vector<int> a(N), b(N);
        for (int i = 0; i < N; ++i) {
            cin >> a[i];
            --a[i];
            b[i] = a[i] % (D + 1);
        }

        long long sum = 0;
        for (int i = 0; i < N; ++i) sum ^= b[i];
        if (!sum) puts("Second");
        else puts("First");

        /*
        bool exist = false;
        int num = 0;
        for (int i = 0; i < N; ++i) {
            if (b[i] > 1) exist = true;
            if (b[i] == 1) ++num;
        }

        COUT(exist); COUT(num);

        if (exist) {
            long long sum = 0;
            for (int i = 0; i < N; ++i) sum ^= b[i];
            if (sum == 0) puts("Second");
            else puts("First");
        }
        else {
            if (num % 2 == 0) puts("Second");
            else puts("First");
        }
        */
    }
}

















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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<LL> a(3*n);
  for(int i=0;i<3*n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  LL ans=0;
  int count=0;
  for(int i=3*n-2;count<n;i-=2,count++){
    ans+=a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import sys
import copy
import heapq
from collections import deque
import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize


# ===CODE===
def main():
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    n = int(input())
    tree = UnionFind(n)

    edges_x = []
    edges_y = []
    for i in range(n):
        x, y = map(int, input().split())
        edges_x.append((x, i))
        edges_y.append((y, i))

    edges_x.sort()
    edges_y.sort()

    edges = []
    for i in range(n - 1):
        tmp = abs(edges_x[i][0] - edges_x[i + 1][0])
        edges.append((tmp, edges_x[i][1], edges_x[i + 1][1]))
        tmp = abs(edges_y[i][0] - edges_y[i + 1][0])
        edges.append((tmp, edges_y[i][1], edges_y[i + 1][1]))

    edges.sort()

    ans = 0
    for d, s, t in edges:
        if not tree.same(s, t):
            tree.union(s, t)
            ans += d

    print(ans)


# ===main===
if __name__ == '__main__':
    main()


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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define rrange(v) v.rbegin(), v.rend()
#define mod (int)(1e9 + 7)
#define inf (int)(5e18)
#define N (int)(2e5 + 10)

using namespace std;

int dp[10005][100][2];
string s;
int n, d;

int digitSum(int pos, int mo, bool tight) {
	if (pos == n) return !mo;
	int &ans = dp[pos][mo][tight];
	if (ans != -1) return ans;

	ans = 0;
	int lim = tight ? s[pos] - '0' : 9;
	for (int i = 0; i <= lim; i++) {
		ans += digitSum(pos + 1, (mo + i) % d, tight and (i == lim));
		ans %= mod;
	}

	return ans;
}

void solve() {
	cin >> s >> d;
	n = s.length();
	memset(dp, -1, sizeof(dp));
	cout << (digitSum(0, 0, 1) - 1 + mod) % mod << endl;
}
// Remember to clear the global containers

// Got stuck and want to leave ? look at the bottom once..
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
	// cin >> t_c;
	while (t_c--)
		solve();
}
/* Come on Dude .. Dont get up until u get the solution
 * Giving up not gonna help ryt ? So get ur lazy ass to code already
 * You can do it ... Stay Calm and Dont Panic :)
 */


Measured memory_bytes: 20064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
 
  if (A >= B && A >= C) {
    cout << pow (2,K) * A + B + C << endl;
  }
  else if (B >= A && B >= C) {
    cout << pow (2,K) * B + A + C << endl;
  }
  else if (C >= A && C >= B) {
    cout << pow (2,K) * C + A + B << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> xy;
    
    for(int i = 0, x, y; i < N; i++){
        cin >> x >> y;
        xy.push_back(make_pair(x, y));
    }
    int sumax{0};
    for(int i = 0; i < N ; i++){
        for(int j = i + 1; j < N; j++){
            int x = xy.at(j).first - xy.at(i).first;
            int y = xy.at(j).second - xy.at(i).second;
            int sum{0};
            for(int l = 0; l < N; l++){
                for(int k = 0; k < N; k++){
                    if(xy.at(l).first - xy.at(k).first == x && xy.at(l).second - xy.at(k).second == y){
                        sum++;
                        sumax = max(sumax, sum);
                        // cout << xy.at(l).first << " " << xy.at(k).first << " " << xy.at(l).second << endl;
                    }
                }
            }
        }
    }
    cout << N - sumax << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, w;
	while (cin >> n >> w, n) {
		vi val(n);
		int ma = 0;
		REP(i, n) {
			cin >> val[i];
			ma = max(ma, val[i] / w);
		}
		vi bar(ma+1);
		REP(i, n)
			bar[val[i] / w]++;
		int ma2 = 0;
		REP(i, ma+1)
			ma2 = max(ma2, bar[i]);
		double ans = 0.01;
		REP(i, ma + 1) {
			ans+=(double)bar[i] / (double)ma2*(double)(ma - i) / (double)(ma);
		}
		printf("%.5lf\n", ans);
	}
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
int main(){
    long long int n;
    cin>>n;
    vector<long long int >a;
    for(long long int i=0;i<n;i++){
        long long int s;
        cin>>s;
        a.push_back(s);
    }
    vector<long long int >sum;
    for(long long int i=0;i<n;i++){
        sum.push_back(a[i]);
    }
    for(long long int i=n-2;i>0;i--){
        a[i]=(a[i]%M+a[i+1]%M)%M;
    }
    long long int Count=0;
    for(long long int i=0;i<n-1;i++){
        Count+=(a[i+1]%M*sum[i]%M)%M;
    }
    cout<<Count%M;
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	string s;
	cin>>s;

	for(int i=0; i<s.length(); i++){
		cout<<"x";
	}
	cout<<endl;




}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll a,b,n;
cin>>a>>b>>n;
auto f = [&](ll x) {
    return (ll)floor(a * x / (double)b);
};

ll ans = f(min(b-1,n));
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
int main(void){
	char s[4];
	scanf("%s",s);
	int i;
	int ans =0;
	for(i=0;i<4;i++){
		if(s[i] =='+')ans++;
		if(s[i]=='-')ans--;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
// AOL 1059 Mysterious Onslaught
// 2018.2.18 bal4u

#include <stdio.h>
#include <string.h>

int n;
int map[5][5][5][5];
char memo[1<<25];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(int b)
{
	int r1, c1, r2, c2, k, ans;

	if (!b) return 0;
	if (memo[b] >= 0) return memo[b];

	for (k = r1 = 0; r1 < n; r1++, k += 5) for (c1 = 0; c1 < n; c1++) {
		if (b & (1<<(k + c1))) goto next;
	}
next:
	ans = 25;
	for (r2 = r1; r2 < n; r2++) for (c2 = c1; c2 < n; c2++) {
		k = b ^ map[r1][c1][r2][c2];
		k = calc(k) + 1;
		if (ans > k) ans = k;
	}
	return memo[b] = ans;
}

void init()
{
	int r1, r2, c1, c2, r, c;

	for (r1 = 0; r1 < 5; r1++) for (c1 = 0; c1 < 5; c1++)
		for (r2 = r1; r2 < 5; r2++) for (c2 = c1; c2 < 5; c2++)
			for (r = r1; r <= r2; r++) for (c = c1; c <= c2; c++)
				map[r1][c1][r2][c2] |= (1<<(r*5+c));
}

int main()
{
	int r, c, b, k;

	memset(memo, -1, sizeof(memo));
	init();
	while (n = in()) {
		b = 0;
		for (k = r = 0; r < n; r++, k += 5) for (c = 0; c < n; c++) {
			if (getchar_unlocked() & 1) b |= 1 << (k+c);
			getchar_unlocked();
		}
		k = calc(b);
		while (k--) printf("myon");
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 34520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	public class Balloon
	{
		public long Height{get;set;}
		public long Speed{get;set;}
	}
	
	public static void Main(string[] args)
	{
		var u = Console.ReadLine();
		for(int i = 0; i < u.Length; i++)
		{
			Console.Write("x");
		}
		Console.WriteLine();
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a < 10 && b < 10)
				System.out.println(a * b);
			else
				System.out.println(-1);
		}
	}
}


Measured memory_bytes: 22996
import sys
input=sys.stdin.readline

s = [int(input()) for i in range(5)]

m = 9999
for i in s:
    t = 0
    ss = s[0:]
    ss.remove(i)
    for j in ss:
        t += j if j%10 == 0 else j + 10-j%10
    t += i    
    m = min(m, t) 

print(m)


Measured memory_bytes: 3060
/*  ex3_2
    person_A  */
#include<stdio.h>
int main(void){
    int N,x;
    //Nの入力
    scanf("%d",&N);
    //Nの一の位xの値の取得
    x=N%10;
    //一の位の数に応じて場合わけ
    //一の位が2,4,5,7,9の時 hon を出力
    if(x==2||x==4||x==5||x==7||x==9){
        printf("hon\n");
    }
    //一の位が0,1,6,8の時 pon を出力
    else if(x==0||x==1||x==6||x==8){
        printf("pon\n");
    }
    //一の位が3の時 bon を出力
    else if(x==3){
        printf("bon\n");
    }
    return 0;
}

Measured memory_bytes: 1620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;

int H, W;
char c[110][110];	
bool f[110][110];

void solve(int y, int x){
	if (f[y][x]){
		cout << "LOOP\n";
		return;
	}
	if (c[y][x] == '.'){
		cout << x << " " << y << endl;
		return;
	}	
	f[y][x] = 1;
	if (c[y][x] == '>'){
		solve(y, x + 1);
	}
	else if (c[y][x] == 'v'){
		solve(y + 1, x);
	}
	else if (c[y][x] == '<'){
		solve(y, x - 1);
	}
	else{
		solve(y - 1, x);
	}
}

int main(){
	while (cin >> H >> W){
		if (H + W == 0)break;
		REP(i, H){
			REP(j, W){
				cin >> c[i][j];
			}
		}
		solve(0, 0);
		REP(i, H){
			REP(j, W){
				f[i][j] = 0;
			}
		}
	}
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll>a(n+1),b(n+1),c(n+1),p(n+1);
    c[0]=1;
    REP(i,1,n+1){
        c[i]=c[i-1]+1;
    }
    rep(i,n){
        ll d;cin>>d;
        p[d]=i+1;
    }
    a[1]=1;
    b[1]=p[1]-a[1];
    ll mi=b[1];
    REP(i,2,n+1){
        if(p[i]<p[i-1]){
            a[i]=a[i-1]+1;
            b[i]=p[i]-a[i];
        }else{
            b[i]=b[i-1]-1;
            a[i]=p[i]-b[i];
        }
        mi=min(b[i],mi);
    }
    REP(i,1,n+1)b[i]+=abs(mi)+1;
    REP(i,1,n+1)cout<<a[i]<<' ';
    cout<<endl;
    REP(i,1,n+1)cout<<b[i]<<' ';
}

Measured memory_bytes: 1280
# Problem B - Echo

# input process
N = int(input())
S = input()

if not N%2==0:
    print('No')
else:
    parts_1 = S[:(N//2)]
    parts_2 = S[N//2:]
    if parts_1==parts_2:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 38256
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    static class sol{
        static int []A=new int[31235325];
        public static void solve(InputReader in,PrintWriter out) {
            int a=in.nextInt();
            int b=in.nextInt();

            A[a ] = 1;
            A[b ] = 1;
            if(A[1]==0)
                out.print(1);
            else if(A[2]==0)
                out.print(2);
            else if(A[3]==0)
                out.print(3);

        }
    }
    public static void main(String[] args) throws FileNotFoundException {
          InputStream input=System.in;
//        InputStream input=new FileInputStream(new File("src//input.in"));
        InputReader in=new InputReader(input);
        OutputStream output=System.out;
        PrintWriter out=new PrintWriter(output);
        sol a=new sol();
        a.solve(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    return false;
                }
            }
            return true;
        }

        public String next() {
            if (hasNext())
                return tokenizer.nextToken();
            return null;
        }

        public String nextLine() {
            if (hasNext())
                return tokenizer.nextToken("");
            else
                return null;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        public BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


Measured memory_bytes: 144724
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,d,i,j,ans=0;
	cin>>n>>d;
	ll x[n+1][d+1];
	for(i=0;i<n;i++)
		for(j=0;j<d;j++)
			cin>>x[i][j];
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			ll sum=0;
			for(int k=0;k<d;k++)
				sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			int t=sqrt(sum);
			if(sum==t*t)ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
input = sys.stdin.readline


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def isSame(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)]


if __name__ == "__main__":
    N, M, K = map(int, input().split())
    friend = UF_tree(N)
    block = UF_tree(N)
    cnt = defaultdict(int)
    for _ in range(M):
        a, b = map(int, input().split())
        cnt[a] += 1
        cnt[b] += 1
        friend.unite(a, b)

    for _ in range(K):
        c, d = map(int, input().split())
        if friend.isSame(c, d):
            cnt[c] += 1
            cnt[d] += 1

    ans = [0] * (N + 1)
    for i in range(1, N + 1):
        cand = friend.getNodeLen(i) - 1
        cand -= cnt[i]
        ans[i] = cand

    print(*ans[1:])


Measured memory_bytes: 25900
#include<bits/stdc++.h>
#define R(a) int a;cin>>a;
#define deb(x) cout<<#x<<" "<<x<<endl;
#define mod 1000000007
#define f_arr(n) for(int i=0;i<n;i++)
#define r_arr(n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define all(x) x.begin(),x.end()
#define int long long int
using namespace std;

#ifndef ONLINE_JUDGE
template<typename T>		
void __p(T a) {
  cerr<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cerr<<"[";
  __p(a.first);
  cerr<<",";
  __p(a.second);
  cerr<<"]";
}
template<typename T>
void __p(std::vector<T> a) {
  cerr<<"[";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cerr<<",]"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr<<name<<" : ";
  __p(arg1);
  cerr<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cerr.write(names,comma-names)<<" : ";
  __p(arg1);
  cerr<<" | ";
  __f(comma+1,args...);
}
#define trace(...) cerr<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#endif

double dist(int x,int y){
  x=x*x;
  y=y*y;
  x=x+y;
  return sqrt(x);
}
void test_case()
{
  R(n);
  double d;
  cin>>d;
  int c=0;
  for(int i=0;i<n;i++){
    R(x);R(y);
    if(dist(x,y)>d)
      c++;
  }
  cout<<n-c;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int t=1;
    // cin>>t;
    while(t--)
    {
        test_case();
    }

    cerr<<endl<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";

    return 0;
}


Measured memory_bytes: 3824
a = input()
b = [bool(int(a[i])) for i in range(len(a))]
b.insert(0, True)
c = [bool(int(a[i])) for i in range(len(a))]
c.insert(0, False)
bc = 0
cc = 0

for i in range(1, len(b)):
    if b[i-1] == b[i]:
        b[i] = not b[i-1]
        bc += 1
    if c[i-1] == c[i]:
        c[i] = not c[i - 1]
        cc += 1

print(min(bc, cc))


Measured memory_bytes: 4852
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
 
const int N=15,OO=1e18;
int x[N],y[N],p[N];
int dp[N+1][1<<N];
int opt[1<<N];
int32_t main(){
    int n;
    cin>>n;
    forn(i,n)cin>>x[i]>>y[i]>>p[i];
    for(int mask=1;mask<(1<<n);++mask){
        opt[mask]=OO;
        forn(i,n){
            if(mask>>i&1){
                {
                    int w=x[i],pot=0;
                    forn(j,n)if(mask>>j&1)pot+=abs(x[j]-w)*p[j];
                    upn(opt[mask],pot);
                }
                {
                    int w=y[i],pot=0;
                    forn(j,n)if(mask>>j&1)pot+=abs(y[j]-w)*p[j];
                    upn(opt[mask],pot);
                }
                dp[0][mask]+=min(abs(x[i]),abs(y[i]))*p[i];
            }
        }        
    }
    cout<<dp[0][(1<<n)-1]<<'\n';
    for(int k=1;k<=n;++k){
        for(int mask=1;mask<(1<<n);++mask){
            dp[k][mask]=OO;
            for(int sub=mask;sub;sub=(sub-1)&mask)
                upn(dp[k][mask],dp[k-1][mask^sub]+opt[sub]);
        }
        cout<<dp[k][(1<<n)-1]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 7964
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
int n,m,i,j,c1,c2,c3,s;
string st,sss;
int main()
{
	scanf("%d",&n);
	fz1(i,n){
		rdst(st,18);
		if (st[0]=='B'&&st[st.length()-1]=='A') c3++;
		else if (st[0]=='B') c2++;
		else if (st[st.length()-1]=='A') c1++;
		for (j=1;j<st.length();j++) if (st[j-1]=='A'&&st[j]=='B') s++;
	}
	if (!(c1+c2)) cout<<s+max(0,c3-1)<<endl; else cout<<s+min(c1,c2)+c3<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (String.valueOf(i).length() % 2 != 0) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27604
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    char s[4];
    cin >> s;

    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }

    return 0;
}

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

#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define all(v) v.begin(), v.end()
#define ar array

#define F first
#define S second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using ld = long double;

// const int mod = 1e9 + 7;
const int mod = 998244353;
const ll inf = 2e9;
const ll INF = 2e18;
const ld EPS = 1e-7;

const int N = 1e6 + 5;

int n, m, q;

int a[N], b[N], c[N], d[N];

int p[N];

int best;

void go (int i, int ai) {
	if (i > n) {
		int total = 0;
		for (int j = 1 ; j <= q ; ++ j) {
			if (p[b[j]] - p[a[j]] == c[j]) {
				total += d[j];
			}
		}
		best = max (best, total);
		return;
	}
	for (int j = ai ; j <= m ; ++ j) {
		p[i] = j;
		go (i + 1, j);
	}
}

void solve () {
	cin >> n >> m >> q;
	for (int i = 1 ; i <= q ; ++ i) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	go (1, 1);
	cout << best;
}

int main () {
	ios;
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
		cout << "\n";
	}
}

Measured memory_bytes: 3668
n, m = map(int, input().split())
Py = []
for i in range(m):
    py = list(map(int, input().split()))
    Py.append(py+[i])
Py = sorted(sorted(Py, key = lambda x: x[1]))
tmp = -1
ans = []
for i in range(m):
    out = str(Py[i][0]).zfill(6)
    cnt = cnt + 1 if Py[i][0] == tmp else 1
    out += str(cnt).zfill(6)
    tmp = Py[i][0]
    ans.append([Py[i][2], out])
ans.sort()
for i in range(m):
    print(ans[i][1])

Measured memory_bytes: 95320
#include <stdio.h>

int main(void)
{
	double r,a,b;

	scanf("%lf",&r);
	
	a = r * r * 3.141592653589;
	b = r * 2 * 3.141592653589;

	printf("%.6f %.6f\n",a,b);
	return 0;
}

Measured memory_bytes: 652
#include <iostream>

using namespace std;

void riffle(int n, int cards[]) {
    int tmp[200];
    for (int i = 0; i < n; ++i) {
        tmp[2 * i] = cards[i];
        tmp[2 * i + 1] = cards[i + n];
    }
    for (int i = 0; i < 2 * n; ++i) {
        cards[i] = tmp[i];
    }
}

void cut(int n, int cards[], int k) {
    int tmp[200];
    for (int i = 0; i < k; ++i) {
        tmp[i + 2 * n - k] = cards[i];
    }
    for (int i = k; i < 2 * n; ++i) {
        tmp[i - k] = cards[i];
    }
    for (int i = 0; i < 2 * n; ++i) {
        cards[i] = tmp[i];
    }
}

int main() {
    int n, m, k;
    int cards[200];
    cin >> n >> m;
    for (int i = 0; i < 2 * n; ++i) {
        cards[i] = i;
    }
    for (int i = 0; i < m; ++i) {
        cin >> k;
        if (k > 0) {
            cut(n, cards, k);
        } else {
            riffle(n, cards);
        }
    }
    for (int i = 0; i < 2 * n; ++i) {
        cout << cards[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m,d,x; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

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

int main() {
	cin >> n >> m;
	ll mi = 0; ll mm = INF;
	rep(i, m) {
		ll l, r;
		cin >> l >> r;
		if (mi <= l)mi = l;
		if (r <= mm)mm = r;
		if (mm < l || r < mi) {
			cout << 0 << endl;
			return 0;
		}
	}
	ll res = mm - mi + 1;
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=-1e12;
const double pi=acos(-1);



void solve(int T){
    ll n;
    string x;
    cin>>n>>x;
    ll s=0;
    for(int i=0;i<x.size();i++){
        if(x[i]!='.'){
            s*=10;
            s+=(x[i]-'0');
        }
    }
    ll ans=s*n;
    ans/=100;
    cout<<ans;

}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
    }
	return 0;
}


Measured memory_bytes: 3584
/****************### With The name of ALLAH, most Gracious, most Compassionate ###****************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : Monday, 14 September, 2020
|   Source      : AtCoder Online Judge
|   Problem link: https://atcoder.jp/contests/abc150/tasks/abc150_c
|   Algorithm   :
|
\**============================================================================**/

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

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
/**************************************************************************************************/

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

    vector <int> per1(n), per2(n);
    for(int &x: per1)cin >> x;
    for(int &x: per2)cin >> x;

    vector <int> vc;
    for0(i, n)vc.pb(i+1);

    int mark1 = 0, mark2 = 0, cnt = 0;

    do
    {
        cnt++;
        if(per1 == vc)mark1 = cnt;
        if(per2 == vc)mark2 = cnt;
        //for(int x: vc)cout << x << " ";
        //cout <<endl;
        if(mark1 and mark2)break;
    }
    while( next_permutation( all(vc) ) );

    cout << abs(mark1 - mark2) << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
    //FasterIO

    int T = 1;
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc)
    {
        //cout << "Case #" << tc << ":" << endl;
        test_case();
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int n;
    string s;
    cin>>n>>s;
    set<int> r,g,b;
    for(int i = 0;i < n;++i) {
        switch (s[i]) {
            case 'R':r.insert(i);break;
            case 'G':g.insert(i);break;
            case 'B':b.insert(i);break;
        }
    }
    ll ans=0;
    ll bs=b.size();
    for(auto x:r) {
        for(auto y:g) {
            int nd= x<y?2*y-x:2*x-y;

            if(b.find(nd)!=b.end()){
                --ans;
            }

            nd = x<y?2*x-y:2*y-x;

            if(b.find(nd)!=b.end()){
                --ans;
            }

            nd = x+y;

            if(nd%2==0&&b.find(nd/2)!=b.end()){
                --ans;
            }

            ans+=bs;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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


int main() {
	int a, b, c;
	int x, y;
	cin >> a >> b >> c >> x >> y;
	// plan1
	int m = min(x, y);
	ll result1 = m * c * 2;
	if (x > m) {
		result1 += (x - m) * a;
	}
	if (y > m) {
		result1 += (y - m) * b;
	}

	int ma = max(x, y);
	ll result3 = ma * c * 2;

	ll result2 = a * x + b * y;

	result2 = min(result3, result2);

	cout << min(result1, result2) << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
ll a,b;
  cin>>b>>a;
  if(b-2*a>0)
    cout<<b-2*a;
  else
    cout<<"0";
  return 0;
}
  

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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(3*N);
    rep(i, 0, 3*N) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = 0;
    for(ll i = 1; i < 2*N; i+=2){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

const int MAXN = 105;

int n, a[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	
	int res = 0;
	for(int i = 0; i + 1 < n; ){
		if(a[i] == a[i + 1]){
			res++;
			i += 2;
		}else{
			i++;
		}
	}
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 3760
K = int(input())
ans = [i for i in range(50)]
cnt = 0
loop = K%50
plus = K//50
ans = list(map(lambda x: x+plus, ans))
for i in range(loop):
    cnt%=50
    ans = list(map(lambda x: x-1, ans))
    ans[cnt] += 51
    cnt+=1
print(50)
print(*ans)

Measured memory_bytes: 9128
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int MX=200011,inf=0x3f3f3f3f,md=1000000007;
typedef long long LL;

int n,x,y;
int c[MX],w[MX],cnt[MX];
int bel[MX],mnw[MX],mnno[MX],mn,smn,mnc,smnc;
int fac[MX],facinv[MX],inv[MX];
int hed[MX],nxt[MX],t[MX];

inline int Bel(int x){return bel[x]==x?x:(bel[x]=Bel(bel[x]));}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++)scanf("%d%d",&c[i],&w[i]);
	memset(mnw+1,inf,sizeof(int)*n);
	for(int i=1;i<=n;i++)if(mnw[c[i]]>w[i])mnw[c[i]]=w[i],mnno[c[i]]=i;
	mn=smn=inf;
	for(int i=1;i<=n;i++)if(mnw[i]<smn){
		smn=mnw[i];smnc=i;
		if(smn<mn)swap(mn,smn),swap(mnc,smnc);
	}
	for(int i=1;i<=n;i++){
		if(c[i]!=mnc){
			if(mn+w[i]<=y){
				bel[i]=mnno[mnc];continue;
			}
			else if(mnw[c[i]]+w[i]<=x){
				bel[i]=mnno[c[i]];continue;
			}
		}else{
			if(mn+w[i]<=x||smn+w[i]<=y){
				bel[i]=mnno[mnc];continue;
			}
		}
		
		bel[i]=i;
	}
	for(int i=1;i<=n;i++)++cnt[Bel(i)],nxt[i]=hed[Bel(i)],hed[Bel(i)]=i;
	int ans=1;
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=(LL)fac[i-1]*i%md;
	inv[1]=1;
	for(int i=2;i<=n;i++)inv[i]=(LL)(md-md/i)*inv[md%i]%md;
	facinv[0]=1;
	for(int i=1;i<=n;i++)facinv[i]=(LL)facinv[i-1]*inv[i]%md;
	for(int i=1;i<=n;i++){
		ans=(LL)ans*fac[cnt[i]]%md;
		for(int j=hed[i];j;j=nxt[j])++t[c[j]];
		for(int j=hed[i];j;j=nxt[j])ans=(LL)ans*facinv[t[c[j]]]%md,t[c[j]]=0;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n,m; cin >> n >> m;
    vector<vector<int>> A(n,vector<int>(m));
    vector<int> b(m);
    vector<int> ans(n,0);

    rep(i,n)rep(j,m) cin >> A.at(i).at(j);
    rep(i,m) cin >> b.at(i);

    rep(i,n){
        rep(j,m){
            ans.at(i) += A.at(i).at(j)*b.at(j);
        }
    }
    rep(i,n) cout << ans.at(i) << endl;
    return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int ans;
string s,a;
int main()
{
	getline(cin,s);
	a="CODEFESTIVAL2016"; 
	for(int i=0;i<s.size();i++)
		if(s[i]!=a[i]) ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]

ans = 'No'
for i in range(n - m + 1):
    for j in range(n - m + 1):
        C = []
        for k in range(m):
            C.append(A[i + k][j : j + m])
        if B == C:
            ans = 'Yes'
            break
            
print(ans)

Measured memory_bytes: 3064
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

N,T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if t[i+1] < t[i]+T: ans += (t[i+1]-t[i])
    else: ans += T
ans += T

print(ans)

Measured memory_bytes: 34236