akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================

int gcd(int a, int b);

int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	

	ll N, K;
	cin >> N >> K;

	vll X(N), left, right;
	for (int i = 0; i < N; i++) {
		ll temp;
		cin >> temp;

		if (temp > 0) {
			right.emplace_back(temp);
		}
		else {
			left.emplace_back(-temp);
		}


	}

	sort(left.begin(), left.end());

	if (left.size() >= 1 && left[0] == 0) {
		K--;

		if (K == 0) {
			cout << 0;
			return 0;
		}
	}



	if (right.size() == 0) {
		cout << left[K - 1];
		return 0;
	}
	else if (left.size() == 0) {
		cout << right[K - 1];
		return 0;
	}


	ll ans = LLINF;
	for (int i = 0; i <= K; i++) {

		if (i <= right.size() && K - i <= left.size()  ) {

			ll r = right[i - 1];
			ll le;
			if (K - i >= 1) {
				le = left[K - i - 1];
			}
			else {
				le = 0;
			}

			ans = min(ans, r + le + min(r, le));
		}
	}


	cout << ans;
}



Measured memory_bytes: 2424
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut seq = vec![0 as i64; n + 1];
    seq[0] = 2;
    seq[1] = 1;
    for i in 2..n + 1 {
        seq[i] = seq[i - 1] + seq[i - 2];
    }
    println!("{}", seq[n]);
}


Measured memory_bytes: 4352
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int ans = 0;
        if (A + B < 2 * C) {
            ans += A * X + B * Y;
        } else {
            ans += Math.min(X, Y) * 2 * C;
            if (X > Y) {
                ans += (X - Y) * Math.min(A, 2 * C);
            } else {
                ans += (Y - X) * Math.min(B, 2 * C);
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
  int n;
  pair<int,int> ans(1,0);
  cin >> n;
  while(n--) {
    int a, v;
    cin >> a >> v;
    ans = min(ans, make_pair(-v, a));
  }
  cout << ans.second << " " << -ans.first << endl;
  return 0;
}

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

using namespace std;

int main() {
    int mod = int(1e9) + 7;
    int n;
    cin >> n;
    int sum = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ans = (ans + 1LL * x * sum % mod) % mod;
        (sum += x) %= mod;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    ll n,k;
    cin>>n>>k;
    vll h(n);
    rep(i,n)cin>>h[i];
    sort(all(h));
    ll sum=0;
    if(k<=n){
        rep(i,n-k)sum+=h[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
s=input()
s1=int(s[:4])
s2=int(s[5:7])
s3=int(s[8:10])
if s1<2019:
    print('Heisei')
elif s1==2019:
    if s2<4:
        print('Heisei')
    elif s2==4:
        if s3<=30:
            print('Heisei')
        else:
            print('TBD')
    else:
        print('TBD')
else:
    print('TBD')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1000;
typedef long long ll;
int n;
ll x,y;
ll a[N],b[N];
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
    scanf("%lld %lld",&x,&y);
    a[i]=x+y;
    b[i]=x-y;
  }
  sort(a+1,a+1+n);sort(b+1,b+1+n);
  cout<<max((a[n]-a[1]),(b[n]-b[1]))<<endl;
}


Measured memory_bytes: 6796
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline

def combination(n, k):
    numer = denom = 1
    for i in range(k):
        numer = numer * (n-i)
        denom = denom * (i+1)
    return numer // denom

N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort()
ave = sum(v[N-A:]) / A
x = v[N-A]
comb = 0
if x == v[-1]:
    n = N - bisect_left(v, x)
    for k in range(A, min(B, n)+1):
        comb += combination(n, k)
else:
    n = bisect_right(v, x) - bisect_left(v, x)
    k = bisect_right(v, x) - (N - A)
    comb = combination(n, k)
print(ave)
print(comb)

Measured memory_bytes: 38384
from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
q=[0]*7**6
v=[[]for _ in q]
z=0
for a,b in t:v[a-1]+=[b]
for i in v[:M]:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)


Measured memory_bytes: 59364
N=int(input())
S=input()

alphabet=[chr(i) for i in range(97,97+26)]

count_max=0
for i in range (N):
    left=S[:i]
    right=S[i:]
    count=0
    for j in range (len(alphabet)):
        if right.count(alphabet[j])>0 and left.count(alphabet[j])>0:
            count+=1
    if count>count_max:
        count_max=count
print(count_max)

Measured memory_bytes: 3064
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
count = 0

for i in range(N):
    if A[i] <= B[i]:
        count += A[i]
        B[i] = B[i] - A[i]
        if B[i] <= A[i+1]:
            count += B[i]
            A[i+1] = A[i+1] - B[i]
        else:
            count += A[i+1]
            A[i+1] = 0
    else:
        count += B[i]
print(count)


Measured memory_bytes: 19648
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

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

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s := r.nextString()

	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(s[2] == s[3] && s[4] == s[5])])
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    string s;

    cin >> n >> s;

    ll ma = 0;
    rep(i, 0, n){
        ll count = 0;
        map<ll, ll> m;
        rep(j, 0, i){
            if(!m.count(s[j])){
                m[s[j]]++;
                rep(k, i, n){
                    if(s[j] == s[k]){
                        count++;
                        break;
                    }
                }
            }
        }
        ma = max(ma, count);
    }

    cout << ma << endl;
}


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

int main() {
	unsigned long long x;
	unsigned long long a;
	unsigned int ret = 0;
	unsigned long long money = 100;

	cin >> x;

	while (true) {
		ret++;
		a = money / 100ull;
		money += a;
		if (x <= money) {
			break;
		}
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, M, L;
    cin >> N >> M >> L;

    vll A, B, C;
    REP(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        A.pb(a); B.pb(b); C.pb(c);
    }

    vector<vll> D(N, vll(N, INF));
    REP(i, N) D[i][i] = 0;
    vector<vll> F(N, vll(N, INF));
    REP(i, N) F[i][i] = 0;

    REP(i, M) {
        D[A[i]][B[i]] = min(D[A[i]][B[i]], C[i]);
        D[B[i]][A[i]] = min(D[A[i]][B[i]], C[i]);
    }

    REP(i, N) {
        REP(j, N) {
            REP(k, N) {
                D[j][k] = min(D[j][k], D[j][i] + D[i][k]);
            }
        }
    }

    REP(i, N) {
        REP(j, N) {
            if (i == j) continue;
            if (D[i][j] <= L) F[i][j] = 1LL;
        }
    }

    REP(i, N) {
        REP(j, N) {
            REP(k, N) {
                F[j][k] = min(F[j][k], F[j][i] + F[i][k]);
            }
        }
    }

    int Q; cin >> Q;
    REP(i, Q) {
        int s, t;
        cin >> s >> t;
        --s; --t;

        print(F[s][t] != INF ? F[s][t] - 1 : -1);
    }
}


Measured memory_bytes: 5868
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

    private static final String YES = "YES";
    private static final String NO = "NO";

    private static final int NUM_ROADS = 3;
    private static final int NUM_CITIES = 4;

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        List<List<Integer>> roads = new ArrayList<>();
        for (int i = 0; i < NUM_ROADS; ++i) {
            List<Integer> road = new ArrayList<>();
            int a = sc.nextInt();
            int b = sc.nextInt();
            road.add(a);
            road.add(b);

            roads.add(road);
        }

        sc.close();
        return new TestCase(roads);
    }

    public static String process(TestCase testCase) {
        final List<List<Integer>> roads = testCase.roads;
        int[] cityCounts = new int[NUM_CITIES];

        roads.forEach(road -> road.forEach(rawCity -> cityCounts[rawCity - 1]++));

        int oddCount = 0;
        for (int count : cityCounts) {
            if (count == 0) {
                return NO;
            }
            final boolean isOdd = count % 2 != 0;
            if (isOdd) {
                oddCount++;
            }
        }
        final boolean isPossible = oddCount == 0 || oddCount == 2;
        return isPossible ? YES : NO;
    }


    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final List<List<Integer>> roads;

        public TestCase(List<List<Integer>> roads) {
            this.roads = roads;
        }
    }

}


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

const int NMAX = 8;
bool graph[NMAX][NMAX];

int dfs(int v, int N, bool visited[NMAX])
{
    bool all_visited = true;
    for (int i = 0; i < N; i++)
    {
        if (visited[i] == false)
            all_visited = false;
    }
    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (int i = 0; i < N; i++)
    {
        if (graph[v][i] == false)
            continue;
        if (visited[i])
            continue;
        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }
    return ret;
}

int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        graph[A - 1][B - 1] = true;
        graph[B - 1][A - 1] = true;
    }
    bool visited[NMAX];
    for (int i = 0; i < N; i++)
    {
        visited[i] = false;
    }
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
    return 0;
}


Measured memory_bytes: 256
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9+7;

int gcd(int a,int b){ return b ? gcd(b,a % b) : a; }
int lcm(int a,int b){ return a / gcd(a,b) * b; }

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> h(n),dp(n);
	rep(i,n){
		cin >> h[i];
	}
	reps(i,n-1){
		if(i == 1) dp[i] = abs(h[i-1]-h[i]) + dp[i-1];
		else dp[i] += min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2]); 
	}
	cout << dp[n-1] << '\n';
	return 0;	
}


Measured memory_bytes: 1792
ab=[]
n, m = map(int, input().split())
h = list(map(int, input().split()))

for i in range(m):
    ab.append(list(map(int, input().split())))

f = [1] * len(h)

for i,abi in enumerate(ab):
    if h[abi[0]-1] <= h[abi[1]-1]:
        f[abi[0]-1] = 0
    if h[abi[0]-1] >= h[abi[1]-1]:
        f[abi[1]-1] = 0

print(sum(f))

Measured memory_bytes: 32052
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;
typedef string str;

int main(){
  str s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll K, A, B; cin >> K >> A >> B;
	ll ans = K + 1;
	if (B - A > 1) {
		ll tmp = A - 1;
		K -= tmp;
		tmp++;
		tmp += K / 2 * (B - A);
		if (K % 2)++tmp;
		chmax(ans, tmp);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> a, a2;


int main()
{
    ll n, k;
    cin>>n>>k;
    a.resize(n);
    REP(i,n) cin>>a[i];

    ll ans = 0ll;
    REP(i,n) {
        FOR(j,i+1,n) {
            if (a[i] > a[j]) {
                ans += k * (k+1) / 2ll;
                ans %= MOD;
            } else if (a[i] < a[j]) {
                ans += (k-1) * k / 2ll;
                ans %= MOD;
            }

        }
    }
    cout<<ans<<endl;

    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;
    return (0);
}


Measured memory_bytes: 256
n = gets.to_i
chars = gets.chars

r_cnt = chars.count('R')
w_cnt = 0
ans = [w_cnt, r_cnt].max
chars.each do |c|
  if c == 'R'
    r_cnt -= 1
  else
    w_cnt += 1
  end
  ans = [ans, [r_cnt, w_cnt].max].min
end
puts ans

Measured memory_bytes: 30228
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    string s;
    cin >> s;

    cout << s.rfind("Z") - s.find("A") + 1 << endl;

    return 0;
}

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

using namespace std;

int n, c, k;


int main(){
    cin >> n >> c >> k;
    vector<int> t(n);
    for (int i = 0; i < n; i++){
        cin >> t[i];
    }

    sort(t.begin(), t.end());

    int now = t[0];
    int j = 0;
    int ans = 1;
    for (int i = 0; i < n; i++){
        if (t[i] > t[j] + k || i - j == c){
            ans++;
            j = i;
        }
    }

    cout << ans << endl;
}

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

int main(){
int a,b,c;
cin >> a >> b>> c;
if(a+b+c>=22)cout <<"bust" << endl;
else cout << "win" << endl;
}

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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())

//int infiint = std::numeric_limits<int>::max();
//float infiflt = std::numeric_limits<float>::infinity();


int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
//	freopen("input.txt", "rt", stdin);

	int n;
	cin >> n;
	vector<int> v;
	int gh = 0;

	for(int i = 0; i < n; i++) {
		cin >> gh;
		v.push_back(gh);
	}

	int mini = v[0];
	int ans = 1;
	for(int i = 1; i < n; i++) {
		mini = min(mini, v[i]);
		if(mini == v[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i, n) for (int32_t i = 0; i < n; ++i)
#define repl(i, n) for (int64_t i = 0; i < n; ++i)

using namespace std;

vector<string> poll(vector<string> &vec) {
  auto max = 0;
  auto map = unordered_map<string, int>();
  for (auto str : vec) {
    map[str] += 1;
    auto count = map[str];
    if (count > max) {
      max = count;
    }
  }

  auto results = vector<string>();
  for (auto p : map) {
    if (p.second == max) {
      results.push_back(p.first);
    }
  }
  return results;
}

int main() {
  int n;
  cin >> n;
  auto invec = vector<string>(n);
  for (auto &s : invec) {
    cin >> s;
  }
  auto vec = poll(invec);
  sort(vec.begin(), vec.end());
  for (auto x : vec) {
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 26952
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A,B,K=nm()

eat_A=min(K,A)
K-=eat_A
A-=eat_A
eat_B=min(K,B)
K-=eat_B
B-=eat_B

ans=[A,B]
print(*ans)

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

using ll = long long;

int main() {
    int n, u, k, v;
    cin >> n;
    vector<vector<int>> edge(n);
    vector<int> d(n, -1);
    rep(i, n) {
        cin >> u >> k;
        rep(j, k) {
            cin >> v;
            edge[u - 1].push_back(v - 1);
        }
    }
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    d[0] = 0;
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        int v0 = p.first, d0 = p.second;
        rep(i, edge[v0].size()) {
            int v1 = edge[v0][i];
            if (d[v1] != -1) continue;
            q.push(make_pair(v1, d0 + 1));
            d[v1] = d0 + 1;
            //cout << "d[" << v1 << "]=" << d0 + 1 << "\n";
        }
    }
    rep(i, n) {
        cout << i + 1 << " " << d[i] << "\n";
    }
}


Measured memory_bytes: 3148
from itertools import accumulate as acc
import sys

N,C=map(int,input().split())
a=[list(map(int,input().split())) for i in range(N)]

if N==1: print(max(0, a[0][1]-a[0][0], a[0][1]-(C-a[0][0]) ) ),sys.exit()

b=list(acc( [ a[i][1] for i in range(N)] ))

ans= sum([a[i][1] for i in range(N)])+max(C-a[0][0],a[N-1][0])

l=[[b[i]-a[i][0],0] for i in range(N)]
r=[[b[N-1]-(C-a[0][0]),0]]+[[b[N-1]-b[i]-(C-a[i+1][0]),0] for i in range(N-1)]

tmp=0
for i in range(N):
    if l[i][0]>tmp: tmp=l[i][0]
    l[i][1]=tmp
tmp=0
for i in range(N-1,-1,-1):
    if r[i][0]>tmp: tmp=r[i][0]
    r[i][1]=tmp

p=[l[0][1],r[0][1],l[0][1]-a[0][0]+r[1][1]]
q=[l[N-1][1],r[N-1][1],r[N-1][0]-(C-a[N-1][0])+l[N-2][1]]

ans=max(p+q)

for i in range(1,N-1):
    p1=l[i][1]
    p2=r[i][1]
    p3=l[i][1]-a[i][0]+r[i+1][1]
    p4=r[i][1]-(C-a[i][0])+l[i-1][1]
    
    ans=max(ans,p1,p2,p3,p4)
    
print(ans)

Measured memory_bytes: 54156
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
#include <unordered_map>
#include <cstring>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;

const ll MOD = 1e9 + 7;


ll power(ll n, ll p) {
	ll ans = 1;
	while (p > 0) {
		if (p & 1) {
			ans = (n * ans) % MOD;
		}
		n = (n * n) % MOD;
		p /= 2;
	}
	return ans;
}


ll inverse(ll n) {
	return power(n, MOD - 2);
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> fact(2000000 + 2), inv(2000000 + 2, 1);
	fact[1] = 1, fact[0] = 1;
	for (ll i = 2; i <= 2000001; i++) {
		fact[i] = (i * fact[i - 1]) % MOD;
	}

	inv[2000000 + 1] = inverse(fact[2000000 + 1]);
	for (ll i = 2000000; i >= 1; i--) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	ll ans = 0;
	for (ll i = r1; i <= r2; i++) {
		ans += (((fact[i + 1 + c2] * inv[c2]) % MOD) * inv[i + 1]) % MOD - (((fact[c1 - 1 + i + 1] * inv[c1 - 1]) % MOD) * inv[i + 1]) % MOD;
		ans %= MOD;
	}
	ans = ((ans % MOD) + MOD) % MOD;
	cout << ans;
}



Measured memory_bytes: 31488
#include <stdio.h>

int main(void){

  //755 575 557  3!/2!
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a == 7 && b == 5 && c == 5)
    printf("YES");
  else if(a == 5 && b == 7 && c == 5)
  	printf("YES");
  else if(a == 5 && b == 5 && c == 7)
    printf("YES");
  else
    printf("NO");
}



Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * 2 for _ in range(n + 1)]

dp[0][1] = -1e9
for i in range(n):
    dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i])
    dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i])
print(dp[n][0])

Measured memory_bytes: 25600
from collections import deque
s = deque(list(input()))
q = int(input())
cnt = 0
for _ in range(q):
    fc = input().split()
    if fc[0] == '1':
        cnt += 1
    else:
        if cnt == 1:
            fc[1] = '1' if fc[1] == '2' else '2'
        if fc[1] == '1':
            s.appendleft(fc[2])
        else:
            s.append(fc[2])
    cnt %= 2
if cnt == 1:
    s.reverse()
print(*s, sep='')


Measured memory_bytes: 12256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll a, b;
ll c, d;

int main(){

  a = in();
  b = in();

  if( abs( a - b ) >= 2 ){
    puts( "Alice" );
  } else {
    puts( "Brown" );
  }

  return 0;
}


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

int mx[ ]={0,1,0,-1};
int my[ ]={1,0,-1,0};

int main(){
	queue<pair<pair<int,int>,int> > bfs;
	int h,w;
	cin >> h >> w;
	char area[h+5][w+5];
	bool vis[h+5][w+5];
	memset(vis,0,sizeof vis);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> area[i][j];
			if(area[i][j]=='#'){
				bfs.push({{i,j},0});
				vis[i][j]=1;
			}
		}
	}
	int ans=0;
	while(!bfs.empty()){
		int x=bfs.front().first.first;
		int y=bfs.front().first.second;
		int n=bfs.front().second;
		ans=max(ans,n);
		bfs.pop();
		for(int i=0;i<4;i++){
			if(x+mx[i]>=0 && y+my[i]>=0 && x+mx[i]<h && y+my[i]<w && !vis[x+mx[i]][y+my[i]]){
				bfs.push({{x+mx[i],y+my[i]},n+1});
				vis[x+mx[i]][y+my[i]]=1;
			}
		}
	}
	cout << ans << '\n';
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  REP(i,100000){
    if(a%2 || b%2 || c%2){
      cout<<i<<endl;
      return 0;
    }
    ll x = a/2;
    ll y = b/2;
    ll z = c/2;
    a = y+z;
    b = x+z;
    c = x+y;
  }
  puts("-1");
  return 0;
}


Measured memory_bytes: 764
#pragma GCC optimize("O3")

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
   SpeedForce;
	cin >> n;
	ll ans = n * (ll)(n - 1) / 2ll;
	cout << ans << '\n';
   return Accepted;
}

// B...a

Measured memory_bytes: 18688
#include <algorithm>
#include <cstring>
#include <cstdio>
int lst[10005], to[100005], pre[100005], cap[100005], tot; 
int dep[10005], fst[10005], que[10005]; 
inline void add_edge(int u, int v, int _cap)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	cap[tot] = _cap; 
	lst[u] = tot++; 
	to[tot] = u; 
	pre[tot] = lst[v]; 
	cap[tot] = 0; 
	lst[v] = tot++; 
}
inline bool bfs(int s, int t)
{
	int he = 0, ta = 1; 
	que[0] = s; 
	memset(dep, -1, sizeof(dep)); 
	dep[s] = 0; 
	while (he < ta)
	{
		int u = que[he++]; 
		for (int i = lst[u]; ~i; i = pre[i])
		{
			if (cap[i] && dep[to[i]] == -1)
			{
				dep[to[i]] = dep[u] + 1; 
				que[ta++] = to[i]; 
			}
		}
	}
	return dep[t] != -1; 
}
int dfs(int u, int t, int mx)
{
	if (u == t)
		return mx; 
	int ans = 0; 
	for (int i = fst[u]; ~i; i = pre[i])
	{
		if (cap[i] && dep[to[i]] == dep[u] + 1)
		{
			int res = dfs(to[i], t, std::min(mx - ans, cap[i])); 
			cap[i] -= res; 
			cap[i ^ 1] += res; 
			if (cap[i])
				fst[u] = i; 
			ans += res; 
			if (ans == mx)
				return ans;
		}
	}
	if (!ans)
		dep[u] = -1; 
	return ans; 
}
inline int dinic(int s, int t)
{
	int ans = 0; 
	while (bfs(s, t))
	{
		memcpy(fst, lst, sizeof(lst)); 
		ans += dfs(s, t, 1e9); 
	}
	return ans; 
}
char str[105]; 
int main()
{
	// freopen("ARC074-F.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	int n, m, stx, sty, enx, eny; 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < n; i++)
	{
		scanf("%s", str); 
		for (int j = 0; j < m; j++)
		{
			if (str[j] == 'S')
			{
				add_edge(0, i + 1, 1e9); 
				add_edge(0, j + n + 1, 1e9); 
				stx = i; 
				sty = j; 
			}
			else if (str[j] == 'T')
			{
				add_edge(i + 1, n + m + 1, 1e9); 
				add_edge(j + n + 1, n + m + 1, 1e9); 
				enx = i; 
				eny = j; 
			}
			else if (str[j] == 'o')
			{
				add_edge(i + 1, j + n + 1, 1); 
				add_edge(j + n + 1, i + 1, 1); 
			}
		}
	}
	if (stx == enx || sty == eny)
		puts("-1"); 
	else
		printf("%d\n", dinic(0, n + m + 1));
	return 0; 
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        double a2 = Math.sqrt(a);
        double b2 = Math.sqrt(b);
        double c2 = Math.sqrt(c);
        double d2 = c2 - (a2 + b2);
        
        // a+b+2r(ab) < c
        // 2r(ab) < c - a - b;
        // 4ab < (c - a - b) ^2
        double x3 = a2 * b2 * 2;
        
        if (c - a - b < 0) {
            System.out.println("No");
            return;
        }
        
        if ((long)4 * a * b < (long)(c-a-b) * (c-a-b)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  vector<int > vec(5);
  vec[0]=a;vec[1]=b;vec[2]=c;vec[3]=d;vec[4]=e;int k=0;int l=100;
  for(int i=0;i<5;i++){
  if(vec[i]%10 == 0){k += vec[i];}
    else{k+= (vec[i]/10 + 1 ) * 10;
        l =min(l,vec[i]%10);
        }
  }
if(l==100)l=10;
  
  cout << k -10 + l <<endl;
  
  
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,m; cin >> n >> m;
    vector<int> G[n];
    rep(i,m){
        int x,y,z; cin >> x >> y >> z;
        x--; y--;
        G[x].pb(y);
        G[y].pb(x);

    }
    int ans=0;
    queue<int> q;
    vector<bool> vis(n,0);
    rep(i,n){
        if(!vis[i]){
            q.push(i); vis[i]=1;
            while(!q.empty()){
                int v=q.front(); q.pop();
                for(int u:G[v]){
                    if(vis[u]) continue;
                    vis[u]=1; q.push(u);
                }
            }
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6520
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
using namespace std;

void solve(long long n, std::vector<long long> a){
    deque<long long> q;
    for(int i=0; i<n; i++){
        if(i%2==0)q.push_back(a[i]);
        else q.push_front(a[i]);
    }
    if((n-1)%2==0)reverse(q.begin(), q.end());
    for(auto it=q.begin(); it!=q.end(); it++)cout << *it << (it != q.end()-1 ? " " : "");
    cout << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  unsigned int N , M;
  C2(N,M);

  unsigned int a[N];
  unsigned int b[N];

  rep(i,0,M)
    cin >> a[i] >> b[i];

  bool e[N] = {};
  rep(i,0,M){
    if(a[i] == 1)
      e[b[i]] = true;
  }

  rep(i,0,M){
    if(b[i] == N && e[a[i]]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  
  
  
  
  
  cout << "IMPOSSIBLE" << endl;


  ret 0;

}

Measured memory_bytes: 2048
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int n, m;
    cin >> n >> m;
    for(int i= 0;i < m;i++)
    {
        int a;
        cin >> a;
        n -= a;
    }
    cout << max(-1, n);
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define PI 3.141592653589793238
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
#define MAX 200000
multiset<int> kind[MAX+1]; // kind[i] has multiset representing kg i
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in2.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T=1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		int n; cin >> n;
		set<string> st;
		FOR1(i, n){
			string s; cin >> s;
			st.insert(s);
		}
		cout << st.size();
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 28596
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

constexpr int N = 1e5;
constexpr char init_c = 0b11;
std::array<std::vector<int>, N> Edge;
std::array<char, N> Dist;

int main(void){
    int n, m; scanf("%d%d", &n, &m);
    REP(i, m){
        int u, v; scanf("%d%d", &u, &v); u--; v--;
        Edge[u].push_back(v); Edge[v].push_back(u);
    }
    lli res = 0;
    REP(i, n) Dist[i] = init_c;
    REP(i, n) if(Dist[i] == init_c){
        std::array<lli, 2> Unit{1, 0};
        std::queue<int> Q;
        Q.push(i); Dist[i] = 0;
        bool flag = false;
        while(not Q.empty()){
            int v = Q.front(); Q.pop();
            const char nd = (Dist[v] + 1) & 0b01;
            for(int nv : Edge[v]){
                if(Dist[nv] == init_c){
                    Dist[nv] = nd; Q.push(nv); Unit[nd]++;
                }
                else if(Dist[nv] == Dist[v]) flag = true;
            }
        }
        if(flag) res += (Unit[0] + Unit[1]) * (Unit[0] + Unit[1] - 1) / 2;
        else res += Unit[0] * Unit[1];
    }
    res -= m;
    printf("%lld\n", res);

    

    
    return 0;
}



Measured memory_bytes: 6016
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let n = line.trim().parse::<usize>().unwrap();
    let mut v = vec![];
    v.push("Christmas");
    for _ in 0..(25 - n) {
        v.push("Eve");
    }
    println!("{}", v.join(" "));
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
    int i,j,a;
    int num[4];
    for (i=0;i<3;i++)
    {
        scanf("%d",&num[i]);
    }
    for (i=0;i<3;i++)
    {
        for (j=i+1;j<3;j++)
        {
            if (num[i]>num[j])
            {
                a=num[i];
                num [i]=num[j];
                num[j]=a;
            }
        }
    }

printf("%d %d %d\n",num[0],num[1],num[2]);


}



Measured memory_bytes: 2748
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
    long long N;
    long long K;
    long long L;
    long long R;
    long long one_index;
    scanf("%lld%lld", &N, &K);
    long long A[N];
    for(long long n = 0;n < N;n++) {
        scanf("%lld", &A[n]);
        if(A[n] == 1) {
            one_index = n;
            L = n - 1 + 1;
            R = N - n - 1;
        }
    }

    long long saisyo = N;
    for(long long s = one_index - K + 1; s <= one_index;s++) {
        long long count = 1;
        long long l = s;
        long long r = N - (s + K);
        if(l < 0 || r < 0)continue;
        count += l/(K - 1) + (l%(K - 1) == 0 ? 0 : 1);
        count += r/(K - 1) + (r%(K - 1) == 0 ? 0 : 1);
        saisyo = min(saisyo, count);
    }

    printf("%lld\n", saisyo);
    return 0;
}


Measured memory_bytes: 1024