akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll a, b;

	cin >> a >> b;

	ll ans = max(a, b);

	if (a < b) {
		b--;
	}
	else {
		a--;
	}

	ans += max(a, b);

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    int k,p;
    cin >> k >> p;
    if(k<p){
     cout << k << endl; 
    }else if(k%p == 0){
     cout << p << endl; 
    }else{
     cout <<  k%p <<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3104
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	int n, m;
	cin >> n >> m;
	vector < int > a(m);
	for (auto &el: a) {
		cin >> el;
	}
	if (n >= m) {
		cout << "0\n";
		return;
	}
	sort(all(a));
	vector < int > b;
	int ans = 0;
	for (int i = 1; i < m; ++i) {
		b.eb(a[i] - a[i - 1]);
		ans += b.back();
	}
	sort(rall(b));
	for (int i = 0; i < n - 1; ++i) {
		ans -= b[i];
	}
	cout << ans << "\n";
}

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

using namespace std;

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

int main() {
	int N;
	cin >> N;
	REP(n, N) {
		printf("Case %d:\n", n + 1);
		int s;
		cin >> s;
		REP(i, 10) {
			s = (s * s) / 100 % 10000;
			cout << s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1196
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, k; readV(n, k);
  int[] h; readC(n, h);

  h.sort();

  auto r = 10^^9;
  foreach (i; 0..n-k+1)
    r = min(r, h[i+k-1]-h[i]);

  writeln(r);
}


Measured memory_bytes: 3580
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1e18
using namespace std;
typedef long long ll;

int main(){
  ll N, K; cin >> N >> K;
  ll cnt = 0;
  map<ll, ll> mp;
  rep(i, 0, N){
    int a, b; cin >> a >> b;
    mp[a] += b;
  }
  for(auto i = mp.begin(); i != mp.end(); i++){
    cnt += i->second;
    if(cnt>=K){
      cout << i->first << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

int64 GCD(int64 a, int64 b){
  if(a<b){
    swap(a,b);
  }
  while(true){
    if(b==0){
      return a;
    }else{
      int64 new_b=a%b;
      a=b;
      b=new_b;
    }
  }

}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int64 a,b;
  cin>>a>>b;

  int64 result=a*b/GCD(a,b);


  cout<<result<<endl;




  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
string s;
int main(){
	cin>>n;
	cin>>s;
	int t=0;
	int cou1=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='('&&t==0)cou1++;
		else if(s[i]=='(')t--;
		else t++;
	}
	t=0;
	int cou2=0;
	for(int i=0;i<s.size();i++){
		if(s[i]==')'&&t==0)cou2++;
		else if(s[i]==')')t--;
		else t++;
	}
	for(int i=0;i<cou1;i++){
		s=s+')';
	}
	for(int i=0;i<cou2;i++){
		s='('+s;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

aA = [[] for i in range(N)]
for i in range(N):
    aA[i] = [i+1, A[i]]

aA = sorted(aA, key = lambda x:x[1])
for i in range(N):
    print(aA[i][0],end="")
    print(" ",end="")
print("")


Measured memory_bytes: 25740
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

template<class T> 
ostream& operator<<(ostream &os, vector<T> input) {
    os << "[ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "]";
}

template<class T> 
ostream& operator<<(ostream &os, set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, unordered_map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

#define ll long long
const int MAXN = 100005;
const int INF = 1e9;
const int MOD = 1e9 + 7;

class TaskA {
private:

public:
	void solveOne(int it){
		string s;
		cin >> s;
		if (s.back() == 's') {
			s.append("es");
		} else {
			s.append("s");
		}
		cout << s << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3616
x, y = map(int, input().split())
a=[1, 3, 5, 7, 8, 10, 12]
b=[4, 6, 9, 12]
c=[2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else: 
    print("No")

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

int main(){
  int N,ans=0;
  cin >> N;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(i%2==0 && a%2==1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
module app;

import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto input = parseInput();
    writefln("%d", input.n ^^ 3);
}

struct Input
{
	int n;
}

auto parseInput()
{
	Input input = void;
	input.n = readln().strip().to!int;
	return input;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  while(true){
    string s1,s2;
    cin>>s1;
    if(s1==".")return 0;
    cin>>s2;
    bool flg=(s1==s2);
    vector<string>S1,S2;
    vector<string>S1_,S2_;
    for(int i=0;i<s1.size();i++){
      if(s1[i]=='\"'){
        string memo;
        i++;
        for(;i<s1.size();i++){
          if(s1[i]=='\"')break;
          memo.push_back(s1[i]);
        }
        S1.push_back(memo);
      }
      else{
        string memo;
        for(;i<s1.size();i++){
          if(s1[i]=='\"'){
            i--;
            break;
          }
          memo.push_back(s1[i]);
        }
        S1_.push_back(memo);
      }
    }
    for(int i=0;i<s2.size();i++){
      if(s2[i]=='\"'){
        string memo;
        i++;
        for(;i<s2.size();i++){
          if(s2[i]=='\"')break;
          memo.push_back(s2[i]);
        }
        S2.push_back(memo);
      }
      else{
        string memo;
        for(;i<s2.size();i++){
          if(s2[i]=='\"'){
            i--;
            break;
          }
          memo.push_back(s2[i]);
        }
        S2_.push_back(memo);
      }
    }
    int diff=0;
    bool d=false;
    if(S1.size()!=S2.size())d=true;
    for(int i=0;i<min(S1.size(),S2.size());i++)if(S1[i]!=S2[i])diff++;
    for(int i=0;i<min(S1_.size(),S2_.size());i++)if(S1_[i]!=S2_[i])d=true;
    /*
    cout<<"WORDS"<<endl;
    for(int i=0;i<min(S1.size(),S2.size());i++)cout<<S1[i]<<" "<<S2[i]<<endl;
    cout<<endl;
    cout<<"OTHERS"<<endl;
    for(int i=0;i<min(S1_.size(),S2_.size());i++)cout<<S1_[i]<<" "<<S2_[i]<<endl;
    cout<<endl;
    */
    if(flg)cout<<"IDENTICAL"<<endl;
    else if(diff==1&&!d)cout<<"CLOSE"<<endl;
    else cout<<"DIFFERENT"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>

typedef struct U
{
	tm L;
	int F,t;
}U;

tm set(int M,int D,int h,int m)
{
	tm t={0,m,h,D,M,100,0};
	return t;
}

int N,i,j,G,M,D,h,m,u,R;
U X[1000];

int main()
{
	char f;
	for(;scanf("%d\n",&N),N;)
	{
		G=0;
		memset(X,0,sizeof(X));
		for(i=0;i<N;i++)
		{
			scanf("%2d/%2d%2d:%2d%*c%[IO]%d",&M,&D,&h,&m,&f,&u);
			tm tmp1=set(M,D,h,m);
			time_t tmp=mktime(&tmp1);
			if(f=='I')
			{
				if(u==0)
					G=1;
				else
				{
					X[u].F=1;
				}
				X[u].L=tmp1;
			}
			else
			{
				if(u==0)
				{
					
					for(j=1;j<1000;j++)
					{
						if(X[j].F==1)
						{
							long long aaa=mktime(&X[0].L);
							long long  bbb=mktime(&X[j].L);
							double eee=difftime(tmp,aaa)/60;
							double fff=difftime(tmp,bbb)/60;
							X[j].t+=fff<eee?fff:eee;
						}
					}
					G=0;
				}
				else
				{
					if(G==1)
					{
						long long aaa=mktime(&X[0].L);
						long long  bbb=mktime(&X[u].L);
						double eee=difftime(tmp,aaa)/60;
						double fff=difftime(tmp,bbb)/60;
						X[u].t+=fff<eee?fff:eee;
					}
					X[u].F=0;
					X[u].L=tmp1;
				}
			}
		}
		for(i=1,R=0;i<1000;i++)
			R=R<X[i].t?X[i].t:R;
		printf("%d\n",R);
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

ll a[10005], b[10005];
int main()
{
	int N;
	cin >> N;

	REP(i, N)
	{
		cin >> a[i];
	}
	REP(i, N)
	{
		cin >> b[i];
	}

	ll ua = 0, ub = 0;
	REP(i, N)
	{
		if (a[i] - b[i] > 0)
		{
			ua += (a[i] - b[i]);
		}
		else
		{
			ub += ((b[i] - a[i]) >> 1) << 1;
		}
	}

	if (ua * 2 <= ub)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"math"
	"strconv"
	"strings"
)

func run() {
	n := nextInt()
	arr := make([]int, n)

	for i := 0; i < n; i++ {
		arr[i] = nextInt()
	}

	// var n = 200
	// arr := make([]int, n)

	// for i := 0; i < n; i++ {
	// 	arr[i] = i
	// }

	var maxInt = 0
	var secondMaxInt = 0
	var maxIntCount = 0

	for i := 0; i < n; i++ {
		var a = arr[i]

		if maxInt < a {
			secondMaxInt = maxInt
			maxInt = a
			maxIntCount = 1
		} else if maxInt == a {
			maxIntCount++
		} else if secondMaxInt < a {
			secondMaxInt = a
		}
	}

	for i := 0; i < n; i++ {
		var a = arr[i]

		if maxInt == a && maxIntCount == 1 {
			println(secondMaxInt)
		} else {
			println(maxInt)
		}
	}
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

const bufferSize = 64 * 1024 * 1024

func print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}

func println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


func nextArray() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

func nextIntArray() []int {
	str := nextArray()
	buf := make([]int, len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

func min(nums []int) int {
    if len(nums) == 0 {
        panic("funciton min() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Min(float64(res), float64(nums[i])))
    }
    return res
}

func max(nums []int) int {
    if len(nums) == 0 {
        panic("funciton max() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Max(float64(res), float64(nums[i])))
    }
    return res
}

func abs(a int) int {
    return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
    return int(math.Pow(float64(p), float64(q)))
}

func main() {
	sc.Buffer(make([]byte, 0, bufferSize), bufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
	int n, p;
	vector<ll> rem;
	ll ans = 0;
	string s;
	cin>>n>>p;
	cin>>s;
	if(p==2 || p==5){
		int cnt = 0;
		for(int i=0;i<n;i++){
			int digit = s[i]-'0';
			if(digit%p == 0){
				ans += (i+1);
			}
		}
	}
	else{
		reverse(s.begin(), s.end());
		rem.assign(p, 0);
		int cur_rem = 0, pw = 1;
		for(int i=0;i<n;i++){
			int digit = s[i]-'0';
			cur_rem = (pw*digit + cur_rem)%p;
			pw*=10;
			pw%=p;
			rem[cur_rem]++;
		}
		for(int i=0;i<p;i++){
			//cout<<i<<": "<<rem[i]<<"\n";
			ans += (rem[i]*(rem[i]-1))/2;
		}
		ans += rem[0];
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "YES" : "NO") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

int main()
{
    int i;
    cin >> i;
    if(i == 3 || i == 5 || i == 7)
    {
        Yes(true);
    }else
    {
        Yes(false);
    }
    
}

vector<string> split(string str, string separator) 
{
    if (separator == "") 
        return {str};
    vector<string> result;
    string tstr = str + separator;
    long long unsigned int l = tstr.length(), sl = separator.length();
    string::size_type pos = 0, prev = 0;
    
    for (;pos < l && (pos = tstr.find(separator, pos)) != string::npos; prev = (pos += sl))
    {
        result.emplace_back(tstr, prev, pos - prev);
    }
    return result;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;


int main() {

	int n;

	cin >> n;

	vector <int> a(n);

	int xo;

	rep(i, n) {
		cin >> a[i];
		if (i == 0)xo = a[i];
		else xo^= a[i];
	}

	rep(i, n) {
		ll aa;

		aa = xo ^ a[i];

		cout << aa << endl;
	}

	return 0;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

inline ll powmod(ll x, ll y) {
	ll res = 1;
	while (y--)
		res = res * x % MOD;
	return res;
}

int main() {
	ll n; cin >> n;
	ll res = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
	res %= MOD;
	res = (res + MOD) % MOD;
	cout << res << '\n';
    return 0;
}


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

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

    char str[3];
    int cnt=0;
    for(int i=0; i<n; i++){
        cin >> str;
        if(cnt>=0){
            if(str[0]=='A'){
                cnt++;
            }else{
                cnt--;
            }
        }
    }
    if(cnt==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#define INF 1000000000
using namespace std;
int A,B,C,N;
int l[8];
    int dfs(int cur,int a,int b,int c){
        if(cur==N){
            if(min({a,b,c})>0){
                return abs(a-A)+abs(b-B)+abs(c-C)-30;
            }else{
                return INF;
            }
        }
        int ans0 = dfs(cur+1,a,b,c);
        int ans1 = dfs(cur+1,a+l[cur],b,c)+10;
        int ans2 = dfs(cur+1,a,b+l[cur],c)+10;
        int ans3 = dfs(cur+1,a,b,c+l[cur])+10;
        return min({ans0,ans1,ans2,ans3});
    }
int main(){
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++){
        cin>>l[i];
    }
    int ans = dfs(0,0,0,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int r,c;
	while(cin >> r >> c && r){
		bool data[r][c];
		rep(i,r)rep(j,c)data[i][j] = 0;
		int ret = 0;
		rep(i,r)rep(j,c){
			cin >> data[i][j];
		}
		
		rep(bit,(1<<r)){
			int val[c][2];
			rep(i,c)rep(j,2)val[i][j] = 0;
			
			rep(j,r){
				if( (1<<j) & bit){
					rep(i,c){
						val[i][data[j][i]^1]++;
					}
				}else{
					rep(i,c){
						val[i][data[j][i]]++;
					}
				}
			}
			int sum = 0;
			rep(i,c){
				sum+=max(val[i][0],val[i][1]);
			}
			ret = max(sum,ret);
		}
		
		cout << ret << endl;
	}
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
typedef long long int lint;
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
int main(){
    lint n;
    cin >> n;
    vector < pair <int, int> > v;
    for(int i=0; i<n; i++){
        int temp1, temp2;
        cin >> temp1 >> temp2;
        v.push_back(make_pair(temp1,temp2));
    }
    sort(v.begin(), v.end(), sortbysec);
    lint cntr1 = 0;
    
    for(int i=0; i<n; i++){
        cntr1+=v[i].first;
        
        if(cntr1>v[i].second){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a;
  cin >> b;
  if(a==1){
    if(b==2){
      cout << "3" << endl;
    }
    else{
      cout << "2" << endl;
    }
  }
  else if(a==2){
    if(b==1){
      cout << "3" << endl;
    }
    else{
      cout << "1" << endl;
    }
  }
  else{
    if(b==1){
      cout << "2" << endl;
    }
    else{
      cout << "1" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt_min(vector<int>&v,int i,vector<int>&s)
{
    if(i==(v.size()-1))
    {
        return 0;
    }
    if(i==(v.size()-2))
    {
        return (abs(v[i]-v[i+1]));
    }
    int cnt1=0;
    int cnt2=0;
    if(s[i+1]!=-1)
    {
         cnt1 = abs(v[i]-v[i+1]) + s[i+1];
    }
    else
    {
        cnt1 = abs(v[i]-v[i+1]) + cnt_min(v,i+1,s);
    }
     if(s[i+2]!=-1)
    {
         cnt2 = abs(v[i]-v[i+2]) + s[i+2];
    }
    else
    {
       cnt2 = abs(v[i]-v[i+2]) + cnt_min(v,i+2,s);
    }
    s[i] = min(cnt1,cnt2);
    return min(cnt1,cnt2);
}
int main()
{

    int n;
    cin>>n;
    vector<int>v;
    vector<int>s(n,-1);
    for(int i=0;i<n;i++)
    {
        int p;
        cin>>p;
        v.push_back(p);
    }

    int ans = cnt_min(v,0,s);
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 10380
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    int a, b;

    cin >> a >> b;

    if (a % 2 == 0 || b % 2 == 0) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() { 
  ll n;
  cin >> n;
  
  std::vector<ll> l(n);
  rep(i,n) cin >> l.at(i);

  sort(l.begin(),l.end());
  ll count = 0;

  for(ll i = 0; i < n - 2; i++) {
    for(ll j = i + 1; j < n - 1; j++) {
      for(ll k = j + 1; k < n; k++) {
        if(l.at(i) < l.at(j) + l.at(k) && l.at(j) < l.at(i) + l.at(k) && l.at(k) < l.at(i) + l.at(j)) {
          if(l.at(i) != l.at(j) && l.at(j) != l.at(k) && l.at(k) != l.at(i)) count++;
          //cout << i << j << k << endl;
        }
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int n, k;
vector<int> a;
vector<bool> tdp, jdp;

int main() {
  cin >> n >> k;
  a.resize(n);
  tdp.resize(k + 1);
  jdp.resize(k + 1);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) {
      if (i + a[j] > k)
        continue;
      if (!tdp[i]) {
        jdp[i + a[j]] = true;
      }
      if (!jdp[i]) {
        tdp[i + a[j]] = true;
      }
    }
  }
  if (tdp[k]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}


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

int main() {
    char a,b;
    cin >> a >> b;
    if (a=='H'){
        if (b=='H'){
            cout << 'H';
        }else{
            cout << 'D';
        }
    }else{
        if (b!='H'){
            cout << 'H' ;
        }else{
            cout << 'D';
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;
typedef vector<ll> vll;
ll gcd(ll a, ll b){if (b==0){return a;}return gcd(b, a%b);}
// for (ll i=0;i<n;i++) {
// sort(.begin(),.end());
int main(){
  ll n,g,x;
  cin>>n;
  vll t(n);
  for (ll i=0;i<n;i++) cin>>t[i];
  
  vll a(n);
  a[0]=t[0];
  for (ll i=1;i<n;i++) {
    g=gcd(a[i-1],t[i]);
    x=t[i]/g;
    x*=a[i-1];
    a[i]=x;
  }
  
  cout<< a[n-1] <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int partition(int A[], int n, int p, int r)
{
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ )
  {
    if ( A[j] <= x )
    {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

int main()
{
  int A[MAX], n, i, q;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) 
    scanf("%d", &A[i]);
  q = partition(A, n, 0, n-1);

  for ( i = 0; i < n; i++ ) 
  {
    if ( i ) printf(" ");
    if ( i == q ) 
      printf("[");
    printf("%d", A[i]);
    if ( i == q ) 
      printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2164
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    ll x,y;
    cin >> x >> y;
    ll ans = 1;
    while(1){
        x *= 2;
        if(x <= y) ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n,ans=0;cin>>n;
  vector<int> p(n,0);REP(i,n) cin>>p.at(i);
  REP(i,n-2) ans+=(p.at(i+1)!=min(p.at(i),min(p.at(i+1),p.at(i+2)))&&p.at(i+1)!=max(p.at(i),max(p.at(i+1),p.at(i+2)))?1:0);
  cout<<ans;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	x := readInt()

	fmt.Println(x/500*1000 + x%500/5*5)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
		Long b = sc.nextLong();

		long gcd = gcd(a, b);
		System.out.println(prime(gcd));
		sc.close();
	}

	private static long gcd(Long a, Long b) {

		if (b > a)
			return gcd(b, a);
		if (a % b == 0)
			return b;

		return gcd(b, a % b);
	}

	private static long prime(long n) {
		int count = 1;

		long d = n;
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (d % i == 0) {
				count++;
				while (d % i == 0) {
					d = d / i;
				}
			}
		}

		if (d != 1)
			count++;
		return count;
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	
	return 0;
}

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

int main() {
  
  int n, m;
  cin >> n >> m;
  
  int c[m] = {0};
  int k, a;
  REP(i,n) {
    cin >> k;
    REP(j,k) {
      cin >> a;
      c[a-1]++;
    }
  }
  
  int ans = 0;
  REP(i,m) {
    if (c[i] == n) ans++;
  }
  
  cout << ans << endl;    
  
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int memo[100010];

int solve(vector<vector<int>> &v, int a){
  int res = 0;
  if(memo[a] != -1) return memo[a];
  REPI(itr,v[a]){
    res = max(res, solve(v, *itr));
  }
  memo[a] = res+1;
  return res + 1;
}

int main(){

  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> v(n);
  REP(i,m){
    int x, y;
    cin >> x >> y;
    x--; y--;
    v[x].pb(y);
  }

  REP(i,n){
    memo[i] = -1;
  }

  int ans = 0;
  REP(i,n){
    ans = max(ans, solve(v, i));
  }

  cout << ans - 1 << endl;
  return 0;
}



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

int main(){
  int n;
  cin >> n;
  int a[n];

  for (int i = 0; i < n; i++){
    int b;
    cin >> b;
    a[i] = b;
  }

  for (int i = n-1; i >= 0; i--){

    if (i != n-1) cout << " ";
    cout << a[i];
  }

  cout << endl;


return 0;
}

Measured memory_bytes: 3024
while 1:
    try:
        x=int(input())
        h=int(input())
        if x==h==0:break
        ans=x**2
        he=(h**2+x**2/4)**0.5
        tri=he*x*0.5
        ans+=tri*4
        print(f"{ans:.7f}")
    except:break


Measured memory_bytes: 5656
void main()
{
    long n = rdElem;

    long total;
    foreach (i; 1 .. n+1)
    {
        if (i % 3 && i % 5) total += i;
    }

    total.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 2764
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

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

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ll N, M;
    in >> N >> M;
    vector<ll> s(M), c(M);
    vector<ll> v(N, -1);
    bool valid = true;
    REP(i, M) {
        in >> s[i] >> c[i];
        auto ss = s[i]-1;
        auto cc = c[i];
        if (v[ss] == -1 || v[ss] == cc) v[ss] = cc;
        else {
            valid = false;
            break;
        }
        if (ss == 0 && cc == 0 && N > 1) {
            valid = false;
            break;
        }
    }
    if (!valid) {
        out << -1 << endl;
        return 0;
    }
    ll ans = 0;
    REP(i, v.size()) {
        auto& x = v[i];
        if (x == -1) {
            if (i == 0 ) {
                if (N > 1) {
                    x = 1;
                } else {
                    x = 0;
                }
            }
            else x = 0;
        }
    }
    reverse(v.begin(), v.end());
    REP(i, v.size()) {
        ans += v[i]*(power(10, i));
    }
    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int K,T,a[100]={0},sum=0,max=0,i;
    scanf("%d%d",&K,&T);
    
    for(i = 0;i < T;i++)
    {
        scanf("%d",&a[i]);
        if(max <= a[i]){
            max = a[i];
        }
        sum += a[i];
    }
    (max - 1 - (sum-max) > 0) ? printf("%d\n",max-1-(sum-max)) : printf("%d\n",0);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int n, q;
    string s;
    cin >> n >> q >> s;

    vector<int> t(n, 0);
    for (int i = 0; i < n; i++) {
        t[i+1] = t[i] + (s[i] == 'A' && s[i+1] == 'C');
    }

    vector<int> count(q, 0);
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        count[i] = t[r-1] - t[l-1];
    }

    for (auto c: count) cout << c << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

  cin >> n;
  for (int i = 0; i < n; i++) cin >> R[i];

  int maxv = -1000000001;
  int minv = R[0];

  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

}


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,x,maxv,d;
    cin>>n;
    int vec[100001];
    for(i=0;i<100001;i++){
        vec[i]=0;
    }
    for(i=0;i<n;i++){
        cin>>x;
        vec[x]++;
    }
    maxv=0;
    for(i=0;i<100001-2;i++){
        maxv=max(maxv,vec[i]+vec[i+1]+vec[i+2]);
    }
    cout<<maxv<<endl;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
l=[0]*3*n
r=[-1000000000000000]*3*n
from heapq import heappop,heappush
h=[]
s=0
for i in a[:n]:
  heappush(h,i)
  s+=i
l[n-1]=s
for i in range(n,2*n):
  heappush(h,a[i])
  s+=a[i]
  s-=heappop(h)
  l[i]=s
h=[]
s=0
for i in a[2*n:]:
  heappush(h,-i)
  s+=-i
for i in range(2*n-1,n-2,-1):
  r[i]=s
  heappush(h,-a[i])
  s+=-a[i]
  s-=heappop(h)
print(max(l[i]+r[i]for i in range(3*n)))

Measured memory_bytes: 42556
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) throws IOException {
        int a = System.in.read();
        if ('A' <= a && a <= 'Z') {
            System.out.print('A');
        } else System.out.print('a');
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32176
#include<bits/stdc++.h>
#define rep(i,n,k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i=n-1; i>=k; --i)
using namespace std;

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  int sum = 1;
  string ans = "Yes";
  rep(i,s.size()-1,0){
    if(s[i] == s[i+1]) sum++;
    else{
      if(sum % 2 == 1) ans = "No";
      sum = 1;
    }
  }
  if(sum % 2 == 1) ans = "No";
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let s = format!("{}{}", a.to_string(), b.to_string());
	let k:i32 = s.parse().ok().unwrap();
	let mut flag = false;
	for i in 1.. {
		if i*i > k {
			break;
		}
		if i*i == k {
			flag = true;
			break;
		}
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	int b;
	cin>>b;
	n+=b;
	if(n>=24)
		n-=24;
		cout<<n<<endl;
		return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define ll long long

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

  ll r=0, sl=0, sl_xor=0, sr=A[0], sr_xor=A[0];
  ll ans = 0;
  for(ll l=0; l<N; ++l){
    for(; r<N && (sr-sl==(sr_xor^sl_xor)); ++r) { sr+=A[r+1]; sr_xor^=A[r+1]; }
    ans += r-l;
    sl += A[l];
    sl_xor ^= A[l];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, long long M, std::vector<long long> A){
    long long sum = accumulate(A.begin(), A.end(), 0);
    if (sum <= N) cout << N - sum << '\n';
    else cout << -1 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using PP = pair<int, int>;

int n;
vector<PP> G[100000];
bool col[100000];

void rec(int from, int prev, bool c) {
  col[from] = c;
  for (PP e : G[from]) {
    int to = e.first;
    int dist = e.second;
    if (to == prev) continue;
    rec(to, from, dist % 2 == 0 ? c : !c);
  }
}

int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    G[a].push_back(PP(b, c));
    G[b].push_back(PP(a, c));
  }
  
  rec(0, -1, 0);
  
  for (int i = 0; i < n; ++i) {
    cout << col[i] << endl;
  }
}


Measured memory_bytes: 8832
#pragma GCC optimize("Ofast")

// #define _GLIBCXX_DEBUG

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
// typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
// using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
/*
void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
*/
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10); x/=10;} reverse(all(res)); return res;}

void solve() {
  int n; cin>>n;
  vi x(n),y(n); rep(i,n) cin>>x[i]>>y[i];
  vi bikuri={0,1,2,6,24,120,720,5040,40320};
  vi z(n); rep(i,n) z[i]=i;
  double ans=0;
  do {
    rep(i,n-1){
      ans+=sqrt(POW(x[z[i]]-x[z[i+1]],2)+POW(y[z[i]]-y[z[i+1]],2));
    }
  } while(NP(all(z)));
  ans/=bikuri[n];
  decimal(10); out(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  ll ans = 0;
  int i,j;
  for(i=1;i<=n;i++)
  {
    for(j=i;j<=n;j+=i)
    {
      ans += j;
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 3612
using System;
using System.Text.RegularExpressions;

namespace P0050_Apple_and_Peach
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = ReadLine();

            a = Regex.Replace(a, @"apple", "イ");
            a = Regex.Replace(a, @"peach", "apple");
            a = Regex.Replace(a, @"イ", "peach");

            Console.Write(a);
        }

        private const int READLINE_BUFFER_SIZE = 1024;

        private static string ReadLine()
        {
            System.IO.Stream inputStream = Console.OpenStandardInput(READLINE_BUFFER_SIZE);
            byte[] bytes = new byte[READLINE_BUFFER_SIZE];
            int outputLength = inputStream.Read(bytes, 0, READLINE_BUFFER_SIZE);
            //Console.WriteLine(outputLength);
            char[] chars = System.Text.Encoding.UTF7.GetChars(bytes, 0, outputLength);
            return new string(chars);
        }

    }
}

Measured memory_bytes: 21292