akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}
vector<ll> divv(ll n);

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(a, b);
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};
int main() {
    ll n,m;
    // string s;
    cin>>n>>m;
    ll u,v,w;
    auto uf = new UF(n);
    rep(i, m) {
        cin>>u>>v>>w;
        uf->merge(u-1, v-1);
    }
    unordered_set<int> s;
    rep(i, n) {
        s.insert(uf->find(i));
    }
    pr(s.size());


    return 0;
}

// return sorted 約数s 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(alll(v));
  return v;
}


Measured memory_bytes: 5024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt() //都市の数
	M := nextInt() //道路の数
	list := make([]int, N)

	var a, b int
	for i := 0; i < M; i++ {
		a = nextInt()
		b = nextInt()
		if a != b {
			list[a-1]++
			list[b-1]++
		}
	}
	for i := 0; i < N; i++ {
		fmt.Println(list[i])
	}
}

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


Measured memory_bytes: 640
icase=0
if icase==0:
    import sys
    ws=input()
    w=list(ws)
    ww=set()
    for i in range(len(w)):
        if not w[i] in ww:
            ww.add(w[i])
    for www in ww:
        if ws.count(www)%2==1:
            print("No")
            sys.exit()
    print("Yes")

Measured memory_bytes: 3188
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
	ll n;
	cin>>n;
	long double ans=100;
	ll num=100,tdd=0;
	while(num<n){
		tdd++;
		ans=ans*(1.01);
		num=floor(ans);
		ans=num*1.0;
	}
	cout<<tdd<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 3808
import scala.io.StdIn._
import scala.collection.mutable

object Main extends App {
  def fibonacci(n: Int, memo: mutable.Map[Int, Long] = mutable.Map[Int, Long]()): Long = n match {
    case x if (x == 0 || x == 1) => { memo += (x -> 1); 1 }
    case x if memo.get(x) != None => memo(x)
    case x => {
      memo += (x -> (fibonacci(n - 2, memo) + fibonacci(n - 1, memo)))
      memo(x)
    }
  }

  val N = readLine.toInt
  println(fibonacci(N))
}


Measured memory_bytes: 43764
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def solve():
    N = I()
    A = III()
    B = III()

    first_use = []
    second_use = []
    for i in range(3):
        if A[i]<B[i]:
            first_use.append(i)
        if A[i]>B[i]:
            second_use.append(i)

    def change(n,A,B,use_index):
        dp = [n]*(n+1)
        for i in range(n+1):
            for j in use_index:
                if i-A[j]>=0:
                    dp[i] = max(dp[i-A[j]]+B[j]-A[j],dp[i])
        return dp[n]

    count1 = change(N,A,B,first_use)
    count2 = change(count1,B,A,second_use)

    print(count2)

solve()

Measured memory_bytes: 228636
#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
    int num_vegetable, bag_capacity;
    while(std::cin >> num_vegetable >> bag_capacity){
        if(num_vegetable == 0 && bag_capacity == 0)
            break;
        std::vector<int> price;
        for(int p, i = 0; i < num_vegetable; ++i){
            std::cin >> p;
            price.push_back(p);
        }
        
        std::sort(price.begin(), price.end(), std::greater<int>());

        int price_sum = 0;
        for(int i = 0; i < num_vegetable; ++i){
            if((i + 1) % bag_capacity != 0)
                price_sum += price.at(i);
        }
        std::cout << price_sum << std::endl;
    }
}

Measured memory_bytes: 1228
#include <stdio.h>
int main(void){
    int S,h,m,s;
    
    scanf("%d",&S);
    
    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return(0);
}



Measured memory_bytes: 2128
s = input()

# t = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
# for i in range(4):
#     t[i] = t[i][::-1]

# print(s,t)

tmp = s

while tmp != '':
    d = tmp[:5] == 'maerd'
    dr = tmp[:7] == 'remaerd'
    e = tmp[:5] == 'esare'
    er = tmp[:6] == 'resare'
    # print(tmp[:5])
    # print(d,dr,e,er)

    if d:
        tmp = tmp[5:]
    elif e:
        tmp = tmp[5:]
    elif dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')


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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> n;

    vector <lint> len(n,0);

    rep0(i,n)
    {
        cin >> len[i];
    }

    lint ans = 0;

    rep0(i,n)
    {
        if ((i % 2 == 0) && (len[i] % 2 == 1))
        {
            ans ++;
        }
    }


    cout << ans << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 3624
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, []int) {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	return n, as
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int, as []int) int {
	sum := 0
	sums := make([]int, len(as)+1)
	for i, a := range as {
		sum += a
		sums[i+1] = sum
	}
	minDiff := math.MaxInt32
	for i := range sums {
		l := sums[i]
		r := sums[len(sums)-1] - sums[i]
		df := abs(l - r)
		if df < minDiff {
			minDiff = df
		}
	}
	return minDiff
}

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

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 7608
n=int(input())
a=list(input().strip())
w=0
wa=[]
for i in a:
  if i=="W":
    w+=1
  wa.append(w)

e=0
ea=[]
for i in a[::-1]:
  if i=="E":
    e+=1
  ea.append(e)
ea=ea[::-1]

ans=3 * 10**5
for i,j in zip(wa,ea):
  ans=min(ans,i+j-1)

print(ans)

Measured memory_bytes: 22520
from itertools import permutations
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
ans=0
p=list(permutations(range(n),n))
for L in p:
    s=L[0]
    for i in L[1:]:
        ans+=((l[s][0]-l[i][0])**2+(l[s][1]-l[i][1])**2)**0.5
        s=i
print(ans/len(p))

Measured memory_bytes: 13864
n,x,y=map(int,input().split())
#a<b
def dis(a,b):
    return min (b-a,abs(a-x)+1+abs(b-y))

# for k in range(1,n):
#   count=0
#   #i<j
#   for i in range(1,n):
#     for j in range(i+1,n+1):
#       if dis(i,j)==k:
#         count+=1
#   print(count)
ans=[0]*(n-1)
#i<j
for i in range(1,n):
  for j in range(i+1,n+1):
    ans[dis(i,j)-1]+=1
print(*ans,sep="\n")

Measured memory_bytes: 3444
/*
AOJ 0611
Silk Road
coder ??¬??°
*/
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<cctype>
#include<string>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF 2100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
int dp[1919][1919],tenko[1919],leng[1919];
int main(void)
{
	int n,m,mn=INF,hirou;
	cin>>n>>m;
	rep(i,0,n) cin>>leng[i];
	rep(i,0,m) cin>>tenko[i];
	rep(i,0,m+1) rep(j,0,n+1)dp[i][j]=INF;
	dp[0][0]=0;
	rep(i,0,m) {
		rep(j,0,n+1) {
			if(dp[i][j]!=INF) {
				hirou=leng[j]*tenko[i];
				if(i+1<=m) dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
				if(i+1<=m&&j+1<=n)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+hirou);
			}
		}
	}
	/*rep(i,0,m) {
		rep(j,0,n+1) {
			printf("%8d",dp[i][j]);
		}
		cout<<endl;
	}*/
	rep(i,0,m+1) mn=min(mn,dp[i][n]);
	cout<<mn<<endl;
}
	

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

string a[110];
int hc[110]={0};
int wc[110]={0};

int main(void)
{
  int h,w;
  cin >> h >> w;
  REP(i, h) {
    cin >> a[i];
  }
  REP(i, h) {
    REP(j, w) {
      if(a[i][j]=='.') {
	hc[i] ++;
	wc[j] ++;
      }
    }
  }
  /*
  REP(i, h) printf("%d ", hc[i]);
  printf("\n");
  REP(j, w) printf("%d ", wc[j]);
  printf("\n");
  */

  
  REP(i, h) {
    if(hc[i] != w) {
      //  printf("%3d %3d ", hc[i], h);
      REP(j, w) {
	if(wc[j] != h) {
	  printf("%c", a[i][j]);
	}
      }
      printf("\n");
    }
  }
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = boost::multiprecision::cpp_int;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int power(Int x){
	Int ret = x;
	x *= x;
	x *= x;
	ret *= x;
	return ret;
}

Int root(Int x){
	if(x == 1) return 1;
	Int l = 0, r = x;
	while(l + 1 < r){
		(power((l + r) / 2) <= x ? l : r) = (l + r) / 2;
	}
	return l;
}

int main(){
	Int x;
	cin >> x;

	for(Int a = 0;; ++a){
		Int pa = power(a);
		Int b;
		if(pa > x){
			b = root(pa - x);
		}else{
			b = - root(x - pa);
		}
		if(pa - power(b) == x){
			cout << a << " " << b << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 3752
#include <stdio.h>

int main(){
    int r,c;
    scanf("%d %d",&r,&c);
    int A[r+1][c+1];
    int i,f;
    for(i=0;i<r;i++){
        for(f=0;f<c;f++){
            scanf("%d",&A[i][f]);
        }
    }
    
    int sum=0;
    for(i=0;i<r;i++){
        sum=0;
        for(f=0;f<c;f++){
            sum+=A[i][f];
        }
        A[i][c]=sum;
    }
    for(i=0;i<c;i++){
        sum=0;
        for(f=0;f<r;f++){
            sum+=A[f][i];
        }
        A[r][i]=sum;
    }
    
    sum=0;
    for(i=0;i<r;i++){
        sum+=A[i][c];
    }
    A[r][c]=sum;
    
    for(i=0;i<r+1;i++){
        for(f=0;f<c+1;f++){
            if(f==0)
                printf("%d",A[i][f]);
            else
                printf(" %d",A[i][f]);
        }
        printf("\n");
    }

}


Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#define MAXN 100000



int main() {
    long long a, b, k;
    std::cin >> a >> b >> k;
    bool l = 0;
    for (int i = 1; i <= k; i++) {
        if (l == 0) {
            if (a % 2 != 0)
                a--;
            b += a /2;
            a = a/2;
        }
        else {
            if (b % 2 != 0)
                b--;
            a += b /2;
            b = b/2;
        }
        l = 1 - l;
    }
    std::cout << a << " " << b;
}


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

int main()
{
  
  int k;
  string nish;
  cin>>k>>nish;
  int siz=nish.size();
  if(siz<=k)
    cout<<nish<<endl;
  else
  {
    string temp=nish.substr(0,k)+"...";
    cout<<temp<<endl;
  }
  
  
  return 0;
  
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long int64;

int64 A, B;
const int INF = 1<<29;
const int NOT_FOX = -1;

const int MAX_SIZE = 2000000;
bool isPrime[MAX_SIZE];
int div_num_instance[1200000];
int *div_num;

void seive(){
	memset(isPrime, -1, sizeof(isPrime));
	bool *ps = isPrime;
	ps[0] = ps[1] = false;
	for(int i=2; i*i<MAX_SIZE; i++)if(ps[i]){
		for(int j=i<<1; j<MAX_SIZE; j+=i){
			ps[j] = false;
		}
	}
}

//æÔâ¿, èØéÅ¬Ìfào¦Ä¨­
//[from, to)
int solve(int64 from, int64 to){

	fill(div_num + from, div_num + to, INF);

	for(int i=2; i<MAX_SIZE; i++)if(isPrime[i]){
		for(int64 j=max(2LL*i, (from+i-1)/i*i); j < to; j += i)if(div_num[j] != NOT_FOX){
			int64 t = j;
			int div_count = 0;
			while(t % i == 0){
				t /= i;
				div_count++;
			}
			if(div_count > div_num[j]){
				div_num[j] = NOT_FOX;
			}
			else{
				div_num[j] = div_count;
			}
		}
	}

	return (int)( to - from - count(div_num + from, div_num + to, NOT_FOX));
}


int main(){

	scanf("%lld%lld",&A, &B);

	div_num = div_num_instance - (A-B);

	//föªð
	seive();

	//{Ì
	printf("%d\n", solve(max(2LL, A-B), A+B+1));

	return 0;
}

Measured memory_bytes: 6592
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main() {
	int N;
	cin>>N;
	int a[SIZE]={};
	vector<pint> abso;
	for(int i=1;i<=N;i++){
		cin>>a[i];
		abso.pb(mp(abs(a[i]),i));
	}
	sort(abso.begin(),abso.end(),greater<pint>());
	vector<pint> ans;
	for(int i=1;i<=N;i++){
		if(i!=abso[0].second){
			a[i]+=a[abso[0].second];
			ans.pb(mp(abso[0].second,i));
		}
	}
	if(a[1]>0){
		for(int i=1;i<N;i++){
			ans.pb(mp(i,i+1));
		}
	}
	else{
		for(int i=N;i>1;i--){
			ans.pb(mp(i,i-1));
		}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n, midNum1 = 0, midNum2 = 0;
	double midmid = 0;
	cin >> n;
	vector<ll>x(n);
	rep(i,n)cin >> x[i];
	vector<ll>x2(x);
	sort(all(x2));
	midNum1 = x2[x2.size()/2-1];
	midNum2 = x2[x2.size() / 2];
	midmid = (midNum1 + midNum2) / 2.0;
	for (ll i = 0; i < n; i++) {
		if (x[i] <= midmid)cout << midNum2 << endl;
		else cout << midNum1 << endl;
	}
}


Measured memory_bytes: 5376
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    robo = []
    for i in range(N):
        x, l = [int(x) for x in input().split()]
        robo.append((x-l, x+l))
    robo.sort()
    robo.sort(key=lambda x: x[1])

    ans = N
    l, r = robo[0]
    for i in range(1, N):
        if robo[i][0] < r:
            ans -= 1
        else:
            l, r = robo[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18312
=begin
構造体クラス City
next -> 転送先のインデックス
loop -> 何回の転送で再び到着するか
cnt  -> 何回の転送で訪れたか
=end
City = Struct.new(:next, :loop, :cnt)

n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map{
                     |v| City[v.to_i-1,nil,nil]}

# 各cityクラスのloop属性、cnt属性をセットする。
j = 0 # 町1スタートなので配列idの初期値は0
(0...n).each do |i|
  city = a[j]
  city.loop = i - city.cnt if city.cnt
  city.cnt = i
  j = city.next
end

# k回目の転送先を算出する。
j = 0
while k > 0
  city = a[j]
  k = k % city.loop if city.loop
  break if k == 0
  j = city.next
  k -= 1
end

print j+1
  

Measured memory_bytes: 37176
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
//const long long MOD = 1e9 + 7;

const long long MOD=1000003;

using ll = long long;
using P = std::pair<ll, ll>;



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

  std::vector<ll> facto(MOD,1);
  rep(i,1,MOD)facto[i]=(facto[i-1]*i)%MOD;

  ll q;
  std::cin>>q;

  rep(_,0,q){
    ll x,d,n;
    std::cin>>x>>d>>n;

    if(d==0){
      std::cout<<pow_mod(x,n,MOD)<<"\n";
    }else{
      ll left=(x*pow_mod(d,MOD-2,MOD))%MOD;
      if(left==0||left+n>MOD){
        std::cout<<0<<"\n";
      }else{
        ll num=pow_mod(d,n,MOD);
        num=(num*((facto[left+n-1]*pow_mod(facto[left-1],MOD-2,MOD))%MOD))%MOD;

        std::cout<<num<<"\n";
      }
    }
  }

  return 0;
}

Measured memory_bytes: 8704
def kaibun(n):
  m = list(str(n))[::-1]
  if m == list(str(n)):
    return True
  else:
    return False

A,B = map(int,input().split())
c = 0
for d in range(B-A+1):
  if kaibun(A+d):
    c += 1
print(c)

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

int main(){
 string s;
 std::cin >> s;
 if(s=="ABC")std::cout << "ARC" << '\n';
 else std::cout << "ABC" << '\n';
  return 0;
}


Measured memory_bytes: 3620
//122 B - ATCoder 2019/03/24
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

bool is_ACGT(char x){
    if(x=='A' || x=='C' || x=='G' || x=='T') return true;
    return false;
}

int main(){
    string s; cin >>s;
    int len=s.size();
    int counter=0;int max=0;
    rep(i ,len){
        if(is_ACGT(s[i])){
            ++counter;int j=i+1;
            while((is_ACGT(s[j])) && j<=len-1){
                ++j;
                ++counter;
            }
        }
        if(max<counter) max=counter;
        counter=0;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

const int mod = 1000000007;

struct mint {
    ll x;
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    ve<mint> dp(w,mint(0));
    dp[0] = mint(1);
    
    ve<ve<int>> p(w,ve<int>(3,0));
    
    rep(i,1<<(w-1)){
        ve<bool> o(w);
        bool fl=false;
        rep(j,w-1){
            if((i>>j)&1){
                o[j] = true;
                if(j!=0)if(o[j-1]){
                    fl = true;
                    break;
                }
            }
        }
        if(fl)continue;
        
        rep(k,w){
            if(o[k]){
                p[k+1][0]++;
                continue;
            }
            if(k-1>=0)if(o[k-1]){
                p[k-1][2]++;
                continue;
            }
            p[k][1]++;
        }
    }
    
    rep(i,h){
        ve<mint> dp2(w,mint(0));
        swap(dp,dp2);
        rep(j,w){
            dp[j] += mint(p[j][1]) * dp2[j];
            if(j==0){
                dp[j] += mint(p[j][2]) * dp2[j+1];
                continue;
            }
            if(j==w-1){
                dp[j] += mint(p[j][0]) * dp2[j-1];
                continue;
            }
            dp[j] += mint(p[j][0]) * dp2[j-1];
            dp[j] += mint(p[j][2]) * dp2[j+1];
            
        }
    }
    cout << dp[k-1].x << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
int  n, a[100001];
int  i, p, c;

scanf("%d", &n);

for(i=1; i<=n; i++){
scanf("%d", &a[i]);
}


i = a[1];
c=1;
while( i != 1 && i != 2){
p = a[i];
a[i] = 1;
i = p;
c++;
}

if( i == 2){
printf("%d\n", c);
} else {
printf("-1\n");
}

return 0;
}

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

int main(){
  int N;
  string S;
  string T;
  cin >> N >> S >> T;
  
  for(int i=0; i<N; i++){
    cout << S.at(i) << T.at(i);
  }
  
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100000

int S[N],T[N];
int n,m;

int binary(){
	int l,r,mid,i;
	int count =0;
	for(i = 0;i<m;i++){
		l = 0;
		r = n;
		while(l < r){
			mid = (l + r )/ 2;
			if(S[mid] == T[i]){
				count++;
				l = r;
			}
			else if(T[i] < S[mid]){
				r = mid;
			}
			else{
				l = mid + 1;
			}
		}
	}
	return count;
}

int main(){
	scanf("%d\n",&n);
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}
	scanf("%d\n",&m);
	for(i=0;i<m;i++){
		scanf("%d",&T[i]);
	}

	int c = binary();

	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 3164
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <bitset>
#include <time.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
char s[109];
int main()
{
    scanf("%s",s);
    s[5]=' ';
    s[13]=' ';
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 764
N = int(input())
s = [int(input()) for i in range(N)]
S = 0
not10 = float("INF")
for i in range(N):
    S += s[i]
    if s[i] % 10 != 0:
        not10 = min(not10, s[i])
if S % 10 != 0:
    print(S)
elif not10 == float("INF"):
    print(0)
else:
    print(S - not10)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
	int a, b, x;
	double res, s1, s2, h;
	cin >> a >> b >> x;
	s1 = x/((double) a);
	s2 = a*b - s1;
	//cout << "s1: " << s1 << "    s2: " << s2 << endl;
	if(s1 <= a*b/((double) 2)){
		h = 2*s1/((double) b);
		res = 90 - (atan(h/((double) b))) *(180/M_PI);
		//cout << "h: " << h << "    b: " << b << endl;
		//cout << "if 0, atan(): " << atan(h/((double) b)) << endl;
	}else{
		h = 2*s2/((double) a);
		res = (atan(h/((double) a)))*(180/M_PI);
		//cout << "h: " << h << "    a: " << a << endl;
		//cout << "if 1, atan(): " << atan(h/((double) a)) << endl;
	}
	cout << fixed << setprecision(10);
	cout << res << endl;
	return 0;
}

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

using namespace std;

#define ll long long

int n, k;

double calc(int a[], int b[]) {
	double x = 0;
	for(int i = 0; i < k; i++) {
		x += pow(a[i] - b[i] , 2);
	}
	return sqrt(x);
}

void solve() {

	
	cin >> n >> k;
	int mat[n][k];
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < k; j++) {
			cin >> mat[i][j];
		}
	}
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			double d = calc(mat[i], mat[j]);
			if((int) d == d) {
				cnt++;
			}
		}
	}
	cout << cnt;

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3688
N=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(N-1):
  if p[i]==i+1:
    p[i],p[i+1]=p[i+1],p[i]
    ans+=1
if p[N-1]==N:
  ans+=1
print(ans)

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

using namespace std;

long long inf=1000000007;

long long modpow(long long n,long long p,long long mod);

int main(){
	long long n,k;
	cin>>n>>k;
	if(k==1){
		cout<<0<<endl;
		return 0;
	}
	cout<<n-k<<endl;

	return 0;
}

long long modpow(long long n,long long p,long long mod){
	if(p==0) return 1;
	if(p%2==0) return (modpow(n,p/2,mod)*modpow(n,p/2,mod))%mod;
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}


Measured memory_bytes: 3576
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    P = LI()

    s = []
    for i in range(N):
        for j in range(N):
            s.append(min(i,N-1-i,j,N-1-j))

    r = [1] * (N*N)

    ans = 0
    q = []
    for p in P:
        p -= 1
        ans += s[p]
        r[p] = 0
        q.append(p)
        while q:
            a = q.pop()
            nc = s[a] + r[a]

            if a >= N:
                if s[a-N] > nc:
                    s[a-N] = nc
                    q.append(a-N)
            if a + N < N*N:
                if s[a+N] > nc:
                    s[a+N] = nc
                    q.append(a+N)
            if a % N:
                if s[a-1] > nc:
                    s[a-1] = nc
                    q.append(a-1)
            if a % N < N -1:
                if s[a+1] > nc:
                    s[a+1] = nc
                    q.append(a+1)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 176836
class Integer
  def !
    (1..self).inject(1){|s,r|s*r%1000000007}
  end
end

n,m=gets.split.map(&:to_i)

if (n-m).abs>1
  p 0
else
  p n.! * m.! * ((n==m)?2:1) % 1000000007
end

Measured memory_bytes: 1788
using System;
using System.Linq;

namespace id_0510cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var ATotalScore = Console.ReadLine().Split(' ').Select(int.Parse).ToArray().Sum();
            var BTotalScore = Console.ReadLine().Split(' ').Select(int.Parse).ToArray().Sum();
            Console.WriteLine(ATotalScore > BTotalScore ? ATotalScore : BTotalScore);
        }
    }
}



Measured memory_bytes: 9428
#include<cstdio>
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int t;
	if(d<=a)t=0;
	else if((c<=a)&&(a<=d)&&(d<=b))t=d-a;
	else if((c<=a)&&(a<=d))t=b-a;
	else if((a<=c)&&(d<=b))t=d-c;
	else if((a<=c)&&(c<=b))t=b-c;
	else t=0;
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

        int taroPnt = 0;
        int hanakoPnt = 0;
        for(int i=0; i<n; i++) {
            String taro = sc.next();
            String hanako = sc.next();
            if(taro.compareTo(hanako) > 0) {
                taroPnt += 3;
            } else if(taro.compareTo(hanako) == 0) {
                taroPnt += 1;
                hanakoPnt += 1;
            } else {
                hanakoPnt += 3;
            }
        }
        System.out.println(taroPnt + " " + hanakoPnt);
    }
}



Measured memory_bytes: 29428
from itertools import combinations

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = map(int, input().split())

s = set()
for i in range(1, n):
    for j in combinations(a, i):
        s.add(sum(j))
for ans in m:
    print('yes' if ans in s else 'no')

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

template <typename T>
using V = std::vector<T>;
template <typename T>
vector<T> make_vec(size_t n, T a) {
  return vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '[';
  for (auto &&e : v) os << e << ' ';
  return os << ']';
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << '[';
  for (auto &&e : v) os << e << ' ';
  return os << ']';
}

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

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

  int N, A, B;
  cin >> N >> A >> B;
  V<i64> v(N);
  REP(i, N) cin >> v[i];
  sort(v.rbegin(), v.rend());

  int rfirst = -1;
  int rcount = 0;
  int maxcount = 0;
  REP(i, N) {
    if (v[i] == v[0]) ++maxcount;
    if (v[i] == v[A - 1]) {
      ++rcount;
      if (rfirst < 0) rfirst = i;
    }
  }

  u64 vsum = 0;
  REP(i, A) { vsum += v[i]; }
  double vmean = (double)vsum / A;

  V<V<u64>> C = make_vec(N + 1, N + 1, 0ULL);
  REP(i, N + 1) C[i][0] = C[i][i] = 1;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j < i; ++j) {
      C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
    }
  }

  DEBUG(vmean, rcount);
  if (v[A - 1] == v[0]) {
    int m = min(maxcount, B);
    u64 cnt = 0;
    for (int k = A; k <= m; ++k) {
      cnt += C[maxcount][k];
      DEBUG(m, k, C[maxcount][k], cnt);
    }
    cout << vmean << '\n' << cnt << '\n';
  } else {
    int k = A - rfirst;
    u64 cnt = C[rcount][k];
    cout << vmean << '\n' << cnt << '\n';
  }
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

vector<int> count_prime(int n){
    int p = 0;
    vector<int> prime(n+1, true);
    prime[0] = prime[1] = false; 
    for(int i = 2; i <= n; i++)
        if(prime[i]) {
            p++;
            for (int j = i*2; j <= n; j += i) prime[j] = false;
        }
    return prime;
}

int main(void)
{
    vector<int> p;
    auto pv = count_prime(55556);
    REP(i, 55556){
        if(pv[i] && (i%5)==1) p.push_back(i);
    }

    int n;
    cin >> n;
    REP(i, n){
        pr(p[i]);
    }
}

Measured memory_bytes: 512
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int H[]=new int[N];
        boolean good[]=new boolean[N];
        int sum=0;
        for(int i=0;i<N;i++){
            H[i]=sc.nextInt();
            good[i]=true;
        }
        for(int i=0;i<M;i++){
            int A=sc.nextInt();
            int B=sc.nextInt();
            if(H[A-1]<H[B-1]){
                good[A-1]=false;
            }else if(H[A-1]>H[B-1]){
                good[B-1]=false;
            }else{
                good[A-1]=false;
                good[B-1]=false;
            }
        }
        for(int i=0;i<N;i++){
            if(good[i]){
                sum++;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 59732
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long A, B, K;
    cin >> A >> B >> K;

    for (int i = 0; i < K; i++) {
        if (i % 2 == 0) {
            B += (A / 2);
            A /= 2;
        }
        if (i % 2 == 1) {
            A += (B / 2);
            B /= 2;
        }
    }

    cout << A << " " << B << endl;

}













































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

int main() {
  vector<string> S(3);
  cin>>S[0]>>S[1]>>S[2];
  vector<int> now(3,0);
  int oya=0;
  while(1){
    if(now[oya]==S[oya].size()) break;
    now[oya]++;
    oya=S[oya][now[oya]-1]-'a';
    //cout<<oya<<endl;
  }
  
  cout<<char('A'+oya)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#include <iostream>
#include <string>

using namespace std;
int main() {
    long long int A, B, K;
    cin >> A >> B >> K;

    long long int takahashi, aoki;

    if (A - K > 0) {
        takahashi = A - K;
        aoki = B;
    } else if (K < (A + B)) {
        takahashi = 0;
        aoki = B - (K - A);
    } else {
        takahashi = 0;
        aoki = 0;
    }
    cout << takahashi << " " << aoki << endl;

    return 0;
}


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

using namespace std;
#define X first
#define Y second
typedef pair<int,int> P;
const int MAXN=1e5+10,INF=1<<27;
int n,m,x,y,z,dist[MAXN];
set<int> s[MAXN];//±ØÐëÒªÓÃset½øÐÐ´æ´¢£¬ÒòÎª¿ÉÄÜdist×îÐ¡Ê±ÓÐ¶àÖÖ¹«Ë¾¹©Ñ¡Ôñ 
vector<P> G[MAXN];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		G[x].push_back(P(y,z));G[y].push_back(P(x,z));
	}
	
	priority_queue<P> q;
	for(int i=2;i<MAXN;i++) dist[i]=INF;
	dist[1]=0;q.push(P(0,1));
	while(!q.empty())
	{
		P t=q.top();q.pop();
		int u=t.Y,cost=-t.X,tmp;
		if(cost>dist[u]) continue;
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i].X,col=G[u][i].Y;
			tmp=dist[u]+(!s[u].count(col));
			if(tmp==dist[v]) s[v].insert(col);
			else if(tmp<dist[v])
			{
				s[v].clear();s[v].insert(col);
				dist[v]=tmp,q.push(P(-dist[v],v));
			}
		}
	}
	printf("%d",(dist[n]==INF)?-1:dist[n]);
	return 0;
}

Measured memory_bytes: 23412
#include <cstdio>
#include <cctype>
#include <algorithm>

const int N = 1e5 + 7;

inline int read() {
	char ch = getchar(); int r = 0, w = 1;
	while(!isdigit(ch)) {if(ch == '-') w = -1; ch = getchar();}
	while(isdigit(ch)) {r = r * 10 + ch - '0', ch = getchar();}
	return r * w;
}

int n;
int tot, w[N], cnt[32], p[20], dp[1 << 16], ans;

inline int calc(int x) {
	int now = 0, res = 0, sz = 0;
	while(x) {
		if(x & 1) res ^= p[now], sz++;
		x >>= 1;
		now++;
	}
	return res ? sz : sz - 1;
}

int main() {
	n = read();
	for(register int i = 1; i < n; i++) {
		int x = read() + 1, y = read() + 1, z = read();
		w[x] ^= z, w[y] ^= z;
	}
	for(register int i = 1; i <= n; i++)
		cnt[w[i]]++;
	for(register int i = 1; i <= 31; i++) {
		ans += cnt[i] / 2;
		if(cnt[i] & 1)
			p[tot++] = i;
	}
	for(register int S = 1; S < 1 << tot; S++) {
		dp[S] = calc(S);
		for(register int T = S; T; T = (T - 1) & S) {
			dp[S] = std::min(dp[S], dp[T] + dp[S ^ T]);
		}
	}
	if(tot) printf("%d\n", ans + dp[(1 << (tot - 1)) - 1]);
	else printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
enu = enumerate
def input():
    return sys.stdin.readline()[:-1]
def pri(x):
    if type(x) is list:
        print('\n'.join(map(str, x)))
    else:
        print(x)

sys.setrecursionlimit(10**7)
N = int(input())

nums = defaultdict(int)

for i in range(1, N+1):
    st = int(str(i)[0])
    en = int(str(i)[-1])
    nums[(st, en)] += 1

cnt = 0
for st in range(1, 10):
    for en in range(1, 10):
        cnt += nums[(st, en)] * nums[(en, st)]

pri(cnt)



Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

int main(){
   int R, G, B, N;
   cin >> R >> G >> B >> N;

   int ans = 0;
   for(int g = 0; g <= 3000; g++){
      for(int b = 0; b <= 3000; b++){
         int sum = g*G + b*B;
         if(sum <= N){
            int others = N - sum;
            if(others % R == 0){
               ans++;
            }
         }
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B=get_i
if A==B
    puts "Draw"
elsif A==1
    puts "Alice"
elsif B==1
    puts "Bob"
elsif A>B
    puts "Alice"
elsif A<B
    puts "Bob"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n,m; cin >> n >> m;
    
    int left = 1 , right = m + 1;
    while(left < right){
        cout << left << " " << right << endl;
        left++; right--;
    }

    left = m + 2, right = 2*m + 1;
    while(left<right){
        cout << left << " " << right << endl;
        left++; right--;
    }

    return 0;
}

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

using P = pair<int, int>;
const int M = 1000000007;
int dd[5] = { 0, 1, 0, -1, 0 };

int main() {
    int n;
    cin >> n;
    vector<int> p2, m2, m1;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a == 2) {
            p2.push_back(i + 1);
        }
        if (a == -2) {
            m2.push_back(i + 1);
        }
        if (a == -1) {
            m1.push_back(i + 1);
        }
    }
    vector<int> ans = p2;
    for (int i = 0; i < m2.size() / 2 * 2; ++i) {
        ans.push_back(m2[i]);
    }
    if (m2.size() % 2 == 1) {
        if (m1.size() > 0) {
            ans.push_back(m2[m2.size() - 1]);
            ans.push_back(m1[0]);
        }
    }
    sort(ans.begin(), ans.end());
    cout << ans.size() << "\n";
    for (int i : ans) {
        cout << i << "\n";
    }
    return 0;
}



Measured memory_bytes: 3156