akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int a[N];
vector<int>v[N];
vector<pair<int,int> >ask[N];
int h[N];
int sol[N];
vector<int>trt;
int bs(int y){
    int st = 0;
    int en = trt.size();
    int ret = 0;
    while(st<=en){
        int mid = (st+en)/2;
        if(trt[mid]>=y){
            ret = max(ret,mid);
            st = mid+1;
        }
        else{
            en= mid-1;
        }
    }
    return trt.size()-ret;
}
void dfs(int x){
    for(auto p:ask[x]){
        int c = p.fi;
        sol[p.se] = bs(c);
        sol[p.se] = max(sol[p.se],1);
    }
    trt.push_back(x);
    for(int y : v[x]){
        h[y] = h[x]-1;
        dfs(y);
    }
    trt.pop_back();
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    int l;
    cin>>l;
    for(int i=1;i<n;i++){
        int st = i;
        int en = n;
        int ans = i;
        while(st<=en){
            int mid  = (st+en)/2;
            if(a[mid]-a[i]<=l){
                ans = max(ans,mid);
                st = mid+1;
            }
            else{
                en = mid-1;
            }
        }
        v[ans].pb(i);
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        if(x>y)swap(x,y);
        ask[x].pb({y,i});

    }
    dfs(n);
    for(int i=0;i<q;i++)cout<<sol[i]<<endl;
    return 0;
}


Measured memory_bytes: 18552
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int r;
    cin >> r;
    cout << fixed << setprecision(10) << 2.00 * r * 3.14159265359;

    return 0;

}




Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	ll ans = max(0, v[0] - x);
	v[0] = max(0ll, v[0] - ans);
	rep(i,n-1) {
		ll sum = v[i] + v[i+1];
		if (sum > x) {
			ll sub = sum - x;
			ans += sub;
			v[i+1] = max(0ll, v[i+1] - sub);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int n, s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a = 0, b = 0;
    bool key = 1;
    for (int j = 0; j < 10; j++) {
      cin >> s;
      if (s > a)
        a = s;
      else if (s > b)
        b = s;
      else
        key = 0;
    }
    cout << (key ? "YES" : "NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 2988
def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    N = len(S)

    rank = [0] * N
    seen = [0] * 26
    cnt = 0
    r = 0
    for i in range(N-1, -1, -1):
        j = ord(S[i]) - 97
        if not seen[j]:
            seen[j] = 1
            cnt += 1
        rank[i] = r
        if cnt == 26:
            r += 1
            seen = [0] * 26
            cnt = 0

    ans = []
    for i in range(26):
        if not seen[i]:
            ans.append(i+97)
            break

    i0 = 0
    while ord(S[i0]) != ans[0]:
        i0 += 1
        if i0 == N:
            print(chr(ans[0]))
            exit()
    r = rank[i0]
    seen2 = [0] * 26
    flg = 1
    for i in range(i0+1, N):
        j = ord(S[i])-97
        if flg:
            if rank[i] == r:
                seen2[j] = 1
            else:
                for k in range(26):
                    if not seen2[k]:
                        ans.append(k+97)
                        break
                flg = 0
                seen2 = [0] * 26
                if j == k:
                    r -= 1
                    flg = 1
        else:
            if j != k:
                continue
            else:
                r -= 1
                flg = 1
    for k in range(26):
        if not seen2[k]:
            ans.append(k + 97)
            break
    print(''.join(map(chr, ans)))



if __name__ == '__main__':
    main()


Measured memory_bytes: 43616
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        x: i64,
        a: i64,
    }

    if x < a {
        print!("0");
    } else {
        print!("10");
    }
}


Measured memory_bytes: 4352
from collections import defaultdict
import itertools
import math

d = defaultdict(int)

N , D = map(int,input().split())
X = []
for i in range(N):
    X.append(list(map(int,input().split())))

c = 0
for i,j in itertools.permutations(range(N),2):
    if i >= j :
        continue
    d = sum(
        map(lambda x:(X[i][x]-X[j][x])**2,range(D))
    )
    if d == math.floor(math.sqrt(d))**2:
        c += 1

print(c)

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

using namespace std;

int main(){
	
	
	string s,sum;
	int K;
	
	cin >> s >> K;
	
	vector<string> vec;
	
	for(int i=0; std::abs(i)<s.size(); i++){
		
		sum = "";
		for(int j=0; j<5 && std::abs(j+i)<s.size(); j++){
			sum = sum + s.at(i+j);
			vec.push_back(sum);
		}
	}
	std::sort(vec.begin(), vec.end());
		
	for(int j=1; j<K; j++){
		
		if(vec.at(j-1) == vec.at(j)) K++;
		
		}
		
	
	
	cout << vec.at(K-1) << endl;
	
	
	
}

Measured memory_bytes: 1660
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	ai := a[len(a)-1]
	aj := 0
	tmp := int(1e10)
	for i := 0; i < n-1; i++ {
		x := a[i]
		t := max(x, ai-x)
		if t < tmp {
			tmp = t
			aj = x
		}
	}

	fmt.Println(ai, aj)
}

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


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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    ll n;
    cin>>n;
    vector<ll> cnt(n+1,0);
    for(int i=1;i<=n;++i)
    {
        for(int j=i;j<=n;j+=i)
            cnt[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;++i)
        ans+=cnt[i]*i;
    cout<<ans;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 81348
h, w = gets.split.map(&:to_i)
s = Array.new(h + 1).map{Array.new(w + 1, 0)}
1.upto(h) do |i|
  c = 0
  l = 1
  b = gets.chomp.bytes
  1.upto(w) do |j|
    if b[j - 1] == 46
      l = j if c == 0
      c += 1
    elsif c > 0
      s[i][l..j - 1] = Array.new(j - l, c)
      c = 0
    end
    if j == w && c > 0
      s[i][l..j] = Array.new(j - l + 1, c)
    end
  end
end
ans = 0
1.upto(w) do |j|
  c = 0
  l = 1
  1.upto(h) do |i|
    if (s[i][j] > 0)
      l = i if c == 0
      c += 1
    elsif c > 0
      l.upto(i - 1) do |k|
        ans = s[k][j] + c if ans < s[k][j] + c
      end
      c = 0
    end
    if i == h && c > 0
      l.upto(i) do |k|
        ans = s[k][j] + c if ans < s[k][j] + c
      end
    end
  end
end
puts ans - 1

Measured memory_bytes: 93424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	string s; cin >> s;
	rep2(i,1,s.size()){
		if(s[i-1]==s[i]){
			out("Bad");return 0;
		}
	}
	out("Good");
}




Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <iostream>
#include <cmath>
#include <set>
#include <string>
using namespace std;



int main()
{
  int n[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int m;
  cin >> m;
  cout << n[m-1];

}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

using namespace std;


int main() {
  int K, T;
  cin >> K >> T;
  priority_queue<int, vector<int>> pq;
  for (int i = 0; i < T; i++) {
    int ai;
    cin >> ai;
    pq.push(ai);
  }
  
  int ans = 0;
  
  while (pq.size() > 1) {
    int a = pq.top();
    pq.pop();
    int b = pq.top();
    pq.pop();
    if (--a != 0) pq.push(a);
    if (--b != 0) pq.push(b);
  }
  
  if (pq.size() > 0) ans = pq.top() - 1;
  
  cout << ans << endl;

  return 0;  
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    li = []
    for _ in range(n):
        xi, yi, pi = map(int, input().split())
        li.append([xi, yi, pi])
    li.sort(key=lambda x: x[2], reverse=True)
    xx = [[abs(li[j][0]) for j in range(n)] for i in range(2**n)]
    yy = [[abs(li[j][1]) for j in range(n)] for i in range(2**n)]

    for i in range(2**n):
        X = [0]
        rest = []
        for j in range(n):
            if i >> j & 1 == 1:
                X.append(li[j][0])
                xx[i][j] = 0
            else:
                rest.append(j)
        for j in rest:
            res = 10**15
            for k in X:
                res = min(res, abs(li[j][0]-k))
            xx[i][j] = res

    for i in range(2**n):
        Y = [0]
        rest = []
        for j in range(n):
            if i >> j & 1 == 1:
                Y.append(li[j][1])
                yy[i][j] = 0
            else:
                rest.append(j)
        for j in rest:
            res = 10**15
            for k in Y:
                res = min(res, abs(li[j][1]-k))
            yy[i][j] = res

    index_list = [2**q for q in range(n)]
    klist = [10**15]*(n+1)
    klist[n] = 0
    xx=tuple(xx)
    yy=tuple(yy)

    for xyr2 in range(3**(n-1)):
        xyr = xyr2
        k, xopen, yopen = 0, 0, 0
        for index in range(n-1):
            xyr, num = divmod(xyr, 3)
            k += (num+1)//2
            xopen += (num % 2)*index_list[index]
            yopen += (num//2)*index_list[index]
        for app in range(3):
            k2, xopen2, yopen2 = k, xopen, yopen
            k2 += (app+1)//2
            xopen2 += (app % 2)*index_list[n-1]
            yopen2 += (app//2)*index_list[n-1]

            cost = 0
            for w in range(n):
                cost += min(xx[xopen2][w], yy[yopen2][w])*li[w][2]

            klist[k2] = min(klist[k2], cost)

    for g in range(n+1):
        print(klist[g])


if __name__ == '__main__':
    main()

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;

//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//def function
//------------------------------------------


//main
//------------------------------------------

int main(){
  char b;
  cin >> b;

  if(b=='A'){
    cout << "T" << endl;
  }else if(b=='C'){
    cout << "G" << endl;
  }else if(b=='G'){
    cout << "C" << endl;
  }else{
    cout << "A" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }
    // b*d, a*c
    let x = std::cmp::max(a*c, a*d);
    let y = std::cmp::max(b*c, b*d);
    let ans = std::cmp::max(x,y);
    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	string S; cin >> S;

	int ans = 0;

	for (int i = 0;i < S.size();i++){
		if(S[i] == '1') ans++;
	}	

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
string s, t;
bool ans = false;
int main(void){
    // Your code here!
    cin >> s >> t;
    for (ll i = 0; i < s.length(); i++) {
        ll x = 0;
        for (ll j = 0; j < s.length(); j++) {
            if (s[j] != t[(j + i) % s.length()]) x++;
        }
        if (x == 0) ans = true;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    string S, T;
    cin >> N >> S >> T;
    rep(i, N)
    {
        cout << S[i];
        cout << T[i];
    }

    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

using Graph = vector<Vi>;

bool topological_sort(std::vector<int>& res, const Graph& g) {
    const int n = static_cast<int>(g.size());
    res.resize(n);
    int idx = 0;

    int e = 0;
    std::vector<int> indeg(n);
    for (const auto& ch : g) {
        for (const auto& to : ch) {
            ++indeg[to];
            ++e;
        }
    }

    std::stack<int> st;
    for (int i = 0; i < n; ++i) {
        if (indeg[i] == 0) st.push(i);
    }

    while (!st.empty()) {
        int u = st.top();
        st.pop();
        res[idx++] = u;
        for (const auto& to : g[u]) {
            --indeg[to];
            --e;
            if (indeg[to] == 0) st.push(to);
        }
    }

    if (e > 0) {
        res.clear();
        return false;
    }

    return true;
}

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

    int N;
    cin >> N;

    vector<Pii> matches;
    matches.reserve(N * (N - 1) / 2);
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            matches.emplace_back(i, j);
        }
    }

    Graph g(N * (N - 1) / 2);

    int prev_idx;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N - 1; j++) {
            int a;
            cin >> a;
            --a;

            Pii key = make_pair(min(i, a), max(i, a));

            int now_idx = lower_bound(matches.begin(), matches.end(), key) - matches.begin();
            if (j != 0) {
                g[prev_idx].push_back(now_idx);
            }

            prev_idx = now_idx;
        }
    }

    Vi topo;
    topological_sort(topo, g);

    if (topo.size() == 0) {
        cout << -1 << endl;
        return 0;
    }

    Vi match_days(N);
    for (int i = 0; i < N * (N - 1) / 2; i++) {
        int a, b;
        tie(a, b) = matches[topo[i]];
        int s = max(match_days[a], match_days[b]);
        match_days[a] = match_days[b] = s + 1;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans = max(ans, match_days[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35328
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = ReadLine().ToArray();
            var ans = new List<char>();
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != 'B') ans.Add(s[i]);
                else if (ans.Count != 0) ans.RemoveAt(ans.Count - 1);
            }
            for (int i = 0; i < ans.Count; i++)
            {
                Write(ans[i]);
            }
            WriteLine();
          
            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 18252
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

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

class CLowElements {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    vector<int> v(n);
    for (int &e : v)in >> e;

    int mini = 1 << 30;
    int ans = 0;
    for (int e : v) {
      if (e <= mini)ans++;
      mini = min(mini, e);
    }
    out << ans << endl;

  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  CLowElements solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,array[1000],sum=0,tsum=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin>> array[i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            sum=array[i]*array[j];
            tsum+=sum;
        }
    }
    cout << tsum <<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	int t=b+c-a;
	if(t<0)t=0;
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
A -= 1
aans = 0
for i in range(A - (A + 1) % 4 + 1, A + 1):
    aans ^= i
bans = 0
for i in range(B - (B + 1) % 4 + 1, B + 1):
    bans ^= i
print(aans ^ bans)

Measured memory_bytes: 3060
# coding:utf-8
import math
X = int(input())
c = 0
x2 = X%100
for i in range(100000):
  x = 0
  if x2/5 >= 1 :
    x = math.floor(x2/5)
    x2 -= 5*x
  elif x2 / 4 >= 1 :
    x = math.floor(x2/4)
    x2 -= 4*x
  elif x2 / 3 >= 1 :
    x = math.floor(x2/3)
    x2 -= 3*x
  elif x2 / 2 >= 1 :
    x = math.floor(x2/2)
    x2 -= 2*x
  elif x2 / 1 == 1 :
    x = math.floor(x2/1)
    x2 -= 1*x
  c += x
  if x2 == 0:
    break
if X > c*100:
  print("1")
else :
  print("0")

Measured memory_bytes: 3064
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	int sum = a + b + c;

	if (sum >= 22) {
		cout << "bust";
	}
	else {
		cout << "win";
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };


int main() {
	int N;
	scanf("%d", &N);
	int S[105];
	for (int i = 0; i < N; i++) {
		scanf("%d", &S[i]);
		if (i > 0)S[i] += S[i - 1];
	}

	int ans = c_INF;

	for (int i = 0; i < N; i++)ans = min(ans, abs(S[N - 1] - 2*S[i]));

	printf("%d", ans);

}

/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
S = input()
a = []
r_ = 0 
l_ = 0
flag = 0
for i in range(len(S)):
    if flag == 0:
        if S[i]=="R":
            r_ = r_ +1
            continue
        elif i != len(S) -1:
            flag = 1
            l_ = l_ +1
            continue
        else:
            l_ = l_ +1
            al = l_ + r_
            a.append([al,r_])
            continue
            
    if flag == 1:
        if S[i] == "L"   :
            l_ = l_ +1
        else:
            al = l_ + r_
            a.append([al,r_])
            r_ = 1
            l_ = 0 
            flag = 0
        if i == len(S) -1:
            al = l_ + r_
            a.append([al,r_])
 

ans = []
for i in range(len(a)):
    n = a[i][0]
    r = a[i][1]
    odd = n // 2
    eve = n - odd
    for j in range(r -1):
        ans.append(0)
    if r // 2 != r/2:
        ans.append(eve)
        ans.append(odd)
    else:
        ans.append(odd)
        ans.append(eve)
    for j in range(n -r -1):
        ans.append(0)
print(*ans)
    
            

    

Measured memory_bytes: 11436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {

    //dice????????????????????????????????????
    dice dice = new dice();

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    //??¢?????°?????\???(num[1]???????????????1)
    String num[] = br.readLine().split("[\\s]+");
    for (int i = 0; i < num.length; i++) {
      dice.diceNum[i + 1] = Integer.parseInt(num[i]);
    }

    //??¢?????¶?????????????????????
    int diceCopy[] = new int[dice.diceNum.length];
    System.arraycopy(dice.diceNum, 0, diceCopy, 0, diceCopy.length);

    //??????????????°??\???
    int questNum = Integer.parseInt(br.readLine());

    for (int i = 0; i < questNum; i++) {
      //?????????????????\???
      String quest[] = br.readLine().split("[\\s]+");
      int syoumen = Integer.parseInt(quest[0]);
      int temae = Integer.parseInt(quest[1]);

      //N???????????¢??????
      for (int j = 0; j < 3; j++) {
        //???????????°?????¨??£??¢???????????°?????????
        if (syoumen == dice.diceNum[1]) {
          break;
        }
        dice.oderN();
      }

      //W???????????¢??????
      for (int j = 0; j < 3; j++) {
        //???????????°?????¨??£??¢???????????°?????????
        if (syoumen == dice.diceNum[1]) {
          break;
        }
        dice.oderW();
      }
      //??£??¢?????°????¢????

      //?°´??????????????????
      for (int j = 0; j < 3; j++) {
        //???????????°?????¨?????¢???????????°?????????
        if (temae == dice.diceNum[2]) {
          break;
        }
        dice.oderRoll();
      }
      //?????¢?????°????¢????

      //?????¶????????´??¢?????°????????????
      System.out.println(dice.diceNum[3]);
    }

  }

}

class dice {
  //??????????????¢?????????0???6,0???????????????
  int diceNum[] = new int[7];
  //????????¨?????°
  int stoc;

  //N???????????¢??????
  public void oderN() {
    //1?????¢?????°????????????
    stoc = diceNum[1];
    //1????????£?????¢???2?????????
    diceNum[1] = diceNum[2];
    //2????????£?????¢???6?????????
    diceNum[2] = diceNum[6];
    //6????????£?????¢???5?????????
    diceNum[6] = diceNum[5];
    //5????????£?????¢???1?????????
    diceNum[5] = stoc;

  }

  //W???????????¢??????
  public void oderW() {

    stoc = diceNum[1];
    diceNum[1] = diceNum[3];
    diceNum[3] = diceNum[6];
    diceNum[6] = diceNum[4];
    diceNum[4] = stoc;

  }

  //?°´???????¨?????????§90?°?????¢
  public void oderRoll() {
    stoc = diceNum[2];
    diceNum[2] = diceNum[3];
    diceNum[3] = diceNum[5];
    diceNum[5] = diceNum[4];
    diceNum[4] = stoc;

  }

}

Measured memory_bytes: 24640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

#define MAX 3000000 
char s[MAX + 10];
int wSum[MAX + 10];
int eSum[MAX + 10];

int dp[45];

int fibo(int n) {
	if (n == 0 || n == 1) 
		return dp[n] = 1;
	if (dp[n] != -1)
		return dp[n];
	return dp[n] = fibo(n - 2) + fibo(n - 1);
}

signed main() {
	ios::sync_with_stdio(false);
	int i, n;
	cin >> n;
	rep(i, 45) dp[i] = -1;
	cout << fibo(n) << "\n";
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<int> b(n);
    rep(i,n) {
        if (i%2==0) b[n/2+i/2]=a[i];
        else b[n/2-1-i/2]=a[i];
    }
    if (n%2==1) reverse(b.begin(),b.end());
    rep(i,n) cout << b[i] << ' ';
    cout << endl;
    
    
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef long long lint;

char a[100005];
char b[100005];
int cnt[100005];
int cnt2[100005];
int n, m;

int main(){
scanf("%s %s", a+1, b+1);
	n = strlen(a+1);
	m = strlen(b+1);
	for(int i=1; i<=n; i++){
		if(a[i] == 'A') cnt[i] = 1;
		else cnt[i] = 2;
		cnt[i] += cnt[i-1];
	}
	for(int i=1; i<=m; i++){
		if(b[i] == 'A') cnt2[i] = 1;
		else cnt2[i] = 2;
		cnt2[i] += cnt2[i-1];
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int sx, ex, sy, ey;
		scanf("%d %d %d %d",&sx,&ex,&sy,&ey);
		int p1 = (cnt[ex] - cnt[sx-1]) % 3;
		int p2 = (cnt2[ey] - cnt2[sy-1]) % 3;
		if(p1 != p2) puts("NO"); else puts("YES");
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

  int n; cin >> n;
  int a[1+n];
  for(int i=1; i<=n; i++) cin >> a[i], a[i] -= i;
  sort(a+1, a+1+n);
  int mid = (n+1) / 2;
  ll ans = 0;
  for(int i=1; i<=n; i++) {
    ans += abs(a[i] - a[mid]);
  }
  cout << ans << endl;

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 1024
n,m,*a=map(int,open(0).read().split())
c=(0,2,5,5,4,5,6,3,7,6)
d=[0]+[-1]*n*9
for i in range(n):
 for j in a:
  if d[i]+1:d[i+c[j]]=max(d[i+c[j]],d[i]*10+j)
print(d[n])

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(100000,0);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[x]++;
	}
	int ans = 0;
	for (int i = 1; i < 99999; i++) {
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
	}
	cout << ans << endl;
}

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


#----------
N,M = list(map(int, input().rstrip().split()))
roads = [list(map(int, input().rstrip().split())) for _ in range(M)]
#----------
city_road = { str(i):0 for i in range(1,N+1)}

for a,b in roads:
    city_road[str(a)] += 1
    city_road[str(b)] += 1

for i in range(1,N+1):
    print(city_road[str(i)])


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
const int mod = 1e9+7;
int main() {
    int H,W;
    cin>>H>>W;
    vector<string> a(H);
    for(auto &e:a) cin>>e;
    int up[H][W],down[H][W],left[H][W],right[H][W];
    for(int c=0;c<W;c++) {
        for(int r=0;r<H;r++) {
            if(a[r][c]=='#')
                up[r][c] = 0;
            else if (r==0) up[r][c] = 1;
            else up[r][c] = up[r-1][c] + 1;
            
            if (a[H-1-r][c]=='#')
                down[H-1-r][c] = 0;
            else if (r==0) down[H-1-r][c] = 1;
            else down[H-1-r][c] = down[H-r][c] + 1;
        }
    }
    for(int r=0;r<H;r++) {
        for(int c=0;c<W;c++) {
            if(a[r][c]=='#')
                left[r][c] = 0;
            else if (c==0) left[r][c] = 1;
            else left[r][c] = left[r][c-1] + 1;
            if (a[r][W-1-c]=='#')
                right[r][W-1-c] = 0;
            else if (c==0) right[r][W-1-c] = 1;
            else right[r][W-1-c] = right[r][W-c] + 1;
        }
    }
    int ans = 0;
    for(int r=0;r<H;r++)
        for(int c=0;c<W;c++)
            ans = max(ans,up[r][c]+down[r][c]+left[r][c]+right[r][c]-3);
    cout<<ans<<'\n';
}

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

#define ll                  long long int
#define new1(n)             ll  n;cin>>n;
#define new2(n,k)           ll  n,k;cin>>n>>k;
#define new3(a,b,c)         ll a,b,c;cin>>a>>b>>c;
#define new4(a,b,c,d)       ll  a,b,c,d;cin>>a>>b>>c>>d;
#define fl(n,i)             for(ll  i=0;i<n;i++)
#define revfl(n)            for(ll i=n-1;i>=0;i--)
#define getMax(a,n)         *max_element(a,a+n);
#define getMin(a,n)         *min_element(a,a+n);
#define lb(a,n,v)           lower_bound(a,a+n,v)-a;
#define ub(a,n,v)           upper_bound(a,a+n,v)-a;
#define rsort(a,n)          sort(a,a+n,greater<long long int >());
#define fast                ios_base::sync_with_stdio(false);cin.tie(NULL);
#define takeA(a,n)          ll  a[n];fl(n,i)cin>>a[i];
#define takeV(c,n)          vector<ll>c;fl(n,i){new1(x);c.push_back(x);}
#define printA(a,n)         fl(n)cout<<a[i]<<" ";
#define printV(v,n)         fl(n)cout<<v[i]<<" ";
#define pair(a,b)           make_pair(a,b)
#define union(a,b,un)       set_union(a.begin(),a.end(),b.begin(),b.end(),insert_iterator<set<int> >(un,un.begin()));
#define intersec(a,b,in)    set_intersection(a.begin(),a.end(),b.begin(),b.end(),insert_iterator<set<int> >(in,in.begin()));
#define mod                 1000000007
#define checkk              cout<<"Yes "
#define test                ll t;cin>>t;while(t--)
#define all(v)              v.begin(),v.end() 

ll arr[100005];
ll n,k,z=0;
ll matrix[100005];

ll func(ll index)
{
    if(index==0) return 0;
    ll minim=LLONG_MAX;
    for(ll i=index-1;i>=max(index-k,z);i--)
    {
        if(matrix[i]==-1)
        matrix[i]=func(i);
        minim=min(minim,matrix[i]+abs(arr[index]-arr[i]));
    }
    return minim;
}

int main()  
{  
    fast;
    memset(matrix,-1,sizeof(matrix));
    cin>>n>>k;
    fl(n,i) cin>>arr[i];
    cout<<func(n-1);
    return 0; 
}


Measured memory_bytes: 9856
#include <iostream>

int main(void){
  int time;
  std::cin >> time;
  int second,minute;
  second = time % 60;
  time /= 60;
  minute = time % 60;
  time /= 60;
  std::cout << time << ':' << minute << ':' << second << '\n';
  return 0;
}


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

int solve() {
    int n, k;
    cin >> n >> k;
    priority_queue<int, vector<int>, greater<int> > que;
    int pre;
    cin >> pre;
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        que.push(x - pre);
        pre = x;
    }
    int sum = 0;
    while (que.size() >= k) {
        sum += que.top();
        que.pop();
    }
    return sum;
}

int main() {
    int t;
    for (cin >> t; t; t--) {
        cout << solve() << endl;;
    }
    return 0;
}

Measured memory_bytes: 1864
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
  int n;
  char c;
  set<char> S;
  cin >> n;
  rep(i,n){
    cin >> c;
    S.insert(c);
  }
  if(3 == S.size()) cout << "Three" << endl;
  else cout << "Four" << endl;

  return 0;
}


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

#define ll long long
#define db double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ino freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

#define fr(i,n) for(i=0;i<n;i++)
#define frs(i,a,n) for(i=a;i<n;i++)
#define frv(i,n) for(i=n-1;i>=0;i--)

#define ne cout<<"\n";
#define cas(i) cout<<"Case #"<<i<<": "

#define vi vector <int>
#define vpi vector <pair <int,int> >
#define vpin(v,a,b) v.push_back(make_pair(a,b))
#define vsort(v) sort(v.begin(),v.end());
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))

#define todegree(rad) rad*(180.0/pi)
#define isnttriangle(a,b,c) (a+b<c||a+c<b||b+c<a)
#define pi acos(-1)
#define siz 1000


int main()
{
    int N,a,b,c;
    db k,m,num;
    cin>>N;
    num=N*1.0;
    bool ok=false;
    a=floor(num/1.08);
    if(floor(a*1.08)==N)
    {
        ok=true;
        cout<<a<<"\n";
    }
    a=ceil(num/1.08);
    if(floor(a*1.08)==N)
    {
        if(!ok)
        cout<<a<<"\n";
        ok=true;
    }
    if(!ok) cout<<":(\n";

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	while (cin >> s) {
		cin >> t;
		int n = s.size(), m = t.size();
		vvi table(n, vi(m, 0));
		REP(i, n) {
			if (s[i] == t[0])table[i][0] = 1;
		}
		REP(i, m) {
			if (s[0] == t[i])table[0][i] = 1;
		}
		REP(i, n - 1) {
			REP(j, m - 1) {
				if (s[i + 1] == t[j + 1])table[i + 1][j + 1] = table[i][j] + 1;
				else table[i + 1][j + 1] = 0;
			}
		}
		int ans = -INF;
		REP(i, n) {
			REP(j, m) {
				ans = max(ans, table[i][j]);
			}
		}
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 65544
#include <iostream>
using namespace std;
int main() {
  int N; cin >> N;
  int H, W; cin >> H >> W;
  int res = 0;
  for (int i = 0; i < N; ++i) {
    int h, w; cin >> h >> w;
    if (h >= H && w >= W) ++res;
  }
  cout << res <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
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;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//************************************************************************//

struct Dijkstra
{
	//距離の型を決めよう！！！！！！！！！！！！！
	typedef ll dType;
	dType inf = 1e18;

	typedef pair<dType, int> P;
	struct edge{int to; dType cost;};

	//始点からの距離
	vector <dType> dis;
	//隣接リスト
	vector <vector <edge>> adj;

	Dijkstra(int N) : dis(N, INFL), adj(N){}

	void add_edge(int s, int t, dType cost, bool isdirected = 0)
	{
		adj[s].pb((edge{t, cost}));
		if (!isdirected)
		{
			adj[t].pb((edge{s, cost}));
		}
	}

	void calc(int s)
	{
		fill(all(dis), inf);
		dis[s] = 0;
		priority_queue<P, vector<P>, greater<P>> q;

		q.push(P(0, s));

		while(!q.empty())
		{
			P p = q.top(); q.pop();
			int now = p.snd;
			if (dis[now] < p.fst)
			{
				continue;
			}
			for (edge e : adj[now])
			{
				if (dis[e.to] > dis[now] + e.cost)
				{
					dis[e.to] = dis[now] + e.cost;
					q.push(P(dis[e.to], e.to));
				}
			}
		}
	}

};



//************************************************************************//

//aoj 単一始点最短経路
void solve(void){

	int V, E, r;
	cin >> V >> E >> r;

	Dijkstra dijkstra(V);

	while(E--)
	{
		int s, g; ll c;
		cin >> s >> g >> c;
		dijkstra.add_edge(s, g, c, 1);
	}
	dijkstra.calc(r);
	rep(V, i)
	{
		ll dis = dijkstra.dis[i];
		if (dis == dijkstra.inf)
		{
			cout << "INF" << endl;
		}
		else
		{
			cout << dis << endl;
		}
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 19416
import java.util.Scanner; 
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
        int h = S/3600;
        int m = (S-3600*h)/60;
        int s = S-3600*h-60*m;
        System.out.println( h + ":" + m + ":" + s );
		sc.close();

	}

}



Measured memory_bytes: 26352
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int N,Q;
	cin >> N >> Q;
	vector<int> year(N+1);
	vector<string> name(N+1);
	name[0]="kogakubu10gokan";
	REP(i,1,N+1) cin >> year[i] >> name[i];
	REP(i,0,N+1) if(year[i]<=Q&&(i+1==N+1||Q<year[i+1])){
		cout << name[i] << endl;
		break;
	}
}

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

Measured memory_bytes: 1204
#include<cstdio>
int main(){
    int n,a;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if(a%2==1){
            printf("first");
            return 0;
        }
    }
    printf("second");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

A = [a[0]]
for i in range(1,n):
    A.append(A[i-1] + a[i])

t = A[-1]
ans = float('inf')
for i in A[0:n-1]:
    ans = min(abs(i - (t-i)), ans)

print(ans)


Measured memory_bytes: 102860
import collections
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
query = []
for _ in range(Q):
    query.append(tuple(map(int, input().split())))

dict_A = collections.Counter(A)
# print(dict_A)
ans = sum(A)
for i in range(Q):
    if query[i][0] in dict_A.keys():
        val = dict_A.pop(query[i][0])
        if query[i][1] in dict_A.keys():
            dict_A[query[i][1]] += val
        else:
            dict_A[query[i][1]] = val
        ans = ans - (val*query[i][0]) + (val*query[i][1])
    print(ans)


Measured memory_bytes: 32644