akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	N := nextInt()
	M := nextInt()
	A := make([]int, M)
	B := make([]int, M)
	for i := 0; i < M; i++ {
		A[i] = nextInt() - 1
		B[i] = nextInt() - 1
	}

	ans := make([]int, M)
	ans[M-1] = N * (N - 1) / 2

	uf := newUnionFind(N)

	for i := M - 1; i >= 1; i-- {
		ans[i-1] = ans[i]
		if uf.root(A[i]) != uf.root(B[i]) {
			ans[i-1] -= uf.size(A[i]) * uf.size(B[i])
			uf.connect(A[i], B[i])
		}
	}

	for i := 0; i < M; i++ {
		fmt.Println(ans[i])
	}
}

type unionFind struct {
	parent []int
}

func newUnionFind(N int) *unionFind {
	parent := make([]int, N)
	for i := 0; i < N; i++ {
		parent[i] = -1
	}

	return &unionFind{parent: parent}
}

func (uf *unionFind) root(A int) int {
	if uf.parent[A] < 0 {
		return A
	}

	uf.parent[A] = uf.root(uf.parent[A])
	return uf.parent[A]
}

func (uf *unionFind) size(A int) int {
	return uf.parent[uf.root(A)]
}

func (uf *unionFind) connect(A, B int) bool {
	A = uf.root(A)
	B = uf.root(B)
	if A == B {
		return false
	}

	if uf.size(A) < uf.size(B) {
		A, B = B, A
	}

	uf.parent[A] += uf.parent[B]
	uf.parent[B] = A

	return true
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

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

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 13440
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Math.sin;
import static java.lang.Math.cos;
import static java.lang.Math.toRadians;

public class Main {

  private static StringBuilder buf = new StringBuilder();

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt( br.readLine() );
      Point2D p1 = new Point2D(0,0);
      Point2D p2 = new Point2D(100, 0);

      buf.append(p1);
      kochCurve( n, p1, p2 );
      buf.append(p2);

      System.out.print(buf);
      
    }
  }

  private static void kochCurve(int d, Point2D p1, Point2D p2) {
    if( d != 0) {
      Point2D s = new Point2D();
      Point2D t = new Point2D();

      s.x = (2*p1.x + p2.x) / 3;
      s.y = (2*p1.y + p2.y) / 3;
      t.x = (p1.x + 2*p2.x) / 3;
      t.y = (p1.y + 2*p2.y) / 3;

      Point2D u = new Point2D();
      double rad = toRadians(60);

      u.x = (t.x - s.x)*cos(rad) - (t.y - s.y)*sin(rad) + s.x;
      u.y = (t.x - s.x)*sin(rad) + (t.y - s.y)*cos(rad) + s.y;

      kochCurve(d-1, p1, s);
      buf.append(s);
      kochCurve(d-1, s, u);
      buf.append(u);
      kochCurve(d-1, u, t);
      buf.append(t);
      kochCurve(d-1, t, p2);
    }
  }
}

class Point2D {
  double x;
  double y;

  public Point2D() {
    x = 0;
    y = 0;
  }
  public Point2D(double x,double y) {
    this.x = x;
    this.y = y;
  }

  @Override
  public String toString() {
    return String.format("%.8f %.8f\n", x, y);
  }
  public double distance(Point2D p) {
    return Math.sqrt(Math.pow((p.x - this.x),2) + Math.pow((p.y - this.y), 2));
  }
}


Measured memory_bytes: 41060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((b-a)==(c-b))
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

typedef pair<int, int> P;

int main() {
	int n, w, d;
	while (cin >> n >> w >> d) {
		if (n == 0 && w == 0 && d == 0) {
			break;
		}
		vector<P> data;
		data.push_back(P(w, d));
		int p, s;
		for (int i = 0; i < n; i++) {
			cin >> p >> s;
			P pp = data[p-1];
			vector<P>::iterator ite = data.begin();
			for (int j = 0; j < p-1; j++) {
				ite++;
			}
			data.erase(ite);
			bool hantei = true;
			s %= pp.first+pp.second;
			if (s > pp.first) {
				s -= pp.first;
				hantei = false;
			} 
			if (hantei) {
				P p1, p2;
				p1 = P(s, pp.second);
				p2 = P(pp.first-s, pp.second);
				if (s > pp.first-s) {
					data.push_back(p2);
					data.push_back(p1);
				} else {
					data.push_back(p1);
					data.push_back(p2);
				}
			} else {
				P p1, p2;
				p1 = P(pp.first, s);
				p2 = P(pp.first, pp.second-s);
				if (s > pp.second-s) {
					data.push_back(p2);
					data.push_back(p1);
				} else {
					data.push_back(p1);
					data.push_back(p2);
				}
			}
		}
		priority_queue<int, vector<int>, greater<int> > pq;
		for (int i = 0; i < data.size(); i++) {
			pq.push(data[i].first*data[i].second);
		}
		cout << pq.top();
		pq.pop();
		while (!pq.empty()) {
			cout << ' '<< pq.top();
			pq.pop();
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int read(){int x;scanf("%d",&x);return x;}
int is[1000];
int main()
{
    int n,k;cin>>n>>k;
    while(k--)
    {
	int d;cin>>d;
	for(int x;d;--d) cin>>x,is[x]=1;
    }
    int ans=0;
    for(int i=1;i<=n;++i) if(!is[i]) ++ans;
    cout<<ans;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;

ll d_size(ll n){
    if(n < 0) return 0;
    ll count = 1;
    while(n >= 10){
        n /= 10;
        count++;
    }
    return count;
}

int main(void){
    FAST_IO

    ll n,k;
    cin >> n >> k;
    vll v(100000+1);

    rep(i,n){
        ll a,b;
        cin >> a >> b;
        v[a] += b;
    }

    rep(i,100000+1){
        k -= v[i];
        if(k <= 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  string s;
  cin >> s;
  ll L = (s.size() + 1)/2;
  for(int i = 0; i < L; i++){
    cout << s.at(2*i);
  }
  cout << endl;
}


Measured memory_bytes: 512
n = int(input())
s = [input() for i in range(n)]
# print(n)
# print(s)
s = list(map(list, s))
# print(s)
for i in range(n):
    s[i].sort()
    s[i] = "".join(s[i])
# print(s)
dic = {}
for i in range(n):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic.setdefault(s[i],1)
a = list(dic.values())
# print(a)
import math
count = 0
for i in range(len(a)):
    if a[i] >= 2:
        count += int(math.factorial(a[i])/(math.factorial(a[i]-2)*2))
print(count)

Measured memory_bytes: 31280
import numpy as np

N = int(input())

values = [tuple(map(int, input().split(' '))) for _ in range(N)]
dp = [values[0]]
for _ in range(N - 1):
    dp.append([0, 0, 0])

for i in range(1, N):
    prev = dp[i - 1]
    dp[i][0] = values[i][0] + max(prev[1], prev[2])
    dp[i][1] = values[i][1] + max(prev[0], prev[2])
    dp[i][2] = values[i][2] + max(prev[0], prev[1])

print(np.max(dp[N - 1]))


Measured memory_bytes: 49128
import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val (n, k) = (sc.nextInt, sc.nextInt)
  val xs = Vector.fill(n)(sc.nextInt)

  @tailrec
  def lp(as: Seq[Int], acc: Int): Int = {
    val x = as.take(k)
    if (x.length == k) {
      val d = x.last - x.head + (Math.abs(x.last) min Math.abs(x.head))
      lp(as.tail, acc min d)
    } else {
      acc
    }
  }

  println(lp(xs, Int.MaxValue))
}


Measured memory_bytes: 72460
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import defaultdict

def f(x):
    return (int(str(x)[0]), int(str(x)[-1])) 
def main():
    N = int(readline())
    df = defaultdict(int)
    for i in range(1, N+1):
        df[f(i)] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans +=  df[(i, j)]*df[(j, i)]
    print(ans)
if __name__ == '__main__':
    main()


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

struct Node{ int l=-1,r=-1,p=-1; };

int N;
Node V[100];
int R;

void Preorder(int p){
 if(p==-1) return;
 printf(" %d",p);
 Preorder(V[p].l);
 Preorder(V[p].r);
}
void Inorder(int p){
 if(p==-1) return;
 Inorder(V[p].l);
 printf(" %d",p);
 Inorder(V[p].r);
}
void Postorder(int p){
 if(p==-1) return;
 Postorder(V[p].l);
 Postorder(V[p].r);
 printf(" %d",p);
}

int main() {
 scanf("%d",&N);
 rep(i,N){
  UL v,l,r; scanf("%u%u%u",&v,&l,&r);
  V[v].l=l; V[v].r=r;
  if(l!=-1) V[l].p=v;
  if(r!=-1) V[r].p=v;
 }
 rep(i,N) if(V[i].p==-1) R=i;

 printf("Preorder\n"); Preorder(R); printf("\n");
 printf("Inorder\n"); Inorder(R); printf("\n");
 printf("Postorder\n"); Postorder(R); printf("\n");
}



Measured memory_bytes: 3200
s = input()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

if A+B+C+D == 7:
    line = str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7"
elif A+B+C-D == 7:
    line = str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7"
elif A+B-C+D == 7:
    line = str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7"
elif A-B+C+D == 7:
    line = str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7"
elif A+B-C-D == 7:
    line = str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7"
elif A-B-C+D == 7:
    line = str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7"
elif A-B+C-D == 7:
    line = str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7"
elif A-B-C-D == 7:
    line = str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7"

print(line)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	//input elements
	int n = Integer.parseInt(scan.nextLine());
	String[] inputs = scan.nextLine().split(" ");
	int[] cards = new int[n];
	for (int i = 0; i < n; i++) {
	    cards[i] = Integer.parseInt(inputs[i]);
	}

	//insertion sort
	for (int i = 1; i < n; i++) {
	    //show cards
	    printArray(cards);
	    int key = cards[i];
	    int j = i - 1;
	    while (j >= 0 && cards[j] > key) {
		cards[j+1] = cards[j];
		j--;
	    }
	    cards[j+1] = key;
	}
	//show cards
	printArray(cards);
    }
    static void printArray(int[] a){
	for (int i = 0; i < a.length-1; i++) {
	    System.out.print(a[i] + " ");
	}
	System.out.println(a[a.length-1]);
    }
}

Measured memory_bytes: 31040
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(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 = 2147483647;
constexpr ll mod = 1000000007;

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();

	int N; cin >> N;
	map<ll, int, greater<ll>>mp;
	rep(i, N) {
		ll a; cin >> a;
		mp[a]++;
	}
	ll ans = 0;
	for (auto p : mp) {
		if (p.second < 2)continue;
		for (auto q : mp) {
			if (q.second < 2)continue;
			if (p.first == q.first && q.second < 4)continue;
			if (chmax(ans, p.first * q.first)) {
				cout << ans << "\n";
				return 0;
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>

int main(void){

	int cardS[13] = { 0 };
	int cardH[13] = { 0 };
	int cardC[13] = { 0 };
	int cardD[13] = { 0 };
	char suits;
	int rank;
	int n, i;

	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		
		scanf(" %c %d", &suits, &rank);

		if (suits == 'S'){
			cardS[rank - 1] = 1;
		}else if (suits == 'H'){
			cardH[rank - 1] = 1;
		}else if (suits == 'C'){
			cardC[rank - 1] = 1;
		}else if (suits == 'D'){
			cardD[rank - 1] = 1;
		}
	}

	for (i = 1; i <= 13; i++){
		if (cardS[i-1] == 0){
			printf("%c %d\n", 'S', i);
		}
	}
	for (i = 1; i <= 13; i++){
		if (cardH[i - 1] == 0){
			printf("%c %d\n", 'H', i);
		}
	}
	for (i = 1; i <= 13; i++){
		if (cardC[i - 1] == 0){
			printf("%c %d\n", 'C', i);
		}
	}
	for (i = 1; i <= 13; i++){
		if (cardD[i - 1] == 0){
			printf("%c %d\n", 'D', i);
		}
	}
	return 0;
}

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

#define ll long long

ll N, res = 0;

void f(ll n, ll k)
{
	if (k == 1) return;
	if (n <= 0) return;
	if (n == 1) { res++; return; }
	if (n%k==0) f(n/k, k);
	else if (n >= k) f(n%k, k);
}

int main()
{
	scanf("%lld", &N);
	for(ll i=1; i*i<=N; i++)
	{
		if (N%i==0)
		{
			f(N, i);
			if (i*i!=N) f(N, N/i);
		}
	}
	N--;
	for(ll i=1; i*i<=N; i++)
	{
		if (N%i==0)
		{
			if (i != 1) res++;
			if (i*i!=N) res++;
		}
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	reus;
	int p,q,r,a,b,c;
	cin>>p>>q>>r;
	a=min(p+q,q+r);
	b=r+p;
	c=min(a,b);
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)

using namespace std;

int main() {
   int a,b;
   cin >>  a >> b;
   cout << (a-1)*(b-1) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M;
    cin >> N >> M;
    ll dan[N];
    rep(i,N) dan[i] = 0;
    ll out = 0;
    bool isZero = false;
    ll a = 0;
    ll b = 0;
    rep(i,M){
        cin >> a;
        if(i>0&&a==b+1){
            isZero = true;
            break;
        }
        dan[a-1] = 1;
        b = a;
    }
    ll mod = 1000000007;
    ll A[N];
    rep(i,N) A[i] = 0;
    if(!isZero){
        rep(i,N){
            if(dan[i]==1) A[i] = 0;
            else if(i==0) A[i] = 1;
            else if(i==1){
                if(A[i-1]==0) A[i] = 1;
                else A[i] = 2;
            }
            else A[i] = (A[i-1]%mod+A[i-2]%mod)%mod;
        }
        out = A[N-1]%mod;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int prime(int i) {
	int k;

	if(i==1)
		return 0;

	if(i==2||i==3)
		return 1;

	for(k=2;k<=sqrt(i);k++)
		if(i%k==0) return 0;

	return 1;
}

int main() {

	int a,d,n;
	int i,count;

	for(;;) {
		scanf("%d %d %d",&a,&d,&n);
		if(!a&&!d&&!n) break;
		count=0,i=a;
		while(count<n) {
			if(prime(i)) {
				count++;
			}
			i+=d;
			//printf("%d\n",i);
		}
		printf("%d\n",i-d);
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <ll> a(n+1);
    ll sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    vector <ll> test(n+1);
    test[1]=sum;
    for(int i=2;i<=n;i+=2)
        test[1]-=2*a[i];
    for(int i=2;i<=n;i++)
        test[i]=2*a[i-1]-test[i-1];
    for(int i=1;i<=n;i++)
        cout<<test[i]<<" ";
    cout<<endl;

    
    
    return 0;   
}


 
 


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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP (i, 0, n)
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double EPS = 1e-8;

int main() {
	int n;
	while (cin >> n, n) {
		int a[n], ans = -100000;
		rep(i, n) cin >> a[i];
		int sum[n + 1];
		sum[0] = 0;
		rep(i, n) sum[i + 1] = sum[i] + a[i];
		for (int i = 1; i < n + 1; ++i) {
			for (int j = i; j < n + 1; ++j) {
				// cout << sum[j] - sum[i - 1] << " ";
				ans = max(ans, sum[j] - sum[i - 1]);
			}
			// cout << endl;
		}
		cout << ans << endl;
	}
}

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

struct Combination{
    Int MOD, MAX_N;
    vector<Int> f, f_inv;

    //---------- 初期化 ----------
    Combination(Int mod = 1e9+7, Int max_n = 1e7){
        MOD = mod;
        MAX_N = max_n;

        f = factorial(MAX_N);
        rep(i,f.size()) f_inv.push_back(inv(f[i]));
    }
    
    //------- べき乗 a^n -------
    Int power(Int a, Int n){
        if(a == 0) return 0;
        if(n == 0) return 1;

        Int res = 1;
        while(n > 0){
            if(n % 2 == 1) res = res * a % MOD;
            a = a * a % MOD; n /= 2;
        }
        return res;
    }

    //------- 逆元 1/a -------
    Int inv(Int a){
        return power(a, MOD-2);
    }

    //------- 階乗 (nまでの階乗の配列を返す) -------
    vector<Int> factorial(Int n){
        vector<Int> res(n+1, 1);
        rep1(i,n) res[i] = i * res[i-1] % MOD;

        return res;
    }


    //------- 組み合わせ nCr -------
    Int comb(Int n, Int r){
        if(r > n) return 0;
        return (f[n] * f_inv[r] % MOD ) * f_inv[n-r] % MOD;
    }
};

int main(){
    Int N, twice;
    cin >> N;

    vector<Int> A(N+1), cnt(N,0);
    rep(i,N+1){
        cin >> A[i];
        cnt[A[i]-1]++;
        if(cnt[A[i]-1] == 2) twice = A[i];
    }
    
    vector<int> pos;
    rep(i,N+1){
        if (A[i] == twice) pos.push_back(i);
    }

    Combination C(1e9+7, 1e5+10);
    rep1(k,N+1){
        Int ans = C.comb(N+1, k);
        ans += C.MOD - C.comb(pos[0]+N-pos[1], k-1);
        ans %= C.MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4468
N, M = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

if N >= M:
    print(0)
    exit()
    
X.sort()
L = []
for i in range(1,M):
    L.append(X[i]-X[i-1])
    
L.sort(reverse=True)

tmp = 0

for i in range(N-1):
    tmp += L[i]
    
print(X[-1]-X[0]-tmp)

Measured memory_bytes: 13840
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int n = 0;

  cin >> n;

  int ans[10042] = {0};

  for(int x = 1; ; x++)
    if(x * x < n) {
      for(int y = 1; ; y++)
        if(x * x + y * y < n) {
          for(int z = 1; ; z++)
            if(x * x + y * y + z * z + x * y + y * z + z * x <= n) {
              ans[(x * x + y * y + z * z + x * y + y * z + z * x)]++;
            } else break;
        } else break;
    } else break;

  for(int i = 1; i <= n; i++) cout << ans[i] << endl;

  return 0;
}
/*

*/


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    vector<double> R(n),X(n);
    for(int i=0;i<n;i++){
        cin>>R[i];
        X[i]=R[i];
        for(int j=0;j<i;j++){
            X[i]=max(X[i],X[j]+2*sqrt(R[i]*R[j]));
        }
        // cout<<X[i]<<endl;
    }
    double ans = 0;
    for(int i=0;i<n;i++) ans = max(ans,X[i]+R[i]);
    cout<<fixed;
    cout.precision(8);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
#define ll long long 
#define ld long double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX 10000003
using namespace std;
vector<vector<ld>> dp(3009,vector<ld>(3009,-1));
ld count(ld arr[], ll n, ll indx, ll c)
{
    if(indx>=n)
    {
        if(c>=(n+1)/2) return 1;
        else return 0;
    }
    if(dp[indx][c]!=-1) return dp[indx][c];
    ld ans=0.00;
    ans+=arr[indx]*count(arr,n,indx+1,c+1);
    ans+=(1-arr[indx])*count(arr,n,indx+1,c);
    return dp[indx][c]=ans;
}
void solve()
{
    ll n;  cin>>n;
    ld arr[n];  
    rep(i,0,n)  cin>>arr[i];
    cout<<fixed<<setprecision(10)<<count(arr,n,0,0);
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}

Measured memory_bytes: 145760
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  int maxElementIndex = max_element(a.begin(),a.end()) - a.begin();
  double half = a[maxElementIndex] / 2.0;
  // cout << "half" << endl;
  // cout << half << endl;
  int min_dis = INT_MAX;
  int r_index;
  rep(i, n){
    if (maxElementIndex == i) continue;
    if ( abs(a[i] - half) < min_dis ){
      // cout << "a[i] ==" << a[i] << endl;
      // cout << "abs(a[i] - half) ==" << abs(a[i] - half) << endl;
      r_index = i;
      min_dis = abs(a[i] - half);
    }
  }
  cout << a[maxElementIndex] << ' ' << a[r_index] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

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

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

const int MAXN = 100005;

int N;
vector<int> T[MAXN];
int a[MAXN];

int solve(int i) {
  if (T[i].empty())
    return 0;

  vector<int> v;
  for (int j : T[i])
    v.push_back(solve(j));

  sort(v.rbegin(), v.rend());

  int sol = 0;
  REP(i, (int)v.size())
    sol = max(sol, v[i] + i + 1);

  return sol;
}

int main(void) 
{
  scanf("%d", &N);
  FOR(i, 2, N + 1) scanf("%d", a+i);

  FOR(i, 2, N + 1)
    T[a[i]].push_back(i);

  printf("%d\n", solve(1));

  return 0;
}



Measured memory_bytes: 15488
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
int main() {
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  ll l = lcm(n, m);
  bool ok = true;
  rep(i, 0, gcd(n, m)) ok &= s[l / m * i] == t[l / n * i];
  cout << (ok ? l : -1) << '\n';
  return 0;
}

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

int main(){
    int n; ll x; cin >> n >> x;
    vector<ll> layer(n+1); // バーガー総数
    layer[0] = 1LL;
    rep(i,n) layer[i+1] = 2*layer[i] + 3;
    vector<ll> paty(n+1); // パティ総数
    paty[0] = 1LL;
    rep(i,n) paty[i+1] = 2*paty[i] + 1;
    // 計算
    ll ans = 0LL;
    for(int i = n; i >= 1; --i){
        if(x <= 1) break;
        if(x == layer[i]){
            ans += 2*paty[i-1]+1;
            break;
        }
        if(i == 1){
            ans += x-1;
            break;
        }
        if(x <= layer[i-1]+2){
            if(x == layer[i-1]+2){
                ans += paty[i-1]+1;
                break; 
            }else{
                x--;
            }
        }else{
            x -= layer[i-1]+2;
            ans += paty[i-1]+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#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 ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll a;
  cin >>a;
  ll b,n;
  cin >>b>>n;
  if(b<=n) {
    cout <<(a*(b-1))/b-a*((b-1)/b)<<endl;
  }else {
    cout <<(a*n)/b-a*(n/b)<<endl;
    
  }
}

Measured memory_bytes: 3596
#include <stdio.h>

int SearchGcd(int, int); // 最大公約数を求める関数


int main() {
  int x, y;

  scanf( "%d" , &x );
  scanf( "%d" , &y );
  printf( "%d\n" , SearchGcd(x, y) );
  
  return 0;
}


int SearchGcd(int x, int y) {
  int r;
  
  if ( x < y ) {
    r = x;
    x = y;
    y = r;
  }
  while( y > 0 ) {
    r = x % y;
    x = y;
    y = r;
  }

  return x;
}



Measured memory_bytes: 2060
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };



template<typename X>
class segtree {
public:
	using func_xx = function<X(X, X)>;
	long long N;
	func_xx fxx;
	const X ex;
	vector<X> dat;
	bool changed;

	segtree(long long n, func_xx fxx, const X& ex) : fxx(fxx), ex(ex), changed(false) {
		if (n == 1) ++n;
		int x = 1;
		while (x < n) x *= 2;
		N = x;
		dat.resize(2 * N - 1, ex);
	}
	//代入後のデータ更新
	void update(int k) {
		dat[k] = fxx(dat[2 * k + 1], dat[2 * k + 2]);
		if (k != 0) update((k - 1) / 2);
	}
	void build() {
		for (int i = N - 2; i >= 0; --i) dat[i] = fxx(dat[2 * i + 1], dat[2 * i + 2]);
		changed = false;
	}
	//要素の代入
	void set(int i, const X& x, bool update = true) {
		dat[N - 1 + i] = x;
		if (update) this->update((N - 2 + i) / 2);
		else changed = true;
	}
	//要素の参照
	const X& elem(int i) {
		return dat[N - 1 + i];
	}
	//[a,b)間のクエリfxx
	X query_sub(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) { return ex; }
		else if (a <= l && r <= b) { return dat[k]; }
		else {
			return fxx(query_sub(a, b, 2 * k + 1, l, (l + r) / 2),
				query_sub(a, b, 2 * k + 2, (l + r) / 2, r));
		}
	}
	X query(int a, int b) {
		if (changed) build();
		return query_sub(a, b, 0, 0, N);
	}
};


ll func_max(ll a, ll b) { return max(a, b); }
ll inf = 1e18;

int main() {
	ll N, K;
	cin >> N >> K;
	segtree<ll> tree{ 1 + 300000, func_max, 0 };
	REP(i, 0, N) {
		ll a;
		cin >> a;
		ll ret = tree.query(max(0LL, a - K), min(a + K + 1, 300001LL));
		tree.set(a, ret + 1);
	}
	ll ans = tree.query(0, 300001);
	PRI(ans);
	return 0;
}

Measured memory_bytes: 11428
#include "bits/stdc++.h"
using namespace std;

long long N, M, COUNTX = 0, COUNTY = 0, COUNTZ = 0;
vector<vector<long long> > V;
vector<bool> B;
vector<long long> C;

bool DFS(long long P) {
	B[P] = false;
	bool RET = true;
	for (int NP : V[P]) {
		if (C[NP] == 2) {
			C[NP] = 1 - C[P];
			if (!DFS(NP)) RET = false;
		}
		else {
			if (C[P] == C[NP]) RET = false;
		}
	}
	return RET;
}

int main() {
	cin >> N >> M;
	V.resize(N), B.assign(N, false), C.assign(N, 2);
	for (int i = 0; i < M; i++) {
		long long X, Y;
		cin >> X >> Y;
		X--, Y--;
		V[X].push_back(Y);
		V[Y].push_back(X);
		B[X] = true, B[Y] = true;
	}
	for (int i = 0; i < N; i++) {
		if (!B[i]) COUNTX++;
	}
	for (int i = 0; i < N; i++) {
		if (B[i]) {
			C[i] = 0;
			if (DFS(i)) COUNTY++;
			else COUNTZ++;
		}
	}
	cout << N * N - (N - COUNTX) * (N - COUNTX) + COUNTY * COUNTY + (COUNTY + COUNTZ) * (COUNTY + COUNTZ) << endl;
}

Measured memory_bytes: 12416
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> PP;
int n,m,k,x,y,z;
vector<PP> v[3010];//cost,to
priority_queue<PP,vector<PP>,greater<PP> >Q;//cost,to
int d[3010];
int main(){
	cin>>n>>m>>k;
	rep(i,m){
		cin>>x>>y>>z;x--,y--;
		v[x].push_back(make_pair(z,y));
		v[y].push_back(make_pair(z,x));
	}
	rep(i,n)d[i]=1145141919;
	rep(u,k){cin>>m;m--;
		while(!Q.empty())Q.pop();
		Q.push(make_pair(0,m));
		while(!Q.empty()){
			x=Q.top().X,y=Q.top().Y;
			Q.pop();
			if(d[y]>x){
				d[y]=x;
				rep(i,v[y].size()){
					if(d[v[y][i].Y]>d[y]+v[y][i].X)
					Q.push(make_pair(d[y]+v[y][i].X,v[y][i].Y));
				}
			}
		}
	}
	//rep(i,n)cout<<d[i]<<" ";cout<<endl;
	int ans=-1;
	rep(i,n)rep(j,v[i].size()){
		ans=max(ans,d[i]+d[v[i][j].Y]+v[i][j].X);
	}cout<<ans/2+ans%2<<endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  for (char i = 'a'; i <= 'z'; i++) {
    if (S.find(i) == -1) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()
    val a = readListOfInt()
    val counts = mutableMapOf<Int, Int>()
    a.forEach { ca ->
        for(i in ca-1..ca+1) {
            counts[i] = if(counts.containsKey(i)) counts[i]!! + 1 else 1
        }
    }
    println(counts.values.max()!!)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    val rtn = v.map { it.toList() }.toList()
    return rtn 
}

fun gcd(a: Long, b: Long): Long = 
if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<double> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> perm(n);
  iota(perm.begin(), perm.end(), 0);
  double ans = 0.0;
  do {
    for (int i = 1; i < n; i++) {
      ans += sqrt((x[perm[i]] - x[perm[i - 1]]) * (x[perm[i]] - x[perm[i - 1]]) + (y[perm[i]] - y[perm[i - 1]]) * (y[perm[i]] - y[perm[i - 1]]));
    }
  } while (next_permutation(perm.begin(), perm.end()));
  for (int i = 2; i <= n; i++) {
    ans /= (double) i;
  }
  cout << fixed << setprecision(10) << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

tuple<int,bool> dfs(const vector<vecint>& g,
    int i, int p = -1) {
  int res = 0;
  bool ok = true;
  int cch = 0;
  int ccz = 0;
  for (auto&& to : g[i]) {
    if (to == p) continue;
    ++cch;
    int cr, cz;
    tie(cr, cz) = dfs(g, to, i);
    if (!cz) ok = false;
    else {
      ++ccz;
      if (ccz > 1) ++cr;
    }
    res += cr;
  }
  if (cch > 1) ok = false;
  return make_tuple(res, ok);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vector<vecint> g(n);
  REP(i,n-1) {
    int a,b;
    cin>>a>>b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int root = -1;
  REP(i,n) {
    if (g[i].size() >= 3) root = i;
  }
  if (root < 0) {
    cout<<1<<endl;
    return 0;
  }
  int ans;
  tie(ans, ignore) = dfs(g, root);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    if(n <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

Measured memory_bytes: 256
/*
    coded by - PATHAKCODES ~~Revamped
    AIT PUNE , INDIA 
     
    "The Key is not will to win ......everybody has that "
    "It is will to prepare that is important"  
     
*/
     
#include <bits/stdc++.h>
 
using namespace std ;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
const ll k = 1e9 +7;



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


    vector<vector<int>> dp(n, vector<int>(3,0));

    for(int i = 0; i < n ; i++){

        int a , b , c;
        cin >> a >> b >> c;

        if(i==0){
            dp[0][0] =a;
            dp[0][1] =b;
            dp[0][2] =c;
        }else {
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a;
            dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b;
            dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c;
        }


    }

    cout << max(dp[n-1][0],max(dp[n-1][1], dp[n-1][2]));

  
}



Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a; cin >> a;
    int ans = a + a * a + a * a * a;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back



ll gcd(ll a , ll b){
    ll bigger=max(a,b);
    ll smaller=min(a,b);
    if (bigger%smaller==0){
        return smaller;
    }
    else {
        return gcd(smaller, bigger%smaller);
    }

}

    






int main(){

    int n,k;
    cin>>n>>k;

    vi data(n);
    rep(i,n){
        int tmp;
        cin>>tmp;
        data.at(i)=tmp;
    }

    sort(ALL(data));

    int answer=0;

    rep(i,k){
        answer+=data.at(i);
    }

    cout<<answer<<endl;



}

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

using namespace std;

vector<pair<int, int>> arr;

int main() {
	int n;
	long long k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		arr.emplace_back(a, b);
	}
	sort(arr.begin(), arr.end());
	int ptr = 0;
	while (true) {
		k -= arr[ptr].second;
		if (k <= 0) {
			cout << arr[ptr].first << endl;
			break;
		} else ++ptr;
	}
	
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	vector<int> w(10);
	vector<int> k(10);
	REP(i, 10) cin >> w[i];
	REP(i, 10) cin >> k[i];

	sort(ALL(w), greater<int>());
	sort(ALL(k), greater<int>());
	cout << w[0]+w[1]+w[2] << " " << k[0]+k[1]+k[2] << endl;
	
}



Measured memory_bytes: 3164
#include <bits/stdc++.h> 
using namespace std; 
const int MAX_SIZE = 1e6; 
  
bool prime[MAX_SIZE + 1]; 
  
void sieve() 
{ 
  
    memset(prime, true, sizeof(prime)); 
  
    for (int p = 2; p * p <= MAX_SIZE; p++) { 
  
        if (prime[p] == true) { 
  
            for (int i = p * p; i <= MAX_SIZE; i += p) 
                prime[i] = false; 
        } 
    } 
} 
  
int main() 
{ 
   int x;
   cin >> x;
    sieve();
    int i;
    for (i = x; i < MAX_SIZE; i++) { 
  
        if (prime[i] == true) 
            break;
    } 
    cout << i;
    return 0; 
} 

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    while(h!=0){
        int i,j;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
    if((i%2==0&&j%2==0)||(i%2==1&&j%2==1))
        cout << "#";
    else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
#include <tgmath.h>
using namespace std;


// https://atcoder.jp/contests/arc061/tasks/arc061_a

// 入力
long S;

long sum(long start, long num, long old){
    long ans = 0;    
    long remain = num % (long)(pow(10, start + 1));
    // cout << "remain=" << remain << "num=" << num << "start="<<start <<endl;
    if (num - remain == 0){
        // cout << num << endl;
        return old + remain;
    }

//   cout << "左" << endl;
    ans += sum(0, num /(long)(pow(10, start + 1)), old + remain);
//   cout << "右" << endl;
    ans += sum(start + 1, num, old);
    
    return ans;
}

int main(){
 cin >>  S;
 cout << sum(0,S,0) <<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(void){
    int n;
    vector<string> w(n);
    while(true){
        cin >>n;
        if(n==0) break;
        for(int i=0;i<n;i++)
        cin >> w[i];
        int tanku[5]={5,7,5,7,7};
        bool judge=false;
        //?§??????????
        for(int i=0;i<n;i++){
            int place=i;
            //tanku ibannme
            for(int j=0;j<5;j++){
    int sum=0;
    //kasan
    while(place<n){
        sum+=w[place].size();
        place++;
        if(sum>=tanku[j])
        break;
    }if(sum>tanku[j])
    break;
    if(j==4&&sum==tanku[4]){
            cout << i+1 << endl;
            judge=true;
            break;
        }
            }
            if(judge)
break;
        }
    }
return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int A[300000];
long long sum[300000];
long long sum2[300000];
PGQ que1;
PQ que2;
int main(){
  int N;
  cin>>N;
  FOR(i,0,3*N){
    cin>>A[i];
  }
  long long x=0,y=0;
  FOR(i,0,N){
    que1.push(A[i]);
    x+=A[i];
  }
  sum[N-1]=x;
  FOR(i,N,2*N){
    que1.push(A[i]);
    x+=A[i];
    x-=que1.top();
    que1.pop();
    sum[i]=x;
  }
  FOR(i,2*N,3*N){
    que2.push(A[i]);
    y+=A[i];
  }
  sum2[2*N-1]=y;
  ROF(i,N,2*N){
    que2.push(A[i]);
    y+=A[i];
    y-=que2.top();
    que2.pop();
    sum2[i-1]=y;
  }
  long long M=-1e15;
  FOR(i,N-1,2*N){
    M=max(M,sum[i]-sum2[i]);
  }
  cout<<M<<endl;
  return 0;
}


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

L = list(map(int, input().split()))
S=set()
for i in range(n):
	if L[i]%2==0:
		S.add(L[i])
p=0
for s in S:
	if s%3!=0 and s%5!=0:
		print('DENIED')
		p+=1
		break

if p==0:
	print('APPROVED')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back

ll N, W, w[105], c[105], dp[100005], ans;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> W;
    for (int i = 1; i <= N; ++i) cin >> w[i] >> c[i];
    memset(dp, 1e9 + 7, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i <= N; ++i) {
    	for (ll j = 1e5; j >= c[i]; --j) {
    		dp[j] = min(dp[j], dp[j - c[i]] + w[i]);
    		if (dp[j] <= W) ans = max(ans, j);
    	}
    }
    cout << ans << '\n';
    return 0;
}



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

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

vector<int> to[100005];

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) {
        cin >> l[i];
    }
    
    sort(l.begin(), l.end());
    int ans = 0;

    rep(i, n) {
        rep (j, i) {
            int ij = l[i] + l[j];
            int r = lower_bound(l.begin(), l.end(), ij) - l.begin();
            int l = i + 1;
            ans += r - l;
        }
    }
    
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 2560
n,a,b,c,d=map(int,input().split())
s=input()
s=list(s)
s.append('#')
s.append('#')
out=0
ct=0
if c<d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    if out>0:print('No')
    else:print('Yes')
elif c>d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-2,d-1):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            #print('Yes')
            ct+=1
        
    if(out>0 or ct==0):print('No')
    else:print('Yes')

Measured memory_bytes: 4916