akhauriyash/Code-Regression huggingface dataset:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

H, W = map(int, input().split())
H += 2
W += 2
B = [0] * H
block = 0
for i in range(H):
    if i == 0 or i == H - 1:
        B[i] = '#' * W
    else:
        B[i] = '#' + input() + '#'
        block += B[i].count("#") - 2

start = (1, 1)
goal = (H - 2, W - 2)

import queue
def bfs(start, goal):
    dist = [[-1] * W for _ in range(H)]
    q = queue.Queue()
    sy, sx = start
    dist[sy][sx] = 1
    q.put(start)

    ys = [0, 1, 0, -1]
    xs = [1, 0, -1, 0]

    while not q.empty():
        y, x = q.get()
        if (y, x) == goal:
            return dist[y][x]

        for dy, dx in zip(ys, xs):
            ny, nx = y + dy, x + dx
            if B[ny][nx] == '#':
                continue
            if dist[ny][nx] != -1:
                continue
            dist[ny][nx] = dist[y][x] + 1
            q.put((ny, nx))
    return -1

res = bfs(start, goal)
if res == -1:
    print(res)
else:
    print((H - 2) * (W - 2) - block - res)

Measured memory_bytes: 9676
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import permutations

n, m = map(int, readline().split())
graph = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)
ans = 0
for check in permutations(range(1, n + 1)):
    if check[0] != 1:
        break
    for u, v in zip(check, check[1:]):
        if v not in graph[u]:
            break
    else:
        ans += 1
print(ans)


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

typedef long long int LLI;

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

  int l = s.size();
  LLI c = 0;
  LLI t = 0;
  for (int i = 0; i < l; ++i) {
    if (s[i] == 'W') {
      ++c;
      t += i;
    }
  }
  t -= c * (c - 1) / 2;

  cout << t << endl;

  return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{ it.toLong() }
    val s = Array<Long>(n + 1, {0})
    var sum = 0L
    for (i in a.indices) {
        s[i + 1] = s[i] + a[i]
        sum += a[i]
    }
    var ans = Long.MAX_VALUE
    for (i in 1 until s.size) {
        val left = s[i]
        val right = sum - s[i]
        val gap = Math.abs(right - left)
        ans = Math.min(ans, gap)
    }
    println(ans)
}

Measured memory_bytes: 80904
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ans = count(N);
		long x = 1;
		while(true){
			N -= keta(N,x)*x;
			if(N<=0)break;
			ans = Math.max(ans, count(N));
			x *= 10;
		}
		System.out.println(ans);
		return;
	}
	
	public static int count(long n){
		int ret = 0;
		long x = n;
		while(x!=0){
			ret += x%10;
			x /= 10;
		}
		return ret;
	}
	
	public static long keta(long n,long x){
		return (n/x)%10 + 1;
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;cin>>n;
    int x=0;
    vector<int> a;
    for(int i=0;i<n;i++){
        int t;cin>>t;
        a.push_back(t);
        x^=t;
    }
    for(int i:a){
        int t=x;
        t^=i;
        cout<<t<<' ';
    }
    cout<<endl;
}


Measured memory_bytes: 4300
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N;
    cin >> N;
    vi A(N);

    REP(i, N) {
        cin >> A[i];
    }
    int bitInt = 0;
    REP(i, N) {
        bitInt |= A[i];
    }
    debug(bitInt);
    int count = 0;
    while (1) {
        if (bitInt % 2 != 0) {
            break;
        }
        bitInt = bitInt >> 1;
        count++;
    }

    cout << count;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)

lli dp[100005][105], n;
vector<lli> val, w;

lli knapsack(lli x, lli i){
    lli &tmp=dp[x][i];
    if(tmp!=-1) return tmp;
    if(x<=0 || i>=n) return 0;

    if(w[i]<=x) return tmp=max(knapsack(x-w[i], i+1)+val[i], knapsack(x, i+1));
    else return tmp=knapsack(x,i+1);
}

int main(){
    lli x;
    cin>>n>>x;
    lli a,b;
    for(lli i=0;i<n;i++){
        cin>>a>>b;
        w.pb(a);
        val.pb(b);
    }
    memset(dp, -1, sizeof(dp));
    cout<<knapsack(x, 0);
}

Measured memory_bytes: 85608
#include <stdio.h>
int main(void){
   
  int a,b,c;
  int x;
  int d=0,e=0,t=0;
  
  while( 1 ){
  
    scanf("%d%d%d",&a,&b,&c);
     
    if( a > b ){
      x = a;
      a = b;
      b = x;
    }
    if( b > c ){
      x = b;
      b = c;
      c = x;
    }
    if( a > b ){
      x = a;
      a = b;
      b = x;
    }
     
    if ( c <= b - a || a + b <= c )break;
 
    if( c*c > a*a + b*b ){
      d++;
    }
    if( c*c < a*a + b*b ){
      e++;
    }
    if( c*c == a*a + b*b ){
      t++;
    }
     
  }
  printf("%d %d %d %d\n", d + e + t, t, e, d);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   ll n;
   cin>>n;
   cout<<(n*(n-1))/2<<endl;
   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll s[1100000];

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

bool isprime(ll x) {
  ll i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

vector<ll> enum_div(ll n) {
  vector<ll> ret;
  for(ll i = 2LL; i*i <= n; i++) {
    if(n%i == 0LL) {
      if(s[i]) ret.push_back(i);
      if(i*i != n) {
        if(s[n/i]) ret.push_back(n/i);
      }
    }
  }
  if(s[n]) ret.push_back(n);
  sort(ret.begin(), ret.end());
  return ret;
}

ll check[1100000];

int main() {
  ll n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  for(ll i = 2; i<=1000000; i++) if(isprime(i)) s[i] = 1;
  ll g = a[0];
  rep(i,n) g = GCD(g,a[i]);
  if(g!=1) {
    cout << "not coprime" << endl;
    return 0;
  }
  rep(i,n) {
    vll v = enum_div(a[i]);
    ll m = v.size();
    rep(j,m) {
      if(check[v[j]]!=0) {
        cout << "setwise coprime" << endl;
        return 0;
      }
      check[v[j]] = 1LL;
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}

Measured memory_bytes: 19504
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<sstream>
#include<stdio.h>
#include<numeric>
#include<bitset>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    lint n, a, b; cin >> n >> a >> b;
    if((a-b) % 2 == 0){
        cout << abs(a-b)/2 << endl;
        return 0;
    }
    else{
        lint c = n - b;
        cout << min(a-1, n-b) + 1 + (abs(a-b)-1)/2 << endl;
        return 0;
    }
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    string g;
    int y, m, d;
    while(cin>>g>>y>>m>>d&&g!="#"){
        if(y<=30 || y==31 && m <= 4){
            cout << "HEISEI " << y << " " << m << " " << d << endl;
        }else{
            cout << "? " << y - 30 << " " << m << " " << d << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3156
def main():
    N, A, B = (int(x) for x in input().split())
    total = 0
    for i in range(1, N+1):
        a = [int(x) for x in str(i)]
        if A <= sum(a) <= B:
            total += i
    print(total)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

  char s[100000+1];
  int end;
  for (int i = 0; i < 100000+1; i++) {
    scanf("%c", &s[i]);
    if (s[i] == '\n') {
      end = i-1;
      break;
    }
  }
  int q;
  scanf("%d", &q);
  int t[q][2];
  char tc[q];
  for (int i = 0; i < q; i++) {
    scanf("%d", &t[i][0]);
    if (t[i][0] == 2) {
      scanf("%d %c", &t[i][1], &tc[i]);
    } else {
      t[i][1] = 0;
      tc[i] = '0';
    }
  }

  int top = 1;
  char left[200000];
  int left_end = -1;
  char right[200000];
  int right_end = -1;

  for (int i = 0; i < q; i++) {
    if (t[i][0] == 1) {
      top *= -1;
    } else {
      if ((t[i][1] == 1 && top == 1) || (t[i][1] == 2 && top == -1)) {
        left_end++;
        left[left_end] = tc[i];
      } else {
        right_end++;
        right[right_end] = tc[i];
      }
    }
  }

  if (top == 1) {
    for (int i = 0; i <= left_end; i++) {
      printf("%c", left[left_end-i]);
    }
    for (int i = 0; i <= end; i++) {
      printf("%c", s[i]);
    }
    for (int i = 0; i <= right_end; i++) {
      printf("%c", right[i]);
    }
  } else {
    for (int i = 0; i <= right_end; i++) {
      printf("%c", right[right_end-i]);
    }
    for (int i = 0; i <= end; i++) {
      printf("%c", s[end-i]);
    }
    for (int i = 0; i <= left_end; i++) {
      printf("%c", left[i]);
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    fast;
    long long n,k,i,j,mn;
    cin >> k >> n;
    long long a[n],b[n];
    for(i = 0; i < n; i++)
        cin >> a[i];
    sort(a,a + n);
    mn = a[n - 1] - a[0];
    mn = min(mn,k - (a[1] - a[0]));
    for(i = 1; i < n - 1; i++)
    {
        mn = min(mn,k - (a[i] - a[i - 1]));
        mn = min(mn,k - (a[(i + 1)] - a[i]));
    }
    mn = min(mn,k - (a[i] - a[i - 1]));
    mn = min(mn,a[n - 1] - a[0]);
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 1792
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
const int MAX_N = 401;
bool visited[MAX_N][MAX_N];
int W = -1;
int H = -1;
char grid[MAX_N][MAX_N];

P dfs(int y, int x, char color) {
    visited[y][x] = true;

    P p = make_pair(0, 0);
    if (color == '.') {
        p.second++;
    } else {
        p.first++;
    }

    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            if (!(i == 0 || j == 0)) continue;
            if (i == 0 && j == 0) continue;
            if (y + i < 0 || y + i >= H || x + j < 0 || x + j >= W) continue;
            if (grid[y + i][x + j] == color || visited[y + i][x + j]) continue;
            P pret = dfs(y + i, x + j, grid[y + i][x + j]);
            p.first += pret.first;
            p.second += pret.second;
        }
    }

    return p;
}

signed main() {
    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        string line;
        cin >> line;
        for (int j = 0; j < W; j++) {
            grid[i][j] = line[j];
        }
    }

    int ret = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (visited[i][j]) continue;
            P p = dfs(i, j, grid[i][j]);
            ret += p.first * p.second;
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 15616
def main():
  import numpy as np
  import itertools
  from scipy.sparse import csr_matrix
  from scipy.sparse.csgraph import dijkstra
  import sys
  readline = sys.stdin.readline
  readlines = sys.stdin.readlines

  N, M, R= map(int, readline().split())
  r = list(map(int,input().split()))
  lines = readlines()
  edge = np.array([line.split() for line in lines], dtype = np.int64).T
  #print(r)
  #print(edge)
  graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
  ans = float("inf")
  distance_mat = {}
  for i in r:
    distance_mat[i-1] = (dijkstra(graph, directed = False, indices = i-1))

  for town in itertools.permutations(r,R):
    #print(town)
    tmp = 0
    for i in range(R-1):
      tmp += distance_mat[town[i]-1][town[i+1]-1]
    ans = min(ans,tmp)
  print(int(ans))
main()

Measured memory_bytes: 23780
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(a) signed(a.size())
using namespace std;

void solve(){
	string n;
	cin >> n;
	ll sum = 0;
	for(int i=0;n[i];i++){
		sum += n[i] - '0';
	}
	if(sum%9 == 0)
	cout << "Yes";
	else
	cout << "No";
}

int main() {
    FAST;
    ll t=1;
    //cin>>t;
    while(t--) solve();	
    return 0;
}



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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A')
    return 1;
  else if(ch == 'C')
    return 2;
  else if(ch == 'G')
    return 3;
  else if(ch == 'T')
    return 4;
  else
    return 0;
}

long long getKey(char str[]){
  long long sum = 0;
  long long p = 1;
  long long i;

  for(i = 0; i < strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5; 
  }
  return sum;
}

int h1(int key){
  return key % M;
}

int h2(int key){
  return 1 + (key % (M-1));
}

int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i = 0;; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0)
      return 1;
    else if(strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0)
      return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for(i = 0; i < M; i++)
    H[i][0] == '\0';
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s %s",com,str);

    if(com[0] == 'i'){
      insert(str);
    } else{
      if(find(str)){
        printf("yes\n");
      } else{
        printf("no\n");
      }
    }
  }

  return 0; 
}


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

int main() {
    long long  n; cin >> n;
    long long ans = 0;
    ans+= (n/500)*1000;
    n= n%500;
    n -= n%5;
    ans += n;
    cout << ans<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long N, M;
	cin >> N >> M;

	if(N == 1 && M == 1)
	{
		cout << 1;
	}
	else if(N == 1 || M == 1)
	{
		cout << max(N, M) - 2;
	}
	else if (N == 2 || M == 2)
	{
		cout << 0;
	}
	else
	{
		cout << (N - 2) * (M - 2);
	}

	return 0;
}

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

using namespace std;

int main()
{
  int n,i;
  string s,t;
  cin>>n;
  cin>>s>>t;
  
  for(i=0;i<n;i++)
  {
    cout<<s[i]<<t[i];
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <algorithm>

struct node {
    long long v, cost;
    node(long long v, long long cost) : v(v), cost(cost) {}
    bool operator<(const node& n) const { return cost > n.cost; }
};

int main() {
    long long n, m, s, t, tu, tv, ta, tb;
    scanf("%lld%lld%lld%lld", &n, &m, &s, &t);
    std::vector<long long> yen(n+1, 1000000000001000), snuuk(n+1, 1000000000001000);
    /* to, yen, snuuk */
    std::vector<std::deque<std::array<long long, 3>>> g(n+1);
    for (long long i = 0; i < m; i++) {
        scanf("%lld%lld%lld%lld", &tu, &tv, &ta, &tb);
        g[tu].push_back({ tv, ta, tb });
        g[tv].push_back({ tu, ta, tb });
    }

    std::priority_queue<node> que;
    que.push(node(s, 0));
    while(!que.empty()) {
        long long v = que.top().v, c = que.top().cost;
        que.pop();
        if (yen[v] >= 0 && yen[v] <= c) continue;
        yen[v] = c;
        for (long long i = 0; i < g[v].size(); i++) {
            if (yen[g[v][i][0]] <= c + g[v][i][1]) continue;
            que.push(node(g[v][i][0], c + g[v][i][1]));
        }
    }

    que.push(node(t, 0));
    while(!que.empty()) {
        long long v = que.top().v, c = que.top().cost;
        que.pop();
        if (snuuk[v] >= 0 && snuuk[v] <= c) continue;
        snuuk[v] = c;
        for (long long i = 0; i < g[v].size(); i++) {
            que.push(node(g[v][i][0], c + g[v][i][2]));
        }
    }

    long long mi[100010];
    for (long long i = 0; i < 100010; i++) {
        mi[i] = 1000000001000000;
    }

    for (long long i = n; i > 0; i--) {
        mi[i] = std::min(mi[i+1], yen[i] + snuuk[i]);
    }

    for (long long i = 1; i <= n; i++) {
        printf("%lld\n", 1000000000000000 - mi[i]);
    }

    return 0;
}


Measured memory_bytes: 69888
//
//  main.cpp
//  TestC
//
//  Created by CHEN SINYU on 2020/02/22.
//  Copyright © 2020 CHEN SINYU. All rights reserved.
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <math.h>
#include <stdio.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ll n;
    cin >> n;
    vector<ll>p(n);
    rep(i, 0, n){
        cin >> p[i];
    }
    ll ans = 0;
    rep(i,0,n-1){
        if(p[i]>p[i+1]){
            ans += p[i] - p[i+1];
            p[i+1] = p[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4784
# -*- coding: utf-8 -*-
S = list(map(int,list(input())))

p_num = 2**(len(S) - 1)
p = []
for i in range(p_num):
    temp_list = []
    temp = i
    for j in range(len(S) - 1):
        temp_list.append(temp % 2)
        temp //= 2

    p.append(temp_list)

g_sum = 0
for p_list in p:
    s_sum = S[0]
    add = 0
    for i in range(1,len(S)):
        if p_list[i-1] == 1:
            add += s_sum
            s_sum = S[i]
        else:
            s_sum = s_sum*10 + S[i]
    add += s_sum
    g_sum += add

print(g_sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  auto yes = []{
    std::cout << "YES" << std::endl;
    exit(0);
  };
  auto no = []{
    std::cout << "NO" << std::endl;
    exit(0);
  };
  int n; std::cin >> n;
  long long N = (long long)n * (n + 1) / 2;
  std::vector<int> a(n);
  for (auto& x : a) std::cin >> x;
  long long sum = std::accumulate(a.begin(), a.end(), 0LL);
  if (sum % N != 0) no();
  int times = sum / N;
  auto dif = [&]{
    std::vector<int> dif(n);
    std::adjacent_difference(a.begin(), a.end(), dif.begin());
    dif.front() = a.front() - a.back();
    assert(std::accumulate(dif.begin(), dif.end(), 0LL) == 0);
    return dif;
  }();
  for (auto&x : dif) {
    x -= times;
    if (x > 0 || x % n != 0) no(); 
  }
  yes();
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    vector<ll> L(n);
    for (ll i = 0; i<n; i++){
        cin>>L[i];
    }
    ll MAX = 0;
    for (ll i = 0; i<n; i++){
        MAX = max(MAX,L[i]);
    }
    
    ll sum = 0;
    for (ll i = 0; i<n; i++){
        sum += L[i];
    }
    
    if (MAX < sum - MAX)puts("Yes");
    else puts("No");
    
    return 0;
}


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

using namespace std;

int main()
{
    int h,w,i,j;
    char a[220][220]={0};
    scanf("%d%d",&h,&w);
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            scanf(" %c",&a[2*i][j]);
            a[2*i+1][j]=a[2*i][j];
        }
    }
    for(i=0;i<2*h;i++)
    {
        for(j=0;j<w;j++)
        {
            printf("%c",a[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
T = [list(map(int, input().split())) for i in range(m)]
ans = 0
start = 0

if n != 1:
    start = 10 ** (n - 1)

for i in range(start, 10 ** n):
    for j in range(m):
        ans = 0
        if (str(i))[(T[j][0] - 1)] != str(T[j][1]):
            ans = -1
            break
    if ans == 0:
        ans = i
        break

print(ans)


Measured memory_bytes: 3064
//code_sm
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define si set<int>
#define ll long long
#define pb push_back
int main()
{
int n,m;
cin>>n>>m;
vector<pair<int,int> >v(m);
for(int i=0;i<m;i++)
{
	cin>>v[i].first>>v[i].second;
}
sort(v.begin(),v.end());
if(v[0].first!=1)
cout<<"IMPOSSIBLE";
else
{
	bool flag=0;
for(int i=0;i<m;i++)
{
	if(v[i].first==1)
	{
		pair<int,int>p={v[i].second,n};
	if(binary_search(v.begin(),v.end(),p))
	{
		flag=1;
		break;
	}
	}
}
if(flag)
cout<<"POSSIBLE";
else
cout<<"IMPOSSIBLE";
}
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  vector<int> A = X;
  sort(A.begin(), A.end());
  int mid1 = A[(N - 1) / 2];
  int mid2 = A[N / 2];
  for (int i = 0; i < N; i++) {
    if (mid1 < X[i])
      cout << mid1 << endl;
    else
      cout << mid2 << endl;
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
//解説写し
int main() {
  int n;
  cin>>n;
  vector<int> a(n), b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  vector<int> c(200005);
  rep(i,n) c[a[i]]++;
  rep(i,n) c[b[i]]++;
  priority_queue<P> q;
  rep(i,200005) if (c[i]) q.emplace(c[i],i);
  if (q.top().first > n) {
      cout<<"No"<<endl;
      return 0;
  }
  cout<<"Yes"<<endl;
  int rn = n;
 
  multiset<int> sa, sb;
  map<int,int> ma, mb;
  rep(i,n) sa.insert(a[i]);
  rep(i,n) sb.insert(b[i]);
  rep(i,n) ma[a[i]]++;
  rep(i,n) mb[b[i]]++;
 
  set<P> ps;
  rep(i,n) ps.emplace(a[i],i);
  vector<int> ans(n);
 
  auto del = [&](int i) {
    c[i]--;
    if (c[i]) q.emplace(c[i],i);
  };
  auto put = [&](int x, int y) {
    sa.erase(sa.find(x));
    sb.erase(sb.find(y));
    del(x);
    del(y);
    ma[x]--;
    if (ma[x] == 0) ma.erase(x);
    mb[y]--;
    if (mb[y] == 0) mb.erase(y);
    auto it = ps.lower_bound(P(x,-1));
    ans[it->second] = y;
    ps.erase(it);
  };
 
  while (rn) {
    while (c[q.top().second] != q.top().first) q.pop();
    P p1 = q.top(); q.pop();
    int x = p1.second;
    while (c[q.top().second] != q.top().first) q.pop();
    if (q.top().first == rn) {
      P p2 = q.top(); q.pop();
      int y = p2.second;
      if (sa.find(x) == sa.end()) swap(x,y);
      put(x,y);
    } else {
      int y = 0;
      if (sa.find(x) != sa.end()) {
        for (auto it = mb.begin();; ++it) {
          if (it->first != x) {
            y = it->first;
            break;
          }
        }
      } else {
        y = x;
        for (auto it = ma.begin();; ++it) {
          if (it->first != y) {
            x = it->first;
            break;
          }
        }
      }
      put(x,y);
    }
    --rn;
  }
 
  rep(i,n)cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 64664
# ABC083 B

def main():
    n, a, b = map(int, input().split())

    sums = []

    for i in range(1, n+1):
        c = 0
        for num in str(i):
            c += int(num)
        
        if a <= c <= b:
            sums.append(i)
    
    print(sum(sums))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3296
#include <bits/stdc++.h>
#include <vector>
#include <string>
#define mod 1000000007
#define INF LLONG_MAX
#define loop(i,x,n) for(int i = x; i < n; i++)
#define pb push_back
#define mp make_pair
#define ll long long 
#define vpl vector< pair<ll,ll> >
#define vpi vector< pair<int,int> >
#define vi vector<int>
#define vl vector<ll>
#define vch vector<char>
#define se second
#define fi first
using namespace std;

int solve(int n,int arr[],int k){
	int dp[n+1];
	
	dp[0] = 0;
	
	for(int i=1;i<n;i++){
		dp[i] = INT_MAX;
		for(int j=1;j<=k;j++){
			int l1 = INT_MAX;
			if(i-j >= 0){
				l1 = abs(arr[i]-arr[i-j]) + dp[i-j];
			}
			dp[i] = min(dp[i],l1);
		}
		
	}
	
	return dp[n-1];
}


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

	
	int n,k;
	cin >> n >> k;
	
	int arr[n];
	
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	
	cout << solve(n,arr,k) << "\n";
	
	
	
	return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    long long a, b, n;
    cin >> a >> b >> n;
    long long ans = 0;
    if (n < b) {
        ans = ((a * n) / b);
    }
    else if (b == 1 || a == 1) {
        ans = 0;
    }
    else {
        long long c = n % b;
        long long nb;
        if (c + 1 == b) {
            nb = n;
        }
        else{
            nb = n - c - 1;
        }
        ans = (a * nb) / b - a * (nb / b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
    int n, m,  i, j;
    int cards[][13] = {{}, {}, {}, {}};
    char ch;
    char c[4] = {'S', 'H', 'C', 'D'};

    scanf("%d", &n);
    for(i = 0; i < 2 * n; i++){
        scanf("%c %d", &ch, &m);
        switch(ch){
            case 'S':
                 cards[0][m - 1] = 1;
                 break;
            case 'H':
                 cards[1][m - 1] = 1;
                 break;
            case 'C':
                 cards[2][m - 1] = 1;
                 break;
            case 'D':
                 cards[3][m - 1] = 1;
                 break;
        }
    }
    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
            if(!cards[i][j])
                printf("%c %d\n", c[i], j + 1);
        }
    }
    return 0;
}
  

Measured memory_bytes: 1824
march = ['M', 'A', 'R', 'C', 'H']
N = int(input())
S = []
people = {prefix: 0 for prefix in march}
for _ in range(N):
	s = input()
	for prefix in march:
		if s[0] == prefix:
			people[prefix] += 1
			break

ns = [n for n in people.values() if n > 0]
ans = 0
for i in range(len(ns)-2):
	for j in range(i+1,len(ns)-1):
		for k in range(j+1, len(ns)):
			ans += ns[i]*ns[j]*ns[k]
			
print(ans)
		

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

typedef long long ll;
const int N = 100000 + 10, INF = 0x3f3f3f3f;

int n;
ll arr[N];
ll a, b;

bool check(ll x)
{
    ll num = x;
    for(int i = 1; i <= n; i++)
    {
        ll tmp = arr[i] - x * b;
        if(tmp > 0)
        {
            ll cnt = tmp / (a - b);
            if(tmp % (a-b)) cnt++;
            num -= cnt;
            if(num < 0) return false;
        }
    }
    return true;
}
int main()
{
    while(~ scanf("%d%lld%lld", &n, &a, &b))
    {
        for(int i = 1; i <= n; i++)
            scanf("%lld", &arr[i]);

        ll l = 1, r = 1e9 + 10, res;
        while(l <= r)
        {
            ll mid = (l + r) >> 1;
            if(check(mid)) r = mid - 1, res = mid;
            else l = mid + 1;
        }
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    // Your code here!
    int m,d;
    int all;
    int i;
    int ans=0;
    scanf("%d %d",&m, &d);
    all=m*d;
    for(i=d;i>10;i--){
    if (i/10 *(i%10)  <=m && (i%10) !=0 && (i%10) !=1 && (i/10)!=1){
        ans++;
    //  printf("%d\n",i);
     }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int main() {
	int n;
	cin >> n;
	VI a(n), b(n);
	REP(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(ALL(b));
	int ans;
	REP(i, n) {
		if (a[i] == b[n - 1])
			cout << b[n - 2] << '\n';
		else
			cout << b[n - 1] << '\n';
	}
}

Measured memory_bytes: 3200
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	r1 := scanInt()
	c1 := scanInt()
	r2 := scanInt()
	c2 := scanInt()

	facInit(r2+c2+2)

	var a mint
	a.add(comb(r2+1+c2+1, c2+1)-1)
	a.sub(comb(r2+1+c1, c1)-1)
	a.sub(comb(c2+1+r1, r1)-1)
	a.add(comb(c1+r1, r1)-1)

	fmt.Println(a)

}

const mod = 1000000007

type mint int

func (a *mint) add(b int) { *a = (*a+mint(b))%mod; if *a<0 { *a += mod } }
func (a *mint) sub(b int) { *a = (*a-mint(b))%mod; if *a<0 { *a += mod } }

var fac, ifac []int

func facInit(n int) {
	fac = make([]int,n+1)
	ifac = make([]int,n+1)

	mpow := func (x,n int) int {
		res := 1
		for n!=0 {
			if n&1 == 1 { res = res*x%mod }
			x = x*x%mod; n >>= 1
		}
		return res
	}

	fac[0] = 1; ifac[0] = 1

	for i := 0; i < n; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		ifac[i+1] = ifac[i]*mpow(i+1,mod-2)%mod
	}
}

func comb(a,b int) int { return (fac[a]*ifac[b]%mod)*ifac[a-b]%mod }
func perm(a,b int) int { return fac[a]*ifac[a-b]%mod }

Measured memory_bytes: 32896
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::string s){
	int r = 0, b = 0;
	for(int i = 0; i < N; ++i) {
		if (s[i] == 'R') {
			r++;
		}
		 else {
			 b++;
		 }
	}
	cout << (r > b ? "Yes" : "No") << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::string s;
    std::cin >> s;
    solve(N, s);
    return 0;
}


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

  vector<int>v(n);
  for(i=0;i<n;i++)
  {
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  if(k>=n)
  {
    cout<<0<<endl;
    return 0;
  }
  for(i=0;i<n-k;i++)
  {
      c+=v[i];
  }
  cout<<c<<endl;
}




Measured memory_bytes: 1024
"use strict"
const assert = require('assert');

function main(input) {
    let ret = check(input);
    console.log(ret);
}

function check(input) {
    let ans;
    let n = parseInt(input.replace(/\n/g,"").slice(-1));
    let hon = [2, 4, 5, 7, 9];
    let pon = [0, 1, 6, 8];
    let bon = [3];
    if (hon.includes(n)) {
        ans = "hon"
    } else if (pon.includes(n)) {
        ans = "pon"
    } else if (bon.includes(n)) {
        ans = "bon"
    }
    return ans;
}

var input;
input = require('fs').readFileSync('/dev/stdin', 'utf8');
main(input);

// check
// var answer;

// input = `16
// `;
// answer = `pon`;
// assert.equal(check(input), answer);

// input = `2`;
// answer = `hon`;
// assert.equal(check(input), answer);

// input = `183`;
// answer = `bon`;
// assert.equal(check(input), answer);

Measured memory_bytes: 29560
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	vector<int> a(10);
	for(int i=0;i<10;i++)
		scanf("%d",&a[i]);
	sort(a.begin(),a.end(),greater<int>());
	for(int i=0;i<3;i++)
		printf("%d\n",a[i]);
	
	return 0;
}

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

int main () {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < 1000; ++i) {
		int d[3] = {i/100, i/10%10, i%10};
		// cout << d[0] << ' ' << d[1] << ' ' << d[2] << endl;
		int vis[2] = {0,0};
		for (int j = 0; j < n; ++j) {
			if (vis[0] and vis[1] and d[2] == (s[j]-'0')) {
				ans++;
				break;
			} else if (vis[0] and d[1] == (s[j]-'0')) {
				vis[1] = 1;
			} else if (d[0] == (s[j]-'0')) {
				vis[0] = 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

    int l, r, d; cin>>l>>r>>d;
    l = (l+d-1)/d;
    r = r/d;
    cout<<r-l+1<<"\n";
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int r, g, b;
  cin >> r >> g >> b;
  int n = r * 100 + g * 10 + b;

  puts((n % 4) ? "NO" : "YES");
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
    return 0;
}

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

using namespace std;

#define ll long long
#define up(i,j,n)	for(int i=j;i<=n;i++)
#define down(i,j,n)	for(int i=j;i>=n;i--)
#define cmax(a,b)	a=max(a,b)
#define cmin(a,b)	a=min(a,b)
#define pii		pair<int,int>
#define fi		first
#define	se		second
#define SZ(x)		(int)x.size()

const int MAXN=1e5+5;
const int oo=0x3f3f3f3f;

int N,fa[MAXN];
struct Axe{
	int x,y,p;
}axe[MAXN],tmp;

int operator - (Axe a,Axe b){
	return min(abs(a.x-b.x),abs(a.y-b.y));
}

vector<Axe>edge;

ll ans=0;

namespace solution{
	inline bool cmpx(Axe a,Axe b){return a.x<b.x;}
	inline bool cmpy(Axe a,Axe b){return a.y<b.y;}
	inline bool cmpp(Axe a,Axe b){return a.p<b.p;}
	int getf(int k){
		if(k==fa[k])return k;
		fa[k]=getf(fa[k]);
		return fa[k];
	}
	void Prepare(){
		scanf("%d",&N);
		up(i,1,N){
			axe[i].p=i;
			scanf("%d%d",&axe[i].x,&axe[i].y);
		}
	}
	void Solve(){
		up(i,1,N)fa[i]=i;
		sort(axe+1,axe+N+1,cmpx);
		up(i,1,N){
			if(i!=1){
				tmp.x=axe[i].p;tmp.y=axe[i-1].p;
				tmp.p=axe[i]-axe[i-1];
				edge.push_back(tmp);
			}
			if(i!=N){
				tmp.x=axe[i].p;tmp.y=axe[i+1].p;
				tmp.p=axe[i]-axe[i+1];
				edge.push_back(tmp);
			}
		}
		sort(axe+1,axe+N+1,cmpy);
		up(i,1,N){
			if(i!=1){
				tmp.x=axe[i].p;tmp.y=axe[i-1].p;
				tmp.p=axe[i]-axe[i-1];
				edge.push_back(tmp);
			}
			if(i!=N){
				tmp.x=axe[i].p;tmp.y=axe[i+1].p;
				tmp.p=axe[i]-axe[i+1];
				edge.push_back(tmp);
			}
		}
		sort(edge.begin(),edge.end(),cmpp);
		up(i,0,SZ(edge)-1){
			int x=edge[i].x,y=edge[i].y,v=edge[i].p;
			x=getf(x);y=getf(y);
			if(x!=y){
				fa[x]=y;
				ans+=v;
			}
		}
		cout<<ans<<endl;
	}
}

int main(){
//	freopen("input.in","r",stdin);
	using namespace solution;
	Prepare();
	Solve();
	return 0;
}

Measured memory_bytes: 10096
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;
int main(void){
	int ans=0,sum=0,x,n,a,b,i;
	cin>>n>>a>>b;
	for(i=1;i<=n;i++){
		x=i;
		while(x!=0){
			sum+=x%10;
			x/=10;
		}
		if(sum>=a&&sum<=b)ans+=i;
		sum=0;
	}
	cout<<ans<<endl;
	return 0;
}



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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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 (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b and b != c) or (b == c and a != c) or (a == c and a != b)) {
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = b/a;
		System.out.print(Math.min(d,c));
	}
}


Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 30 10:49:33 2018
ABC071C
@author: maezawa
"""
import collections
n = int(input())
a = list(map(int,input().split()))
acount = collections.Counter(a)
auniq = list(acount.keys())
auniq.sort(reverse=True)
edge1 = 0
ans = 0
for edge in auniq:
    if acount[edge] >= 4:
        if edge1 == 0:
            ans = edge*edge
            break
        else:
            ans = edge1*edge
            break
    if acount[edge] >= 2:
        if edge1 == 0:
            edge1 = edge
        else:
            ans = edge1*edge
            break
print(ans)       



Measured memory_bytes: 18600
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<long long, long long> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k;
    string S;
    cin >> S;
    ll d = 0;
    ll dm = 0;
    for(i = 0; i < 3; i++) {
        if(S[i] == 'R') {
            d++;
            dm = max(dm, d);
        } else {
            d = 0;
        }
    }
    cout << dm << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define c4(n,m,k,l) cin>>n>>m>>k>>l
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  int a,b,c,d,e=0,n;
  c3(a,b,n);
  if((b-a+1)%2==0){
    if(n*2>=b-a+1){
      rep(i,0,b-a+1) co(i+a);
    }
    else{
      rep(i,0,n) co(i+a);
      rep(i,b-n+1,b+1) co(i);
    }
  }
  else{
    if(n*2>=b-a+1){
      rep(i,0,b-a+1) co(i+a);
    }
    else{
      rep(i,0,n) co(i+a);
      rep(i,b-n+1,b+1) co(i);
    }
  }
  
  
  
  return 0;
}


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

int main() {
  char a;
  cin >> a;
  if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


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

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        bool f = true;
        for(int j = 0; j < i; ++j) {
            f &= h[j] <= h[i];
        }
        ans += f;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
void insertionSort(int A[], int N){// N個の要素を含む0-オリジンの配列A
   int j,v;
   //print input array
   for(int k = 0; k<N; k++){
     if(k!=N-1)cout<<A[k]<<' ';
     else cout<<A[k]<<endl;
   }
   //sort
   for(int i=1;i<N;i++){
     v = A[i];
     j = i - 1;
     while (j >= 0 && A[j] > v){
       A[j+1] = A[j];
       j--;
     }
      A[j+1] = v;

      //print previous array
     for(int k = 0; k<N; k++){
       if(k!=N-1)cout<<A[k]<<' ';
       else cout<<A[k]<<endl;
     }
   }

}


int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0;i < N;i++) cin >> A[i];

  insertionSort(A,N);
  return 0;
}



Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	char chess[300];

	int i, j, k, temp1, temp2, FLAG=0;
	int H[100], W[100];

	//配列chessに格納
	for(i=0;i<300;i=i+2){
		chess[i] = ('#');
		chess[i+1] = ('.');
	}

	//行列の大きさを配列HとWに格納,両方0なら終了
	for(i=0;i<100;i++){
		scanf("%d", &temp1);
		scanf("%d", &temp2);

		if(temp1==0 && temp2==0){
			break;
		}else{
			H[i] = temp1;
			W[i] = temp2;
			FLAG++;
		}
	}

	//行列の描画
	for(i=0;i<FLAG;i++){
		for(k=0;k<H[i];k++){
			for(j=0;j<W[i];j++){
				if(k%2==0){
					printf("%c", chess[j]);
				}else{
					printf("%c", chess[j+1]);
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 1000100, MAXK = 23;
const ll MOD =  2020202003;
const ll INF = 1e18;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}




int main() {
	setIO();

    int s, w;
    cin >> s >> w;
    if (s > w) cout << "safe";
    else cout << "unsafe";

	return 0;
}


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

int main() {
int N,ans;
cin >> N;
ans = 1000;
int x,y;
for(int i = 0 ; i < N;i++){
  cin >> x;
  y = 0;
  while(x%2 == 0 && x !=0){
    y++;
    x = x/2;
  }
  if(y < ans){
    ans = y;
  }
}
 cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int A,B,C,K;
  if(scanf("%d %d %d %d",&A,&B,&C,&K)==4)
  {
    if(A>=K)return printf("%d\n",K),0;
    else if(B>=K-A)return printf("%d\n",A),0;
    else return printf("%d\n",2*A+B-K),0;
  }
}

Measured memory_bytes: 1736
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580