akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;
lld const N = 1e5+5;
#define ordered_set tree<lld, null_type,less<lld>, rb_tree_tag,tree_order_statistics_node_update>

lld fact[N], ifact[N];

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

void findFact() {
    fact[0] = 1;
    for(lld i = 1; i <= N; i++)
        fact[i] = 1ll * fact[i - 1] * i % mod;
    ifact[N] = power_mod(fact[N], mod - 2);
    for(lld i = N - 1; i >= 0; i--)
        ifact[i] = 1ll * ifact[i + 1] * (i + 1) % mod;
}

lld comb(lld n, lld r) {
    return 1ll * fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}


lld gcd(lld a, lld b)
{
  if(b==0)
    return a;
  return gcd(b,a%b);
}
string s;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>s;
  lld n = s.length();
  lld sum = 0;
  lld i;
  for(i=0;i<n;i++)
  {
    sum = (sum + lld(s[i]-'0'))%9;
  }
  if(sum==0)
    cout<<"Yes\n";
  else
    cout<<"No\n";

}


Measured memory_bytes: 3744
// ITP1_8_B
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
int c(string s){
    int ans=0;
    for(int i=0;i<s.size();i++){
        ans+=s[i]-'0';
    }
    return ans;
}

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

    string s;
    cin>>s;
    while(s[0]-'0'!=0){
        cout<<c(s)<<endl;
        cin>>s;
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n;
	cin>>n;
	int a[n];
	int sum=0;
	rep(i,n){
		cin>>a[i];
		sum = sum ^ a[i];
	}

	int k=0;
	rep(i,n){
		k=sum^a[i];
		cout<<k<<" ";
	}
	cout<<endl;

	return 0;
}


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

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

  int ans = 0;

  for(int i = 1; i <= N; i++){
    cin >> a;
    if(i%2 == 1){
      if(a%2 == 1){
      ans++;
      }
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 3580
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        
        AtCoder problem = new AtCoder(sc);
        problem.solve(out);
        
        out.flush();
    }
    
}

class AtCoder {
    final int K;
    final String S;
    AtCoder(FastScanner sc) {
        K = sc.nextInt();
        S = sc.next();
    }

    void solve(PrintWriter out) {
        if (S.length() <= K) {
            out.println(S);
        } else {
            out.println(S.substring(0,K) + "...");
        }
    }
    
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {
    
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }
    
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n;

    cin>>n;

    li a[n+1];

    vi ans(n+1);

    f(i,2,n)
    {
        cin>>a[i];

        ans[a[i]]++;
    }

    f(i,1,n)
    {
        cout<<ans[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 6328
/* https://atcoder.jp/contests/abc100/tasks/abc100_c */

#include <iostream>
#include <vector>

int solve(const int N, std::vector<int> &a)
{
  long long cnt_two_mul = 0;

  for (int i = 0; i < N; ++i) {
    int e = a.at(i);

    while (e%2 == 0) {
      e /= 2;
      cnt_two_mul++;
    }
  }

  return cnt_two_mul;
}

int main(int argc, char *argv[])
{
  // Input
  int N;

  std::cin >> N;

  std::vector<int> a(N);

  for (auto &e: a)
    std::cin >> e;

  // Output
  std::cout << solve(N, a) << std::endl;

  return 0;
}


Measured memory_bytes: 256
program answer
  implicit none
  integer(8) :: i, N, K, ans
  integer(8), allocatable :: h(:)
  read(*,*) N, K
  allocate(h(N))
  read(*,*) h
  ans=0
  do i = 1, N
     if(h(i)>=K) then
        ans=ans+1
     end if
  end do

  write(*,*) ans
  stop
  deallocate(h)
 end program answer

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

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  int first = L;
  int last = L + N - 1;
  int res = (first + last) * N / 2;
  if (first * last <= 0) cout << res << endl;
  else if (first > 0) cout << res - first << endl;
  else cout << res - last << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if(x-r<0 || y-r<0 || x+r>W || y+r>H){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
constexpr ll INF = (1LL << 60);
signed main(){
    int N; cin >> N;
    vector<int>P(N);
    vector<int>toIdx(N+1);
    vector<int>used(N+1,false);
    for(auto & e : P) cin >> e;
    for(int i = 0; i < N; ++i)
        toIdx[P[i]] = i;
    int maxi = -1;
    function<int(int)> visitor  = [&](int num){
        if(used[num] or num >= N or toIdx[num + 1] < toIdx[num]) return 1LL;
        used[num] = true;
        return visitor(num + 1) + 1LL;
    };
    for(auto e : P){
        maxi = max(maxi,visitor(e));
    }
    cout << N - maxi << endl;
    
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

// dijkstra O(ElogV)
// verify : https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_A
// ※拡張ダイクストラ
template<typename T>
struct Dijkstra {
private:
    int V;
    struct edge { int to; T cost; };
    vector<vector<edge>> G;
public:
    const T inf = numeric_limits<T>::max();

    // s から i の最小コスト
    // 経路がない場合は inf
    vector<T> d; // (頂点) ※

    Dijkstra(int V) : V(V) {
        G.resize(V);
    }

    // 辺の追加
    // 有向の場合　directed = true
    void add_edge(int from, int to, T weight, bool directed = false) {
        G[from].push_back({to,weight});
        if (!directed) G[to].push_back({from,weight});
    }

    void build(int s) {
        d.assign(V, inf); // ※
        typedef tuple<T, int> P; //(距離,頂点) ※
        priority_queue<P, vector<P>, greater<P>> pq;
        d[s] = 0; // ※
        pq.push(P(d[s], s)); // ※
        while (!pq.empty()) {
            P p = pq.top(); pq.pop();
            int v = get<1>(p);
            // ※
            if (d[v] < get<0>(p)) continue; // ※
            for (const edge &e : G[v])
            {
                // ※
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    pq.push(P(d[e.to], e.to));
                }
            }
        }
    }
};

int main() {
    int n, m, r; cin >> n >> m >> r;
    Dijkstra<ll> G(n);
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        G.add_edge(a, b, c, true);
    }
    G.build(r);
    for (int i = 0; i < n; i++) {
        if (G.d[i] == G.inf) cout << "INF" << endl;
        else cout << G.d[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 19536
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>

#define rep(i,x) for(ll i=0;i<(int)(x);i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n;
    cin >> n;
    ll odd = 0;
    ll p4 = 0;
    ll p2 = 0;
    rep(i, n){
        ll tmp;
        cin >> tmp;
        if(tmp % 2 == 1) odd++;
        else if(tmp % 4 == 0) p4++;
        else if(tmp % 2 == 0) p2++;
    }

    if(n % 2 == 0){
        if(odd <= p4){
            cout << "Yes";
            return 0;
        }else{
            cout << "No";
            return 0;
        }
    }else{
        if(odd + p4 == n){
            if(odd-1 <= p4){
                cout << "Yes";
                return 0;
            }else{
                cout << "No";
                return 0;
            }
        }else{
            if(odd <= p4){
                cout << "Yes";
                return 0;
            }else{
                cout << "No";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define int long long

inline int read () {
	int ret = 0, t = 1;
	char c = getchar();
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') t = -1, c = getchar();
	while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
	return ret * t;
}

signed main () {
	int n = read();
	int s = 1;
	while (s - 1 < n) s <<= 1;
	printf("%lld\n", s - 1);
	return 0;
}

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



using namespace std;

int main(){
    ll N;
    cin >> N;
    vector<ll> B(N-1);
    for(int i=0;i<N-1;i++) cin >> B[i];
    B.push_back(100000000);
    ll ans = B[0];
    for(int i=0;i<N;i++){
        ans += min(B[i],B[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn can(f: usize, a: &[usize]) -> bool {
    let mut stack = vec![(0, a[0], a[0])];//文字種, 長さ、ここまでの長さ
    for &a in &a[1..] {
        let len = stack.last().unwrap().2;
        if len < a {
            stack.push((0, a - len, a));
            continue;
        }
        while let Some(&p) = stack.last() {
            if p.2 - p.1 >= a {
                stack.pop();
            } else {
                break;
            }
        }
        while let Some(&p) = stack.last() {
            if p.0 == f - 1 {
                stack.pop();
            } else {
                break;
            }
        }
        if stack.is_empty() {
            return false;
        }
        if stack.last().unwrap().2 > a {
            let (x, y, s) = stack.pop().unwrap();
            let front = s - y;
            stack.push((x, a - front, a));
        }
        let (x, y, s) = stack.pop().unwrap();
        if y > 1 {
            stack.push((x, y - 1, s - 1));
        }
        stack.push((x + 1, 1, s));
        if a - s > 0 {
            stack.push((0, a - s, a));
        }
    }
    true
}

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut l = 0;
    let mut r = n;
    while r - l > 1 {
        let m = (l + r) / 2;
        if can(m, &a) {
            r = m;
        } else {
            l = m;
        }
    }
    println!("{}", r);
}

fn main() {
    run();
}


Measured memory_bytes: 17268
while True:
    H,W=map(int, input().split())
    if W == H == 0: break
    for i in range(H):
        if i%2==0 :
                if W%2==0:
                    print(W//2*"#.")
                else:
                    print(W//2*"#."+"#")
        else :
                if W%2==0:
                    print(W//2*".#")
                else:
                    print(W//2*".#"+".")
    print()


Measured memory_bytes: 5616
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

win = {
    'r': p,
    's': r,
    'p': s
}
use = [False for i in range(len(t))]
score = 0
for i in range(len(t)):
    if i < k:
        score += win[t[i]]
        use[i] = True
    elif t[i] != t[i-k] or (not use[i-k]):
        score += win[t[i]]
        use[i] = True
print(score)

Measured memory_bytes: 4212
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
mod = K * 2
XY = []
MAX = K * 4
imos = list2d(MAX+1, MAX+1, 0)
for i in range(N):
    x, y, c = input().split()
    x = int(x)
    y = int(y)
    x %= mod
    y %= mod
    if c == 'B':
        x += K
    for a1 in range(2):
        for a2 in range(2):
            for b in [0, K]:
                if c == 'B':
                    b = -b
                x1 = x + a1 * mod + b
                y1 = y + a2 * mod + b
                x2 = x1 + K
                y2 = y1 + K
                x1 = max(min(x1, MAX), 0)
                y1 = max(min(y1, MAX), 0)
                x2 = max(min(x2, MAX), 0)
                y2 = max(min(y2, MAX), 0)
                imos[x1][y1] += 1
                imos[x2][y2] += 1
                imos[x1][y2] -= 1
                imos[x2][y1] -= 1

for i in range(MAX+1):
    imos[i] = list(accumulate(imos[i]))
for j in range(MAX+1):
    for i in range(MAX):
        imos[i+1][j] += imos[i][j]
ans = 0
for i in range(K*2, K*4+1):
    ans = max(ans, max(imos[i][K*2:K*4+1]))
print(ans)


Measured memory_bytes: 241032
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < (int)s.size(); i++){
        for(int j = 1; j <= (int)s.size(); j++){
            string s2 = s.substr(i, j);
            bool ok = true;
            for(auto& c : s2){
                if(c != 'A' && c != 'C' && c != 'G' && c != 'T'){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ans = max(ans, (int)s2.size());
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";



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

    int x;
    cin >> x;
    if (x >= 30){
        cout << "Yes"
             << "\n";
        return 0;
    }
    cout << "No"
         << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define endl "\n"
#define pque priority_queue

const int mod = 1000000007;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.length(), cnt = 0;
	for (int i = 0; i < n; i++){
		if (s[i] == 'g') cnt++;
		else cnt--;
	}
	cnt /= 2;
	cout << cnt;
}


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

#define rep(i, N) for(int i = 0;i < N;i++)

#define INF 1e10;

using namespace std;

int main(void){
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	rep(i, N) {
		cin >> h[i];
	}

	vector<int> dp(N, 1e10);
	dp[0] = 0;

	for (int i = 1; i < N; i++) {
		
		for (int j = 1; j <= K; j++) {
			if (i - j >= 0) {
				dp[i] = min(dp[i - j] + abs(h[i] - h[i-j]), dp[i]);
			}
			
		}
	}

	
	cout << dp[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------
vector<ll> v[10001];
ll degr[10001];
ll sum=0;
ll ans[10001]={0};
void dfs(ll ver,ll p)
{
	for(ll i=0;i<v[ver].size();i++)
	{
		if(v[ver][i]!=p)
		{
			sum+=min(ans[ver],ans[v[ver][i]]);
			dfs(v[ver][i],ver);
		}
	}
}
int main()
{
	boost
	ll n;
	cin>>n;
	for(ll i=0;i<n-1;i++)
	{
		ll a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
		degr[a]++;
		degr[b]++;
	}
	ll c[n];
	for(ll i=0;i<n;i++)
	{
		cin>>c[i];
	}
	sort(c,c+n);
	set<pair<ll,ll> > s;
	for(ll i=1;i<=n;i++)
	{
		s.insert(mp(degr[i],i));
	}
	ll i=0;
	
	
	while(!s.empty())
	{
		pair<ll,ll> lar = *(s.begin());
		ans[lar.se]=c[i++];
		s.erase(s.begin());
		ll ver=lar.se;
		degr[ver]=0;
		//debug1(ver);
		for(ll i=0;i<v[ver].size();i++)
		{
			if(degr[v[ver][i]]!=0)
			{
				s.erase(mp(degr[v[ver][i]],v[ver][i]));
				degr[v[ver][i]]--;
				s.insert(mp(degr[v[ver][i]],v[ver][i]));
			}
		}
	}
	dfs(1,-1);
	cout<<sum<<endl;
	for(ll i=1;i<=n;i++)
		cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = int long long;
map <int ,int> mpa,mpb;

int main (){
  ll N,M;
  cin >> N >> M;
  ll ans=0;
  if(M>=2*N){
    ans=N;
    M=M-2*N;
    ans+=M/4;
  }
  else{
    ans=M/2;
  }
  cout << ans;
}

Measured memory_bytes: 256
a,b,c,d = gets.chomp.split.map(&:to_i)

c_b = b/c
d_b = b/d
cd_b = b/(c*d/(c.gcd(d)))
c_a = (a-1)/c
d_a = (a-1)/d
cd_a = (a-1)/(c*d/(c.gcd(d)))


puts b - (c_b + d_b - cd_b)-(a-1 - (c_a + d_a - cd_a))

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

map<ll, ll> prime_factor(ll N) {
    map<ll, ll> prime;
    for (ll i = 2; i * i <= N; i++) {
        while (N % i == 0) {
            prime[i]++;
            N /= i;
        }
    }

    if (N != 1) prime[N] = 1;
    return prime;
}
int main()
{
    ll A, B;
    cin >> A >> B;

    map<ll, ll> mpA = prime_factor(A);
    map<ll, ll> mpB = prime_factor(B);

    int ans = 1;
    for (auto itr : mpA) {
        if (mpB.count(itr.first)) ans++;
    }

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

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	ll n, i, ans = 1;
	cin >> n;
	for (i = 1; i <= n; i++)
		ans = ans * i%M;
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
	int a,b,c;
	cin>>a>>b>>c;
	int min=0;
	int k1=a+b;
	int k2=a+c;
	int k3=b+c;
	if(k1<=k2&&k1<=k3)cout<<k1;
else	if(k2<=k1&&k2<=k3)cout<<k2;
else	if(k3<=k1&&k3<=k2)cout<<k3;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

ll gcd(ll m, ll n)
{
	// 引数に０がある場合は０を返す
	if ((0 == m) || (0 == n))
		return 0;

	// ユークリッドの方法
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}

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

	int n;
	cin >> n;
	vi a(n);
	bool f = true;
	rep(i, n) {
		int t;
		cin >> t;
		a[i] = t;
		if (t % 2 != 0)f = false;
	}

	int ans = 0;
	while (f) {
		rep(i, n) {
			a[i] /= 2;
			if (a[i] % 2 != 0)f = false;
		}
		ans++;
		
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = []
flag = True
for i in range(M):
    a.append(int(input()))

a = [-1] + a + [N+1] #add beginning and end

# list of steps between broken steps
s1=[]
for i in range(len(a)-1):
    if a[i+1]-a[i]-2<0:
        flag = False
        break
    s1.append(a[i+1]-a[i]-2) 

if flag==False:
    print(0)    
else:     
    # possibile ways for steps
    s2 = [1, 1, 2]
    while len(s2) < max(s1)+1:
        s2.append(s2[-2]+s2[-1])
    
    # possible ways for all
    s3 = 1 
    for j in s1:
        s3 = s3 * s2[j] 
        
    s4 = s3 % 1000000007 
    print(s4)

Measured memory_bytes: 460020
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000000;
const double PI = acos(-1);
 
int n, m, k, s;
int p, q;
struct edge { LL to, cost; };
 
typedef pair<int, int> PP;
 
LL d[100100]; //?????¢
vector<edge> vec[100100];
 
LL dijkstra() {
	for (int i = 0; i < 100100; i++)d[i] = INF;
	priority_queue<PP, std::vector<PP>, std::greater<PP>> pq;
	d[0] = 0;
	pq.push(make_pair(d[0], 0));
	while (!pq.empty()) {
		PP p = pq.top();
		pq.pop();
		int i = p.second;
		if (d[i] < p.first)continue;
		for (int k = 0; k < vec[i].size(); k++) {
			edge e = vec[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(make_pair(d[e.to], e.to));
		}
	}
	return d[n - 1];
}
 
constexpr int MAX_V = 100100;
vector<int> G[MAX_V];
bool iszombie[MAX_V];
bool isdanger[MAX_V];
int start, goal;
 
LL dis[MAX_V]; //???????????¢????±?????????´???
 
void bfs() {
	queue<int>que;
	//?????????
	for (int i = 0; i < MAX_V; i++)dis[i] = INF;
 
	que.push(start);
	dis[start] = 0;
 
	while (que.size()) {
		int p = que.front();
		que.pop();
		for (int i = 0; i < G[p].size(); i++) {
			if (dis[G[p][i]] == s + 1)continue;
			if (dis[G[p][i]] == INF) {
				que.push(G[p][i]);
				dis[G[p][i]] = dis[p] + 1;
				if (dis[G[p][i]] <= s + 1) {
					iszombie[G[p][i]] = true;
				}
			}
		}
	}
}
 
 
 
int main() {
	cin >> n >> m >> k >> s;
	cin >> p >> q;
	int a, b, c;
	for (int i = 0; i < k; i++) {
		cin >> c;
		c--;
		G[c].emplace_back(100005);
		G[100005].emplace_back(c);
		isdanger[c] = true;
	}
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--, b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	start = 100005;
	bfs();
 
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < G[i].size(); j++) {
			if (!isdanger[G[i][j]] && !isdanger[i]) {
				if (iszombie[G[i][j]] == true) {
					vec[i].emplace_back(edge{ G[i][j],q });
				}
				else {
					vec[i].emplace_back(edge{ G[i][j],p });
				}
			}
		}
	}
	cout << dijkstra() - (iszombie[n - 1] ? q : p) << endl;
}

Measured memory_bytes: 23200
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		Point p1,p2,p3;
		double a,b,c;
		double X,Y,R;
		double A1,B1,C1,A2,B2,C2;
		for(int i=0;i<n;i++){
			p1=new Point(scan.nextDouble(),scan.nextDouble());
			p2=new Point(scan.nextDouble(),scan.nextDouble());
			p3=new Point(scan.nextDouble(),scan.nextDouble());
			a=calcEdge(p1,p2);
			b=calcEdge(p2,p3);
			c=calcEdge(p1,p3);
			A1=2.0*(p2.getX()-p1.getX());
			B1=2.0*(p2.getY()-p1.getY());
			C1=(p1.getX())*(p1.getX())-(p2.getX())*(p2.getX())+(p1.getY())*(p1.getY())-(p2.getY())*(p2.getY());
			A2=2.0*(p3.getX()-p1.getX());
			B2=2.0*(p3.getY()-p1.getY());
			C2=(p1.getX())*(p1.getX())-(p3.getX())*(p3.getX())+(p1.getY())*(p1.getY())-(p3.getY())*(p3.getY());
			X=(B1*C2-B2*C1)/(A1*B2-A2*B1);
			Y=(C1*A2-C2*A1)/(A1*B2-A2*B1);
			R=a/(2.0*Math.sqrt((2.0*(a*a*b*b+b*b*c*c+c*c*a*a)-(a*a*a*a+b*b*b*b+c*c*c*c))/(4.0*b*b*c*c)));
			System.out.printf("%.3f %.3f %.3f\n",X,Y,R);
		}
		scan.close();
	}
	private static double calcEdge(Point p1,Point p2)
	{
		return Math.sqrt((p1.getX()-p2.getX())*(p1.getX()-p2.getX())+
				(p1.getY()-p2.getY())*(p1.getY()-p2.getY()));
	}
	private static class Point
	{
		private double x;
		private double y;
		private Point(double x,double y)
		{
			this.x=x;
			this.y=y;
		}
		public double getX()
		{
			return this.x;
		}
		public double getY()
		{
			return this.y;
		}
	}
}

Measured memory_bytes: 28916
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] h = new int[n];
		int i;
		for(i = 0; i < n; i++)
			h[i] = scan.nextInt();

		int[] f = new int[n];
		Arrays.fill(f, 1);
		int a,b;
		for(i = 0; i < m; i++) {
			a = scan.nextInt();
			b = scan.nextInt();
			if(h[a - 1] <= h[b - 1])
				f[a - 1] = 0;
			if(h[b - 1] <= h[a - 1])
				f[b - 1] = 0;
		}
		long ans = 0;
		for(i = 0; i < n; i++)
			if(f[i] == 1)
				ans++;
		out.print(ans);
		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main(){
    string s;
    cin >> s;
    int a,z;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='A'){
            a=i;
            break;
        }
    }
    for(int i=0;i<s.size();i++){
        if(s.at(s.size()-1-i)=='Z'){
            z=s.size()-i;
            break;
        }
    }
    cout <<z-a << endl;
}

Measured memory_bytes: 640
N=int(input())
import numpy as np

A=np.array(input().split(),dtype=int)
B=np.array(input().split(),dtype=int)

A=np.cumsum(A)
B=np.cumsum(B)
maxV=0
for i in range(N):
  maxV=max(maxV,A[i]+B.max()-(0,B[i-1])[i>0])

print(maxV)

Measured memory_bytes: 12504
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[110];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int b[10]={0};
	int c=0;
	for(int i=0;i<n;i++){
		if(a[i]<400){
			b[0]++;
		}
		else if(400<=a[i]&&a[i]<800){
			b[1]++;
		}
		else if(800<=a[i]&&a[i]<1200){
			b[2]++;
		}
		else if(1200<=a[i]&&a[i]<1600){
			b[3]++;
		}
		else if(1600<=a[i]&&a[i]<2000){
			b[4]++;
		}
		else if(2000<=a[i]&&a[i]<2400){
			b[5]++;
		}
		else if(2400<=a[i]&&a[i]<2800){
			b[6]++;
		}
		else if(2800<=a[i]&&a[i]<3200){
			b[7]++;
		}
		else{
			c++;
		}
	}
	int min=0;
	for(int i=0;i<8;i++){
		if(b[i]!=0){
			min++;
		}		
	}
	int max=min+c;
	if(min==0){
		min=1;
	}
	cout<<min<<' '<<max<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define QOEINDIEDIS freesteed
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int s,t,c;
void solve(){
	int n,C;
	cin>>n>>C;
	map<int,vector<PII> > ma;
	rep(i,0,n){
		cin>>s>>t>>c;
		ma[c].pb({s,t});
	}
	multiset<PII> mt;
	for(auto m:ma){
		vector<PII> ret = m.se;
		sort(all(ret));
		int i=1;
		while(i<sz(ret)){
			if(ret[i].fi!=ret[i-1].se)mt.insert(ret[i-1]);
			else ret[i].fi = ret[i-1].fi;
			i++;
		}
		mt.insert(ret[sz(ret)-1]);
	}
	vector<int> tab;
	for(auto m:mt){
		s = m.fi,t = m.se;
		int f=0;
		//cout<<s<<" "<<t<<"\n";
		for(int i=0;i<sz(tab);i++){
			if(s>tab[i]){
				tab[i] = t;
				f = 1;
				break;
			}
		}
		if(!f)tab.pb(t);
	}
	cout<<sz(tab); 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}

Measured memory_bytes: 6144
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double old;

const int N = 200;

int a[N][N];
map<string, int> mem;

int ask(string &s) {
    if (mem.count(s)) {
        return mem[s];
    }
    cout << "? " << s << endl;
    int x;
    cin >> x;
    return mem[s] = x;
}

int n;

int get_vertex() {
    return rand() % n;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (a[i][j] || a[j][k] || a[i][k]) {
                    continue;
                }
                string s(n, '0');
                s[i] = s[j] = s[k] = '1';
                int x = ask(s);
                if (x == 0) {
                    a[i][j] = a[j][k] = a[i][k] = -1;
                }
                if (x == 1) {
                    s[k] = '0';
                    int y = ask(s);
                    s[k] = '1';
                    if (y) {
                        a[i][j] = 1;
                        a[j][k] = a[i][k] = -1;
                    } else {
                        s[j] = '0';
                        y = ask(s);
                        if (y) {
                            a[i][k] = 1;
                            a[i][j] = a[j][k] = -1;
                        } else {
                            a[j][k] = 1;
                            a[i][k] = a[i][j] = -1;
                        }
                    }
                }
                if (x == 2) {
                    s[k] = '0';
                    int y = ask(s);
                    s[k] = '1';
                    if (!y) {
                        a[i][j] = -1;
                        a[i][k] = a[j][k] = 1;
                    } else {
                        s[j] = '0';
                        y = ask(s);
                        if (!y) {
                            a[i][k] = -1;
                            a[i][j] = a[j][k] = 1;
                        } else {
                            a[j][k] = -1;
                            a[i][j] = a[i][k] = 1;
                        }
                    }
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (a[i][j] == 0) {
                string s(n, '0');
                s[i] = s[j] = '1';
                if (ask(s)) {
                    a[i][j] = 1;
                } else {
                    a[i][j] = -1;
                }
            }
        }
    }
    cout << '!';
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (a[i][j] == 1) {
                cout << " (" << i << ',' << j << ')';
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3924
using System;

namespace DPC_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var dp = new int[n];
            dp[0] = 0;
            dp[1] = Math.Abs(a[0] - a[1]);
            for(var i=2;i<n;i++)
            {
                var s = dp[i - 1] + Math.Abs(a[i - 1] - a[i]);
                var t = dp[i - 2] + Math.Abs(a[i - 2] - a[i]);
                dp[i] = Math.Min(s, t);
            }
            Console.WriteLine(dp[n - 1]);
        }
    }
}


Measured memory_bytes: 16864
#include<iostream>
using namespace std;
int main(){
	int n, m, c; cin>>n>>m>>c;
	int b[m], a[n], ans=0; for(int i=0; i<m; i++) cin>>b[i];
	for(int i=0; i<n; i++){
		int x; a[i]=0;
		for(int j=0; j<m; j++){
			cin>>x;
			a[i]+=x*b[j];
		}
		a[i]+=c;
		if(a[i]>0) ++ans;
	}
	cout<<ans<<endl;	

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int x[3],y[3],n,x1;

        scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);

        x1 = x[0];
        if(x[0]<x[1]){
                n =x[1] -x[0];
                y[2] = n+y[1];
                y[3] =n+y[0];
        }
        else{
                n =x[0]-x[1];
                y[2] = y[1]-n;
                y[3] = y[0]-n;
        }

        n = y[1] - y[0];
        x[2] = x[1] - n;
        x[3] = x1 - n;

        printf("%d %d %d %d\n",x[2],y[2],x[3],y[3]);

        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout,"");
//copy(v.beg,v.en,outp);
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
ll min(ll a, ll b){
    if(a>b){
        return b;
    }
    return a;
}
 
ll max(ll a, ll b){
    if(a>b){
        return a;
    }
    return b;
}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
const int N=1e9 +7;
int main()
{
	int n,m;
	cin>>n>>m;
	char arr[n][m];
	forl(i,0,n)forl(j,0,m) cin>>arr[i][j];
	int dp[n][m];
	forl(i,0,n)
	{
		forl(j,0,m)
		{
			 if(i==0 && j==0)
			 {
			 	dp[i][j]=1;
			 	continue;
			 }
			 if(arr[i][j]=='.')
			 {
			 	if(i>=1)
			 	{
			 		if(j>=1)
			 		{
			 			dp[i][j]=(dp[i-1][j]%N+dp[i][j-1]%N)%N;
					 }else{
					 	dp[i][j]=(dp[i-1][j])%N;
					 }
				}else{
					if(j>=1)
					{dp[i][j]=(dp[i][j-1])%N;
						
					}
				}
			 }
			 else dp[i][j]=0;
		}
	}
	cout<<dp[n-1][m-1]<<endl;
	
}

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

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

    vector<int> H(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> H[i];
    }

    if (K >= N)
    {
        cout << 0 << endl;
        return 0;
    }

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

    long sum = 0;
    for (size_t i = K; i < N; i++)
    {
        sum += H[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 1024