akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

const int M = int(1e9) + 7;
int n;
int a[100010];

int fact[100010];
int finv[100010];

ll ppow(ll a, ll b){
	if(b==0) return 1;
	ll ret = ppow(a, b/2);
	ret = ret*ret%M;
	if(b&1) ret=ret*a%M;
	return ret;
}

ll modinv(ll x){
	return ppow(x, M-2);
}

ll comb(int a, int b){
	if(b<0 || b>a) return 0;
	return fact[a] * 1LL * finv[b] % M * finv[a-b] % M;
}

int main()
{
	fact[0]=1; finv[0]=1;
	for(int i=1; i<=100005; ++i){
		fact[i]=fact[i-1]*1LL*i%M;
		finv[i]=modinv(fact[i]);
	}
	
	read(n);
	map<int,int> m;
	for(int i=1; i<=n+1; ++i) read(a[i]), ++m[a[i]];
	int T = 1;
	for(int i=1; i<=n; ++i) if(m[i] == 2) T=i;
	int l = -1, r = -1;
	for(int i=1; i<=n+1; ++i){
		if(a[i] == T){
			((l == -1) ? l : r) = i;
		}
	}
	printf("%d\n", n);
	for(int i=2; i<=n; ++i){
		ll ans = comb(n+1, i);
		ans -= comb(n-(r-l), i-1);
		ans = (ans + M) % M;
		printf("%lld\n", ans);
	}
	puts("1");
	return 0;
}


Measured memory_bytes: 7040
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL n, k;
    cin >> n >> k;
    LL cnt = 0;
    int a[n];
    vector< LL > v;
    for( int i = 0; i < n; ++i ) {
        cin >> a[i];
        v.pb( a[i] );
    }
    for( int i = 0; i < n; ++i ) {
        v.pb( a[i] );

    }

    for( int i = 0; i < n; ++i ) {
        for( int j = i + 1; j < n; ++j ) {
            if( a[i] > a[j] ) ++cnt;

        }
    }

    if( k == 1 ) {
        cout << cnt << endl;
        return 0;

    }

    LL tmp = cnt;
    LL res = ( cnt * k );
    LL tm = ( k * ( k - 1 ) ) / 2 % MOD;
    cnt = 0;

    for( int i = 0; i < n; ++i ) {
        for( int j = 0; j < n; ++j ) {
            if( i == j ) continue;
            if( a[i] > a[j] ) res = ( res + tm ) % MOD;

        }
    }

    cout << res % MOD << endl;
    return 0;
}



Measured memory_bytes: 384
n, m = map(int, input().split())
max_l = 1
min_r = n 

for _ in range(m):
    l, r = map(int, input().split())
    max_l = max(max_l, l)
    min_r = min(min_r, r)

ans = max(min_r - max_l + 1, 0)
print(ans)

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

using namespace std;
const int N = 2e3 + 5, MOD = 998244353;
int mem[N][N][2][2][2];
int go(int n, int v, bool mid = false, bool pairs = false, bool picked = false) {
	if (n == 0) {
		if (pairs)
			return (1 + picked);
		return 1;
	}
	if (v == 0)
		return 0;
	if (v == 1 && mid)
		return n == 1;
	int &ret = mem[n][v][mid][pairs][picked];
	if (~ret)
		return ret;
	ret = go(n - 1, v, mid, pairs, true);
	if (v > 1)
		if (pairs && picked)
			ret = (ret + go(n, v - 1, mid, pairs, false) * (1LL + picked)) % MOD;
		else
			ret = (ret + go(n, v - 1, mid, pairs, false)) % MOD;
	return ret;
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	memset(mem, -1, sizeof mem);
	int n, k;
	scanf("%d %d", &k, &n);
	for (int i = 2; i <= k * 2; ++i) {
		int pairs = i / 2;
		if (i > k)
			pairs = max(0, k - i / 2 + (i % 2 == 0));
		bool mid = k >= i / 2 && i % 2 == 0;
		int op = k - 2 * pairs + mid;
		int res = 0;
		for (int free = 0; free <= n; ++free)
			res = (res + 1LL * go(free, op) * go(n - free, pairs, mid, true)) % MOD;
		printf("%d\n", res);
	}
	return 0;
}



Measured memory_bytes: 126080
from itertools import accumulate
import sys
a,b=map(int,input().split())
n = 500000
l=[]
for i in range(n):
    l.append(i)
    tmp = sum(l)
    if abs(abs(a+tmp) - abs(b+tmp)) == i:
        print(tmp -b)
        sys.exit()

Measured memory_bytes: 9192
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort()
c.sort()

import bisect
#a=[0,2,3,4,67,8]
#a.sort()
#bisect.bisect_left(a, 4) #被ったら左側のindexを返す
#bisect.bisect_right(a, 4)#被ったら右側のindexを返す
ans=0
for bb in b:
    #print(">>>",bb)
    #print(a,bisect.bisect_left(a, bb))
    #print(c,n-bisect.bisect_right(c, bb))
    ans+=bisect.bisect_left(a, bb)*(n-bisect.bisect_right(c, bb))

print(ans)



Measured memory_bytes: 23248
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

using real = double;
static constexpr real EPS = 1e-10;
struct Point {
    real x, y;
    Point& operator+=(const Point a) { x += a.x; y += a.y;  return *this; }
    Point& operator-=(const Point a) { x -= a.x; y -= a.y;  return *this; }
    Point& operator*=(const real k) { x *= k; y *= k;  return *this; }
    Point& operator/=(const real k) { x /= k; y /= k;  return *this; }
    Point operator+(const Point a) const {return Point(*this) += a; }
    Point operator-(const Point a) const {return Point(*this) -= a; }
    Point operator*(const real k) const {return Point(*this) *= k; }
    Point operator/(const real k) const {return Point(*this) /= k; }
    bool operator<(const Point &a) const { return (x != a.x ? x < a.x : y < a.y); }
    explicit Point(real a = 0, real b = 0) : x(a), y(b) {};
};

bool sorty(Point a, Point b){
    return (a.y != b.y ? a.y < b.y : a.x < b.x);
}

istream& operator>> (istream& s, Point& P){
    s >> P.x >> P.y;
    return s;
}

inline real dot(Point a, Point b){ return a.x*b.x + a.y*b.y; }
inline real cross(Point a, Point b){ return a.x*b.y - a.y*b.x; }
inline real abs(Point a){ return sqrt(dot(a, a)); }

using Polygon = vector<Point>;

int main() {
    int n;
    cin >> n;
    Polygon v(n);
    for(auto &&i : v) cin >> i;
    Point Q = (v[0]+v[n/2])/2;
    for (int j = 0; j < n; ++j) {
        Point R = (v[j]+v[(j+n/2)%n])/2;
        if(abs(Q-R) > EPS){
            puts("NA");
            return 0;
        }
    }
    printf("%.10lf %.10lf\n", Q.x, Q.y);
    return 0;
}


Measured memory_bytes: 3280
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n,k,q;
int a[100010];

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n >> k >> q;
    Forn(i, n) a[i] = k;
    forn(ii, q)
    {
        int x;
        cin >> x;
        a[x]++;
    }
    Forn(i, n) a[i] -= q;
    Forn(i, n)
    {
        if(a[i]>0) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
}


Measured memory_bytes: 1024
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
)
 
var sc = bufio.NewScanner(os.Stdin)

//fmt.Scan(&a)とかの方が楽ではある。

//1行に二つ以上の塊があるパターン
//for r = append(r, s[0])
//的な感じ
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc053a(rate int){
	if rate < 1200{
		fmt.Println("ABC")
	}else {
		fmt.Println("ARC")
	}
}
 
func main(){
	rate := 0
	fmt.Scan(&rate)
	abc053a(rate)
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


int main(){
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int m,d,days,i;
	int date[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
	char *day[7] = {
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday",
	};

	while(1){
		scanf("%d %d",&m,&d);
		if(m == 0){
			break;
		}

		days = 0;

		for(i = 1;i < m;i++){
			days += date[i];
		}

		days += d;
		days += 2;

		printf("%s\n",day[days%7]);
	}

	return 0;
}

Measured memory_bytes: 584
MOD=10**9+7
N = int(input())
s1 = list(input())
s2 = list(input())
pre = s1[0] == s2[0]
if s1[0] == s2[0]:
    ans = 3
    idx = 1

else:
    ans = 6
    idx = 2
while idx < N:
    if pre:
        ans *= 2
    else:
        if s1[idx] != s2[idx]:
            ans *= 3

    pre=s1[idx] == s2[idx]
    if s1[idx] == s2[idx]:
        idx += 1
    else:
        idx += 2

print(ans%MOD)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
 
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値
 
ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}
 
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back
 
 
int main(){
    string s,t; cin >> s >> t;
    ll cnt = 0;
    rep(i,s.size()){
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k)
    {
        cout<<s<<endl;
    }
    else
    {
        for(int i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    
}

Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstdio>
int main(){
  	double N;
  std::cin >> N;
  double n = floor(sqrt(N));
  //std::cout << setprecision(0) << n*n << std::endl;
  printf("%.0lf",n*n);
  return 0;
}


Measured memory_bytes: 384
A, B = gets.chomp.split.map(&:to_i)
S = gets.chomp

ans = "Yes"
for i in 0..(S.size - 1) do
  ans = "No" if i <= A - 1 && S[i] == "-"
  ans = "No" if i == A && S[i] != "-"
  ans = "No" if i > A && S[i] == "-"
end

puts ans

Measured memory_bytes: 3836
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll maxi=1e6;
vc spf(maxi+1,0);

void sieve()
{
	ll i=0,j=0;
	Ff(i,0,maxi+1)
	spf[i]=-1;

	for(i=2;i<=maxi;i++)
	{
		if(spf[i]==-1)
		{
			for(j=i;j<=maxi;j+=i)
			{
				if(spf[j]==-1)
				{
					spf[j]=i;
				}
			}
		}
	}
}

map<ll,ll> get_Factors(ll x)
{
	map<ll,ll> res;
	while(x>1)
	{
		res[spf[x]]++;
		x/=spf[x];
	}
	return res;
}
map<int, int> primeFactorization(int n){
    map<int, int> ret;
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
        ret[i]++;
        n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}
 
int main(){
    int n;
    cin >> n;
	int i=0;
    vector<int> a(n);
    Ff(i,0,n){
        cin >> a[i];
    }
 
    map<int, int> primes;
    for(auto x : a){
        auto tmp = primeFactorization(x);
        for(auto y : tmp){
            primes[y.first]++;
        }
    }
 
    string ans = "pairwise coprime";
    bool flag1 = false;
    for(auto x : primes){
        if(x.second == n){
            ans = "not coprime";
            break;
        }
        if(x.second != 1){
            ans = "setwise coprime";
        }
    }
 
    cout << ans << endl;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 25648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc119c
{
    class Program
    {
        private static int A, B, C, N;
        private static IList<int> L;

        static void Main(string[] args)
        {
            var str = ReadIntList();
            N = str[0];
            //var ABC = str.Skip(1).ToList();
            A = str[1];
            B = str[2];
            C = str[3];
            L = new int[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = ReadInt();
            }
            Console.WriteLine(dfs(0, 0, 0, 0));
            Console.ReadKey();
        }

        private static int dfs(int depth, int a, int b, int c)
        {
            if (depth == N)
            {
                if (a * b * c == 0)
                {
                    return 10000000;
                }
                return Math.Abs(A - a) + Math.Abs(B - b) + Math.Abs(C - c) - 30;
            }
            var ans = new int[4];
            ans[0] = dfs(depth + 1, a, b, c);
            ans[1] = dfs(depth + 1, a + L[depth], b, c) + 10;
            ans[2] = dfs(depth + 1, a, b + L[depth], c) + 10;
            ans[3] = dfs(depth + 1, a, b, c + L[depth]) + 10;
            //Console.WriteLine(String.Join(" ", ans));
            return ans.Min();
        }

        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
        private static double ReadDouble() => double.Parse(Console.ReadLine());
        private static List<double> ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
    }
}


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

D = []
for i in range(n) :
    D.append(list(map(int,input().split())))

for i in range(n) :
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1] :
        cnt = True
        break
    else :
        cnt = False
    if i==n-3 :
        break

if cnt :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 9136
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    x, n= map(int, input().split())
    if n == 0:
        print(x)
        return
    P=[]
    P = list(map(int, input().split()))
    
    for i in range(100):
        a = x-i
        b = x+i
        if a not in P:
            print(a)
            return
        elif b not in P:
            print(b)
            return
    


main()



Measured memory_bytes: 9188
#include <stdio.h>

int main()
{
    int n,tf = 1;
    long long int h[100000];

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld",&h[i]);
    }  
    for (int i = 1; i < n; i++)
    {
        if (h[i - 1] < h[i])
        {
            h[i] --;
        }
        else if (h[i - 1] > h[i])
        {
            tf = 0;
            break;
        }
    }

    printf(tf == 1 ? "Yes" : "No");
}


Measured memory_bytes: 896
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	set<ll> ans;
	for (ll i = 1; i*i <= N; i++)
	{
		if(N%i==0)
		{
			ll d1=i;
			ll x1=N;
			if(d1!=1)
			{
				while (x1%d1==0)
				{
					x1=x1/d1;
				}
				x1=x1%d1;
				if(x1==1)
				{
					ans.insert(d1);
				}
			}
			d1=N/i;
			x1=N;
			if(d1!=1)
			{
				while (x1%d1==0)
				{
					x1=x1/d1;
				}
				x1=x1%d1;
				if(x1==1)
				{
					ans.insert(d1);
				}
			}
		}
	}
	N--;
	for (ll i = 1; i*i <= N; i++)
	{
		if(N%i==0)
		{
			if(i!=1 && (N+1)%i==1)
			{
				ans.insert(i);
			}
			if((N/i)!=1 && (N+1)%(N/i)==1)
			{
				ans.insert(N/i);
			}
		}
	}
	cout<<sz(ans)<<endl;
	
	

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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);
int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        mp[d]++;
    }
    int m;
    cin >> m;
    vector<int> T(m);
    for(int i=0;i<m;i++) cin >> T[i];
    for(int i=0;i<m;i++){
        auto itr=mp.find(T[i]);
        if(itr==mp.end() || itr->second<1){
            cout << "NO" << endl;
            return 0;
        }else mp[T[i]]--;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 10368
#include <iostream>
using namespace std;
int main(void){
     
    int X ;
    cin >> X ;
    
    int x = 1 , count = 0 ;
    
    
    for(int i = 1 ; x <= X ; i++){
         
         x += i ;
         
         count++ ;
    }
    
    if(x - X == 0){
         
         cout << count - 1 << endl ;
    }
    else{
         cout << count << endl ;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int H, W;
    io.read(H, W);
    auto C = io.read_vec<string>(H);
    vector<string> ans(2 * H);
    for(int i = 0; i < 2 * H; i++){
        for(int j = 0; j < W; j++){
            ans[i].push_back(C[i / 2][j]);
        }
    }
    for(int i = 0; i < 2 * H; i++){
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int h, w, s;
int u[35][35];
int sum_from1_1[35][35] = {};
pair<int, int> result[35][35][35][35];

pair<int, int> solve(int sx, int sy, int tx, int ty)
{
	if(result[sx][sy][tx][ty].first >= -1) return result[sx][sy][tx][ty];
	int sum = sum_from1_1[tx][ty] - sum_from1_1[sx - 1][ty] - sum_from1_1[tx][sy - 1] + sum_from1_1[sx - 1][sy - 1];
	int groupnum = 1, mingroup = sum;
	// cout << sx << " " << sy << " " << tx << " " << ty << " " << nowmingroup << endl;
	for(int i = sx; i < tx; i++){
		int nowsum = sum_from1_1[i][ty] - sum_from1_1[sx - 1][ty] - sum_from1_1[i][sy - 1] + sum_from1_1[sx - 1][sy - 1];
		if(sum_from1_1[h][w] - (sum - nowsum) <= s && sum_from1_1[h][w] - nowsum <= s){
			pair<int, int> tmp1 = solve(sx, sy, i, ty);
			pair<int, int> tmp2 = solve(i + 1, sy, tx, ty);
			if(tmp1.first + tmp2.first > groupnum){
				groupnum = tmp1.first + tmp2.first;
				mingroup = min(tmp1.second, tmp2.second);
			} else if(tmp1.first + tmp2.first == groupnum){
				mingroup = max(mingroup, min(tmp1.second, tmp2.second));
			}
		}
	}
	for(int i = sy; i < ty; i++){
		int nowsum = sum_from1_1[tx][i] - sum_from1_1[sx - 1][i] - sum_from1_1[tx][sy - 1] + sum_from1_1[sx - 1][sy - 1];
		if(sum_from1_1[h][w] - (sum - nowsum) <= s && sum_from1_1[h][w] - nowsum <= s){
			pair<int, int> tmp1 = solve(sx, sy, tx, i);
			pair<int, int> tmp2 = solve(sx, i + 1, tx, ty);
			if(tmp1.first + tmp2.first > groupnum){
				groupnum = tmp1.first + tmp2.first;
				mingroup = min(tmp1.second, tmp2.second);
			} else if(tmp1.first + tmp2.first == groupnum){
				mingroup = max(mingroup, min(tmp1.second, tmp2.second));
			}
		}
	}
	// cout << sx << " " << sy << " " << tx << " " << ty << " : " << groupnum << " " << mingroup << endl;
	return result[sx][sy][tx][ty] = make_pair(groupnum, mingroup);
}

int main()
{
	while(1){
		cin >> h >> w >> s;
		if(h == 0) break;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cin >> u[i][j];
				sum_from1_1[i][j] = sum_from1_1[i - 1][j] + sum_from1_1[i][j - 1] - sum_from1_1[i - 1][j - 1] + u[i][j];
			}
		}
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				for(int k = 0; k <= h; k++){
					for(int l = 0; l <= w; l++){
						result[i][j][k][l] = make_pair(-2, -2);
					}
				}
			}
		}
		pair<int, int> ans = solve(1, 1, h, w);
		cout << ans.first << " " << s - (sum_from1_1[h][w] - ans.second) << endl;
	}
	return 0;
}

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

int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H - 1 || j == 0 || j == W - 1){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

typedef long long ll;

int main()
{
    int i,j,k;
    int h,w;
    cin >> h >> w;
    vector<string> maze(h);
    for(i = 0;i < h;++i){
        cin >> maze.at(i);
    }
    vector<int> ans;
    for(i = 0;i < h;++i){
        for(j = 0;j < w;++j){
            if(maze.at(i).at(j) == '#'){
                continue;
            }
            int temp_max = 0;
            int temp_num = 0;
            vector<vector<int>> num(h,vector<int>(w,-1));
            vector<vector<bool>> visit(h,vector<bool>(w, false));
            queue<pair<int,int>> que;
            que.emplace(i,j);
            num.at(i).at(j) = 0;
            int tate[4] = {0,1,0,-1};
            int yoko[4] = {1,0,-1,0};
            while(!que.empty()){
                int temp_i = que.front().first;
                int temp_j = que.front().second;
                que.pop();
                temp_num = num.at(temp_i).at(temp_j);
                if(temp_num > temp_max){
                    temp_max = temp_num;
                }
                visit.at(temp_i).at(temp_j) = true;

                for(k = 0;k < 4;++k){
                    int temp_t = temp_i + tate[k];
                    int temp_y = temp_j + yoko[k];
                    try{
                        if(maze.at(temp_t).at(temp_y) == '#'){
                            continue;
                        }
                    }catch(exception& e){
                        continue;
                    }
                    if(!(visit.at(temp_t).at(temp_y))){
                        que.emplace(temp_t,temp_y);
                        num.at(temp_t).at(temp_y) = temp_num+1;
                        visit.at(temp_t).at(temp_y) = true;
                    }
                }
            }
            ans.push_back(temp_max);
        }
    }
    sort(ans.begin(),ans.end());
    cout << ans.back() << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int a; cin >> a;
  int ans = a + a * a + a * a * a;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main(){
    speed;
    int a , b;
    int ans = 0;
    cin >> a >> b;
    vector <int>vc(a);
    for ( int i = 0 ;i < a;i++){
        cin >> vc[i];
        if (vc[i] >= b){
            ans ++ ;
        }
    }
    cout << ans;
}





Measured memory_bytes: 640
#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)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
 int n;
 cin >> n;
 string s[n+1];
 map <char,ll> cnt;
 map <char,ll> ans;
 
 rep (i,n) {
   cin >> s[i];
   sort(s[i].begin(),s[i].end());
   rep (j,s[i].size()) {
     cnt[s[i][j]]++;
   }
   for (char k = 'a';k <= 'z';k++){
       if (i == 0) {
         ans[k]=cnt[k];
       }
       else {
         ans[k]=min(ans[k],cnt[k]);
       }
       cnt[k]=0;
    } 
 }



for (char k = 'a';k <= 'z';k++){
  while(ans[k]>0){
    cout << k;
    ans[k]--;
  }
}
cout << endl;
 

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  long long X,Y,A,B,C,sum=0;
  cin>>X>>Y>>A>>B>>C;
  long long p[A],q[B],r[C];
  int i;
  for(i=0;i<A;i++)
    cin>>p[i];
   for(i=0;i<B;i++)
    cin>>q[i];
    for(i=0;i<C;i++)
    cin>>r[i];
  
  sort(p,p+A);
  reverse(p,p+A);
  sort(q,q+B);
  reverse(q,q+B);
  sort(r,r+C);
  reverse(r,r+C);
  
  long long ans[X+Y];
  long long ans1[X+Y+C];
  merge(p,p+X,q,q+Y,ans);
  merge(ans,ans+X+Y,r,r+C,ans1);
  sort(ans1,ans1+X+Y+C);
  reverse(ans1,ans1+X+Y+C);
  for(i=0;i<X+Y;i++)
    sum+=ans1[i];
  
  cout<<sum;
  return 0;
}
  

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

int gcd(int x, int y)
{
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

int main()
{
    int n, x;
    cin >> n >> x;
    int ans;
    for (int i = 0; i < n; i++) {
        int xi;
        cin >> xi;
        if (i > 0) {
            ans = gcd(ans, abs(xi - x));
        } else {
            ans = abs(xi - x);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

bool f[200001] = {};
bool s[200001] = {};
int main() {
	ll n, m; cin >> n >> m;
	repe(i, 1, m) {
		ll a, b; cin >> a >> b;
		if (a == 1) {
			s[b] = true;
		}
		else if (b == n) {
			f[a] = true;
		}
	}
	rep(i, 1, n) {
		if (f[i] && s[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 768
// Example program
#include <iostream>
#include <string>

using namespace std;
#define ll long long

const ll mod = int(1e9) + 7;
const ll N = 200100;

ll n, m, a, b;
ll f[N];

ll binpow(ll a, ll b) {
    if (b == 0) return 1;
    ll cur = binpow(a, b >> 1);
    if (b & 1) return (((cur * cur) % mod) * a) % mod;
    return (cur * cur) % mod;
}

ll c(ll n, ll k) {
    ll up = f[n];
    ll down = (f[k] * f[n - k]) % mod;
    return (up * binpow(down, mod - 2)) % mod;
}

ll ct(ll x, ll k) {
    return c(x + k, x);
}

ll ans;
int main() {
    cin >> n >> m >> a >> b;
    
    f[0] = 1;
    for (int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % mod;
    for (int i = 1; i <= n - a; i++) {
        ans += ct(i - 1, b - 1) * ct(n - i, m - b - 1);
        ans %= mod;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ft first
#define sd second
#define mp make_pair
#define MAX 100010
#define pub push_back
#define pob pop_back
#define mt make_tuple
#define len length
#define dbgn(x) cerr<<#x<<": "<<x<<'\n'
#define dbg(x) cerr<<#x<<": "<<x<<' '
#define FOR(i,lbd,rbd) for((i)=(lbd);(i)<(rbd);++(i))
#define setZ(A) memset(A,0,sizeof A)
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
typedef map<lli,lli> mll;
typedef map<int,int> mii;
typedef priority_queue<int,vector<int>,greater<int> > pqi_min;
template<class T, class Y> 
T pow(T a,Y p) {
	if (p==0) return 1;
	if (p&1) {
		return (a*pow(a,p-1));
	}
	T y = pow(a,p>>1);
	return (y*y);
}
//int+string
//cin.ignore();

const int M=1e9+7;
//int arr[1<<17];
set<int> a;
void solve() {
	int i,n,t;
	cin>>n;
	FOR(i,0,n) {
		cin>>t;
		auto it  = a.find(t);
		if (it!=a.end()) a.erase(it);
		else a.insert(t);
	}
	cout<<a.size();
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 4992
a = input()
b = input()

a = sorted(a)
b = sorted(b,reverse=True)

N = len(a)
M = len(b)

can = False
i = 0

while i < N and i < M:
    if can == True:
      break

    if a[i] < b[i]:
        can = True
    elif a[i] > b[i]:
        break
    elif i==N - 1 and N < M:
        can = True
    i+=1

if can == True:
    print('Yes')
else:
    print('No')


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

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    ans += (n ? n * (n - 1) / 2 : 0);
    ans += (m ? m * (m - 1) / 2 : 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <iostream>
#include <set>

using namespace std;

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

  REP(i,s.size()) {
    const char c = s[i];
    if(c != 'a' && 'z' + 1 <= c + n) {
      s[i] = 'a';
      n -= 'z' + 1 - c;
    }
  }

  const int k = 'z' - 'a' + 1;
  int last = s[s.size() - 1];
  s[s.size() - 1] = (char)(((last - 'a') + n) % k) + 'a';

  cout << s << endl;

  return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end())

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

ll dp[105][100005] = { 0 };

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

void Main() {
    int N, W;
    cin >> N >> W;
    vint w(N), v(N);
    rep(i, N)cin >> w[i] >> v[i];

    rep(i, N) {
        rep(j, W + 1) {
            if (j >= w[i]) chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}

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



Measured memory_bytes: 79360
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;

  if(a == b){
    cout << a + b << endl;
  }else if(a < b){
    cout << (b + (b - 1));
  }else{
    cout << (a + (a - 1));
  }
  return 0;
  }

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

int main()
{
	map<long long,long long> mp;
	long long n;
	cin>>n;
	for (long long i=1;i<=n;i++)
	{
		long long k;
		cin>>k;
		mp[k]++;
	}
	long long m;
	cin>>m;
	for (long long i=1;i<=m;i++)
	{
		long long k;
		cin>>k;
		if (mp[k]>0)
		 mp[k]--;
		else
		 {
		 	cout<<"NO\n";
		 	return 0;
		 }
	}
	cout<<"YES\n";
}

Measured memory_bytes: 12800
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,avx,avx2,mmx,abm")
#pragma GCC optimize("unroll-loops,inline")
#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;
const int MAXN = 3010;
int n, s;
int a[MAXN];
int dp[MAXN];

signed main() {
	scanf("%d%d", &n, &s);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	int ans = 0;
	for (int i = 0; i <= s; i++)
		dp[i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int w = s - a[i]; w >= 1; w--) {
			dp[w + a[i]] += dp[w];
			dp[w + a[i]] -= MOD * (dp[w + a[i]] >= MOD);
		}
		dp[a[i]] += i;
		dp[a[i]] -= MOD * (dp[a[i]] >= MOD);
		ans += dp[s];
		ans -= MOD * (ans >= MOD);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vi x(n), y(n);
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	vector<vector<double>> d(n, vector<double>(n));
	rep(i, n) {
		rep(j, n) {
			double s = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
			s = sqrt(s);
			d[i][j] = s;
		}
	}
	double t = 1;
	rep(i, n) {
		t *= (i + 1);
	}
	double b = t / n/(n-1);
	double ans = 0;
	rep(i, n) {
		rep(j, n) {
			ans += b * (n - 1) * d[i][j];
		}
	}
	ans /= t;
	cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

#define MAX_V 100001
const long long INF = 1LL<<60;

static int V, E, r;
static vector<pair<int, long long> > graph[MAX_V];
static long long dist[MAX_V];

int main() {
  cin >> V >> E >> r;
  for (int i = 0; i < E; ++i) {
    int s, t; long long w;
    cin >> s >> t >> w;
    graph[s].push_back(make_pair(t, w));
  }

  priority_queue<pair<long long,int>, vector<pair<long long,int> >, greater<pair<long long, int> > > que;

  for (int i = 0; i < MAX_V; ++i) dist[i] = INF;
  dist[r] = 0;
  que.push(make_pair(0, r));

  while (!que.empty()) {
    long long curDist = que.top().first;
    int curVertex = que.top().second;
    que.pop();

    if (dist[curVertex] < curDist) continue;

    for (int i = 0; i < graph[curVertex].size(); ++i) {
      int toVertex = graph[curVertex][i].first;
      long long toDist = curDist + graph[curVertex][i].second;

      if (dist[toVertex] > toDist) {
	dist[toVertex] = toDist;
	que.push(make_pair(toDist, toVertex));
      }
    }
  }

  for (int i = 0; i < V; ++i) {
    if (dist[i] < INF) cout << dist[i] << endl;
    else cout << "INF" << endl;
  }
}


Measured memory_bytes: 17728
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	vector<ll> P=vecin<ll>(3*N),C(N+1,0);
	priority_queue<ll> R;
	priority_queue<ll,vector<ll>,greater<ll>> L;
	ll sumL=0,sumR=0;
	REP(i,N){
		sumL += P[i];
		L.emplace(P[i]);
		sumR += P[3*N-1-i];
		R.emplace(P[3*N-1-i]);
	}
	C[N]=sumR;
	REP(i,N){
		auto V=R.top();
		R.pop();
		if(V>P[2*N-1-i]){
			sumR += P[2*N-1-i]-V;
			R.emplace(P[2*N-1-i]);
		}
		else{
			R.emplace(V);
		}
		C[N-1-i] = sumR;
	}
	ll ans=-(1LL<<60);
	REP(i,N+1){
		ans = max(ans,sumL-C[i]);
		auto V=L.top();
		L.pop();
		if(V<P[N+i]){
			sumL += P[N+i]-V;
			L.emplace(P[N+i]);
		}
		else{
			L.emplace(V);
		}
	}

	out(ans);
	return 0;
}

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

using namespace std;

int cnt[100005];
vector<int>crr[100005];
int dp[100005];

int n,m;

int dfs(int a,int par)
{
	int ma=0;
	int b;
	for (int i = 0; i < crr[a].size(); ++i)
	{
		if(cnt[crr[a][i]]==0)
		{
			cnt[crr[a][i]]=1;
			b=dfs(crr[a][i],a);
			if(b>ma)
				ma=b;
		}
		else
		{
			if(dp[crr[a][i]]>ma)
				ma=dp[crr[a][i]];
		}
	}
	dp[a]=ma+1;
	return ma+1;
}

int  main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n,a,b,c,d,w;
	cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		cin>>a>>b;
		crr[a].push_back(b);
	}
	int ma=0;
	for (int i = 1; i <=n ; ++i)
	{
		if(cnt[i]==0)
		{
			cnt[i]=1;
			a=dfs(i,0);
			if(a>ma)
				ma=a;
		}
	}

	cout<<ma-1<<endl;

	return 0;
}

Measured memory_bytes: 9216
#include <iostream>

using namespace std;

int main(){
    int c[4] = {0};
    for(int i = 0; i < 3; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        c[a]++;
        c[b]++;
    }
    for(int i = 0; i < 4; i++){
        if(c[i] != 1 && c[i] != 2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for(long long i=0LL; i<n; i++) cin >> a[i];

  long long ans = 0LL;
  for(long long i=1LL; i<n; i++) {
    long long dif = a[i] + a[i-1] - x;
    if (dif>0) {
      a[i] -= min(dif, a[i]);
      ans += dif;
    }
  }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define mod 1000000007
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);


bool compare(char &s1,char &s2) 
{ 
    return s1 > s2; 
} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 

    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;

    return false;

}
ll const mod = 1e9+7;
ll const inf = 1e5+1;


void solve()
{
    ll n; cin >> n;

    ll ans  = 0;
    f(i,1,n+1){
        ll x; cin >> x;
        if( (x&1) && (i&1)) ans++;

    }
    cout << ans << endl;
}
int main() {
Knucklehead 
/*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/

        ll t=1;
        //ll t;cin>>t;
        while(t-->0){
            solve();

        }




    return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;
//bool comp(
//
//	st pll &a, const pll &b) {
//	return a.first < b.first;
//}
//std::vector<int> enum_div(int n)//nの約数を列挙
//{
//	std::vector<int> ret;
//	for (int i = 1; i*i <= n; ++i)
//	{
//		if (n%i == 0)
//		{
//			ret.push_back(i);
//			if (i != 1 && i*i != n)
//			{
//				ret.push_back(n / i);
//			}
//		}
//	}
//	return ret;
//}

template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}

int main()
{
	priority_queue<int> q;
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	string s = {};
	ll x[100005] = {};
	ll y[302][302] = {};
	cin >> a;
	cin >> b;
	cin >> c;
	if (a+b+c>21)
	{
		cout << "bust" << endl;

	}
	else
	{
		cout << "win" << endl;

	}



	//cout<<factorial<10><<endl;

	//cin >> a >> b;
	//for (int i = 0; i < a; i++)
	//{
	//	cin >> s[i];
	//	if (s[i] >= b)
	//	{
	//		ans++;
	//	}
	//}

	//cout << ans << endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005,mod=998244353;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a,b;
int main()
{
	cin>>a>>b;
	for(int i=1;i<=10000;i++)
	{
		if(floor(0.08*i)==a&&floor(0.1*i)==b)
		{
			cout<<i;return 0;
		}
	}
	cout<<"-1";
}

Measured memory_bytes: 256