akhauriyash/Code-Regression huggingface dataset:
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    LL n;   
    cin >> n;
    if(n == 2) {

        cout<<1<<endl;
        return 0;
    }
    LL ans = 2;
    for(LL i = 2; i * i <= n; ++i){
        if(n % i == 0){
            LL  x = i, y = n / i;
            while(y % x == 0) y /= x;
            if(y % x == 1) ans++;
        }
    }
    n--;
    for(LL i = 2; i * i <= n; ++i){
        if(n%i==0){
            ans+=1;
            if(i * i != n) ans += 1;
        }
    }
    cout << ans<< endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)1e9+7
#define eb emplace_back
#define eps 1e-10

/*
 
 1. 1変数だけ変化
 5
 2 2 3
 2 2 2
 bで銅2買う どんぐり-4
 aでで銅3買う どんぐり+6
 
 今回は1つだけ変わる 単純
 
 2. 2つ以上変わりうる
 a -> b, b -> aで分ける
 
 a -> bで上がるかだけ見る
 
 2変数以上の場合
 
 2変数(銅と金とする)
 両方をいい具合に選ばないといけないケースがありうる
 
 ax + by を最大化
 a : 銅に関して上がり具合
 b : 金に関して上がり具合
 x, y : 整数 どんぐりの割り当て
 
 ax + by = k
 x + y <= N
 領域の最大最小解いたらk = aNってなった
 a小数になったら詰む
 
 上がり具合って小数でる
 嫌
 
 売る、買うを別々にする
 
 xに関してループ回せばy決まる
 
 3. 3変数
 ax + by + cz を最大化
 
 */
ll a[3], b[3];
ll calc(vector<ll> sell, vector<ll> buy, ll N) {
    if (sell.size() == 0) return N;
    else if (sell.size() == 1) {
        return (N / sell[0] * buy[0] + N % sell[0]);
    } else if (sell.size() == 2) {
        ll ret = N;
        for (ll x = 0; x * sell[0] <= N; ++x) {
            ll rest = N - x * sell[0];
            chmax(ret, x * buy[0] + rest / sell[1] * buy[1] + rest % sell[1]);
        }
        return ret;
    } else if (sell.size() == 3) {
        ll ret = N;
        for (ll x = 0; x * sell[0] <= N; ++x) {
            for (ll y = 0; x * sell[0] + y * sell[1] <= N; ++y) {
                ll rest = N - x * sell[0] - y * sell[1];
                chmax(ret, x * buy[0] + y * buy[1] + rest / sell[2] * buy[2] + rest % sell[2]);
            }
        }
        return ret;
    }
    return N;
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    rep(i, 3) cin >> a[i]; rep(i, 3) cin >> b[i];
    vector<ll> sell, buy;
    //a -> b
    rep(i, 3) {
        if (a[i] < b[i]) {
            sell.eb(a[i]);
            buy.eb(b[i]);
        }
    }
    N = calc(sell, buy, N);
    sell.clear(); buy.clear();
    //b -> a
    rep(i, 3) {
        if (b[i] < a[i]) {
            sell.eb(b[i]);
            buy.eb(a[i]);
        }
    }
    cout << calc(sell, buy, N) << endl;
}




Measured memory_bytes: 256
S = input()
Q = int(input())

front = ""
end = ""
f = 0
for i in range(Q):
    query = input().split()

    if query[0] == "1":
        if f == 0:
            f = 1
        else:
            f = 0
    else:
        if f == 0:
            if query[1] == "1":
                front = query[2] + front
            else:
                end = end + query[2]
        else:
            if query[1] == "2":
                front = query[2] + front
            else:
                end = end + query[2]

S = front + S + end
if f == 1:
    S = S[::-1]
print(S)

Measured memory_bytes: 4572
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#include <algorithm>
#include <limits>
#include <math.h>

using namespace std;
#define iter(b) for(int i = 0;i < (b);i++)
#define VVI vector<vector<int>>
#define VI vector<int>
#define ll long long

int main()
{
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    if(A > B) swap(A, B);

    if(W >= V) cout << "NO";
    else{
        cout << (A + T * V >= B + T * W ? "YES" : "NO");
    }
}


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    rep(i, n) {
        scanf("%d", &a[i]);
    }

    vector<int> a_copy = a;
    sort(a.begin(), a.end());
    rep(i, n) {
        if (a_copy[i] != a[n-1]) {
            printf("%d\n", a[n-1]);
        } else {
            printf("%d\n", a[n-2]);
        }
    }
}

Measured memory_bytes: 4868
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 054d
int main(){
    int n;
    string s;
    cin >> n >> s;
    int l=0, r=0;
    rep(i, n){
        char tmp = s[i];
        if (r>0 and tmp==')') r--;
        else if (tmp=='(') r++;
    }

    for(int i=n-1; i>=0; i--){
        char tmp = s[i];
        if(l>0 and tmp=='(') l--;
        else if (tmp==')') l++;
    }

    rep(i, l) cout << '(';
    cout << s;
    rep(i, r) cout << ')';
    return 0;
}


Measured memory_bytes: 256
// 無理矢理感...

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

int main() {
  string t;
  vector<int> td(4), rl(8);
  int sum = 0, i;
  cin >> t;
  
  for(int i=0; i<4; i++)
    td.at(i) = t.at(i) - '0';
  
  rl.at(0) = td.at(0) - td.at(1) - td.at(2) - td.at(3);
  rl.at(1) = td.at(0) - td.at(1) - td.at(2) + td.at(3);
  rl.at(2) = td.at(0) - td.at(1) + td.at(2) - td.at(3);
  rl.at(3) = td.at(0) - td.at(1) + td.at(2) + td.at(3);
  rl.at(4) = td.at(0) + td.at(1) - td.at(2) - td.at(3);
  rl.at(5) = td.at(0) + td.at(1) - td.at(2) + td.at(3);
  rl.at(6) = td.at(0) + td.at(1) + td.at(2) - td.at(3);
  rl.at(7) = td.at(0) + td.at(1) + td.at(2) + td.at(3);
  
  for(i=0; i<8; i++)
    if(rl.at(i) == 7)
      break;
  
  vector<int> n2(3);
  n2.at(2) = i % 2;
  i /= 2;
  n2.at(1) = i % 2;
  n2.at(0) = i / 2;
  i = 0;
  
  for(char c : t) {
    cout << c;
    if(i<3)
      if(n2.at(i) == 1)
        cout << '+';
      else
        cout << '-';
    i++;
  }
  
  cout << "=7" << endl;
}

Measured memory_bytes: 256
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: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::BinaryHeap;

fn main() {
    let n: u32 = read();
    println!("{}", n * n * n);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int dp[1000001], dp_odd[1000001];

signed main()
{
    omajinai;

    vi tet, tet_odd;

    for (int i = 1; ; ++i) {
        tet.PB(i * (i + 1) * (i + 2) / 6);
        if (tet.back() >= 1000000) break;
    }

    for (int i = 0; i < tet.size(); ++i) {
        if (tet[i] & 1) tet_odd.PB(tet[i]);
    }

    for (int i = 1; i <= 1000000; ++i) dp[i] = dp_odd[i] = inf;

    for (int i = 1; i <= 1000000; ++i) {
        for (int j = 0; j < tet.size(); ++j) {
            if (i >= tet[j]) {
                dp[i] = min(dp[i], dp[i - tet[j]] + 1);
            }
            if (i < tet[j]) break;
        }

        for (int j = 0; j < tet_odd.size(); ++j) {
            if (i >= tet_odd[j]) {
                dp_odd[i] = min(dp_odd[i], dp_odd[i - tet_odd[j]] + 1);
            }
            if (i < tet_odd[j]) break;
        }
    }

    int N;
    while (cin >> N, N) cout << dp[N] << ' ' << dp_odd[N] << endl;
}

Measured memory_bytes: 9032
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

dp = [0 for _ in range(K+100)]

for i in range(K+1):
    flg = False
    for a in A:
        if i-a >= 0 and dp[i-a] == -1:
            flg = True
    if flg:
        dp[i] = 1
    else:
        dp[i] = -1

if dp[K] == 1:
    print('First')
else:
    print('Second')


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);



void solve()
{
    int c[4][4];
    REP(i, 3) REP(j, 3) cin >> c[i+1][j+1];
    for(int a1 = 0; a1 <= 100; a1++){
        int b1 = c[1][1] - a1;
        int b2 = c[1][2] - a1;
        int b3 = c[1][3] - a1;
        if(c[2][1] - b1 == c[2][2] - b2 && c[2][2] - b2 == c[2][3] - b3){
            if(c[3][1] - b1 == c[3][2] - b2 && c[3][2] - b2 == c[3][3] - b3){
                cout << "Yes" << "\n";
                return;
            }
        }
    }
    cout << "No" << "\n";
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

int d1[2505][10005]; // [i+1, i]
int d2[2505][10005]; // [i, i]
int n, k, x, a[2505];

int main(){
	for(int i=0; i<=2500; i++){
		int s[10005] = {};
		if(i > 0){
			for(int j=1; j<=10000; j++) s[j] = (s[j-1] + d1[i-1][j]) % mod;
		}
		for(int j=1; j<=10000; j++){
			if(j <= 2 * i + 1) d2[i][j]++;
			d2[i][j] += s[j-1] - s[max(0, j-2*i-1)] + mod;
			d2[i][j] %= mod;
		}
		for(int j=1; j<=10000; j++) s[j] = (s[j-1] + d2[i][j]) % mod;
		for(int j=1; j<=10000; j++){
			if(j <= 2 * i + 2) d1[i][j]++;
			d1[i][j] += s[j-1] - s[max(0, j-2*i-3)] + mod;
			d1[i][j] %= mod;
		}
	}
	cin >> n >> k >> x;
	for(int i=0; i<k; i++) cin >> a[i];
	lint ret = 1;
	for(int i=1; i<k; i++){
		if(x - i < 0) ret = 0;
		else ret *= d1[x-i][a[i] - a[i-1]];
		ret %= mod;
	}
	cout << ret << endl;
}


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

using namespace std;

typedef long long ll;

ll ai, ao, at, aj, al, as, az, ans;

int main() {
    cin >> ai >> ao >> at >> aj >> al >> as >> az;

    if(aj > 0 && al > 0 && ai > 0) {
        ans = max(ans, ((ai - 1) / 2) * 2 + 3 + ao + ((aj - 1) / 2) * 2 + ((al - 1) / 2) * 2);
    }

    ans = max(ans, (ai / 2) * 2 + ao + (aj / 2) * 2 + (al / 2) * 2);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
xyz_list = N.times.map { gets.split.map(&:to_i) }
ans = [
  xyz_list.map { |x, y, z| x + y + z }.sort_by { |n| -n }.take(M).reduce(0, &:+),
  xyz_list.map { |x, y, z| x + y - z }.sort_by { |n| -n }.take(M).reduce(0, &:+),
  xyz_list.map { |x, y, z| x - y + z }.sort_by { |n| -n }.take(M).reduce(0, &:+),
  xyz_list.map { |x, y, z| x - y - z }.sort_by { |n| -n }.take(M).reduce(0, &:+),
  xyz_list.map { |x, y, z| -x + y + z }.sort_by { |n| -n }.take(M).reduce(0, &:+),
  xyz_list.map { |x, y, z| -x + y - z }.sort_by { |n| -n }.take(M).reduce(0, &:+),
  xyz_list.map { |x, y, z| -x - y + z }.sort_by { |n| -n }.take(M).reduce(0, &:+),
  xyz_list.map { |x, y, z| -x - y - z }.sort_by { |n| -n }.take(M).reduce(0, &:+),
].max
puts ans


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

int c(char s,char t){
    int ret = 0;
    ret += (int)(s-'0')*10 + (int)(t-'0');
    return ret;
}

bool tw(int a){
    return (1<=a && a<=12);
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int a = c(s[0],s[1]);
    int b = c(s[2],s[3]);
    if(tw(a)&&tw(b)){cout<<"AMBIGUOUS";return 0;}
    else if(tw(a)){cout<<"MMYY";return 0;}
    else if(tw(b)){cout<<"YYMM";return 0;}
    else{cout<<"NA";return 0;}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
int calcScore(vector<int> &plan, vector<int> &c, vector<vector<int>> &s) {
	int D = 365;
	int score = 0;
	vector<int> last(26, -1);
	for (int i = 0; i < D; i++) {
		score += s[i][plan[i]];
		last[plan[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= c[j] * (i - last[j]);
		}
	}
	return score;
}
 
int main() {
	int D;
	cin >> D;
	vector<int> c(26);
	for (int i = 0; i < 26; i++)cin >> c[i];
	vector<vector<int>> s(365,vector<int>(26,0));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++)cin >> s[i][j];
	}
	
	vector<int> plan(365, 0);
	for (int i = 0; i < 365; i++) {
		int mi = 0, m = -1;
		for (int j = 0; j < 26; j++) {
			if (m < s[i][j]) {
				mi = j;
				m = s[i][j];
			}
		}
        plan[i] = mi;
	}
	int sc = calcScore(plan, c, s);
 
	for (int n = 0; n < 300000; n++) {
		if (rand() % 10 < 4) {
			int i = rand() % 365, j = rand() % 26, old = plan[i];
			plan[i] = j;
			int nsc = calcScore(plan, c, s);
			if (nsc > sc) {
				sc = nsc;
			}
			else {
				plan[i] = old;
			}
		}
		else {
			int k = rand() % 5;
			int i = rand() % (365 - k), j = i + k;
			swap(plan[i], plan[j]);
			int nsc = calcScore(plan, c, s);
			if (nsc > sc) {
				sc = nsc;
			}
			else {
				swap(plan[i], plan[j]);
			}
		}
	}
 
	for (int i = 0; i < 365; i++) {
		cout << plan[i] + 1 << endl;
	}
}


Measured memory_bytes: 3684
k,n = map(lambda x:int(x),input().split())
a = list(map(lambda x:int(x),input().split()))
maxdist = a[0]+(k-a[len(a)-1])
for i in range(1,n):
  maxdist = max(maxdist,a[i]-a[i-1])
print(k-maxdist)

Measured memory_bytes: 26420
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    ll count = 0, MAX = a+b, over = 0;
    for(ll i = 0; i < n; i++){
        if(s[i]=='c')
            cout << "No" << endl;
        else if(s[i]=='a'&&count<MAX){
            cout << "Yes" << endl;
            count++;
        }
        else if(s[i]=='a'&&count>=MAX)
            cout << "No" << endl;
        else if(s[i]=='a'&&count<MAX){
            cout << "Yes" << endl;
            count++;
        }
        else if(s[i]=='b'&&count<MAX && over<b){
            cout << "Yes" << endl;
            count++; over++;
        }
        else if(s[i]=='b'&&count>=MAX || s[i]=='b'&&over>=b)
            cout << "No" << endl;
       //cout << count << " " << over << endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int w,n;
	int l1, l2;
	int ans[30];
	int i;
	
	scanf("%d %d", &w, &n);
	
	for (i = 0; i < w; i++){
		ans[i] = i + 1;
	}
	
	while (n){
		scanf("%d%*c%d", &l1, &l2);
		
		ans[l1 - 1] += ans[l2 - 1];
		ans[l2 - 1] = ans[l1 - 1] - ans[l2 - 1];
		ans[l1 - 1] -= ans[l2 - 1];
		
		n--;
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", ans[i]);
	}
	
	return (0);
}

Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;


int zeller(int y , int m , int d){
	if(m==1 || m==2) {m+=12; y-=1;}
	return(y + y/4 - y/100 + y/400 + ((13*m+8)/5) + d )%7;
}

int main(){
	int m , d , w=4 , fw;
	while (cin >> m >> d, m){
		switch(zeller(2004,m,d)){
			case 0:
			cout << "Sunday" << endl;
			break;
			case 1:
			cout << "Monday" << endl;
			break;
			case 2:
			cout << "Tuesday" << endl;
			break;
			case 3:
			cout << "Wednesday" << endl;
			break;
			case 4:
			cout << "Thursday" << endl;
			break;
			case 5:
			cout << "Friday" << endl;
			break;
			case 6:
			cout << "Saturday" << endl;
		}
	}
	return 0; 
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall

	ins(a);
	if(a[2] == a[3] and a[4] == a[5])out("Yes");
	else out("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define repd(i,a,b) for (int i=a;i<int(b);i++)
#define rep(i,n) repd(i,0,n)
#define VARNAME(v) #v
using P = pair<int,int>;


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  constexpr int BEAM = 500;
  int d;vector<int> c(26);cin>>d;rep(i,26)cin>>c[i];
  vector<vector<int>> s(d, vector<int>(26));
  rep(i,d)rep(j,26)cin>>s[i][j];
  vector<int> curs = {0};
  vector<vector<int>> curl(1, vector(26, 0));
  vector<vector<int>> cura(1);
  rep(i,d){
    vector<P> nxs;
    vector<vector<int>> nxl;
    vector<vector<int>> nxa;
    rep(j, curs.size()){
      rep(t, 26){
        int score = curs[j];
        vector<int> last = curl[j], ans = cura[j];
        score += s[i][t];
        last[t] = i+1;
        rep(k,26)score -= c[k]*(i+1 - last[k]);
        ans.emplace_back(t);
        nxs.emplace_back(P(score, nxs.size()));
        nxl.emplace_back(last);
        nxa.emplace_back(ans);
      }
    }
    sort(nxs.rbegin(), nxs.rend());
    curs.resize(0);curl.resize(0);cura.resize(0);
    rep(j,min(int(nxs.size()), BEAM)){
      curs.emplace_back(nxs[j].first);
      curl.emplace_back(nxl[nxs[j].second]);
      cura.emplace_back(nxa[nxs[j].second]);
    }
  }
  int ans = 0;
  rep(i,min(int(curs.size()), BEAM)){
    if(curs[ans] < curs[i])ans = i;
  }

  for(auto x : cura[ans]){
    cout << x+1 << endl;
  }
}


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

using namespace std ;

int main()
{
	int n ;
	while( cin >> n ,n )
	{
		int m ;
		cin >> m ;
		int num[ n ] ;
		for( int i  = 0 ; i < n ; i++ )
			cin >> num[ i ] ;
		int ans = 0 ;
		for( int i  = 0 ; i < n ; i++ )
		{
			int cnt = 0 ;
			for( int j = i ; j < m + i && m + i < n ; j++ )
				cnt += num[ j ] ;
			ans = max( ans ,cnt ) ;
		}
		cout << ans << endl ;
	}
	return 0 ;
}

Measured memory_bytes: 3400
#include <iostream>

using namespace std;

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

	//1 <= N <= 100
	//Sは英小文字から成る
	//|S| = N
	string s;
	cin >> s;

	//2つに割って、くらべりゃいいのか
	int len = n;
	//int len = s.length();
	int halfLen = len / 2;

	string s1 = s.substr(0, halfLen);
	string s2 = s.substr(halfLen, len);
	

	if (s1 == s2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;

	}

	return 0;
}

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

using namespace std;

int main() {
	int n , x ,t;
	ios::sync_with_stdio(0);
	cin >> n >> x >> t;
	int tmp =n / x + ( ( n % x == 0 ) ? 0 : 1 ); 
	cout << tmp * t << "\n";
	return 0;
}

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

using namespace std;
using i64 = int64_t;

signed main(){
    
    int h1, h2, k1, k2, a, b, c, d;
    cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
    
    int p = a * h1 + b * h2 + c * (h1 / 10) + d * (h2 / 20);
    int q = a * k1 + b * k2 + c * (k1 / 10) + d * (k2 / 20);
    if(p > q){
        cout << "hiroshi" << endl;
    }else if(p < q){
        cout << "kenjiro" << endl;
    }else{
        cout << "even" << endl;
    }
    
    return 0;
}


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

int main()
{
    string S;
    cin >> S;
    long long ans = 0;
    int c = 0;
    int i = 0;
    while ( i < S.size() - 1)
    {
        if (S[i] == 'A')
            c ++;
        else if (S[i] == 'B' and S[i + 1] == 'C')
        {
            ans += c;
            i ++;
        }
        else
            c = 0;
        i ++;
    }
    cout << ans << endl;
  	return 0;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	string s;
	cin >> s;
	cout << string(s.length(), 'x') << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ll long long
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define lowbit(x) (x&-x)
#define ms(x,a) memset(x,a,sizeof x)
using namespace std;
template <class T> inline bool Max(T &x, T y){
	return x<y?x=y,1:0;
}
template <class T> inline bool Min(T &x, T y){
	return x>y?x=y,1:0;
}
template <class T> inline T rd() {
	static char ch;static bool neg;
	static T x=0;
	for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
	for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
	return x=(neg?-x:x);
}
const int mod=1e9+7,oo=1e9;

int main(){
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	int n=rd<int>();
	if(n<10) printf("%d\n",n);
	else if(n>=10 && n<100) printf("9\n");
	else if(n>=100 && n<1000) printf("%d\n",10+n-100);
	else if(n>=1000 && n<10000) printf("909\n");
	else if(n>=10000 && n<100000) printf("%d\n",910+n-10000);
	else if(n==100000) printf("90909\n");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5504
using System;

public class Hello
{
    public static void Main()
    {
        var team = new char[] { 'A', 'B', 'C', 'D', 'E' };
        while (true)
        {
            var amax  = -1; char amaxt = ' ';
            for (int i = 0; i < 5; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var a1 = int.Parse(line[0]);
                var a2 = int.Parse(line[1]);
                if (a1 == 0 && a2 == 0) goto end;
                if (a1 + a2 > amax) { amax = a1 + a2; amaxt = team[i]; }
            }
            Console.WriteLine("{0} {1}", amaxt, amax);
        }
        end:;
    }
}

Measured memory_bytes: 9248
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String s = next();
    String t = next();

    int a = nextInt();
    int b = nextInt();

    String u = next();

    if(u.equals(s)){
      System.out.println((a-1)+" "+b);
    }
    else{
      System.out.println(a+" "+(b-1));
    }



    //System.out.println();

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1LL<<60;
const int INF = 1LL<<17;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll bit[500500];
ll n;
#define N 500010

ll sum(ll i){
    ll res=0;
    while(0<i){
        res += bit[i];
        i -= i&-i;
    }
    return res;
}
void add(ll i, ll x){
    while(i<=n){
        bit[i] += x;
        i += i&-i;
    }
}


ll rsum(ll l, ll r){
    return sum(r)-sum(l-1);
}
vector<vector<ll>> qr(N), qri(N);
vector<ll>  res(N);
int main(){
    ll q;   cin >> n >> q;

    vector<ll> c(n+1);
    rep(i, n) cin >> c[i+1];
    vector<ll> a(N);
    rep(i, q){
        ll a, b;    cin >> a >> b;
        qr[b].push_back(a);
        qri[b].push_back(i);
    }

    FOR(i, 1, n+1){
        if(a[c[i]]>0) add(a[c[i]], -1);
        add(i, 1);
        a[c[i]] = i;
        rep(j, qr[i].size()){
            res[qri[i][j]] = rsum(qr[i][j], i);
        }
    }
    rep(i, q) cout << res[i] << endl;
}


Measured memory_bytes: 62652
#include <bits/stdc++.h>
 using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
typedef double ld;
//#define For(i,0,n) for(long long i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
		
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}

long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}


//TEMPLATE ENDS HERE!!!! ------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------------















struct custom
{
	bool operator()(ll a, ll b)
	{
		return a > b;
	}
};

// struct triplet{

// 	ll a;
// 	ll b;
// 	ll c;
// };
int main()
 {
		
		// ios_base::sync_with_stdio(false);
		// cin.tie(NULL);
		// cout.tie(NULL);
 		
 	ll x,y,z,maxk;
 	cin>>x>>y>>z>>maxk;
 	ll a[x+1],b[y+1],c[z+1];
 	map <pair<pair<ll,ll>,ll>,ll> is_there;
 	vector <pair<pair<ll,ll>,ll>> allposs;
 	
 	for(ll i=1 ; i<=x ;i++)
 	cin>>a[i];
 	for(ll i=1 ; i<=y ;i++)
 	cin>>b[i];
 	for(ll i=1 ; i<=z ;i++)
 	cin>>c[i];
 	sort(a+1,a+x+1,greater<>());
 	sort(b+1,b+y+1,greater<>());
 	sort(c+1,c+z+1,greater<>());
 	for(ll i=1 ; i<=x ; i++ )
 		{
 			if(i>maxk)
 				break;
 			for(ll j=1 ; j<=y ;j++)
 			{
 				// if(i*j > maxk)
 				// 	break;
 				for(ll k=1;k<=z ;k++)
 				{
 					if(i*j*k> maxk)
 						break;
 					else
 					{
 						pair<pair<ll,ll>,ll> trip;
 						trip.ff.ff = i;
 						trip.ff.ss=j;
 						trip.ss=k;

 						if(!is_there[trip])
 						{
 							allposs.pb(trip);
 							is_there[trip]++;
 						}
 					}
 				}
 			}
 		}
 	vector <ll> ans;
 	for(ll i=0 ;i<allposs.size();i++)
 	{
 		ll m1 = allposs[i].ff.ff;
 		ll m2 = allposs[i].ff.ss;
 		ll m3 =allposs[i].ss;
 		ans.pb(a[m1]+b[m2]+c[m3]);
 	}

 	sort(ans.begin(),ans.end(),greater<>());

 	for(ll i=0 ;i<maxk ;i++)
 	cout<<ans[i]<<'\n';			


	//cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 13104
N,M = map(int,input().split())

war = [float('inf')]*N

for i in range(M):
    a,b = map(int,input().split())
    war[a-1] = min(war[a-1],b-1)

ans = 0
cat = float('inf')
for i in range(N):
    if i == cat:
        ans += 1
        cat = float('inf')
    cat = min(cat,war[i])
print(ans)

Measured memory_bytes: 6900
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n;
    cin >> n;
    vec<int> v(n), c(n);
    for (auto& e : v)
    {
        cin >> e;
    }
    for (auto& e : c)
    {
        cin >> e;
    }

    int ans {};

    for (int i = 0; i < n; ++i)
    {
        if (v[i] - c[i] > 0)
            ans += v[i] - c[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N,M,Q=map(int,input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
  a[i], b[i], c[i], d[i]= map(int, input().split())

S=0
temp=0
A=[1] * N

while A[0]!=M:
  for k in range(Q):
    if A[b[k]-1]-A[a[k]-1]==c[k]:
      temp+=d[k]
  if temp>S:
    S=temp
  temp=0
  for i in range(1,N+1):
    if A[N-i]!=M:
      for j in range(1,i+1):
        A[N-j]=A[N-i]+1
      break

A=[M]*N
for k in range(Q):
  if A[b[k]-1]-A[a[k]-1]==c[k]:
    temp+=d[k]
if temp>S:
  S=temp
  
print(S)

Measured memory_bytes: 9260
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }
    else{
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
static const int mod = 1e+7;
static const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    int x,a;
    cin >> x >> a;
    if(x<a){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100010
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
int n;
int A[N],B[N],fa[N];
int vis[N];
int suma,sumb;
vector<int>vec1,vec2;
int find(int x) { return fa[x]=fa[x]==x?x:find(fa[x]); }
int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(A[i]),suma^=A[i],vec1.push_back(A[i]);
	for(int i=1;i<=n;i++) read(B[i]),sumb^=B[i],vec2.push_back(B[i]);
	A[n+1]=suma;B[n+1]=sumb;
	vec1.push_back(suma);vec2.push_back(sumb);
	sort(vec1.begin(),vec1.end()); sort(vec2.begin(),vec2.end());
	for(int i=0;i<=n;i++)
		if(vec1[i]!=vec2[i])return puts("-1"),0;
	vec1.erase(unique(vec1.begin(),vec1.end()),vec1.end());
	vec2.erase(unique(vec2.begin(),vec2.end()),vec2.end());
	for(int i=1;i<=n+1;i++) A[i]=lower_bound(vec1.begin(),vec1.end(),A[i])-vec1.begin()+1;
	for(int i=1;i<=n+1;i++) B[i]=lower_bound(vec2.begin(),vec2.end(),B[i])-vec2.begin()+1,fa[i]=i;
	for(int i=1;i<=n+1;i++)
		if(A[i]!=B[i])
			if(find(A[i])!=find(B[i])) fa[find(A[i])]=find(B[i]);
	int sum=0,ans=0;
	for(int i=1;i<=n;i++)
		if(A[i]!=B[i])ans++,vis[A[i]]=vis[B[i]]=1;
	vis[A[n+1]]=vis[B[n+1]]=1;
	for(int i=1;i<=n+1;i++)
		if(vis[i]&&find(i)==i)++sum;
	cout<<ans+max(0,sum-1)<<endl;
	return 0;
}

Measured memory_bytes: 4216
#include<iostream>
#include<string>
using namespace std; 
int main(void){ 
	long a,b,c,d,ans;
	cin >> a >> b;
	for(int i=0;i<2000;i++){
		if((int)(i*0.08) == a && (int)(i*0.1) == b){
			cout << i;
			return 0;
		}
	}
	cout <<"-1";
	return 0;
}

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

void solve();
string s;
int yes[9][4]={1,3,-1,-1,0,2,4,-1,1,5,-1,-1,0,4,6,-1,1,3,5,7,2,4,8,-1,3,7,-1,-1,4,6,8,-1,5,7,-1,-1};

int main(){
  int i,j;
  /*for(i=0;i<9;i++){
    for(j=0;j<4;j++)cout << yes[i][j]<<' ';
    cout << endl;
    }*/
  for(i=0;i<1000;i++){
    cin >> s;
    solve();
  }
  return 0;
}

void solve(){
  int bf=s[0]-'A',now,i,j;
  bool ch;
  for(i=1;i<s.size();i++){
    now = s[i]-'A';
    //cout <<bf<<' '<<now<<endl;
    ch = 0;
    for(j=0;j<4;j++)if(yes[bf][j]==now)ch++;
    if(ch==0)return;
    bf = now;
  }
  cout << s << endl;
}



Measured memory_bytes: 3200
n, m, x = map(int, input().split())
a = [[] for i in range(n)]
c = [0] * n
for i in range(n):
	c[i], *a[i] = map(int, input().split())
ans = 1e9
for mask in range(2 ** n):
	cost = 0
	b = [0] * m
	for i in range(n):
		if mask & (1 << i):
			cost += c[i]
			for j in range(m):
				b[j] += a[i][j]
	cnt = True
	for j in range(m):
		cnt &= b[j] >= x
	if cnt:
		ans = min(ans, cost)
			
if ans < 1e9:
	print(ans) 
else:
	print(-1)


Measured memory_bytes: 9228
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;
const double pi = 3.141592653589793;

int main(){
  int n;
  cin >> n;
  ll p[n];
  rep(i,n)cin >> p[i];
  ll q[n];
  rep(i,n)q[p[i]-1]=i+1;
  ll a[n]={},b[n]={};
  rep(i,n){
    a[i]=20001*i+q[i];
    b[i]=-20001*i+20001*20001;
  }
  rep(i,n)cout << a[i] << ' ';
  cout << endl;
  rep(i,n)cout << b[i] << ' ';
  cout << endl;
return 0;}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18



int main(){
  int N; cin >> N;
  vector<int> W(N);
  rep(i,N){
    cin >> W[i];
  }
  int sum = 0;
  rep(i,N){
    sum += W[i];
  }
  int ans = INF;
  rep(i,N-1){
    int sum1 = 0;
    repr(j,i+1,N){
      sum1 += W[j];
    }
    ans = min(ans,abs((sum-sum1) - sum1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	string st;
	cin >> st;
	if(st == "ABC")
		cout << "ARC" << endl;
	else	
		cout << "ABC" << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
struct __orz_newbie314159_akioi__{
	int m,inv,a[50010],t[50010];
	void update(int x){while(x<=m)++t[x],x+=x&-x;}
	int query(int x){int r=0;while(x)r+=t[x],x-=x&-x;return r;}
	ll rev;
	void fuck(){
		//1-m -> a
		for(int i=m;i;--i)rev+=query(a[i]),update(a[i]);
	}
}A[2];
int _a[3][100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=0;i<3;++i)for(int j=1;j<=n;++j)_a[i][j]=gi();
	for(int i=1;i<=n;++i){
		if(std::max(abs(_a[0][i]-_a[1][i]),abs(_a[1][i]-_a[2][i]))>1)return puts("No"),0;
		int col=(std::min(_a[0][i],_a[2][i])-1)/3+1;
		if(std::max(_a[0][i],_a[2][i])!=col*3||_a[1][i]!=col*3-1)return puts("No"),0;
		if(col-i&1)return puts("No"),0;
		A[i&1].inv+=_a[0][i]>_a[2][i];
		A[i&1].a[++A[i&1].m]=col+1>>1;
	}
	A[0].fuck(),A[1].fuck();
	if(A[0].rev-A[1].inv&1)return puts("No"),0;
	if(A[0].inv-A[1].rev&1)return puts("No"),0;
	puts("Yes");
	return 0;
}


Measured memory_bytes: 2304
while 1:
    try:
        a,b,c,d,e,f = map(float, input().split(" "))
        det = a*e-b*d
        x = (c*e-b*f)/det
        y = (a*f-c*d)/det
        if abs(x) < 0.0001:
            x = 0.0
        if abs(y) < 0.0001:
            y = 0.0
        print("{0:.3f}".format(x),"{0:.3f}".format(y))
    except:
        break


Measured memory_bytes: 5588
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)
if s == t:
    print("No")
    exit()
S = ""
T = ""
for i in s:
    S += i
for i in t:
    T += i

lst1 = [S,T]
lst2 = lst1[:]

lst2.sort()

if lst1 == lst2:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int N; cin >> N;
    vector<int>T(N);
    int ans = 0;
    rep(i, N) {
        cin >> T[i];
        ans += T[i];
    }
    int M; cin >> M;
    vector<int>P(M);
    vector<int>X(M);
    rep(i, M) {
        cin >> P[i] >> X[i];
        cout << ans - T[P[i]-1] + X[i] << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

const int MAXN = 300010;

int n;
int a[MAXN];
ll s[MAXN], t[MAXN];

int main()
{
	
	scanf("%d", &n);
	for (int i = 1; i <= 3*n; ++ i)
		scanf("%d", &a[i]);
	
	{
	priority_queue<int, vector<int>, greater<int> > Q;
	ll cur = 0;
	for (int i = 1; i <= 3*n; ++ i)
	{
		if (i <= n)
		{
			cur += a[i];
			Q.push(a[i]);
			s[i] = cur;
			continue;
		}
		if (Q.top()<a[i])
		{
			cur += a[i]-Q.top();
			Q.pop();
			Q.push(a[i]);
		}
		s[i] = cur;
	}
	}
	
	{
	priority_queue<int> Q;
	ll cur = 0;
	for (int i = 3*n; i >= 1; -- i)
	{
		if (i > 2*n)
		{
			cur += a[i];
			Q.push(a[i]);
			t[i] = cur;
			continue;
		}
		if (Q.top()>a[i])
		{
			cur += a[i]-Q.top();
			Q.pop();
			Q.push(a[i]);
		}
		t[i] = cur;
	}
	}
	
	ll ans = -10000000000000000LL;
	for (int i = n; i <= 2*n; ++ i)
		ans = max(ans, s[i]-t[i+1]);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 7028
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	int n,d;
  	cin >> n >> d;
  	// 1 人で (2d+1) の木を監視できる	
  	cout << (n+2*d)/(2*d+1) << endl;

  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

int main(void) {
  int N, X, mi = 10000;
  cin >> N >> X;
  for (int i = 0; i < N; i++) {
    int m;
    cin >> m;
    mi = min(mi, m);
    X -= m;
  }
  cout << N + X / mi << 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 num = sc.nextInt();
        int sum = 0;
        int max = 0;
        for (int i = 0; i < num; i++) {
            int n = sc.nextInt();
            sum += n;
            max = Math.max(max, n);
        }
        sum -= max/2;
        System.out.println(Integer.valueOf(sum));
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;


int main(){

    ll N, M;
    cin >> N >> M;

    vector<ll> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];

    vector< vector<int> > connect(N);

    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        connect[a].push_back(b);
        connect[b].push_back(a);
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        bool flag = true;
        for(int j = 0; j < connect[i].size(); j++){
            if(DEBUG) cout << H[i] << " " << H[ connect[i][j]]  << endl;
            if(DEBUG) cout << i << " " << connect[i][j] << endl;
            if( H[i] <= H[ connect[i][j] ]  ) flag = false;
        }
        if(flag) ans ++;
        if(DEBUG) cout << "flag " << flag << endl;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9020
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
typedef long long ll;
 
using namespace std;

const int mod=1e9+7;
const int INF=1<<30;

int main(){
  int N,T;
  cin >> N >> T ;
  ll A[N],B[N],C[N]; //Bその町での最大利益,Cそこまでのmin
  ll d=0; //町あたりの最大利益
  int cnt=0; //最大利益のカウント
  rep(i,N)  cin >> A[i] ;
  C[0]=A[0];
  REP(i,1,N)  C[i]=min(A[i],C[i-1]);
  rep(i,N){
    if(C[i]>A[i]){
      B[i]=0;
    }else{
      B[i]=A[i]-C[i];
      d=max(d,B[i]);
    }
  }
  rep(i,N)  if(B[i]==d) ++cnt;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 2560