akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i
array = []
N.times do
    array.push(gets.to_i)
end

def insertionSort(array, n, g)
    (g..(n-1)).each do |i|
        v = array[i]
        j = i - g
        while j >= 0 && array[j] > v do
            array[j+g] = array[j]
            j = j - g
            @cnt += 1
        end
        array[j+g] = v
    end
end
def shellSort(array, n, m, g_array)
    @cnt = 0
    (0..(m-1)).each do |i|
        insertionSort(array, n , g_array[i])
    end
end

m = 1
g_array = [N/2]
while g_array[-1] > 1 do
    m+=1
    g_array.push(g_array[-1]/2)
end
shellSort(array, N, m, g_array)

puts m
puts g_array.join(" ")
puts @cnt
puts array



Measured memory_bytes: 14800
import java.util.Scanner;

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();
if(a < b){
    if(b < c){
 System.out.println("Yes");
    }else{
        
 System.out.println("No");
    }
 }else{
 System.out.println("No");
 }
}
}


Measured memory_bytes: 26128
package main

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

func main() {
	sc := NewScanner()
	H, W := sc.NextInt(), sc.NextInt()

	if H == 1 || W == 1 {
		fmt.Println(1)
		return
	}

	ans := ((H+1)/2)*((W+1)/2) + (H/2)*(W/2)
	fmt.Println(ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e6+3;
const int dx[8]={0,1,0,-1,-1,-1,1,1},dy[8]={1,0,-1,0,-1,1,-1,1};

int n,y;

int main(){
	cin>>n>>y;
	y/=1000;
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) if(i+j<=n&&10*i+5*j+n-i-j==y){
		cout<<i<<' '<<j<<' '<<n-i-j<<endl;
		return 0;
	}
	cout<<-1<<' '<<-1<<' '<<-1<<endl;
}

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

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

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}
int main() {
  long long A, B, C, D;
  cin >> A >> B >> C >> D;

  long long countsToA = (A-1LL)/C + (A-1LL)/D - (A-1LL)/lcm(C,D);
  long long countsToB = B/C + B/D - B/lcm(C,D);
  
  cout << (B-A+1LL) - (countsToB-countsToA) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N;
  cin >> N;
  vector<int>D(N);
  for (int i = 0; i < N; i++) {
    cin >> D.at(i);
  }
  int M;
  cin >> M;
  vector<int>T(M);
  for (int i = 0; i < M; i++) {
    cin >> T.at(i);
  }
  sort(D.begin(), D.end());
  sort(T.begin(), T.end());
  
  int J = 0;
  for (int i = 0; i < M; i++) {
    for (int j = J; j < N; j++) {
      if (D.at(j) == T.at(i)){
        J = j + 1;
        break;
      }
      else if (j == N-1){
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}
        
    
  
    
  

Measured memory_bytes: 4708
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define N 100005
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef long long int ll;
typedef long int li;

int n,k,q,p; ll a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
   cin>>n>>k>>q;
   ll t=k-q;
   while(q--) { cin>>p; a[p]++; }
   for(int i=1;i<=n;i++) {
       if(t+a[i] <= 0) cout<<"No\n";
       else cout<<"Yes\n";
   }
   return 0 ;
}

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

int main(){
    ll x,k,d,ans;
    cin >> x >> k >> d;
    x = abs(x);
    if(x == d){
        if(k % 2 == 1)ans = 0;
        else ans = d;
    }else if(x < d){
        if(k % 2 == 1) ans = abs(x - d);
        else ans = x;
    }else{
        if(x / d <= k){
            k -= (x/d);
            if (k % 2 == 1){
                ans = abs(x % d - d);
            }else {
                ans = abs(x % d);
            }
        } 
        else ans = abs(x - k * d);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Solver().solve(new Scanner(System.in));
//        new Solver().solve(new Scanner(ex));
    }

    private static final String ex = "9999 1\n" +
            "0";
}

class Solver {
    Solver() {}

    void solve(Scanner scanner) {
        int[] split = splitInt(scanner.nextLine());
        int N = split[0];
        int K = split[1];
        int[] DInt = splitInt(scanner.nextLine());
        char[] D = new char[DInt.length];
        for (int i = 0; i < K; i ++) {
            D[i] = String.valueOf(DInt[i]).toCharArray()[0];
        }

        while (! acceptable(N, D)) N ++;

        System.out.println(N);
    }

    private boolean acceptable(int N, char[] D) {
        char[] chars = String.valueOf(N).toCharArray();

        for (char c: chars) {
            for (char d: D) {
                if (c == d) return false;
            }
        }

        return true;
    }

    private int[] splitInt(String s) {
        String[] split = s.split(" ");
        int[] splitInt = new int[split.length];
        for (int i = 0; i < split.length; i ++) {
            splitInt[i] = Integer.parseInt(split[i]);
        }
        return splitInt;
    }
}


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

using namespace std;

long long x, y;

int main(){
//	freopen("input.inp", "r", stdin);
	cin >> x >> y;
	for(int i = 1; ; ++i){
		x *= 2;
		if (x > y){
			cout << i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#%%
alpha2num = lambda c: ord(c) - ord('a') + 1
num2alpha = lambda c: chr(c+64)

s = list(input())
k = int(input())

l = [0] * len(s)
for i in range(len(s)):
    tmp = alpha2num(s[i])
    tmp2 = 27 - tmp
    if tmp2 == 26:
        tmp2 = 0
    l[i] = tmp2

#print(l)

for i in range(len(s)):
    if l[i] <= k:
        k -= l[i]
        l[i] = 0

l[-1] -= k%26
while True:
    if l[i] <= -1:
        l[i] += 26
    elif 26 <= l[i]:
        l[i] -= 26
    else:
        break

#print(l)

ans = ''
for i in range(len(s)):
    if l[i] == 0:
        l[i] = 1
    else:
        l[i] = 27 -l[i]
    #print(num2alpha(l[i]))
    ans += num2alpha(l[i])

print(ans.lower())


#%%


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

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

  vector<int> A(N + 2);
  for (int i = 1; i <= N; i++)
    cin >> A[i];

  vector<int> s(N + 2);
  s[0] = 0;
  for (int i = 1; i < N + 2; i++)
    s[i] = s[i - 1] + abs(A[i - 1] - A[i]);

  int sum = s.back();

  for (int i = 1; i <= N; i++) {
    int n = s[i + 1] - s[i - 1];
    int m = abs(A[i - 1] - A[i + 1]);
    cout << sum - (n - m) << endl;
  }
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n, m; cin >> n >> m;
  V<lint> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  V<lint> c(n + 1); for (int i = 0; i < n; i++) c[i + 1] = c[i] + a[i];
  map<int, int> mp;
  lint res = 0;
  mp[0]++;
  for (int i = 0; i < n; i++) {
    res += mp[c[i + 1] % m]++;
  }
  cout << res << '\n';
}

Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <vector>

using namespace std;

//get val
int gv(string str){
  return atoi(&str[1]);
}

//set val
void sv(string str,int val){
  str[1] = '0'+val;
}

int main(){

  int n;
  cin >> n;
  vector<string> x(n);
  vector<string> x_bak(n);

  char map[9][4];
  memset(map,0,36*sizeof(char));
  
  for(int i=0;i<n;i++){
    cin >> x[i];
    for(int j=0;j<4;j++){
      if(map[gv(x[i])-1][j] == 0){
        map[gv(x[i])-1][j] = x[i][0];
        break;
      }
    }
  }

  copy(x.begin(), x.end(), x_bak.begin());

  //bubble sort
  for(int i=0;i<n;i++){
    for(int j=n-1;j>=i+1;j--){
      if(gv(x[j]) < gv(x[j-1]) ){
        string tmp = x[j];
        x[j] = x[j-1];
        x[j-1] = tmp;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << x[i];
    if(i==n-1) cout << endl;
    else cout << " ";
  }

  bool end = false;
  for(int i=0;i<9;i++){
    if(map[i][1] != 0){
      int start_idx;
      for(int j=0;j<n;j++){
        if(gv(x[j]) == (i+1)){
          start_idx = j;
          break;
        }
      }
      for(int j=0;j<4;j++){
        if(map[i][j] == 0 ) break;
        if(x[start_idx+j][0] != map[i][j]){
          end = true;
          break;
        }
      }
    }
    if(end) break;
  }
  if(end) cout << "Not stable" << endl;
  else cout << "Stable" << endl;



  // selection sort
  copy(x_bak.begin(), x_bak.end(), x.begin());

  for(int i=0;i<n;i++){
    int mini = i;
    for(int j=i;j<n;j++){
      if(gv(x[j]) < gv(x[mini]) ){
        mini = j;
      }
    }
    if(i != mini){
      string tmp = x[i];
      x[i] =  x[mini];
      x[mini] = tmp;
    }
  }


  for(int i=0;i<n;i++){
    cout << x[i];
    if(i==n-1) cout << endl;
    else cout << " ";
  }

  end = false;
  for(int i=0;i<9;i++){
    if(map[i][1] != 0){
      int start_idx;
      for(int j=0;j<n;j++){
        if(gv(x[j]) == (i+1)){
          start_idx = j;
          break;
        }
      }
      for(int j=0;j<4;j++){
        if(map[i][j] == 0 ) break;
        if(x[start_idx+j][0] != map[i][j]){
          end = true;
          break;
        }
      }
    }
    if(end) break;
  }
  if(end) cout << "Not stable" << endl;
  else cout << "Stable" << endl;
  


}



Measured memory_bytes: 3236
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>

#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}

struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

int main(void) {

	ll a, b;
	cin >> a >> b;

	cout << a * b << endl;



	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<map>
using lint=int64_t;
using namespace std;

int main()
{
	lint N;
	lint A[200010]={};
	
	cin >> N;
	for(int i=1;i<=N;i++)
		cin >> A[i];
	for(int i=1;i<=N;i++)
		A[i]+=A[i-1];
	
	map<lint,lint> m;
	for(int i=0;i<=N;i++)
		m[A[i]]++;
	
	lint ans=0;
	for(auto&& i:m)
		ans+=((i.second*(i.second-1))/2);
		
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 14336
use std::cmp::max;

fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn digit(n: u64) -> u64 {
    if n < 10 {
        return 1;
    }
    digit(n / 10) + 1
}

fn max_digit(a: u64, b: u64) -> u64 {
    max(digit(a), digit(b))
}

fn main() {
    let n = get_line().parse::<u64>().unwrap();
    let sqrt_n = (n as f32).sqrt() as u64;
    let mut result = 100000;
    for a in 1..sqrt_n + 1 {
        if n % a != 0 { continue; }
        let b = n / a;
        let f = max_digit(a, b);
        if f < result {
            result = f;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(){
    int n;
    vector<char> str;

    while(cin >> n, n){
        map<char,char> m;
        char a, b;
        for(int i=0; i<n; i++){
            cin >> a >> b;
            m[a] = b;
        }
        cin >> n;
        for(int i=0; i<n; i++){
            cin >> a;
            if(m[a]){
                str.push_back(m[a]);
            }else{
                str.push_back(a);
            }
        }

        vector<char>::iterator it = str.begin();
        while(it != str.end()){
            cout << *it;
            it++;
        }
        cout << endl;
        str.clear();
    }
    return 0;
}

Measured memory_bytes: 1128
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,X,Y;
ll ans[2010];
ll pos[2010];
int main(){
    cin>>N>>X>>Y;
    for(ll i=1;i<=N;i++){
        if(i<=X)pos[i]=0;
        else if(i<Y)pos[i]=1;
        else pos[i]=2;
    }
    for(ll i=1;i<=N;i++){
        for(ll j=i+1;j<=N;j++){
            if(pos[i]==0){
                switch(pos[j]){
                    case 0:
                        ans[j-i]++;
                    break;
                    case 1:
                        ans[X-i+min(j-X,Y-j+1)]++;
                    break;
                    case 2:
                        ans[X-i+1+j-Y]++;
                    break;
                }
            }else if(pos[i]==1){
                if(pos[j]==1){
                    ans[min(j-i,i-X+1+Y-j)]++;
                }else if(pos[j]==2){
                    ans[min(i-X+1,Y-i)+j-Y]++;
                }
            }else if(pos[i]==2){
                ans[j-i]++;
            }
        }
    }
    for(ll i=1;i<N;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char a[2], b[2];
    scanf("%s%s", a, b);
    if (a[0] == 'H') {
        if (b[0] == 'H') printf("H\n");
        else printf("D\n");
    } else {
        if (b[0] == 'H') printf("D\n");
        else printf("H\n");
    }
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 998244353;
const double eps = DBL_EPSILON;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    freopen("input.txt", "r", stdin);
#endif
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int& i : p) cin >> i;
    for (int& i : q) cin >> i;
    for (int& i : r) cin >> i;
    sort(all(p), greater<int>());
    sort(all(q), greater<int>());
    sort(all(r), greater<int>());
    vector<int> vx, vy, vc;
    for (int i = 0; i < x; i++) vx.push_back(p[i]);
    for (int i = 0; i < y; i++) vy.push_back(q[i]);
    for (int i = 0; i < c; i++) {
        if (vx.size() && vy.size()) {
            if (vx.back() < vy.back()) {
                if (r[i] > vx.back()) {
                    vc.push_back(r[i]);
                    vx.pop_back();
                }
            }
            else {
                if (r[i] > vy.back()) {
                    vc.push_back(r[i]);
                    vy.pop_back();
                }
            }
        }
        else if (vx.size()) {
            if (r[i] > vx.back()) {
                vc.push_back(r[i]);
                vx.pop_back();
            }
        }
        else if (vy.size()) {
            if (r[i] > vy.back()) {
                vc.push_back(r[i]);
                vy.pop_back();
            }
        }
    }
    ll sum = 0;
    for (int& i : vx) sum += i;
    for (int& i : vy) sum += i;
    for (int& i : vc) sum += i;
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 2936
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  #include <map>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)


  int main(){
    int n;
    cin >> n;
    int mx = 0, mn = 10000;
    rep(i,n){
      int tmp;
      cin >> tmp;
      mx = max(tmp,mx);
      mn = min(tmp,mn);
    }
    cout << mx-mn << endl;
    

    return 0;
  }


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

using namespace std;

int main() {
  int n, m; cin >> n >> m;
  vector <int> cnt(n, 0);
  for(int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    u--; v--;
    cnt[u]++; cnt[v]++;
  }
  for(int i = 0; i < n; i++) {
    cout << cnt[i] << '\n';
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif

static const LLONG LL_HUGE_NUM = 1000000007LL;

static void C_task();

int main()
{
	C_task();
	
	fflush(stdout);
	return 0;
}


static void C_task()
{
	int N, M;
	scanf(" %d %d", &N, &M);

	auto dp = new LLONG[N + 1];
	memset(dp, 0, sizeof(LLONG) * (N + 1));

	int brkStep;
	for (int i = 0; i < M; i++) {
		scanf(" %d", &brkStep);
		//	壊れた段に目印
		dp[brkStep - 1] = 0xFFFF;
	}

	if (!dp[0] && !dp[1]) {
		dp[0] = 1;
		dp[1] = 2;
	}
	else if (dp[0] && dp[1]) {
		dp[0] = dp[1] = 0;
	}
	else if (dp[0] == 0xFFFF) {
		dp[0] = 0;
		dp[1] = 1;
	}
	else if (dp[1] == 0xFFFF) {
		dp[0] = 1;
		dp[1] = 0;
	}
	for (int i = 2; i < N; i++) {
		if (dp[i] != 0xFFFF) {
			dp[i] = (dp[i - 1] + dp[i - 2]) % LL_HUGE_NUM;
		}
		else {
			dp[i] = 0;
		}
	}

	printf("%lld\n", dp[N - 1]);
	
	delete[] dp;
}


Measured memory_bytes: 1024
/*
¼´×îÐ¡»¯ÁÐ³µµÄÍù·µ´ÎÊý¡£µ±¹ºÎïÍê³Éºó£¬Ò»¶¨»áÔÚµÚÒ»´Î³µÀ´µÄÊ±ºòÉÏ³µ
ÏÂÃæ¶¼Ã»ÓÐÌØÊâ¿¼ÂÇT[i] = 0µÄÇé¿ö 
Ê×ÏÈÈÃ´ð°¸¼ÓÉÏËùÓÐµÄfloor(T[i] / 2L)£¬È»ºóÁîËùÓÐT[i] mod= 2L£¬ÕâÓëÔ­À´µÄÇé¿öÏÔÈ»ÊÇµÈ¼ÛµÄ
Ê×ÏÈÓÐÒ»¸ö³õÊ¼²ßÂÔ£¬¾ÍÊÇ°´ÕÕ´ÓÐ¡µ½´óµÄË³Ðò·ÃÎÊ£¬Ã¿´Î·ÃÎÊÍêi½Úµã£¬¾ÍµÈ³µ¡¢ÉÏ³µ¡¢Ò»Ö±µ½³µÔÚi + 1½Úµã£¬²»Í£ÕâÃ´×ö 
¿¼ÂÇ°ÑÍù·µ´ÎÊý¿´³ÉÓëÆäÏàµÈµÄ¡°Åö×îÓÒ±ß±ÚµÄ´ÎÊý¡±¡£ÄÇÃ´ÔÚÕâ¸ö²ßÂÔÏÂ£¬Ã¿¸ö½Úµã³õÊ¼¶¼»á¶Ô´ð°¸²úÉú1µÄ¹±Ï×£¨ÔÚÕâ¸öµãÏÂ³µºó³µÒ»Ö±ÍùÓÒ¿ªÅö±Ú£© 
¼ÇL[i] = [T[i] <= 2 * X[i]]£¬±íÊ¾´ÓÓÒ±ß½øÈëÕâ¸öµãµÄÊ±ºò£¬»áÔÚ³µÍùÓÒ¿ªµÄÊ±ºòÉÏ³µ
¼ÇR[i] = [T[i] <= 2 * (L - X[i])]£¬±íÊ¾´Ó×ó±ß½øÈëÕâ¸öµãµÄÊ±ºò£¬»áÔÚ³µÍù×ó¿ªµÄÊ±ºòÉÏ³µ
¿ÉÒÔ·¢ÏÖ£¬µ±i < jÇÒL[i] = R[j] = 1Ê±£¬¿ÉÒÔÍ¨¹ýÏÈ×ßµ½j£¬Åö±Ú»ØÀ´Ö®ºóµ½´ïi£¬È»ºó´Ói¿ªÊ¼ÓÖÍùÓÒ×ß¡£¿ÉÒÔ°ÑÕâ¸ö¿´³ÉÒ»¶ÔÆ¥ÅäÏûÈ¥£¬Ò»¶ÔÆ¥Åä¿ÉÒÔÊ¹µÃ´ð°¸¼õÈ¥1
Ö»¿¼ÂÇ1 ~ N - 1µÄµãµÄÆ¥Åä¡£ÏÈ°ÑL[i] = R[i] = 1µÄµãÈ«²¿É¾È¥£¬Ê£ÏÂµÄµã×öÒ»´ÎÀ¨ºÅÆ¥Åä£»È»ºó°ÑÉ¾È¥µÄµã¿¼ÂÇÉÏ£¬Ã¿´Î¾¡Á¿È¥Ïû»¹Ã»Æ¥ÅäµÄÖ®Ç°Ã»±»É¾µÄµã
×îºóµ±R[N] = 0Ê±£¬´ð°¸»¹Òª¼ÓÉÏ1£¬ÒâÎ¶×Å²»ÄÜÍ¨¹ýÏÈ×ßµ½NÀ´¼õÉÙÒ»´Î´ÎÊý 
*/

#include <stack>
#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_N(300050);
typedef long long int LL;

namespace io
{
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
	inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
	template <class I>
	inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
	template <class I>
	inline void print (I x){
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0',  x /= 10;while (qr) putc (qu[qr--]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;

int N;
bool L[Max_N], R[Max_N], Del[Max_N];
LL Ans, M, X[Max_N], T[Max_N];

int main()
{
	gi(N), gi(M);
	for (int i = 1;i <= N;++i)
		gi(X[i]);
	for (int i = 1;i <= N;++i)
		gi(T[i]);
	for (int i = 1;i <= N;++i)
	{
		Ans += T[i] / (M << 1LL);
		if (T[i] %= (M << 1LL))
			L[i] = (T[i] <= 2LL * X[i]), R[i] = (T[i] <= 2LL * (M - X[i])), ++Ans;
	}
	if (R[N] == false)
		++Ans;
	stack<int> Sta;
	for (int i = 1;i <= N - 1;++i)
	{
		if (L[i] == R[i])
			continue;
		if (L[i])
			Sta.push(i);
		else
			if (Sta.empty() == false)
				Del[i] = Del[Sta.top()] = true, Sta.pop(), --Ans;
	}
	int Cnt = 0;
	for (int i = 1, x = 0;i <= N - 1;++i)
	{
		if (!L[i] && !R[i])
			continue;
		if (Del[i])
			continue;
		if (L[i] && R[i])
			if (x)
				--x, --Ans;
			else
				++Cnt;
		else
			if (L[i])
				++x;
			else
				if (Cnt)
					--Cnt, --Ans;
	}
	print((Ans - (Cnt >> 1LL)) * (M << 1LL));
	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

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


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;
typedef pair<int, int> P;

int N, M, R;
int r[8];
int A[50505], B[50505], C[50505];

const int MAX_V = 210;
const ll LLINF = LLONG_MAX / 10;
int d[MAX_V][MAX_V];

signed main()
{
    cin >> N >> M >> R;
    REP(i,R) {
        cin >> r[i];
        r[i] -= 1;
    }

    REP(i,N) REP(j,N) {
        if (i == j) d[i][j] = 0;
        else d[i][j] = LLINF;
    }

    REP(i,M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
        d[A[i]][B[i]] = d[B[i]][A[i]] = C[i];
    }

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

    sort(r, r + R);
    int ans = LLINF;
    do {
        int sum = 0;
        REP(i,R-1) {
            sum += d[r[i]][r[i+1]];
        }
        ans = min(ans, sum);
    } while (next_permutation(r, r + R));

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
long long n[10000];
int main(){
 long long a,min,max,sum=0;
 scanf("%lli",&a);
int i;
for(i=0;i<a;i++){
    scanf("%lli",&n[i]);
    sum += n[i];
}
min = n[0];
max = n[0];
for(int i=0;i<a;i++){
    if(n[i]<min){
        min = n[i];
    }
    if(n[i]>max){
        max = n[i];
    }
}
printf("%lli %lli %lli\n",min,max,sum);

return 0;
}



Measured memory_bytes: 2120
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,i,j,k,l,m,a,b;
  int number[10][10];
  bool wrong[10][10];//wrong??????true*
  int check[10]={};
 
  cin>>n;

  rep(i,n){
    if(i)cout<<endl;
    rep(j,9)rep(k,9){
      wrong[j][k]=false;
      scanf("%d",&number[j][k]);
    }

    rep(j,9){//yoko check
      rep(k,10)
	check[k]=0;//0??§?????????
      rep(k,9){
	check[number[j][k]]++;
	if(check[number[j][k]]>1){//2nd
	  rep(l,9)
	    if(number[j][l]==number[j][k])
	      wrong[j][l]=true;
	    
	}
      }//repk
    }//repj
    

    rep(k,9){//tate check
      rep(j,10)
	check[k]=0;//?????????
      rep(j,8){
	for(l=j+1;l<9;l++)
	  if(number[j][k]==number[l][k]){
	    wrong[j][k]=true;
	    wrong[l][k]=true;
	  }
      }//repj
    }//repk
    
    rep(j,3){//block check
      rep(k,3){
	rep(l,10)
	  check[l]=0;//?????????
	rep(l,3)
	  rep(m,3){
	  check[number[3*j+l][3*k+m]]++;
	  if(check[number[3*j+l][3*k+m]]>1){//2nd
	    rep(a,3)
	      rep(b,3)
	      if(number[3*j+a][3*k+b]==number[3*j+l][3*k+m])
		wrong[3*j+a][3*k+b]=true;
	      
	  }
	}
      }//repk
    }//repj

    rep(j,9){
      rep(k,9){
	if(wrong[j][k])
	  cout<<"*";
	else 
	  cout<<" ";
	cout<<number[j][k];
      }
      cout<<endl;
    }


 
  }
}

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

int main()
{
    long long int n, a, b, ans, rem;
    cin >> n >> a >> b;
    ans = n / (a + b) * a;
    rem = n % (a + b);
    ans += min(rem, a);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
csf = [list(map(int, input().split())) for i in range(N - 1)]

for i in range(N):
    ans = 0
    for c, s, f in csf[i::]:
        if ans <= s:
            ans = s
        else:
            if ans % f == 0:
                pass
            else:
                ans = (ans // f + 1) * f
        ans += c
    print(ans)


Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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 int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    cout << fixed << setprecision(10) << ((n+1)/2)/(double)n << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
const int maxn=200010;
int n;
ll ans;
struct node{
	int x,y;
	double a;
}p[maxn<<1];
ll sx[maxn<<1],sy[maxn<<1];
bool cmp(const node &a,const node &b){return a.a<b.a;}
inline void check(int l,int r){
	if(l<=r) ans=max(ans,(sx[r]-sx[l-1])*(sx[r]-sx[l-1])+(sy[r]-sy[l-1])*(sy[r]-sy[l-1]));
}
#define Is(c) ('0'<=c && c<='9')
inline int read(){
	int ret=0,f=1; char c=getchar();
	while(!Is(c)){
		if(c=='-')	f=-f;
		c=getchar();
	}
	while(Is(c)) ret=ret*10+c-48,c=getchar();
	return ret*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) p[i].x=read(),p[i].y=read(),p[i].a=atan2(p[i].x,p[i].y),p[i+n]=p[i],p[i+n].a+=2*pi;
	sort(p+1,p+2*n+1,cmp);
	for(int i=1;i<=2*n;i++)	sx[i]=sx[i-1]+p[i].x,sy[i]=sy[i-1]+p[i].y;
	int j=1;
	for(int i=1;i<=2*n;i++){
		for(;j<i&&p[j].a<=p[i].a-pi;j++,check(j,i-1));
		check(j,i);
	}
	for(;j<=2*n;check(j,2*n),j++);
	printf("%.48f",sqrt((double)ans));
	return 0;
}

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

int main() {
        int h, w;
        cin >> h >> w;
        vector<string> red(h, "#"), blue(h, ".");
        for (int i = 0; i < h; i ++) {
                if (i & 1) for (int j = 1; j < w - 1; j ++) { 
                        red[i] += ".";
                } else for (int j = 1; j < w - 1; j ++) {
                        red[i] += "#";
                }
                red[i] += ".";
        }
        for (int i = 0; i < h; i ++) {
                if (i & 1) for (int j = 1; j < w - 1; j ++) { 
                        blue[i] += "#";
                } else for (int j = 1; j < w - 1; j ++) {
                        blue[i] += ".";
                }
                blue[i] += "#";
        }
        //for (int i = 0; i < h; i ++) cerr << blue[i] << endl;
        for (int i = 0; i < h; i ++) {
                string s;
                cin >> s;
                for (int j = 0; j < w; j ++) {
                        if (s[j] == '#') {
                                red[i][j] = blue[i][j] = '#';
                        }
                }
        }
        for (int i = 0; i < h; i ++) cout << red[i] << endl;
        cout << endl;
        for (int i = 0; i < h; i ++) cout << blue[i] << endl;
        return 0;
}



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

int main() {
    long n, d, d2, x, y, count;
    scanf("%ld", &n);
    scanf("%ld", &d);
    d2 = d * d;
    count = 0;
    for(int i=0; i<n; i++) {
        scanf("%ld", &x);
        scanf("%ld", &y);
        if(x <= d && y <= d && (x * x + y * y) <= d2) count++;
    }
    cout << count << '\n';
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
ll gcd(ll a,ll b){
    if (a<b){
        swap(a,b);        
    }
    if(a%b==0){
        return b;
    }
    ll c=a;
    a=b;
    b=c%b;
    return gcd(a,b);
}

int main() {
    ll n,y;
    cin>>n>>y;
    vector<ll>a;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        if(x>=y){
        a.push_back(x-y);
        }
        else{
            a.push_back(y-x);
        }

    }
    if(n>1){
    ll min;
    min=gcd(a[0],a[1]);
    for(ll i=2;i<n;i++){
        min=gcd(min,a[i]);
    }
    cout<<min<<endl;
    }
    else{
        cout<<a[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

using namespace std;

struct Info{

	Info(double arg_left,double arg_right,double arg_div){
		left = arg_left;
		right = arg_right;
		div = arg_div;
	}

	bool operator<(const struct Info &arg) const{
		return div > arg.div;
	};

	double left,right,div;
};

int main(){

	int N;
	double top4[4] = {0,0,0,0};
	scanf("%d",&N);

	double table[N];

	for(int i = 0; i < N; i++)scanf("%lf",&table[i]);

	sort(table,table+N);

	top4[0] = table[N-1];
	top4[1] = table[N-2];
	top4[2] = table[N-3];
	top4[3] = table[N-4];

	priority_queue<Info> Q;

	for(int i = 1; i < N; i++){
		Q.push(Info(table[i],table[i-1],table[i]-table[i-1]));
	}

	int count = 0;
	double maximum = 0;

	while(Q.empty() == false && count <= 50){
		for(int i = 0; i < 3; i++){
			for(int k = i+1; k < 4;k++){
				if(Q.top().left != top4[i] && Q.top().left != top4[k] &&
						Q.top().right != top4[i] && Q.top().right != top4[k]){
					maximum = max(maximum,(top4[i]+top4[k])/Q.top().div);
				}

			}
		}
		Q.pop();
	}

	printf("%.5lf\n",maximum);

    return 0;
}

Measured memory_bytes: 2796
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		int cnt = 0;
		int temp = 0;
		int l_cnt = 0;
		int r_cnt = 0;
		int ans[] = new int[N];
		for(int i = 0; i < N - 1; i++) {
			if(S.substring(i, i + 1).equals("R") && S.substring(i + 1, i + 2).equals("L")) {
				temp = i;
				cnt++;
			} else if(S.substring(i, i + 1).equals("L") && S.substring(i + 1, i + 2).equals("R")){
				cnt++;
				if(cnt % 2 == 0) {
					ans[temp] = cnt / 2;
					ans[temp + 1] = cnt / 2;
				} else {
					if(r_cnt > l_cnt) {
						if(r_cnt % 2 == 1) {
							ans[temp] = cnt / 2;
							ans[temp + 1] = cnt / 2 + 1;
						} else {
							ans[temp] = cnt / 2 + 1;
							ans[temp + 1] = cnt / 2;
						}
					} else {
						if(l_cnt % 2 == 1) {
							ans[temp] = cnt / 2 + 1;
							ans[temp + 1] = cnt / 2;
						} else {
							ans[temp] = cnt / 2;
							ans[temp + 1] = cnt / 2 + 1;
						}
					}
				}
				cnt = 0;
				r_cnt = 0;
				l_cnt = 0;
			} else {
				cnt++;
				if(S.substring(i, i + 1).equals("R")) {
					r_cnt++;
				} else {
					l_cnt++;
				}
			}
		}
		cnt++;
		if(cnt % 2 == 0) {
			ans[temp] = cnt / 2;
			ans[temp + 1] = cnt / 2;
		} else {
			if(r_cnt > l_cnt) {
				if(r_cnt % 2 == 1) {
					ans[temp] = cnt / 2;
					ans[temp + 1] = cnt / 2 + 1;
				} else {
					ans[temp] = cnt / 2 + 1;
					ans[temp + 1] = cnt / 2;
				}
			} else {
				if(l_cnt % 2 == 1) {
					ans[temp] = cnt / 2 + 1;
					ans[temp + 1] = cnt / 2;
				} else {
					ans[temp] = cnt / 2;
					ans[temp + 1] = cnt / 2 + 1;
				}
			}
		}
		for(int i = 0; i < N; i++) {
			if(i == N - 1) {
				System.out.println(ans[i]);
			} else {
				System.out.print(ans[i] + " ");
			}
		}
	}
}


Measured memory_bytes: 50724
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N, As):
    c = 0
    for i in range(N):
        if (i + 1) % 2 == 1 and As[i] % 2 == 1:
            c += 1
    return c


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))

    print(solve(N, As))


Measured memory_bytes: 9472
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#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> 

using namespace std;

#define _int64 long long

int aa[210000];
int a[2][210000];
int d[2][2][210000][20];
int pos[210000];

priority_queue<pair<pair<int,int>,pair<int,int> > > pq;

void doit(pair<int,int> pp)
{
  //cout<<"pp:"<<pp.first<<" "<<pp.second<<endl;
  pair<int,int> v;
  int i,j,tmp,pow2,tmp1,tmp2,pos1;
  if (pp.second<pp.first) return;
  tmp=pp.first%2;
  pow2=0;
  while ((1<<pow2)+(1<<pow2)<pp.second-pp.first+1) pow2++;
  tmp1=d[tmp][0][pp.first][pow2];
  tmp2=d[tmp][1][pp.second][pow2];
  if (tmp1<tmp2) v.first=tmp1;
  else v.first=tmp2;
  //cout<<v.first<<endl;
  pos1=pos[v.first];
  pos1++;
  //cout<<pos1<<endl;
  pow2=0;
  while ((1<<pow2)+(1<<pow2)<pp.second-pos1+1) pow2++;
  //cout<<pow2<<endl;
  tmp1=d[1-tmp][0][pos1][pow2];
  tmp2=d[1-tmp][1][pp.second][pow2];
  //cout<<tmp1<<" "<<tmp2<<endl;
  if (tmp1<tmp2) v.second=tmp1;
  else v.second=tmp2;
  //cout<<"v:"<<v.first<<" "<<v.second<<endl;
  v.first=-v.first;
  v.second=-v.second;
  pq.push(make_pair(v,pp));
}

int main()
{
  int i,j,k,n,tmp,o,p,pos1,pos2;
  pair<int,int> p1,p2,p3;
  scanf("%d",&n);
  for (i=0;i<n;i++)
  {
    scanf("%d",&aa[i]);
    pos[aa[i]]=i;
  }
  
  memcpy(a[0],aa,sizeof(aa));
  for (i=1;i<n;i+=2) a[0][i]=2000000000;
  memcpy(a[1],aa,sizeof(aa));
  for (i=0;i<n;i+=2) a[1][i]=2000000000;
  for (o=0;o<2;o++)
  {
    for (p=0;p<2;p++)
    {
      for (i=0;i<n;i++)
        d[o][p][i][0]=a[o][i];
      for (j=1;j<20;j++)
        for (i=0;i<n;i++)
        {
          d[o][p][i][j]=d[o][p][i][j-1];
          if (p==0) tmp=i+(1<<(j-1));
          else tmp=i-(1<<(j-1));
          if ((tmp>=0)&&(tmp<n))
            if (d[o][p][tmp][j-1]<d[o][p][i][j]) 
              d[o][p][i][j]=d[o][p][tmp][j-1];
        }
    }
  }
  while (!pq.empty()) pq.pop();
  doit(make_pair(0,n-1));
  while (!pq.empty())
  {
    pair<pair<int,int>,pair<int,int> > tmp=pq.top();
    pq.pop();
    printf("%d %d ",-tmp.first.first,-tmp.first.second);
    pos1=pos[-tmp.first.first];
    pos2=pos[-tmp.first.second];
    p1=make_pair(tmp.second.first,pos1-1);
    p2=make_pair(pos1+1,pos2-1);
    p3=make_pair(pos2+1,tmp.second.second);
    doit(p1);
    doit(p2);
    doit(p3);
    //return 0;
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 71032
import sys
from string import digits

def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    place = dict((i, set()) for i in digits)
    for i in range(n):
        place[s[i]].add(i)

    l = [None] * n
    l[0] = set()
    for i in range(1, n):
        l[i] = l[i-1] | set([s[i-1]])
    
    r = [None] * n
    r[n-1] = set()
    for i in range(n-2, -1, -1):
        r[i] = r[i+1] | set([s[i+1]])

    res = set()
    for j in digits:
        for i in digits:
            for k in digits:
                for c in place[j]:
                    if not i in l[c]:
                        continue
                    if not k in r[c]:
                        continue
                    res.add((i, j, k))
                    break
    print(len(res))


if __name__ == '__main__':
    main()

Measured memory_bytes: 50672
package main

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

func main() {
	N := nextInt()
	B := nextInts(N - 1)
	ans := B[0]
	for i := 0; i < N-2; i++ {
		ans += Min(B[i], B[i+1])
	}
	ans += B[N-2]
	fmt.Println(ans)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

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

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
N = int(input())
T,A = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
ans = []
for i in range(N):
    H[i] = T - H[i]*0.006
    ans.append(abs(H[i]-A))
print(ans.index(min(ans))+1)


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
int main (){
    cin >> N;
    int s[N];
    int score = 0;
    for(int i=0; i<N; i++){
        cin >> s[i];
        score += s[i];
    }
    int m = 0;
    if( score % 10 == 0 ) {
        for(int i=0; i<N; i++){
            if ( s[i] % 10 != 0 ) m = max( score - s[i], m );
        }
        cout << m << endl;
        return 0;
    } else cout << score << endl;
    return 0;
}


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

int main(){
 	int a,b,k;
  	cin >> a >> b >> k;
  	for(int i = a; i<=b;i++) {
      	if(i <= a+k-1 || i >= b - k+1)
          	cout << i << endl;
     	 
      
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;


long long cal_mem(long long H, long long W){
    long long ans_1, ans_2, ans_3;
    long long tmp_a, tmp_b, tmp_c;

    tmp_a = (H / 3) * W;
    tmp_b = (H - (H/3)) * (W / 2);
    tmp_c = H * W - (tmp_a + tmp_b);
    ans_1 = max(max(tmp_a, tmp_b), tmp_c) - min(min(tmp_a, tmp_b), tmp_c);
    
    tmp_a = (H / 3 + 1) * W;
    tmp_b = (H - (H/3 + 1)) * (W / 2);
    tmp_c = H * W - (tmp_a + tmp_b);
    ans_2 = max(max(tmp_a, tmp_b), tmp_c) - min(min(tmp_a, tmp_b), tmp_c);
    
    ans_3 = W;
    return min(min(ans_1, ans_2), ans_3);

}

int main(void){
    long long H, W;
    long long s_max, s_mid, s_min;
    long long ans_h=0;
    long long ans_w=0;

    cin >> H >> W;
    if(H % 3 == 0 || W % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    else{
        ans_h = cal_mem(H, W);
        ans_w = cal_mem(W, H);
        cout << min(ans_h, ans_w) << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import heapq

class PriorytyQueue(object):

    def __init__(self, arr, target='min'):
        self.arr = arr
        self.target = target
        self._heapify()
    
    def _heapify(self):
        if self.target == 'max':
            self.arr = list(map(lambda x:x*(-1), self.arr))
        heapq.heapify(self.arr)
    
    def push(self, x):
        if self.target == 'max':
            x *= -1
        heapq.heappush(self.arr, x)

    def pop(self):
        res = heapq.heappop(self.arr)
        if self.target == 'max':
            return res*(-1)
        else:
            return res
    
    def get_arr(self):
        if self.target == 'max':
            return list(map(lambda x:x*(-1), self.arr))
        else:
            return self.arr
    
    def is_empty(self):
        return len(self.arr) == 0

N = int(input())
v = list(map(int, input().split()))
pq = PriorytyQueue(v, target='min')
for i in range(N-1):
    min1 = pq.pop()
    min2 = pq.pop()
    pq.push((min1+min2)/2)
print(pq.pop())

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int O,Q,P,R,S;

int mtos(int a,int b,int c,int d){
	Q=(c*60+d)-(a*60+b);
	P=Q%60;
	return (P+60)%60;
}
	
int stom(int a,int b,int c,int d){
	Q=(c*60+d)-(a*60+b);
	if(Q>=0)O=Q/60;
	else O=((Q+60)*60)/60;
	return O;
}

int hour(int a,int b,int c,int d,int e,int f){
	R=d-a;
	if(((e*60+f)-(b*60+c))<0) R=R-1;
	return R;
}

int main() {
	
	int a[7]{},b[7]{},c[7]{},x[9]{};
	
	for (int i=1;i<=6;i++){
		cin >> a[i];
	}
	for (int i=1;i<=6;i++){
		cin >> b[i];
	}
	for (int i=1;i<=6;i++){
		cin >> c[i];
	}
	
	x[1]=hour(a[1],a[2],a[3],a[4],a[5],a[6]);
	x[2]=stom(a[2],a[3],a[5],a[6]);
	x[3]=mtos(a[2],a[3],a[5],a[6]);
		
	x[4]=hour(b[1],b[2],b[3],b[4],b[5],b[6]);
	x[5]=stom(b[2],b[3],b[5],b[6]);
	x[6]=mtos(b[2],b[3],b[5],b[6]);
	
	x[7]=hour(c[1],c[2],c[3],c[4],c[5],c[6]);
	x[8]=stom(c[2],c[3],c[5],c[6]);
	x[9]=mtos(c[2],c[3],c[5],c[6]);
	
	
	cout << x[1] << " " << x[2] << " " << x[3] << endl;
	cout << x[4] << " " << x[5] << " " << x[6] << endl;
	cout << x[7] << " " << x[8] << " " << x[9] << endl;
	
	
	return 0;
}

Measured memory_bytes: 3096
N,K = map(int,input().split())
data = [0]*N
for i in range(K):
    di = int(input())
    ai = list(map(int,input().split()))
    for j in range(di):
        data[ai[j]-1] += 1

cnt = 0
for i in range(N):
    if data[i] == 0: cnt += 1

print(cnt)

Measured memory_bytes: 67588
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

signed main(){
  long long N;
  scanf("%lld",&N);
  map<string, int> m;

  REP(i, N) {
    string s; cin >> s; 
    m[s] = m[s] + 1;
  }

  int maxN = INT_MIN;
  for(const auto& x : m) {
    maxN = max(x.se, maxN);
  }
  for(const auto& x: m) {
    if (x.se == maxN) {
      cout << x.fi << endl;
    }
  }
}


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

const int MAX = 1e6;
const int MOD = 1e9+7;
long fac[MAX],finv[MAX],inv[MAX];

void combinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; ++i){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD-inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}

long com(int n, int k){
    if(n < k) return 0;
    if(n < 0 or k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
  combinit();
  int n, k;
  cin >> n >> k;
  long ans =0;
  for(int i=0; i<min(n, k+1); i++){
    ans = (ans+com(n,i)*com(n-1, n-i-1))%MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 23680
numbers=input()
slimmes=raw_input()
slimmes=slimmes.split(" ")

prev=slimmes[0]
count=0
spell=False
for i in range(1,numbers):
    if (prev==slimmes[i] and spell==False):
        count+=1
        spell=True
    else:
        spell=False
        
    prev=slimmes[i]
    
print count


Measured memory_bytes: 2820