akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

ll n, tot, cur, A[MAXN], B[MAXN];

int main() {
    scanf("%lld", &n);

    for (int i = 0; i < n + 1; i++) {
        scanf("%lld", &A[i]);
    }

    for (int i = 0; i < n; i++) {
        scanf("%lld", &B[i]);
    }

    for (int i = 0; i < n; i++) {
        tot += min(A[i], B[i]);
        B[i] -= min(A[i], B[i]);
        tot += min(A[i + 1], B[i]);
        A[i + 1] -= min(A[i + 1], B[i]);
    }

    printf("%lld\n", tot);

    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main()
{
    int N, M; cin >> N >> M;
    if (N >= M) { cout << 0 << endl; return 0; }

    vector<int> X(M, 0);
    for(auto &item : X) cin >> item;
    sort(X.begin(), X.end());
    vector<int> L(M-1, 0);
    for(int i = 0; i < M-1; i++) L.at(i) = X.at(i+1) - X.at(i);
    sort(L.begin(), L.end());
    cout << accumulate(L.begin(), L.end() - (N-1), 0) << endl;
    return 0;
}


Measured memory_bytes: 1024
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       mut s:Chars,
    }

    if s[s.len() - 1] == 's' {
        s.push('e');
        s.push('s');
    } else {
        s.push('s');
    }

    echo!(s.joinToString(""));
}


Measured memory_bytes: 2204
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i < (int)(n); i++)

using namespace std;

int main() {
    string str;
    int sum = 0;
    char gucci;
    cin >> str;
    gucci = str.at(0);
    rep(i , str.size()){
        if ( gucci != str.at(i)){
            sum++;
            gucci = str.at(i);
        }
    }
    cout << sum << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<string> A(N);
	for (int i = 0;i < N;++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	for (int i = 0;i < N - 1;++i) {
		if (A[i] == A[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// struct compare{
//     bool operator()(pair<pair<int,int>,ll> a,pair<pair<int,int>,ll> b)
//     {
//         int x = a.first.first+a.first.second;
//         int y = b.first.first+b.first.second;
//         return (x)>(y);
//     }
// };
struct S{
    int w,s,v;
    bool operator <(S const &b) const {
        return (w+s<b.w+b.s);
    }
 
};
int n;
int main() {
    // priority_queue<pair<pair<int,int>,ll>,vector<pair<pair<int,int>,ll>>,compare> pq;
    cin>>n;
    // for(int i=0;i<n;i++)
    // {
    //     int a,b;
    //     ll c;
    //     cin>>a>>b>>c;
    //     pq.push({{a,b},c});
    // }
    vector<S> boxes(n);
    int max_cap=20005;;
    for(int i=0;i<n;i++){
        cin>>boxes[i].w>>boxes[i].s>>boxes[i].v;
    }
    sort(boxes.begin(),boxes.end());
    ll dp[max_cap+1];
    memset(dp,0,sizeof dp);
    for(auto box:boxes)
    {
        int w,s,val;
        w = box.w;
        s = box.s;
        val = box.v;
        for(int cap=min(s,max_cap-w);cap>=0;--cap)
        {
            dp[cap+w] = max(dp[cap+w],dp[cap]+val);
        }
        // pq.pop();
    }
    ll ans=0;
    for(int i=0;i<max_cap;i++)
    ans = max(ans,dp[i]);
    cout<<ans;
}

Measured memory_bytes: 3764
// 4_abc138_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int n, q;
vector<vector<int>> g;
vector<ll> c;
vector<ll> ans;

void dfs(int nd, int parent){
    ans[nd] = c[nd] + ans[parent];
    rep(i, g[nd].size()){
        int next = g[nd][i];
        if(next == parent) continue;

        dfs(next, nd);
    }
}

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

    cin >> n >> q;
    g.resize(n + 1);
    c.resize(n + 1);
    ans.resize(n + 1);
    ans[0] = 0;
    for(int i = 1; i <= n; i++){
        c[i] = 0;
    }
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i, q){
        int p, x;
        cin >> p >> x;
        c[p] += x;
    }

    ans[1] = c[1];
    dfs(1, 0);

    rep1(i, n){
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 25856
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 1<<17, mlg = 17, mod = 1e9 + 7;
ll n, l, q, x[maxn], go[maxn][mlg];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i];
	cin >> l >> q;
	for(int i = 1, j = 1; i <= n; i++) {
		while(j < n && x[j+1]-x[i] <= l) j++;
		go[i][0] = j;
		//cout << j << " ";
	}
	for(int j = 1; j < mlg; j++)
		for(int i = 1; i <= n; i++)
			go[i][j] = go[go[i][j-1]][j-1];
	int a, b;
	while(q--) {
		cin >> a >> b;
		if(a > b) swap(a, b);
		int ans = (a!=b);
		for(int i = mlg; i--;) if(go[a][i] && go[a][i] < b) {
			//cout << a << " " << i << '\n';
			a = go[a][i], ans += 1<<i;
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 17280
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

result = int()

for i in range(N):
    result += B[A[i] - 1]
    if (A[i - 1] == A[i] - 1 and i >= 1):
        result += C[A[i - 1] - 1]

print(str(result))

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

int main(void) {
  string s,t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    if (s==t) {
      cout << "Yes" << endl;
      return 0;
    }
    s = s[s.size()-1] + s.substr(0,s.size()-1);
  }
  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())
a = [1]
b = [1]
for i in range(N):
  a.append(2*a[i] + 3)
  b.append(2*b[i] + 1)

def F(N, X):
  if N == 0:
    if X > 0:
      return 1
    else:
      return 0

  if X == 1:
    return 0

  if 1 < X <= a[N-1] + 1:
    return F(N-1, X-1)

  if X ==  a[N-1] + 2:
    return b[N-1] + 1

  if a[N-1] + 2 < X <= 2*a[N-1] + 2:
    return b[N-1] + 1 + F(N-1, X - 2 - a[N-1])

  if X == 2 * a[N-1] + 3:
    return 2 * b[N-1] + 1

print(F(N, X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
using pii = pair<int,int>;

const int INF = 1e9;

int bubblesort(vector<pair<pii, bool > > C, int N){
    int sw = 0;
    vector<int> B(N);
    rep(i, 0, N){
        B[i] = C[i].first.first;
    }
    sort(B.begin(), B.end());
    for(int i = 0; i < N; i++){
        int tmp = i;
        while((!(B[i] == C[tmp].first.first &&( ((C[tmp].first.second - i)&1) == C[tmp].second) )) && tmp < N) tmp++;
        if(tmp == N) return -1;

        for(int j = tmp; j >= i+1; j--){
            swap(C[j], C[j-1]);
            sw++;
        }
    }
    //for(auto e: C) cerr << e.first.first << " " << e.second << endl;
    /* rep(i, 0, N){
        if(C[i].second != i % 2) return -1;

        if(i < N -1 && A[i].first > A[i+1].first) return -1;
    } */
    return sw;
}

int main(){
    int N; cin >> N;
    vector<int> A(N), B(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];
    int ans = INF;

    rep(i, 0, 1 << N){
        int tcnt = 0;
        vector<pair<pii, bool> > C(N);
        
        rep(j, 0, N){
            if((i >> j) & 1) C[j] = {{A[j], j}, 0};
            else C[j] = {{B[j], j}, 1};
        }
        //cerr << i << endl;
        //for(auto e: C) cerr << e.first.first << " " << e.first.second << " " << e.second << endl;
        int t = bubblesort(C, N);
        if(t == -1) continue;
        else ans = min(ans, t);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;


}

Measured memory_bytes: 256
n = int(input())
red = [list(map(int, input().split())) for i in range(n)]
red.sort(key=lambda x:x[1], reverse=True)
blue = [list(map(int, input().split())) for i in range(n)]
blue = sorted(blue)
ans = 0
for x_b, y_b in blue:
  for x_r, y_r in red:
    if x_r < x_b and y_r < y_b:
      red.remove([x_r, y_r])
      ans += 1
      break
print(ans)

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

int main(){
    int A, B, C, D;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    printf("%d\n", min(A, B) + min(C, D));
    return 0;
}


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


int main(){
    long long a;
    scanf("%lld",&a);
    long long temp=100;
    for(int i=1;;i++){
        temp=(long long)(temp*1.01);
        if(temp>=a){
            printf("%d",i);
            break;
        }
    }
    //printf("%s",flag?"OK":"NG");
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if((a+b)%2 == 0){
      cout << int((a+b)/2) << endl;
  }
  else{
      cout << int((a+b+1)/2) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <tuple>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <tuple>
#include <random>
#include <stack>

using namespace std;

#define endl '\n'

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using lld = long double;
using ull = unsigned long int;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int precision = 13;
  cout.precision(precision);
  cout.setf(ios_base::fixed);

  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (auto& it : a) cin >> it;

  vector<bool> nim(k+1, false);
  for (int i = 1; i <= k; ++i) {
    bool win = false;
    for (int v : a) {
      if (i >= v and nim[i-v] == false) {
        win = true;
        break;
      }
    }
    nim[i] = win;
  }

  cout << (nim[k] ? "First" : "Second") << endl;

  return 0;
}


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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MAXN 200005
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define pb push_back
#define endl '\n'
#define int long long

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// auto timer_start = chrono::steady_clock::now().time_since_epoch().count();

int n;
int h[MAXN], v[MAXN];
int bit[MAXN];

void update(int x, int v){ 
    while(x < MAXN){
        bit[x] = max(bit[x], v);
        x += (x & -x); 
    }    
}

int query(int x){ 
    int sum = 0; 
    while(x > 0){
        sum = max(sum, bit[x]);
        x -= (x & -x); 
    }
    return sum;
}

int32_t main(){
    fastio
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 1; i <= n; i++) cin >> v[i];

    int res = 0;
    for(int i = 1; i <= n; i++){
        int atual = query(h[i] - 1);
        res = max(res, atual + v[i]);
        update(h[i], atual + v[i]);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {

    static class UnionFind {
        int[] size;
        int[] id;

        public UnionFind(int n) {
            size = new int[n];
            id = new int[n];

            for (int i = 0; i < n; ++i) {
                size[i] = 1;
                id[i] = i;
            }
        }

        void unify(int p, int q) {
            int root1 = find(p);
            int root2 = find(q);

            if (size[root1] > size[root2]) {
                size[root1] += size[root2];
                id[root2] = root1;
            } else {
                size[root2] += size[root1];
                id[root1] = root2;
            }
        }

        int find(int p) {
            int root = p;
            while (root != id[root]) root = id[root];
            while (p != root) {
                int next = id[p];
                id[p] = root;
                p = next;
            }
            return root;
        }

        boolean connected(int p, int q) {
            return find(p) == find(q);
        }
    }

    static class Edge {
        int from, to;

        public Edge(int from, int to) {
            this.from = from;
            this.to = to;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Edge> li = new ArrayList<>();
        for (int i = 0; i < m; ++i) li.add(new Edge(sc.nextInt()-1, sc.nextInt()-1));

        int res = 0;
        for (int i = 0; i < m; ++i) {
            UnionFind uf = new UnionFind(n);
            for (int j = 0; j < m; ++j) {
                if (i == j) continue;
                uf.unify(li.get(j).from, li.get(j).to);
            }
            if (!uf.connected(li.get(i).from, li.get(i).to)) ++res;
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 21972
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True

an=0
n,m=MI()
a=LI()
q=[]
for i in a:
    heappush(q,-i)

for i in range(m):
    x=-heappop(q)
    x//=2
    heappush(q,-x)
print(-sum(q))

Measured memory_bytes: 65504
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
//18:55~19:33 44~54
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w==0&&h==0) break;
			String gomi = sc.nextLine();
			int[][] map = new int[h][w];
			Queue<Man> st = new LinkedList<>();
			int count=0;
			for(int j=0;j<h;++j){
				String line = sc.nextLine();
				String[] line_b = line.split("");
				for (int i=0;i<w;++i){
					if(line_b[i].matches("#")) map[j][i]=-1;
					else if(line_b[i].matches("@")){
						map[j][i]=1;
						st.add(new Man(i,j));
						count++;
					}
				}
			}
			while(!st.isEmpty()){
				Man syori = st.remove();
				if(-1<syori.remove_y()-1){
					if(map[syori.remove_y()-1][syori.remove_x()]==0){
						st.add(new Man(syori.remove_x(),syori.remove_y()-1));
						map[syori.remove_y()-1][syori.remove_x()]=1;
						count++;
					}
				}
				if(-1<syori.remove_x()-1){
					if(map[syori.remove_y()][syori.remove_x()-1]==0){
						st.add(new Man(syori.remove_x()-1,syori.remove_y()));
						map[syori.remove_y()][syori.remove_x()-1]=1;
						count++;
					}
				}
				if(syori.remove_x()+1<w){
					if(map[syori.remove_y()][syori.remove_x()+1]==0){
						st.add(new Man(syori.remove_x()+1,syori.remove_y()));
						map[syori.remove_y()][syori.remove_x()+1]=1;
						count++;
					}
				}
				if(syori.remove_y()+1<h){
					if(map[syori.remove_y()+1][syori.remove_x()]==0){
						st.add(new Man(syori.remove_x(),syori.remove_y()+1));
						map[syori.remove_y()+1][syori.remove_x()]=1;
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
}

class Man{
	private int x,y;
	Man(int x,int y){
		this.x=x;
		this.y=y;
	}
	int remove_x(){
		return this.x;
	}
	int remove_y(){
		return this.y;
	}
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define scd(n) scanf("%d",&n)
#define scl(n) scanf("%I64d",&n)
#define mp(x,y) make_pair(x,y)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define fi first
#define se second

const int mx = 2e5+100;

int main() {
   int n,arr[mx],ans=0;
   scd(n);
   repi(0,n,1) scd(arr[i]);
   sort(arr,arr+n);
   repis(n,1,1) ans += arr[i]-arr[i-1];
   printf("%d\n",ans);
}


Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(N, T) = reads()
A = reads()

B = [0] * N

B[0] = A[0]
for i in range(1, N):
  B[i] = min(B[i-1], A[i])

C = [max(A[i] - B[i], 0) for i in range(N)]

M = max(C)
result = sum(c == M for c in C)

print(result)


Measured memory_bytes: 14940
import queue

n, k = input().split()
p = input().split()
n = int(n)
k = int(k)
p = [int(p_tmp) for p_tmp in p]
q = queue.Queue()

wa = []
max = 0
sum = 0
for i in p:
    i += 1
    sum += i
    q.put(i)
    if q.qsize() > k:
        sum -= q.get()
    
    if q.qsize() == k:
        if max < sum:
            max = sum
        
ans = max
ans /= 2
print(ans)
    

Measured memory_bytes: 26064
from scipy.sparse import*
f=csgraph.floyd_warshall
I=9e9
n,m,l,*t=map(int,open(0).read().split())
d=eval('[I]*-~n,'*-~n)
for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
d=f(d,0)
d[d>l]=I
d[d<I]=1
d=f(d)
for i in zip(*[iter(t[m*3+1:])]*2):print((I>d[i])*int(d[i])-1)

Measured memory_bytes: 40860
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int n,x,y; cin >> n >> x >> y;
  vector<vi> to(n);
  rep(i,n-1){
    to[i].push_back(i+1);
    to[i+1].push_back(i);
  }
  to[x-1].push_back(y-1);
  to[y-1].push_back(x-1);

  vector<vi> dist(n,vi(n,-1));
  rep(i,n){
    queue<int> q;
    q.push(i);
    while(!q.empty()){
      int now = q.front(); q.pop();
      for(int next : to[now]){
        if(0 <= dist[i][next]) continue;
        dist[i][next] = dist[i][now] + 1;
        q.push(next);
      }
    }
  }

  vi cnt(n);
  rep(i,n){
    for(int j = i+1; j < n; j++){
      cnt[dist[i][j]]++;
    }
  }
  rep(i,n-1) cout << cnt[i] << "\n";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 19012
/* ex 5_4
   yy8332 */

#include <stdio.h>
#include <string.h>

int main(void){
  char str1[11], *str2;
  int len1, len2, ans, i;

  //入力読み取り
  scanf("%s", str1);

  len1 = strlen(str1);

  //最長部分文字列の取得
  ans = 0;

  for(i = 0; i < len1; i++){
    if(str1[i] == 'A' || str1[i] == 'C' || str1[i] == 'G' || str1[i] == 'T'){
      len2 = 0;
      str2 = &str1[i];
      while(*str2 == 'A' || *str2 ==  'C' || *str2 == 'G' || *str2 == 'T'){
        len2++;
        str2++;
      }
    }
    if(len2 > ans){
      ans = len2;
    }
  }

  //出力
  printf("%d\n", ans);
}


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

using namespace std;

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

  vector<vector<int>> abc(n, vector<int>(3));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> abc[i][j];
    }
  }
  // dp[i][j] := i日目に活動jをしたときi日目までに得られる幸福度の総和の最大値
  vector<vector<int>> dp(n + 1, vector<int>(3, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) {
          continue;
        }
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[i][j]);
      }
    }
  }
  cout << *max_element(dp[n].begin(), dp[n].end()) << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  string S,T;
  cin>>S>>T;
  
  vector<char> X(S.size()+T.size());
  for(int i=0;i<S.size();i++) X.at(2*i)=S[i];
  for(int i=0;i<T.size();i++) X.at(2*i+1)=T[i];
  for(int i=0;i<S.size()+T.size();i++) cout<<X.at(i);
return 0;}

Measured memory_bytes: 3600
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    ll a , b , c;
    cin >> a >> b >> c;
    cout << c << ' ' << a << ' ' << b << endl;

















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/





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

def dfs(s):
    if int(s) > n:
        return 0
#     print(s)
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s + c)
    return ret

print(dfs('0'))#avoid line4's contition
        

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
    long long x, y;
    cin >> x >> y;
    if(abs(x - y) < 2) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <stdlib.h> // @atoi
#include <map>
#include <algorithm>
using namespace std;


int main(void)
{
	std::string input;
	cin >> input;

	std::vector<char> vACGT = {
		{ 'A'},
		{ 'T'},
		{ 'C'},
		{ 'G'},
	};

	std::string resultStr = "";
	int resultLength = 0;

	for (int i = 0; i < input.size(); ++i)
	{
		bool isHit = false;
		for (int j = 0; j < vACGT.size(); ++j)
		{
			if (input[i] == vACGT.at(j))
			{
				isHit = true;
				break;
			}
		}
		if (isHit)
		{
			resultStr += input[i];
			resultLength = max(resultLength, (int)resultStr.size());
		}
		else
		{
			resultLength = max(resultLength, (int)resultStr.size());
			resultStr = "";
		}
	}
	cout << resultLength << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x= scan.nextInt();
		scan.close();
		while(true) {
			int check=1;
			for(int i=2;i<x;i++) {
				if(x%i==0)check=0;
			}
			if(check==1)break;
			x++;
		}
		System.out.println(x);
	}

}

Measured memory_bytes: 21972
#include <cstdio>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    ll i;
    ll s,t;
    ll root;
    scanf("%lld",&s);
    root=(ll)sqrt(s);
    if(root*root==s){
        printf("0 0 %lld 0 0 %lld\n",root,root);
        return 0;
    }
    t=(root+1)*(root+1)-s;
    for(i=1;;i++){
        if(t%i==0){
            printf("0 0 %lld %lld %lld %lld\n",root+1,i,t/i,root+1);
            return 0;
        }
    }

}


Measured memory_bytes: 2156
N = int(input())
A = list(map(int, input().split()))
c=0
odd_exist = True
for j in range(200):
    for i in range(N):
        if A[i]%2 == 0:
            A[i] = int(A[i]/2)
        else:
            odd_exist = False
            break
    if odd_exist:
        c+=1
print(c)

Measured memory_bytes: 9180
unittest
{
	assert( [ "4 2 2" ].solve == 14 );		// 追加ケース
	
	assert( [ "3 2 1" ].solve == 6 );
	assert( [ "100 100 0" ].solve == 73074801 );
	assert( [ "60522 114575 7559" ].solve == 479519525 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s %s"( n, m, k );
	
	// 隣り合うブロックの色が違う箇所の数を決め打ち
	const M = 998244353L;
	auto ans = ModWorld!M( 0L );
	foreach( i; n - 1 - k .. n )
	{
		// 色が違う箇所のパターン数を計算
		auto a = ( n - 1 ).combination!M( i );
		
		// 色の塗り方のパターン数を計算
		auto b = ModWorld!M( m - 1 ) ^^ i * m;
		
		// 答えに加算
		ans += a * b;
	}
	return ans;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	this( long n ){ this.n = n % M; }
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	auto opEquals( ModWorld r ){ return this.n == r.n; }
	
	void opAssign( long r ){ this.n = r % M; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}

// 階乗
auto factorial( long M )( long n )
{
	static memo = [ ModWorld!M( 1L ) ];
	if( memo.length <= n )
	{
		auto i = memo.length.signed;
		memo.length = n + 1;
		for( ; i < memo.length; i++ ) memo[ i ] = memo[ i - 1 ] * i;
	}
	return memo[ n ];
}

// 組み合わせ数
auto combination( long M )( long n, long k )
{
	if( n < k ) return ModWorld!M( 0L );
	else        return n.factorial!M / ( k.factorial!M * ( n - k ).factorial!M );
}


Measured memory_bytes: 4256
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13)cout << b << endl;
	else if (6 <= a && a <= 12)cout << b / 2 << endl;
	else cout << 0 << endl;
	return 0;
}


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

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

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

    vector<int> dp(n+1, 50000);
    dp[0] = 0;
    dp[1] = 1;

    vector<int> c(m);
    REP(i, m) {
        cin >> c[i];
    }

    for (int i = 2; i < n+1; i++) {
        REP(j, m) {
            if (i >= c[j])
                dp[i] = min(dp[i], dp[i-c[j]]);
        }

        dp[i] += 1;
    }
    
    cout << dp[n] << endl;
}


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

int wari(int x) {
  int res = 0;
  while(x%2 == 0) {
    res++;
    x /= 2;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int ans = 10000000;

  rep(i,n) {
    int a;
    cin >> a;
    int s = wari(a);
    ans = min(ans,s);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include "bits/stdc++.h"

using namespace std;

using i64 = int_fast64_t;

// Mint {{{
template <i64 MOD>
class ModInt {
    i64 value;
public:
    inline ModInt(const ModInt& other) noexcept : value(other.value) {}
    inline ModInt(i64 value = 0) noexcept :
        value((value >= MOD) ? value % MOD : (value < 0) ? (value + MOD) % MOD : value) {}

    inline ModInt inv() const noexcept { return power(value, MOD - 2); }

    inline ModInt& operator+=(const ModInt& other) noexcept {
        value = (value + other.value) % MOD; return *this;
    }

    inline ModInt& operator-=(const ModInt& other) noexcept {
        value = (MOD + value - other.value) % MOD; return *this;
    }

    inline ModInt& operator*=(const ModInt& other) noexcept {
        value = (value * other.value) % MOD; return *this;
    }

    inline ModInt& operator/=(const ModInt& other) noexcept {
        value = (value * other.inv().value) % MOD; return *this;
    }

    inline ModInt operator+(const ModInt& other) noexcept { return ModInt(*this) += other; }
    inline ModInt operator-(const ModInt& other) noexcept { return ModInt(*this) -= other; }
    inline ModInt operator*(const ModInt& other) noexcept { return ModInt(*this) *= other; }
    inline ModInt operator/(const ModInt& other) noexcept { return ModInt(*this) /= other; }

    inline bool operator==(const ModInt& other) noexcept { return value == *other; }
    inline bool operator!=(const ModInt& other) noexcept { return value != *other; }

    template <class int_>
        explicit inline operator int_() const noexcept { return static_cast<int_>(value); }

    friend ostream& operator<<(ostream &os, ModInt other) noexcept {
        os << other.value; return os;
    }

    friend istream& operator>>(istream &is, ModInt& other) noexcept {
        is >> other.value; return is;
    }

    static constexpr inline ModInt power(i64 n, i64 p) noexcept {
        i64 ret = 1;
        for (; p > 0; p >>= 1) {
            if (p & 1) ret = (ret * n) % MOD;
            n = (n * n) % MOD;
        }
        return ret;
    }
};

using Mint = ModInt<int(1e9) + 7>;
// }}}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    i64 n, k;
    cin >> n >> k;
    vector<i64> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    Mint value1 = 0, value2 = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            value1 += (a[j] > a[i]);
        }
        for (int j = 0; j < n; ++j) {
            value2 += (a[j] > a[i]);
        }
    }
    value1 *= k;
    value2 *= ((k - 1) * k) >> 1;
    cout << value1 + value2 << "\n";
    return 0;
}


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


int main(){
    string s;
    cin >> s;
    int len = s.size();
    set<char> x;
    for(char i : s) x.insert(i);
    cout << (len == x.size() ? "yes" : "no") << endl;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    T, X = LI()
    result = float(T)/float(X)
    result = round(result, 10)
    print('{:.10f}'.format(result))



main()


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k) {
        cout << k << endl;
    }
    else if (a + b >= k) {
        cout << a << endl;
    }
    else {
        cout << 2 * a + b - k << endl;
    }
}

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

using namespace std;

int main(){

  int n, a;
  int x = 1000000001;
  cin >> n;

  for ( int i = 0; i < n; i++ ){
    cin >> a;
    int tmp = 0;
    while ( a % 2 == 0 ){
      a = a >> 1;
      tmp++;
    }

    if ( tmp < x ){
      x = tmp;
    }
    if ( x == 0 )
      break;
  }
  cout << x << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define make_pair
using namespace std;
 
int main()
{
    ll n; cin>>n;
    ll ar[n];
    ll sum = 0;
    
    map<ll,ll> m;
    
    for(int i = 0;i < n;i++){
        cin>>ar[i];
        m[ar[i]] += 1;
        sum += ar[i];
    }
    
    ll q; cin>>q;
    while(q--){
        
        ll b,c; cin>>b>>c;
        m[c] += m[b];
        sum -= m[b]*b;
        sum += m[b]*c;
        m[b] = 0;
        
        cout<<sum<<"\n";
        
    }

	return 0;
}

Measured memory_bytes: 10212
N = int(input())
import sys
input = sys.stdin.readline
lis = {}
A = list(map(int, input().split()))
for i in range(N-1):
  x = A[i]
  if x in lis:
    lis[x] += 1
  else:
    lis[x] = 1
for i in range(1, N+1):
  if lis.get(i) == None:
    print(0)
  else:
    print(lis.get(i))

Measured memory_bytes: 118676
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  int lowX = 0, lowY = 0;
  int x, y, a;
  for (int i = 0; i < N; ++i) {
    cin >> x >> y >> a;
    if (a == 1) {
      lowX = max(lowX, x);
    } else if (a == 2) {
      W = min(W, x);
    } else if (a == 3) {
      lowY = max(lowY, y);
    } else {
      H = min(H, y);
    }
  }
  int ans = (W <= lowX or H <= lowY ? 0: (W - lowX) * (H - lowY));
  cout << ans << endl;
  return 0;
}


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

int main() {
	double f;
	while (cin >> f) {
		double cnt = f;
		for (int i = 2; i <= 10; i++) {
			if (i & 1)f /= 3;
			else f *= 2;
			cnt += f;
		}
		printf("%.8f\n", cnt);
	}
	return 0;
}

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

int main() {
  int N;
  int c = 1;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a.at(i);
  int b = a.at(0);
  for (int i = 0; i < N; i++) {
    if ( b == 2 && i != N-1 ) {
      cout << c << endl;
      break;
    }
    else {
      c++;
      b = a.at(b-1);
      }
    if ( i == N-1 )
      cout << -1 << endl;
  }
}

Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;
class E { static void Main() => new _K(); }
class _K
{
	int[] G => Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
	public const long Mod = 924844033;
	int N, K;
	long ans, s = 1;
	long[,] comb;
	public _K()
	{
		var I = G;
		N = I[0]; K = I[1];
		var M = N / K + 10;
		comb = new long[M, M];
		for (var i = 0; i < M; i++) comb[i, 0] = 1;
		for (var i = 1; i < M; i++) for (var j = 1; j <= i; j++) comb[i, j] = (comb[i - 1, j] + comb[i - 1, j - 1]) % Mod;
		var p = Convolution(Pow(Chain(N / K), 2 * (K - N % K)), Pow(Chain(N / K + 1), 2 * (N % K)));
		var fact = new long[N + 1];
		fact[0] = 1;
		for (var i = 1; i <= N; i++) fact[i] = (i * fact[i - 1]) % Mod;
		for (var i = 0; i <= N; i++)
		{
			ans = (ans + s * fact[N - i] * p[i] % Mod) % Mod;
			s *= -1;
		}
		if (ans < 0) ans += Mod;
		Console.WriteLine(ans);
	}
	long[] Chain(int n)
	{
		var p = new long[n / 2 + 1];
		for (var k = 0; k <= n / 2; k++) p[k] = comb[n - k, k];
		return p;
	}
	long[] Pow(long[] a, int n)
	{
		var p = new long[] { 1 };
		var x = a;
		while (n > 0)
		{
			if ((n & 1) == 1) p = Convolution(p, x);
			n >>= 1;
			x = Convolution(x, x);
		}
		return p;
	}
	long[] Convolution(long[] a, long[] b)
	{
		var c = new long[a.Length + b.Length];
		for (var i = 0; i < a.Length; i++)
			for (var j = 0; j < b.Length; j++)
				c[i + j] = (c[i + j] + a[i] * b[j] % Mod) % Mod;
		return c;
	}
}


Measured memory_bytes: 25808
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N, K = 0, 0
H = []


def set_inputs():
    global N, K, H
    N, K = get_li()
    H = get_data(N, [int])
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    sorted_h = sorted(H)
    diff = inf
    for _min, _max in zip(sorted_h, sorted_h[K-1:]):
        diff = min(diff, _max - _min)
    print(diff)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 52056
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
int h[100010];

vector<int> cnt;

int main(void){
	cin>>n;
	for (int i = 0; i < n; i++) cin>>h[i];

	int t = 0, num = 0;
	for (int s = 0; s < n; s++) {
		while (t < n - 1 && h[t] >= h[t + 1]) t++;

		num = t - s;

		cnt.push_back(num);

		if (s == t) t++;
	}

	sort(cnt.begin(), cnt.end(), greater<int>());

	cout<< cnt[0] <<endl;
	
	return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 105;
int n, cn[MX][MX][MX], mx1, mx2, mx3;
ll res, s, a[200005];

int count (ll n, int k) {
	ll res = 0;
	while (n % k == 0) {
		n /= k;
		res++;
	}
	return res;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	
	forn (i, n) {
		string in;
		cin >> in;

		int f = 0;
		forn (j, in.size()) f |= in[j] == '.';

		if (f) {
			f = 0;
			for (int j = (int)in.size() - 1; j >= 0 && in[j] != '.'; j--)
				f++;
		}

		forn (j, in.size()) if (in[j] != '.') {
			a[i] *= 10;
			a[i] += in[j] - '0';
		}

		int two = count(a[i], 2);
		int five = count(a[i], 5);

		cn[f][two][five]++;

		mx1 = max(mx1, f);
		mx2 = max(mx2, two);
		mx3 = max(mx3, five);
	}

	forn (i, mx1 + 1) forn (j, mx2 + 1) forn (k, mx3 + 1) {
		forn (a, mx1 + 1) forn (b, mx2 + 1) forn (c, mx3 + 1) {
			if (i + a <= min(j + b, k + c)) {
				if (a != i || b != j || c != k)
					res += 1ll * cn[i][j][k] * cn[a][b][c];
				else
					res += 1ll * cn[i][j][k] * (cn[i][j][k] - 1);
			}
		}
	}

	cout << res / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 5148