akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int dp[100001];

int main(){
    int X;
    cin >> X;
    rep(i,100001){
        dp[i] = 0;
    }
    dp[100] = 1;
    dp[101] = 1;
    dp[102] = 1;
    dp[103] = 1;
    dp[104] = 1;
    dp[105] = 1;
    for(int i=0;i<=100000;i++){
        if(dp[i]==1){
            for(int j=100;j<=105;j++){
                if(i+j<=100000)dp[i+j]=1;
            }
        }
    }
    cout << dp[X] << endl;
    return 0;
}

Measured memory_bytes: 640
import numpy as np

n = int(input())
h = list(map(int,input().split()))

dp = [0]*n

dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Measured memory_bytes: 38916
package main

import (
	"fmt"
	"sort"
)

type pair struct {
	a, b int
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	ps := make([]pair, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ps[i].a, &ps[i].b)
	}
	sort.Slice(ps, func(i, j int) bool {
		return ps[i].a < ps[j].a
	})

	var price int
	for _, p := range ps {
		if m <= p.b {
			price += p.a * m
			break
		}
		price += p.a * p.b
		m -= p.b
	}
	fmt.Println(price)
}


Measured memory_bytes: 6332
n = input()
N = int(n[-1])
# print(N)

if N == 2 or N == 4 or N == 5 or N == 7 or N == 9:
  print('hon')
elif N == 0 or N == 1 or N == 6 or N == 8:
  print('pon')
elif N == 3:
  print('bon')

Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

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

struct Item
{
    int value;
    int weight;
};

struct Key
{
    int i_th;
    int W;

    bool operator==(const Key& rhs) const
    {
        return i_th == rhs.i_th && W == rhs.W;
    }

    bool operator!=(const Key& rhs) const
    {
        return *this == rhs;
    }
};

namespace std
{
    template<>
    class hash<Key>
    {
    public:
        size_t operator() (const Key& key) const
        {
            size_t seed = 0;
            auto i_hash = hash<int>()(key.i_th);
            auto w_hash = hash<int>()(key.W);

            seed ^= i_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
            seed ^= w_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);

            return seed;
        }
    };
}


class DpKnapsack
{
private:
    static constexpr ll nil = -1;

    vec<Item> items;
    //vec<vec<ll>> dp;
    std::unordered_map<Key, ll> dp;
    ll W;

public:
    DpKnapsack(vec<Item> items, ll W)
        : items {items}
        //, dp {vec<vec<ll>>(items.size(), vec<ll>(W + 1, nil))}
        , W {W}
    {}

    ll ans(int w)
    {
        return solve(items.size() - 1, w);
    }

private:

    // i番目の品物までで制約jのときの最大値
    ll solve(int i, int j)
    {
        if (i < 0 || j <= 0)
            return 0;

        Key current {i, j};

        if (dp.count(current) != 0)
            return dp.at(current);

        //dp.emplace(current);
        auto& currentDp = dp[current];

        currentDp = solve(i - 1, j);
        if (j >= items[i].weight)
            currentDp = std::max(currentDp, solve(i - 1, j - items[i].weight) + items[i].value);
        
        return currentDp;
    }

};

void solve()
{
    using namespace std;

    // Wが小さいときのナップサック
    int N, W;
    cin >> N >> W;
    vec<Item> items(N);
    for (auto & x : items)
        cin >> x.weight >> x.value;

    DpKnapsack dp {items, W};

    cout << dp.ans(W) << endl;
}

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

Measured memory_bytes: 5668
n=int(input())
#s=[]
l=[0]*5
#print(l)
for _ in range(n):
    s=input()
    if s[0]=="M": l[0]+=1
    if s[0]=="A": l[1]+=1
    if s[0]=="R": l[2]+=1
    if s[0]=="C": l[3]+=1
    if s[0]=="H": l[4]+=1
#print(l)
ans=0
for i in range(5):
    for j in range(5):
        for k in range(5):
            if i!=j and j!=k and k!=i:
                ans+=l[i]*l[j]*l[k]
ans//=6
print(ans)


Measured memory_bytes: 9148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

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

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	string s,t; cin >> s >> t;
	string ans = t+s;
	out(ans);

}




Measured memory_bytes: 256
n = int(input())
sosuu = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199]
ans = 0
for i in range(1,n+1,2):
    r = []
    tmp = 0
    for j in sosuu:
        tmp = 0
        while i%j==0:
            tmp += 1
            i //= j
        r.append(tmp)
    rr = 1
    for i in r:
        rr *= i+1
    if rr==8:
        ans += 1
    #print(r)
print(ans)


Measured memory_bytes: 3064
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
A = LI()
B = LI()
C = LI()

ans = sum(B)

for i in range(N - 1) :
    if A[i] + 1 == A[i + 1] :
        ans += C[A[i] - 1]

print(ans)


Measured memory_bytes: 43376
n = int(input())
s = [int(x) for x in input().split()]
q = int(input())
t = [int(x) for x in input().split()]
c = 0

for i in t:
    left = 0
    right = n
    mid = lambda x,y:(x + y)/2
    while left < right:
        if s[int(mid(left,right))] == i:
            c += 1
            break
        elif s[int(mid(left,right))] > i:
            right = int(mid(left,right))
        else:
            left = int(mid(left,right)) + 1

print(c)

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

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

#define PUSH intStackPush
#define POP intStackPop
#define TOP intStackTop
#define FREE intStackFree

typedef struct stack{ int data; struct stack* next; }stack;

stack *top = NULL;

stack* makeNewStack(int data){
  stack *new = (stack*)malloc(sizeof(stack));
  new->data = data;
  new->next = NULL;
  return new;
}

void intStackPush(int data){
  stack *new = makeNewStack(data);
  if(top != NULL){ new->next = top; top = new; }
  else top = new;
}

void intStackPop(){
  stack *temp;
  temp = top;
  top = top->next;
  free(temp);
}

int intStackTop(){ return top->data;}

void intStackFree(){ while(top != NULL) intStackPop();}

int main(){
  int in;

  while(scanf("%d", &in) != EOF){
    if(in == 0){
      printf("%d\n",TOP());
      POP();
    }
    else PUSH(in);
  }

  FREE();
  return 0;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();

        System.out.println(solve(a));

        sc.close();
    }

    static int solve(int a) {
        return a + a * a + a * a * a;
    }
}

Measured memory_bytes: 35848
//  AOJ Algorithms and Data Structures I - Heaps - Priority Queue
// s 2013 0913 1556
//

/*
[ヒープを表す配列A、ヒープのサイズ（要素数）をheap_sizeとすれば、A[1...heap_size]にヒープの要素が格納される。木の根はA[1]であり、節点の添え字iが与えられたとき、その親parent(i)、左の子left(i)、右の子right(i)は以下の式で算出される： ]
と、問題文に書いてあるので、添え字０は使わず、獲得する領域も１大きくする。
add 2013 0913 1714
　要素数が決まってないので、動的配列で作りたいが、vectorは要素追加したときに
アドレス変わっちゃうし、面倒なので、最初に静的に持っておく。
問題はそのサイズだが、命令数２bilion に合わせて、int型2billionの配列とったら
「Memory Limit : 65536 KB」なので完璧オーバー。
よって適当に10000KB取って実行後に足りなかったら、足す。　


add 2013 0913 1556
 ヒープは、最大（最少）を簡単に求められるデータ構造なので　
優先度付きキュー(priority queue)にはぴったり。
計算機上でのジョブスケジューリング
 特に、以下の関数が、いい味を出している。
＝＞　extractMax(S): 最大のキーを持つSの要素をSから削除してその値を返す


そういえば、なんで普通のソートで並べておかないんだろ？
それでも最大と最少は出るのに。
唯のソートなら、クイックソートとか使えばいいが、
木構造の探索の速さ（そこからくるinsertのはやさ）（これは普通にソートした配列でも同じ用にヒープにできるが）
（あと、ヒープは探索まともにできない。挿入場所を早く決められるってだけ？）
と、　値を取った後木を組みなおす簡単さが　一番うまいこといってるのが
ヒープなんでしょう。
最大とか、最少のみがほしいときにしか使えないが


add 2013 0913 1854
insert は　とりあえず配列の後ろに入れて　親より大きかったら交換を繰り返して適切な位置へ。
（確かに挿入の適切な位置への探索はいらない。　木構造内での交換のみ）
extractはrootを出して、そこに配列の一番後ろの要素入れて、要素数減らしてから、maxHeapifyでヒープ組み直し

*/

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;


//関数の引数に書くの面倒なので、ここで宣言
int heap_size;



void maxHeapify(int *heap, int i){
	int l,r, largest;

	l=i*2;
	r=i*2+1;

	if(l <= heap_size && heap[l] > heap[i]) largest = l;
	else largest = i;

	if(r <= heap_size && heap[r] > heap[largest]) largest = r;

	if(largest!=i){
		swap(heap[i], heap[largest]);
		maxHeapify(heap, largest);
	}

}

void buildMaxHeap(int *heap){
	int i;

	for(i=heap_size/2; i>=1; i--) maxHeapify(heap, i);
}


void heapIncreaseKey(int *heap, int i, int key){
    
	if (key < heap[i]) printf("error 新しいキーは現在のキーより小さい");
    heap[i] = key;
    while( i > 1 && heap[i/2] < heap[i]){
		swap(heap[i], heap[i/2]);
		i = i/2;
	}
}

void maxHeapInsert(int *heap, int key){
	heap_size++;
	heap[heap_size]= -1; //キーは非負なのでこれでOK
	heapIncreaseKey(heap, heap_size, key);
}


int heapExtractMax(int *heap){
	int max;

    if(heap_size < 1){ 
		printf("ヒープアンダーフロー");
		return 0;
	}
    max = heap[1];
    heap[1] = heap[heap_size];
    heap_size--;
    maxHeapify(heap, 1);

    return max;
}


int main() {
	int i,j;
	//int heap_size;
	int key;
	string order;

	//input
	// 標準入力をファイルに変更////////////////////////////////////////////////////////
    //FILE* fp_in = freopen("\\\\k1300\\k1300\\s1350010\\.windows\\Desktop\\input_data.txt", "r", stdin);
	/////////////////////////////////////////////////////////////////////////////////////

	heap_size=0;
	//int *heap = new int[heap_size+1]; //[1...heap_size]まで使うので
	int heap[2000000];

	while( cin >> order){

		if(order=="insert"){
			cin >> key;
			maxHeapInsert(heap, key);
		}
		else if(order=="extract"){
			printf("%d\n", heapExtractMax(heap));
		}
		else{ //if(order=="end"){
			break;
		}	
	}

	// ファイルを閉じる//////////////////////////////////////////////////////////////////
    //fclose(fp_in);
	/////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}

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

namespace _0003
{
    class Program
    {
        static void Main(string[] args)
        {
            int infomationLength = int.Parse(Console.ReadLine());
            List<string> answerList = new List<string>();
            for (int i = 0; i < infomationLength; ++i)
            {
                int[] sideList = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                Array.Sort(sideList);
                answerList.Add(IsRightAngle(sideList));
            }
            foreach(string i in answerList)
            {
                Console.WriteLine(i);
            }
        }
        static string IsRightAngle(int[] sideList)
        {
            if(Math.Pow(sideList[2],2) == (Math.Pow(sideList[0], 2) + Math.Pow(sideList[1], 2)))
            {
                return "YES";
            }
            else
            {
                return "NO";
            }
        }
    }
}



Measured memory_bytes: 14256
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> H;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        H.emplace_back(tmp);
    }

    for (int i = N - 2; i >= 0; i--)
    {
        if (H[i] > H[i + 1])
        {
            H[i]--;
            if (H[i] > H[i + 1])
            {
                cout << "No" << endl;
                return 0;
            }

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

Measured memory_bytes: 892
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	int n = A - B;

	if (C - n > 0) {
		cout << C - n << endl;
	}
	else {
		cout << 0 << endl;
	}

}






Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define PI acos(-1)
#define EPS 1e-12
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bitCount __builtin_popcount
#define forn(i, n) for(i = 0; i < (ll)n; i++)
#define for1(i, n) for(i = 1; i <= (ll)n; i++)
#define forv(i, v) for(i = 0; i < v.size(); i++)
#define forab(i, a, b) for(i = a; i <= (ll)b; i++)
#define Sort(v) sort(v.begin(), v.end())
#define bend(v) v.begin(), v.end()
#define sz(v) v.size()
#define trace(x) cout<<"x = "<<x<<"\n"
#define trace2(x, y) cout<<"x = "<<x<<" y = "<<y<<"\n"
#define trace3(x, y, z) cout<<"x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define trace4(w, x, y, z) cout<<"w = "<<w<<" x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define ln "\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef set<int>::iterator sit;
typedef set<ll>::iterator sllt;
typedef set<char>::iterator sct;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;
typedef multiset<int>::iterator msit;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
const int alphabet = 26;
const int inf = INT_MAX;
const ll linf = 1e18+9;
namespace util{
	inline ll cnm(char ch){ return (ch-'0'); }
	inline ll cap(char ch){ return (ch-'a'); }
	inline void instr(string& s, ll& n){ cin>>s;    n = s.length(); }
	inline void instr(string& s){ cin>>s; }
	template<typename T> T gcd(T a, T b){ if(a==0) return b; return gcd(b%a, a); }
	template<typename T> bool min(T a, T b, T c){
		return  std::min(a, std::min(b, c));
	}
}
using namespace util;

ll a[maxn];
void solve(int tc)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll i, j, k, m, n;
	map<ll, ll> cache;
	ll sum = 0;
	cin>>n;
	for(i = 0; i < n; i++){
		cin>>a[i];
		cache[a[i]] += 1;
		sum += a[i];
	}

	ll q; cin>>q;
	while(q--){
		ll b, c;
		cin>>b>>c;
		ll cnt = cache[b];
		sum -= b*cnt;
		sum += c*cnt;
		cache[c] += cnt;
		cache.erase(b);

		cout<<sum<<ln;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	int i = 1;
	// cin>>t;
	while(i <= t){
		solve(i);
		i++;
	}

	return 0;
}



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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	double n, c;
	cin >> n;
	c = n / 3;
	double ans = c * c * c;
	cout << fixed << setprecision(10) << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input1.txt","r",stdin);
//    freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll t = 1;
//	 cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main() {
	int A, B;
	bool exist = false;
	cin >> A >> B;
	for (int C = 0;C <= 3;C++) {
		if (A * B * C % 2 != 0) {
			exist = true;
			break;
		}


	}
	if (exist) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int k, x;
    cin >> k >> x;
    for (int i = x-k+1; i <= x+k-1; i++)
    {
        cout << i << " ";
    }
    cout << endl;
    
    return 0;
}

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

int bubbleSort(int A[],int N){
	int sw = 0;
	bool flag =1;
	for(int i=0;flag;i++){
		flag=0;
		for (int j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				
				swap(A[j],A[j-1]);
				flag =1;
				sw++;
			}
		}
	}
	return sw;
}

int main(){
	int A[100],N,sw;
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
	sw = bubbleSort(A,N);
	for(int i=0;i<N;i++){
		if(i)cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}

Measured memory_bytes: 3104
import Data.Bool (bool)

main :: IO ()
main = do
  a <- read <$> getLine :: IO Int
  b <- read <$> getLine :: IO Int
  c <- read <$> getLine :: IO Int
  d <- read <$> getLine :: IO Int
  e <- read <$> getLine :: IO Int
  k <- read <$> getLine :: IO Int
  putStrLn . bool ":(" "Yay!" $ e - a <= k


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

#define dk23      ios_base :: sync_with_stdio(false);
#define inp       freopen("input.txt","r",stdin);
#define ll        long long

int main()
{
    dk23

    ll n,i,j,k;
    cin>>n;
    ll sum=0;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
                sum+=__gcd(__gcd(i, j),k);
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  ll n, m;
  cin >> n >> m;
  ll ex = (1 << m);
  cout << ex * (100 * n + 1800 * m) << endl;
}


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

int main()
{
 int n;
 cin>>n;
bool t=false;
while(n>0)
{
  int rem =n%10;
    if (rem==7)
    {
      t=true;
      break;
    }
    n /=10;


}

if(t)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int h,n; cin >> h >> n;
	vector<pair<int, int>> v(n);
	for(int i=0;i<n;i++) cin >> v[i].first >> v[i].second;
	//dp[i] the minimum total points we can get at health i
	vector<int> dp(10001, INF);	
	dp[0] = 0;
	for(int i=1;i<=h;i++){
		for(int j=0;j<n;j++){
			if(i-v[j].first < 0) dp[i] = min(dp[i], dp[0]+v[j].second);
			else dp[i] = min(dp[i], dp[i-v[j].first]+v[j].second);
		}
	}
	cout << dp[h] << "\n";
	return 0;
}


Measured memory_bytes: 256
import bisect, math
N,D,A = map(int,input().split())
enemy = list(list(map(int,input().split()))for i in range(N))
enemy.sort()

damege = [0]*N

ans = 0
p = 0
while p < N:
    if p>=1:
        damege[p] += damege[p-1]
    enemy[p][1] -= damege[p]
    if enemy[p][1] <= 0:
        p += 1 
        continue
    d = math.ceil(enemy[p][1]/A)
    ans += d
    d *= A
    r = bisect.bisect_right(enemy,[enemy[p][0]+D*2,10**9+7])
    if r!=N:
        damege[r]-=d
    damege[p] += d
    p+=1
print(ans)



Measured memory_bytes: 59928
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
    int i,j;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];

    int ans_min = 2;
    int ans_max = 2;

    for(int i = n-1; i >= 0; i--){
        if(ans_min / a[i] == ans_max / a[i] && ans_min % a[i]){
            cout << -1 << endl;
            return 0;
        }
        ans_min = ((ans_min + a[i] - 1)/a[i])*a[i];
        ans_max = (ans_max / a[i] + 1)*a[i] - 1;
    }

    cout << ans_min << " " << ans_max << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,zx,xc,i,j,ii,jj,sac[10000009];
long long pas,ans[10000009];
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    for(i=2; i<=a; i++){
        if(sac[i]==0){
            sac[i]=i;
            if(i>=10000) continue;
            for(j=i*i; j<=a; j+=i){
                if(sac[j]==0) sac[j]=i;
            }
        }
    }
    ans[1]=1;
    pas=1;
    for(i=2; i<=a; i++){
        if(sac[i]==i){
            ans[i]=2;
            pas+=i*2;
            continue;
        }
        c=i;d=0;
        while(c%sac[i]==0){
            d++;c/=sac[i];
        }
        ans[i]=ans[i/sac[i]]/d*(d+1);
        pas+=i*ans[i];
    }
    cout<<pas;
    return 0;
}

Measured memory_bytes: 120820
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

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

	float val=(float)n/1000.0;
	int amount=ceil(val);
	cout<<amount*1000 - n<<endl;
	return 0;
}


Measured memory_bytes: 3596
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if (S.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (S.equals("Cloudy")) {
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 25172
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val isAccepted = Array(n) {false}
    val waCount = Array(n) {0}
    var ans = 0
    repeat(m) {
        val ss = readLine()!!.split(' ')
        val p = ss[0].toInt() - 1
        when (ss[1]) {
            "WA" -> waCount[p]++
            else -> if (!isAccepted[p]) {
                ans += waCount[p]
                isAccepted[p] = true
            }
        }
    }
    println("${isAccepted.count{it}} $ans")
}

Measured memory_bytes: 53008
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define M2DVEC(type,name,a,b) vector<vector<type>> name((a),vector<type>(b))
int main(){
	int h,w;
	cin>>h>>w;
	vector<string> sh(h);
	REP(i,h){
		cin>>sh.at(i);
	}
	M2DVEC(int,L,h,w);
	M2DVEC(int,R,h,w);
	M2DVEC(int,D,h,w);
	M2DVEC(int,U,h,w);
	REP(i,h){
		REP(j,w){
			if(j==0){
				if(sh[i][j]=='.'){
					L[i][j]=1;
				}else{
					L[i][j]=0;
				}
				if(sh[i][w-1-j]=='.'){
					R[i][w-1-j]=1;
				}else{
					R[i][w-1-j]=0;
				}
			}else{
				if(sh[i][j]=='.'){
					L[i][j]=L[i][j-1]+1;
				}else{
					L[i][j]=0;
				}
				if(sh[i][w-1-j]=='.'){
					R[i][w-1-j]=R[i][w-j]+1;
				}else{
					R[i][w-1-j]=0;
				}
			}
		}
	}
	REP(j,w){
		REP(i,h){
			if(i==0){
				if(sh[i][j]=='.'){
					D[i][j]=1;
				}else{
					D[i][j]=0;
				}
				if(sh[h-i-1][j]=='.'){
					U[h-i-1][j]=1;
				}else{
					U[h-i-1][j]=0;
				}
			}else{
				if(sh[i][j]=='.'){
					D[i][j]=D[i-1][j]+1;
				}else{
					D[i][j]=0;
				}
				if(sh[h-i-1][j]=='.'){
					U[h-i-1][j]=U[h-i][j]+1;
				}else{
					U[h-i-1][j]=0;
				}
			}
		}
	}
	priority_queue<int> a;
	REP(i,h){
		REP(j,w){
			//printf("%d %d %d %d\n",L[i][j],R[i][j],U[i][j],D[i][j]);
			a.push(L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
		}
	}
	OUT(a.top());
	return 0;
}

Measured memory_bytes: 85364
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll a, b;
    cin >> a >> b;
    if(a <= 0 && 0 <= b){
        cout << "Zero" << endl;
    }else if(0 < a){
        cout << "Positive" << endl;
    }else{
        if((b - a + 1) % 2){
            cout << "Negative" << endl;
        }else{
            cout << "Positive" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	string s;
	cin>>s;
	vi co(3);
	rep(i,n)if(s[i]=='R')co[0]++;
	else if(s[i]=='G')co[1]++;
	else co[2]++;
	int out=co[0]*co[1]*co[2];
	rep(i,n)rep(j,n)if(i-j>=0&&i+j<n&&s[i-j]!=s[i]&&s[i]!=s[i+j]&&s[i-j]!=s[i+j])out--;
	cout<<out<<endl;
}












Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const 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;
}

ll lcm(ll a, ll b) {
    return a* b / __gcd(a,b);
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    vector<ll> a(n);rep(i,n){
        cin>>a[i];
        a[i] /= 2;
    }
    sort(begin(a), end(a), greater<ll>());
    ll tmp = 1;
    rep(i,n) {
        tmp = lcm(tmp, a[i]);
    }
    rep(i,n) {
        if (tmp/a[i]%2==0) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll res = m/tmp;
    cout << (res%2 ? res/2+1:res/2) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int x,y; cin >> x >> y;
  if(y % 2 == 1) cout << "No" << "\n";
  else {
    if(2*x <= y && y <= 4*x) cout << "Yes" << "\n";
    else cout << "No" << "\n";
  }    
  return 0;
}


Measured memory_bytes: 3632
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        ++$this->pointer;

        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int) $this->next();
    }

    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();
$S = $sc->next();
$T = $sc->next();
$chr = "";
$times = strlen($S) - strlen($T) + 1;
$min_revise_num = 99999999;

for($i=0;$i<$times;$i++){
  	$current_revise_num = 0;
    $chr = substr($S, $i, strlen($T));
    for($j=0;$j<strlen($T);$j++){
       if($chr[$j] != $T[$j]){
           $current_revise_num ++;
       } 
    }
    if($current_revise_num < $min_revise_num){
        $min_revise_num = $current_revise_num;
    }
}

echo $min_revise_num.PHP_EOL;


Measured memory_bytes: 16080
// 本番
//   両端点が長方形の端にあるペアのみ注目すればよいことは気付いたが、
//   判定方法をうまく実装できず
// 本番後
//    解説pdfに従う
//    ある地点から順に頂点をstackに入れていく
//    x, yの座標軸方向が直感と逆なので注意!!

#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stack>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int R, C, N;

bool on_border(int x, int y) {
    return (x == 0 || x == R) || (y == 0 || y == C);
}

// 長方形の周上にある点について、
// 左上点を原点として時計回りに周上を進んだときの距離を計算
int coord_to_score(int x, int y) {
	if (y == 0) {
		return x;
	}
	else if (x == R) {
		return R + y;
	}
	else if (y == C) {
		return R + C + R - x;
	}
	else {
		return R + C + R + C - y;
	}
}

int main(void)
{
	cin.sync_with_stdio(false);
	cin >> R >> C >> N;

	map<int, int> score_to_idx;
	REP(n, N) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		// 両方の点が長方形の周上にあるペアに注目
		if (on_border(x1, y1) && on_border(x2, y2)) {
			score_to_idx[coord_to_score(x1, y1)] = n;
			score_to_idx[coord_to_score(x2, y2)] = n;
		}
	}
	stack<int> idxes;
	for (auto p : score_to_idx) {
		auto idx = p.second;
		if (SIZE(idxes) > 0 && idxes.top() == idx) {
			idxes.pop();
		}
		else {
			idxes.push(idx);
		}
	}

	cout << (SIZE(idxes) == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 9984
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int H,W;
		
		H = in.nextInt();
		W = in.nextInt();
		
		while(H!=0 || W!=0){
			/*
			char[][] sharps = new char[H][W];
			for(int i=0; i<H; i++){
				for(int j=0; j<W; j++){
					sharps[i][j] = '#';
				}
			}
			*/
			for(int i=0; i<H; i++){
				for(int j=0; j<W; j++){
					System.out.print('#');
				}
				System.out.println();
			}
			System.out.println();
			H = in.nextInt();
			W = in.nextInt();
		}
	}
}

Measured memory_bytes: 28868
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

const int NMAX = 3005;

long double dp[NMAX][NMAX],p[NMAX];

int main()
{
    int N,i,j;
    cin>>N;

    for(i = 1 ; i <= N ; ++i)
        cin>>p[i];

    dp[0][0] = 1.0;
    for(i = 1 ; i <= N ; ++i)
    {
        for(j = 0 ; j <= i ; ++j)
        {
            dp[i][j] = (1.0 - p[i])*dp[i-1][j];
            if(j != 0)
                dp[i][j] += dp[i-1][j-1]*p[i];
        }
    }

    long double sum = 0;
    for(i = (N+1)/2 ; i <= N ; ++i)
        sum += dp[N][i];

    cout<<setprecision(10)<<sum;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000000

typedef long long ll;
using namespace std;
int mod = 1000000007;

typedef pair<ll, int> P;
struct edge{
    int from;
    int to;
    ll cost;
};

edge E[5000];
vector<int> parent[2500];
vector<int> child[2500];
bool visited[2500] = {};
set<int> connect_to_n;
set<int> reach_from_one;

void dfs_one(int p, int s){
    visited[s] = true;
    reach_from_one.insert(s);
    rep(i, child[s].size()){
        int to = child[s][i];
        if(visited[to]) continue;
        dfs_one(s, to);
    }
}

void dfs_n(int p, int s){
    visited[s] = true;
    connect_to_n.insert(s);
    rep(i, parent[s].size()){
        int to = parent[s][i];
        if(visited[to]) continue;
        dfs_n(s, to);
    }
}

void bellman_ford(int n, int m){
    ll cost1[n], cost2[n];
    rep(i, n) cost1[i] = INF;
    cost1[0] = 0;
    rep(i, n){
        rep(j, m){
            edge e = E[j];
            cost1[e.to] = min(cost1[e.to], cost1[e.from] + e.cost);
        }
    }
    rep(i, n) cost2[i] = cost1[i];
    rep(i, n){
        rep(j, m){
            edge e = E[j];
            cost1[e.to] = min(cost1[e.to], cost1[e.from] + e.cost);
        }
    }
    rep(i, n){
        if(reach_from_one.count(i) == 1 && connect_to_n.count(i) == 1 && cost1[i] != cost2[i]){
            cout << -1 << endl;
            return;
        }
    }
    cout << max(0ll, -cost1[n-1]) << endl;
}

int main(void){
    int N, M; ll P; cin >> N >> M >> P;
    rep(i, M){
        int a, b; ll c; cin >> a >> b >> c;
        a--; b--; c = -c + P;
        edge e; e.from = a; e.to = b; e.cost = c;
        E[i] = e;
        child[a].push_back(b);
        parent[b].push_back(a);
    }
    dfs_one(-1, 0);
    rep(i, N) visited[i] = false;
    dfs_n(-1, N-1);

    bellman_ford(N, M);

    return 0;
}

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

int main()
{
    int n; cin>>n;
    map<int, int> a;
    for(int i=0; i<n; ++i) {
        int t; cin>>t;
        a[-t]++;
    }

    long y=0, x=0;
    for(auto& e: a) {
        if (e.second>1) {
            if (x==0)
                x=e.first;
            else if (y==0)
                y=e.first;
            e.second-=2;
        }
        if (e.second>1) {
            if (x==0)
                x=e.first;
            else if (y==0)
                y=e.first;
        }
    }
    cout<<x*y<<endl;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
#define rep(i,n) for ( int i = 0; i < n; i++)
#define L 1000
 
long long getValue(long long x){
  if ( x <= L ) return x +1;
  else return L - x%(L+1);
}
 
main(){
  int n;
  int tcase = 0;
  while( cin >> n){
    tcase++;
    long long cnt = 0;
 
    for ( int i = 0; i <= 2*L; i++ ){
      int t = n - i;
      if ( 0 <= t && t <= 2*L ){
    cnt += getValue(i) * getValue(t);
      }
    }
 
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1156
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <unordered_map>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef unsigned long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (LL)((a).size())

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e15;
const LL MAX = 2e5 + 7;
const LL MAXN = 5e5 + 1;

void bad()
{
	cout << "Impossible";
	exit(0);
}

int n;
int m;
VLL a;
VI p;
vector<multiset<LL>> s;
set<PII> fathers;

int find(int v)
{
	if (p[v] == v)
		return v;
	return p[v] = find(p[v]);
}

bool unite(int i, int j, int def = 1)
{
	bool res = 0;
	i = find(i);
	j = find(j);
	if (i != j)
	{
		if (SZ(s[i]) < SZ(s[j]))
			swap(i, j), res = 1;

		if (!def)
		{
			fathers.erase(MP(SZ(s[i]), i));
			fathers.erase(MP(SZ(s[j]), j));
		}

		for (auto x : s[j])
			s[i].insert(x);
		s[j].clear();

		fathers.insert(MP(SZ(s[i]), i));
		p[j] = i;
	}
	return res;
}


int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);
	
	cin >> n >> m;
	a.resize(n);
	FOR(i, 0, n)
		cin >> a[i];

	s.resize(n);
	FOR(i, 0, n)
		s[i].insert(a[i]), fathers.insert(MP(1, i));

	p.resize(n);
	FOR(i, 0, n)
		p[i] = i;

	int u, v;
	FOR(i, 0, m)
	{
		cin >> u >> v;
		unite(u, v, 0);
	}

	LL ans = 0;
	LL cost;
	while (SZ(fathers) > 1)
	{
		auto x = *fathers.rbegin();
		fathers.erase(x);
		auto y = *fathers.rbegin();
		fathers.erase(y);

		if (!(x.X && y.X))
			bad();

		cost = *s[x.Y].begin();
		cost += *s[y.Y].begin();
		s[x.Y].erase(s[x.Y].begin());
		s[y.Y].erase(s[y.Y].begin());

		ans += cost;
		unite(x.Y, y.Y);
	}

	cout << ans;
	cin >> n;
	return 0;
}

Measured memory_bytes: 15488
#include<stdio.h>
int main()
{
	int N, K, X, Y;
	scanf("%d%d%d%d",&N, &K, &X, &Y);
	if(N<=K){	printf("%d\n",X*N);}
	else{printf("%d\n",X*K+N*Y-K*Y);}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 int Alice = 0;
 int Bob = 0;
 cin >> N;
 vector <int> card(N);
 for (int i = 0;i < N; i++){
 	cin >> card.at(i);
 }
 sort(card.begin(),card.end());
 for (int j = N-1; j >= 0; j--){
 Alice += card.at(j);
 j--;
 if (j == -1){
 break;
 }
 Bob += card.at(j);
 }
 int Answer = Alice - Bob;
 cout << Answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

static const double pi = 3.14159265358979323846;
static const int N = 100;

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

  int ret = 1;
  while (ret*2 <= N) ret *= 2;

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
for i in range(n):
    a,b,c=map(int,input().split())
    
    if a*a==b*b+c*c:
        print("YES")
    elif b*b==a*a+c*c:
        print("YES")
    elif c*c==a*a+b*b:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5600
# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = deque(sr())
Q = ir()
rev = 0
for _ in range(Q):
    q = sr().split()
    if q[0] == '1':
        rev ^= 1
    else:
        _, f, c = q
        if (int(f)^rev)&1:
            S.appendleft(c)
        else:
            S.append(c)

if rev&1:
    S.reverse()

print(''.join(S))
# 06

Measured memory_bytes: 8428
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(3).
01 a              PIC 9(1).
01 b              PIC 9(1).
01 n              PIC 9(1).
01 i              PIC 9(2).
01 ans            PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF a < b
      MOVE b TO n
  ELSE
      MOVE a TO n
      MOVE b TO a
  END-IF.
  PERFORM VARYING i FROM 1 BY 1 UNTIL n < i
      MOVE a TO ans(i:1)
  END-PERFORM.
  DISPLAY ans(1:n).
  STOP RUN.


Measured memory_bytes: 892
# ABC158
# D - String Formation

def ChangeState(Is_normal):
    if Is_normal==True:
        return False
    else:
        return True



S=input()
Q=int(input())
Is_normal=True

h=''
t=[]

for _ in range(Q):
    q = input()
    if len(q)== 1 :
        Is_normal = ChangeState(Is_normal)
    else:
        if q[2]=='1':
            if Is_normal==True:
                h=h+q[4]
            else :
                S=S+q[4]
        else :
            if Is_normal==True:
                S=S+q[4]
            else:
                h=h+q[4]
    # print(Is_normal, S)
h=h[::-1]
S=h+S
if Is_normal==False:
    S=S[::-1]
print(S)


Measured memory_bytes: 9856
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int group_no(int x) {
    switch (x) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            return 0;
        case 4:
        case 6:
        case 9:
        case 11:
            return 1;
        case 2:
            return 2;
    }
    return -1;
}

int main(void) {
    int x, y;
    cin >> x >> y;
    cout << (group_no(x) == group_no(y) ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  string s;cin>>s;
  int n = s.size();
  rep(i,(n-1)/2) {
    if (s[i] != s[n-1-i]) {
      cout << "No";
      return 0;
    }
  }
  rep(i,(n-1)/2) {
    if (s[i] != s[(n+1)/2+i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int x = scan.nextInt();
        int count = 0;
        if(x%50!=0)
        {
            System.out.println(0);
            return;
        }
        
        for(int i=0;i<=a;i++)
        {
            for(int j=0;j<=b;j++)
            {
                for(int k=0;k<=c;k++)
                {
                    if(500*i+100*j+50*k==x)
                    {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N;
	cin >> N;
	map<string, set<P>> mp;
	REP(i, N) {
		string s;
		int p;
		cin >> s >> p;
		mp[s].insert(P(p, i + 1));
	}
	for (auto it1 = mp.begin();it1 != mp.end();it1++) {
		for (auto it2 = it1->second.rbegin();it2 != it1->second.rend();it2++) {
			cout << it2->second << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int W, a, b;
	do{
		scanf("%d%d%d", &W, &a, &b);
	}while(W < 1 || W > 100000 || a < 1 || a > 100000 || b < 1 || b > 100000);

	if(b + W < a)	printf("%d\n", a - (b + W));
	else if(a + W < b)	printf("%d\n", b - (a + W));
	else if((b >= a && b <= a + W) || (b + W >= a && b + W <= a + W))	printf("0\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    while(cin>>a[0]>>a[1]>>a[2])
    {
        int sum1=0,sum2=0,i;

        for(i=0;i<3;i++)
        {
            if(a[i]==5)
                sum1++;
            if(a[i]==7)
                sum2++;
        }
        if((sum1==2) && (sum2==1))
           cout<<"YES\n"<<endl;
           else
            cout<<"NO\n"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3576
// AtCoder Regular Contest 062
// E - AtCoDeerくんと立方体づくり / Building Cubes with AtCoDeer

#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#define MAX_N 400
using namespace std;

typedef long long int ll;
typedef vector<int> Tile;


int N;
vector<Tile> tiles;
multiset<Tile> used;
ll ans;

Tile rotate(Tile t) {
  return { t[1], t[2], t[3], t[0] };
}

int main() {

  Tile t1, t2;
  int c;
  ll cnt, tmp;
  vector<Tile>::iterator itr1, itr2;

  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    Tile t;
    for (int j = 0; j < 4; j++) {
      scanf("%d", &c);
      t.push_back(c);
    }
    tiles.push_back(t);
  }

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

  ans = 0;
  for (itr1 = tiles.begin(); itr1 != tiles.end(); itr1++) {
    for (itr2 = itr1, itr2++; itr2 != tiles.end(); itr2++) {
      t1 = *itr1; t2 = *itr2;
      for (int d = 0; d < 4; d++, t2 = rotate(t2)) {
        used.clear();
        used.insert(t1);
        used.insert(t2);
        cnt = 1;
        for (int i = 0; i < 4; i++) {
          tmp = 0;
          Tile t = { t1[(1 + i) % 4], t1[(0 + i) % 4], t2[(4 - i) % 4], t2[(7 - i) % 4] };
          for (int j = 0; j < 4; j++, t = rotate(t)) {
            tmp += upper_bound(tiles.begin(), tiles.end(), t) - lower_bound(tiles.begin(), tiles.end(), t);
            tmp -= used.count(t);
          }
          tmp = max(tmp, 0LL);
          cnt *= tmp;
          used.insert(t);
        }
        ans += cnt;
      }
    }
  }

  ans /= 3;
  printf("%lld\n", ans);

  return 0;

}




Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
C=[n for i in range(n)]

for m in range(k):
    B=[0 for _ in range(n)]
    for i in range(n):
        l,r=max(0,i-A[i]),min(n-1,i+A[i])
        B[l] +=1
        if r+1<n:B[r+1] -=1
    for i in range(n-1):
        B[i+1]=B[i]+B[i+1]
    A=B
    if A==C:break
print(*A)

Measured memory_bytes: 170124