akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

vector<pair<size_t, size_t>>
count(const string & str)
{
  const auto size = str.size();
  vector<pair<size_t, size_t>> out(size);
  for(size_t i = 0; i < size; ++ i)
    (str[i] == 'A' ? out[i].first : out[i].second) = 1;

  for(size_t i = 1; i < size; ++i)
  {
    out[i].first += out[i - 1].first;
    out[i].second += out[i - 1].second;
  }

  return out;
}

inline int
parity(const size_t i, const size_t j,
       const vector<pair<size_t, size_t>> & a)
{
  const int x = a[j].first - (i ? a[i - 1].first : 0);
  const int y = a[j].second - (i ? a[i - 1].second : 0);
  return (((x % 3) + 3 - (y % 3)) % 3 + 3) % 3;
}

void arc071c()
{
  string s, t;
  size_t n;
  cin >> s >> t >> n;

  const auto a = count(s);
  const auto b = count(t);

  for(size_t i = 0; i < n; ++i)
  {
    array<size_t, 4> q;
    cin >> q;
    --q[0]; --q[1];
    --q[2]; --q[3];

    const auto fail = parity(q[0], q[1], a) != parity(q[2], q[3], b);
    cout << (fail ? "NO" : "YES") << '\n';
  }
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  arc071c();

  return EXIT_SUCCESS;
}



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

int main() {

    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n){
        rep(j, d){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i<n-1; ++i){
        for(int j=i+1; j<n; ++j){
            int sum = 0;
            rep(k, d){
                sum += pow(abs(x[i][k]-x[j][k]), 2);
            }
            
            for(int s=1; s*s<=sum; ++s){
                if(s*s == sum){
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}

const int K = 5000;

int sqrt5(int n) {
    int l = -K, r = K;
    while (r - l > 1) {
        int c = l + ((r - l) >> 1);
        if (c * c * c * c * c > n) {
            r = c;
        } else {
            l = c;
        }
    }
    return l;
}

void run() {
    int x;
    cin >> x;
    for (int b = -K; b <= K; ++b) {
        int a = sqrt5(x + b * b * b * b * b);
        if (a * a * a * a * a - b * b * b * b * b == x) {
            cout << a << " " << b << endl;
            return;
        }
    }
    assert(false);
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>l(n);
    for(int i=0;i<n;i++)
    {
        cin>>l[i];
    }
    int count=0;
    sort(l.begin(),l.end());
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(l[i]+l[j]>l[k]&&l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){
                    count++;
                }
            }

        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3624
// AtCoder Templete
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define FOR(i,a) for(auto i:a)
#define pub push_back
#define pob pop_buck
#define all(in) in.begin(),in.end()

using ll = long long; // typedef long long ll; と同意
using ull = unsigned long long;
using namespace std;

int main(){
  ll a,aa,b,bb;
  cin >> a >> aa;
  cin >> b >> bb;
  ll t; cin >> t;
  if(abs(a-b) <= (aa-bb)*t) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
char arr[100];
char aki[100] = "AKIHABARA";
int akiptr = 0;
int main() {
	scanf("%s", arr);
	int len = strlen(arr);
	for (int i = 0; i < len; ++i) {
		if (arr[i] == aki[akiptr]) {
			akiptr++;
		}
		else if (aki[akiptr] == 'A') {
			--i, akiptr++;
		}
		else {
			printf("NO");
			return 0;
		}
		if (i == len - 1 && akiptr>7) {
			printf("YES");
			return 0;
		}
	}
	printf("NO");
}

Measured memory_bytes: 128
require 'prime'

def comb(n, r)
  r = [r, n - r].min
  return 1 if r == 0

  (n - r + 1).upto(n).inject(:*) / 1.upto(r).inject(:*)
end

n = gets.to_i
h = Hash.new(0)

2.upto(n) do |i|
  i.prime_division.each { |p, e| h[p] += e }
end

ans = h.count { |_k, v| 74 <= v }

x = h.count { |_k, v| 24 <= v }
y = h.count { |_k, v| 2 <= v && v < 24 }
ans += x * (x - 1) + x * y

x = h.count { |_k, v| 14 <= v }
y = h.count { |_k, v| 4 <= v && v < 14 }
ans += x * (x - 1) + x * y

x = h.count { |_k, v| 4 <= v }
y = h.count { |_k, v| 2 <= v && v < 4 }

if x >= 3
  ans += comb(x, 3) * 3 + comb(x, 2) * y
else
  ans += x == 2 ? y : 0
end

puts ans


Measured memory_bytes: 14460
package main

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

type light struct {
	k  int
	sl []bool
	p  int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())

	l := make([]light, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		li := light{k, make([]bool, n), i}
		for j := 0; j < k; j++ {
			sc.Scan()
			s, _ := strconv.Atoi(sc.Text())
			li.sl[s-1] = true
		}
		l[i] = li
	}

	for i := 0; i < m; i++ {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())
		l[i].p = p
	}

	ans := 0
	for i := 0; i < pow(2, n); i++ {
		sl := convsl(i, n)
		for j, li := range l {
			if check(li.sl, sl)%2 != li.p {
				break
			}
			if j == len(l)-1 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

func check(x, y []bool) int {
	c := 0
	for i := range x {
		if x[i] && y[i] {
			c++
		}
	}
	return c
}

func convsl(x, n int) []bool {
	r := make([]bool, n)
	for i := 0; i < n; i++ {
		if x%2 == 1 {
			r[i] = true
		}
		x >>= 1
	}
	return r
}

func pow(x, n int) int {
	ans := 1
	for i := 0; i < n; i++ {
		ans *= x
	}
	return ans
}


Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: 桁和 / Digit Sum
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

typedef long long ll;
const ll LINF = 1LL << 60;

/* typedef */

/* global variables */

/* subroutines */

ll f(ll b, ll n) {
  ll sum = 0;
  while (n > 0) {
    sum += n % b;
    n /= b;
  }
  return sum;
}

/* main */

int main() {
  ll n, s;
  cin >> n >> s;

  if (n < s) {
    puts("-1");
    return 0;
  }

  for (ll b = 2; b * b <= n; b++) {
    //if (b % 10000 == 0) printf("b=%lld\n", b);
    if (f(b, n) == s) {
      //printf("f(%lld, %lld) == %lld\n", b, n, s);
      printf("%lld\n", b);
      return 0;
    }
  }

  // bx+y=n -> (b-1)x=(n-s) -> x=(n-s)/(b-1) (b^2>n,0<=x<b,0<=y<b)
  //  x+y=s
  ll m = n - s;
  if (m == 0) {
    printf("%lld\n", n + 1);
    return 0;
  }

  ll minb = LINF;
  for (ll c0 = 1; c0 * c0 <= m; c0++)
    if (m % c0 == 0) {
      ll c1 = m / c0;

      // b=c1+1,x=c0,y=n-bx=n-(c1+1)c0
      ll b = c1 + 1, x = c0, y = n - b * c0;
      if (x >= 0 && x < b && y >= 0 && y < b && minb > b) minb = b;

      // b=c0+1,x=c1,y=n-bx=n-(c0+1)c1
      b = c0 + 1, x = c1, y = n - b * c1;
      if (x >= 0 && x < b && y >= 0 && y < b && minb > b) minb = b;
    }

  printf("%lld\n", (minb >= LINF) ? -1LL : minb);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int N, M;
	cin >> N >> M;

	int n[50] = { 0 };
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		n[a-1]++;
		n[b-1]++;
	}
	for (int i = 0; i < N; i++) {
		cout << n[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(r,x,y) for(register int r=(x); r<(y); r++)
#ifdef sahdsg
#define DBG(...) printf(__VA_ARGS__)
#else
#define DBG(...) (void)0
#endif
#define EPS 1e-6
using namespace std;
int main() {
	int a,b,c;
	scanf("%d%d%d", &a, &b, &c);
	if(a==b && b==c && c==a) {
		puts("Yes");
	}else puts("No");
	return 0;
}

Measured memory_bytes: 256
(defun f()
  (let* ((line (parse-integer (read-line nil nil))))
    (labels ((rec(i)
               (if (<= i line)
                 (let ((ii (* i 108)))
                   (if (= (* 100 line) (- ii (mod ii 100)))
                     (format t "~A~%" i)
                     (rec (1+ i))))
                 (format t ":(~%" ))))
      (rec 1))))
(compile 'f)
(f)


Measured memory_bytes: 16100
#include<stdio.h>
int a,b,c;
int main()
{
 scanf("%d%d%d",&a,&b,&c);
 if((100*a+10*b+c)%4==0)
 {
  printf("YES\n");
 }
 else
 {
  printf("NO\n");
 }
 return 0;
}

Measured memory_bytes: 128
public class Main {
 
    public static void main(String args[]) throws Exception {
    	for(int i=1;i<10;i++){
    		for(int j=1;j<10;j++){
    	        System.out.println(i+"x"+j+"="+i*j);
    		}
    	}
    return;
    }
}

Measured memory_bytes: 16848
import java.util.*;

class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	int[] hills = new int[10];
	for(int i=0; i<10; i++){
	    hills[i] = sc.nextInt();
	}

	int max = 0;
	int maxi = 0;;
	for(int j=0; j<3; j++){
	    max = 0;
	    for(int i=0; i<10; i++){
		if(hills[i]>max){max = hills[i]; maxi = i;}
	    }
	    System.out.println(max);
	    hills[maxi] = 0;
	}
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int H,W,N;
int a[MAXN],b[MAXN];
int64 ans[MAXN];
map<pii,int> zz;
map<pii,int> cnt;
int dx[9] = {-1,1,0,0,0,1,1,-1,-1};
int dy[9] = {0,0,-1,1,0,1,-1,1,-1};
void Solve() {
    read(H);read(W);read(N);
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);read(b[i]);
	zz[mp(a[i],b[i])] = 1;
    }
    for(int i = 1 ; i <= N ; ++i) {
	for(int k = 0 ; k < 9 ; ++k) {
	    int tx = a[i] + dx[k];
	    int ty = b[i] + dy[k];
	    if(tx > 1 && tx < H && ty > 1 && ty < W) {
		int c = 0;
		for(int h = 0 ; h < 9 ; ++h) {
		    if(zz[mp(tx + dx[h],ty + dy[h])]) ++c;
		}
		cnt[mp(tx,ty)] = c;
	    }
	}
    }
    ans[0] = 1LL * (H - 2) * (W - 2);
    for(auto t : cnt) {
	ans[0]--;
	ans[t.se]++;
    }
    for(int i = 0 ; i <= 9 ; ++i) {
	out(ans[i]);enter;
    }
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 213504
import numpy as np
def abss(x, y):
    return np.abs(np.abs(x) - np.abs(y))
x, y = map(int, input().split())
ans = abss(x, y)
sign_x = np.sign(x)
sign_y = np.sign(y)
if sign_x == sign_y and x > y:
    ans += 2
elif sign_x != sign_y: 
    if sign_x * sign_y == 0:
        if x > y:
            ans += 1
    else:
        ans += 1
print(ans)

Measured memory_bytes: 12508
import sys


def solve(inp):
    N = int(inp.readline().strip())
    P = list(map(int, inp.readline().strip().split(' ')))

    r = 0
    minp = P[0]
    for p in P:
        if minp >= p:
            r += 1
            minp = p

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24744
#include <iostream>
#define MAX 100
#define INF (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;

int M[MAX][MAX],n;
int prim(){
	int u,minv;
	int d[MAX],p[MAX],color[MAX];
	for(int i = 0;i < n;i++){
		d[i] = INF;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while(1){
		minv = INF;
		u = -1;
		for(int i = 0;i < n;i++){
			if(minv > d[i] && color[i] != BLACK){
				u = i;
				minv = d[i];
			}
		}
		if(u == -1)break;
		color[u] = BLACK;
		for(int v = 0;v < n;v++){
			if(color[v] != BLACK && M[u][v] != INF){
				if(d[v] > M[u][v]){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for(int i = 0;i < n;i++){
		if(p[i] != -1)sum += M[i][p[i]];
	}

	return sum;

}


int main(){
	int e;
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			cin >> e;
			if(e == -1)M[i][j] = INF;
			else M[i][j] = e;
		}
	}

	cout << prim() <<endl;
	return 0;
}

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

string base = "YAKI";
string s;

int main()
{
    cin >> s;
    s = s.substr(0,4);
    if(base == s)
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N,M = (int(i) for i in input().split())  

x = [0] * N
result = [0] * N

ans = 0
wa = 0

for i in range(M):
    p, S = input().split()
    if (result[int(p) - 1] == 0) and (S == "WA"):
        x[int(p)-1] += 1
    if (result[int(p) - 1] == 0) and (S == "AC"):
        result[int(p)-1] = 1

ans = sum(result)

wa = 0
for i in range(N):
    if result[i] == 1:
        wa += x[i]

print(ans, wa)

Measured memory_bytes: 46624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long a = x / 11;
        a *= 2;
        long b =  x % 11;
        if (b > 6) {
            a += 2;
        } else if (b <= 6 && b > 0) {
            a += 1;
        }
        System.out.println(a);
    }

}

Measured memory_bytes: 22996
import java.util.Scanner;
import java.io.*;


class Main {
	public static void main(String args[]) {
	    Scanner sc = new Scanner(System.in);
	    int i = 1;
	    while( true ){
	    	String s = sc.next();
	    	int x = Integer.parseInt(s);
	    	if( x == 0 ){
	    		break;
	    	}
	    	System.out.println("Case " + i + ": " + x );
	    	i++;
	    }
	}
}

Measured memory_bytes: 29512
def create_equ(eq, index):
    global L
    if index == 4:
        L.append(eq)
    else:
        create_equ(eq + "+" + S[index], index + 1)
        create_equ(eq + "-" + S[index], index + 1)


if __name__ == "__main__":
    S = list(input())
    index = 1
    eq = S[0]
    L = []
    create_equ(eq, index)
    for l in L:
        if eval(l) == 7:
            print(l + '=7')
            break


Measured memory_bytes: 3060
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<b)swap(a,b);
	if(a<c)swap(a,c);
	if(b<c)swap(b,c);
	//a>b>c
	printf("%d",a-b+(b-c)/2+(b-c&1?2:0));
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  ll A, B; scanf("%lld %lld", &A, &B);
  vector<int> H(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &H[i]);
  }

  sort(H.begin(), H.end(), greater<int>());
  int low = 0, high = INF;
  int diff = A - B;
  while (high - low > 1) {
    int mid = (high + low) / 2, cnt = 0;
    bool ok = true;
    for (int i = 0; i < N; ++i) {
      ll val = H[i] - B * mid;
      if (val <= 0) { continue; }
      cnt += (val + diff - 1) / diff;
      if (cnt > mid) {
        ok = false;
        break;
      }
    }
    if (ok) { high = mid; }
    else { low = mid; }
  }
  int ans = high;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

vvi g;
vector<bool> visited;
void dfs(int v,int k,vi &d){
    if(visited[v])return;
    visited[v]=true;
    d[v]=k;
    for(int u:g[v])dfs(u,k+1,d);
}

void run(){
    int n,u,v;
    cin>>n>>u>>v;
    g=vvi(n);
    u--,v--;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].eb(b);
        g[b].eb(a);
    }
    vi dt(n),da(n);
    visited=vector<bool>(n);
    dfs(u,0,dt);
    visited=vector<bool>(n);
    dfs(v,0,da);
    int ans=0;
    rep(i,n){
        if(dt[i]<da[i]&&ans<da[i])ans=da[i];
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 11392
import java.util.Scanner;

public class Main {
	private static int n, m;
	private static int[] a, b;
	
	public static void main(String[] args) {
		inputData();
		solve();
	}
	
	private static void inputData() {
		try (Scanner scan = new Scanner(System.in)) {
			n = scan.nextInt();
			a = new int[n];
			for(int i=0; i<n; i++) a[i] = scan.nextInt();
			m = scan.nextInt();
			b = new int[m];
			for(int i=0; i<m; i++) b[i] = scan.nextInt();
		}
	}
	
	private static void solve() {
		for(int i=0; i<m; i++) {
			if(serchNumber(0, b[i])) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}
	
	private static boolean serchNumber(int i, int m) {
		if(m == 0) return true;
		if(m < 0) return false;
		if(i == n) return false;
		if(serchNumber(i+1, m)) return true;
		if(serchNumber(i+1, m-a[i])) return true;
		return false;
	}
}



Measured memory_bytes: 26900
#include <stdio.h>
#include <algorithm>
#include <functional>

int W[10], K[10];

int main(void) {
	for (int i = 0; i < 10; ++i) { scanf("%d", &W[i]); }
	for (int i = 0; i < 10; ++i) { scanf("%d", &K[i]); }

	std::sort(W, W + 10, std::greater<int>());
	std::sort(K, K + 10, std::greater<int>());

	printf("%d %d\n", W[0] + W[1] + W[2], K[0] + K[1] + K[2]);
	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int a,b;cin >> a >> b;
   int ans = 0;
   ans += max(a,b);
   if(max(a,b) == a){
      a--;
   }else{
      b--;
   }
   ans+=max(a,b);
   cout << ans << endl;
   return 0;
}

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

using namespace std;

#define ld long double
#define ll long long int
#define endl '\n'
#define check_time() cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define maxarr(A,n) *max_element(A,A+n) 
#define minarr(A,n) *min_element(A,A+n);
#define ft first
#define sd second
#define all(v) (v.begin(),v.end())
#define vll vector<ll> 
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define pb push_back
#define show(x) cout<<#x<<" "<<x<<endl;

void solve()
{
	ll n,i;
	cin>>n;
	ll mo=n%10;
	if(mo==2 || mo==4 ||mo==5|| mo==7||mo==9)
		cout<<"hon"<<endl;
	else if(mo==0||mo==6||mo==8||mo==1)
		cout<<"pon"<<endl;
	else if(mo==3)
		cout<<"bon"<<endl;
}

int main()
{
	fastio();

	ll T=1;	//cin>>T;
	while(T--) solve();
	
	//check_time();
	return 0;   
}   



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

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


    int ans = (n-1)/(k-1);
    if((n-1)%(k-1)!=0) ans ++;
    cout << ans << endl;
}

Measured memory_bytes: 3644
n, m = map(int, input().split())
pair = [i for i in range(n + 1)]
def find(x):
    if pair[x] == x:
        return x
    else:
        pair[x] = find(pair[x]) 
        return pair[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    pair[x] = y
    
for i in range(m):
    a, b = map(int, input().split())
    unite(a,b)


ans = 0
for i, k in enumerate(pair[1:], 1):
    if i == k:
        ans += 1
    
print(ans - 1)



Measured memory_bytes: 13568
/**
 *      ABC 109 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-08 21:02:26
**/

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

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

    string W[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> W[i];
    }

    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (W[i] == W[j]){
                cout << "No" << endl; return 0;
            }            
        }        
    }

    for (int i = 0; i < N - 1; ++i) {
        int size = W[i].size();
        if (W[i][size - 1] != W[i + 1][0]){
            cout << "No" << endl; return 0;
        }        
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#include <unordered_map>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007 
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
using namespace std;
vector<int> vertexs[2000];
vector<string> mapping;
int dp[2000] = {};
int validation(int a, int b) {
	int x[8] = { 1,1,1,0,0,-1,-1,-1 };
	int y[8] = { 1,0,-1,1,-1,1,0,-1 };
	for (int i = 0; i < 8; ++i) {
		if(x[i]+a >= 0&&x[i]+a < mapping.size()&&y[i]+b >= 0&&y[i]+b < mapping[0].size()&&mapping[x[i] + a][y[i] + b] >= 'A'&&mapping[x[i] + a][y[i] + b] <= 'Z') return 1;
	}
	return 0;
}
int main() {
	REP(i, 2000) {
		dp[i] = 1000;
	}
	int h, w;
	cin >> h >> w;
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < h; ++i) {
		string s;
		cin >> s;
		mapping.push_back(s);
	}
	for (int i = 0; i < h; ++i) {
		int backing = -1;
		for (int q = 0; q < w; ++q) {
			if (mapping[i][q] == '.'||mapping[i][q] == '|') {
				backing = -1;
			}
			else if (mapping[i][q] >= 'A'&&mapping[i][q] <= 'Z') {
				int next = mapping[i][q] - 'A';
				if (backing != -1) {
					vertexs[backing].push_back(next);
					vertexs[next].push_back(backing);
				}
				backing = next;
			}
		}
	}
	for (int q = 0; q < w; ++q) {
		int backing = -1;
		for (int i = 0; i < h; ++i) {
			if (mapping[i][q] == '.' || mapping[i][q] == '-') {
				backing = -1;
			}
			else if (mapping[i][q] >= 'A'&&mapping[i][q] <= 'Z') {
				int next = mapping[i][q] - 'A';
				if (backing != -1) {
					vertexs[backing].push_back(next);
					vertexs[next].push_back(backing);
				}
				backing = next;
			}
		}
	}
	queue<int> nexting;
	nexting.push(a[0] - 'A');
	dp[nexting.front()] = 0;
	while (nexting.empty() == false) {
		int hoge = nexting.front();
		nexting.pop();
		for (int i = 0; i < vertexs[hoge].size(); ++i) {
			if (dp[vertexs[hoge][i]] > dp[hoge] + 1) {
				dp[vertexs[hoge][i]] = dp[hoge] + 1;
				nexting.push(vertexs[hoge][i]);
			}
		}
	}
	cout << dp[b[0] - 'A'] << endl;
	return 0;
}


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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n; cin >> n;
    rep(i, 1 << n) {
        cout << i << ":";
        int c = 0;
        int j = i;
        while (j) {
            if (j & 1) cout << " " << c;
            c++; j >>= 1;
        }
        cout << endl;
    }
}


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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long a,b;
	cin >> a >> b;
	long long ans = a*b - (a+b-1);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


bool lucky7(int n) {
  for(; n > 0; n = n / 10) {
    if(n % 10 == 7) {
      return true;
    }
  }

  return false;
}

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

  if(lucky7(N)) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include <algorithm>

using namespace std;

int root(int *B, int i)
{
	if (B[i]==i)
		return i;
	B[i] = root(B,B[i]);
	return B[i];

}

int main()
{
	std::ios::sync_with_stdio(false);
	int A[100000], B[100000], s[100000], N, M;
	cin>>N>>M;
	for(int i=0; i<N; i++)
	{
		cin>>A[i];
		A[i]--;
		B[i] = i;
		s[i] = 1;
	}
	for(int i=0; i<M; i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		int rx = root(B,x);
		int ry = root(B,y);
		if(rx!=ry)
		{
			if(s[rx]>s[ry])
			{
				B[ry]=rx;
				s[rx]+=s[ry];
			}
			else
			{
				B[rx]=ry;
				s[ry]+=s[rx];
			}
		}
	}
	int count = 0;
	for(int i=0; i<N; i++)
		if(root(B,i)==root(B,A[i]))
			count++;
	
		
	cout<<count<<endl;
		
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=20010,M=2000010,NN=80010;
struct position{
	int pos,id;
}pt[N];
struct node{
	int f;
}tree[NN];
struct edge{
	int y,next;
}data[M];
int n,l,r,num,num1,num2,top,sta[NN],h[NN],dfn[NN],low[NN],arc[NN];
bool vis[NN],insta[NN];
inline int read(){
	int x=0,f=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f?-x:x;
}
inline void add(int x,int y){
	data[++num].y=y;data[num].next=h[x];h[x]=num;
}
bool cmp(position i,position j){
	return i.pos<j.pos;
}
inline int get_front(int pos,int a,int b){
	while(a<=b){
		int mid=(a+b)>>1;
		if(pt[mid].pos<pos)a=mid+1;
		else b=mid-1;
	}
	return a;
}
inline int get_back(int pos,int a,int b){
	while(a<=b){
		int mid=(a+b)>>1;
		if(pt[mid].pos>pos)b=mid-1;
		else a=mid+1;
	}
	return b;
}
void build(int p,int a,int b){
	if(a==b){arc[pt[a-1].id]=p;return;}
	int mid=(a+b)>>1;
	build(p<<1,a,mid);build(p<<1|1,mid+1,b);
	add(p<<1,p);add(p<<1|1,p);
}
void addedge(int p,int pa,int pb,int a,int b,int x){
	if(a<=pa&&pb<=b){add(p,x);return;}
	int mid=(pa+pb)>>1;
	if(a<=mid)addedge(p<<1,pa,mid,a,b,x);
	if(mid<b)addedge(p<<1|1,mid+1,pb,a,b,x);
}
void tarjan(int u){
	sta[++top]=u;
	insta[u]=vis[u]=true;
	dfn[u]=low[u]=++num1;
	for(int i=h[u];i!=-1;i=data[i].next){
		int v=data[i].y;
		if(!dfn[v]){tarjan(v);low[u]=min(low[u],low[v]);}
		else if(insta[v]&&low[u]>dfn[v])low[u]=dfn[v];
	}
	if(dfn[u]==low[u]){
		num2++;
		while(dfn[sta[top]]!=low[sta[top]]){
			tree[sta[top]].f=num2;insta[sta[top--]]=false;
		}
		tree[u].f=num2;insta[sta[top--]]=false;
	}
}
bool two_sat(int x){
	memset(h,-1,sizeof h);num=num1=num2=top=0;
	build(1,1,n+n);
	for(int l1,r1,i=0;i<n+n;i++){
		l1=get_front(pt[i].pos-x+1,0,i-1);
		r1=get_back(pt[i].pos+x-1,i+1,n+n-1);
		if(l1<i)addedge(1,1,n+n,l1+1,i,arc[pt[i].id^1]);
		if(i<r1)addedge(1,1,n+n,i+2,r1+1,arc[pt[i].id^1]);
	}
	memset(dfn,0,sizeof dfn);
	memset(vis,false,sizeof vis);
	for(int i=0;i<n+n;i++)if(!vis[arc[i]])tarjan(arc[i]);
	for(int i=0;i<n;i++)if(tree[arc[i<<1]].f==tree[arc[i<<1|1]].f)return false;
	return true;
}
int main(){
	n=read();
	for(int i=0;i<n;i++){
		pt[i<<1].pos=read();pt[i<<1].id=i<<1;
		pt[i<<1|1].pos=read();pt[i<<1|1].id=i<<1|1;
	}
	sort(pt,pt+n+n,cmp);
	l=0;r=1000000000;
	while(l<=r){
		int mid=(l+r)>>1;
		if(two_sat(mid))l=mid+1;
		else r=mid-1;
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
using namespace std;

int main() {
    int h,n;
    cin >> h >> n;
    int sum = 0;
    rep(i,n) {
        int a;
        cin >> a;
        sum += a;
    }

    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef struct{
    int top,front,right,left,back,bottom;
}Dice;

void roll(char c,Dice* d){
    int tmp;
    switch(c){
        case 'N':
        tmp=d->top;
        d->top=d->front;
        d->front=d->bottom;
        d->bottom=d->back;
        d->back=tmp;
        break;
        case 'S':
        tmp=d->top;
        d->top=d->back;
        d->back=d->bottom;
        d->bottom=d->front;
        d->front=tmp;
        break;
        case 'E':
        tmp=d->top;
        d->top=d->left;
        d->left=d->bottom;
        d->bottom=d->right;
        d->right=tmp;
        break;
        case 'W':
        tmp=d->top;
        d->top=d->right;
        d->right=d->bottom;
        d->bottom=d->left;
        d->left=tmp;
        break;
    }
    return;
}

int main(void){
    int i;

    Dice d1;
    scanf("%d%d%d%d%d%d",&d1.top,&d1.front,&d1.right,&d1.left,&d1.back,&d1.bottom);
    Dice d2;
    scanf("%d%d%d%d%d%d",&d2.top,&d2.front,&d2.right,&d2.left,&d2.back,&d2.bottom);
    
    if(d1.front==d2.top){
        roll('S',&d2);
    }
    else if(d1.front==d2.bottom){
        roll('N',&d2);
    }
    else if(d1.front==d2.right){
        roll('W',&d2);
        roll('S',&d2);
    }
    else if(d1.front==d2.left){
        roll('E',&d2);
        roll('S',&d2);
    }
    else if(d1.front==d2.back){
        roll('S',&d2);
        roll('S',&d2);
    }

    for(i=0;i<4;i++){
        if(d1.top==d2.top&&
        d1.bottom==d2.bottom&&
        d1.right==d2.right&&
        d1.left==d2.left&&
        d1.back==d2.back){
            printf("Yes\n");
            return 0;
        }
        roll('E',&d2);
    }

    printf("No\n");
    
    return 0;
}

Measured memory_bytes: 580
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
struct edge {
	int to, cost;
};
int p[1005], x[1005];
vector<int>G[1005];
int dp[2][1005];
int dp2[2][1005][5005];
int C[2];

int memo(int color, int now) {
	if (dp[color][now] >= 0)return dp[color][now];

	if (G[now].size()) {
		vector<P>V1, V2;
		for (int e : G[now]) {
			//重みF/価値S
			V1.push_back(P(x[e], memo(1, e)));//子が黒い
			V2.push_back(P(memo(0, e), x[e]));//白い
		}

		rep(i, 5005)dp2[color][C[color]][i] = inf;
		dp2[color][C[color]][0] = 0;

		rep(i, V1.size()) {
			int nc = C[color];
			rep(j, x[now] + 1) {
				if (!color) {
					if (j + V1[i].first <= x[now])dp2[0][nc + 1][j + V1[i].first] = min(dp2[0][nc + 1][j + V1[i].first], dp2[0][nc][j] + V1[i].second);
					if (j + V2[i].first <= x[now])dp2[0][nc + 1][j + V2[i].first] = min(dp2[0][nc + 1][j + V2[i].first], dp2[0][nc][j] + V2[i].second);
				}
				else {
					if (j + V1[i].second <= x[now])dp2[1][nc + 1][j + V1[i].second] = min(dp2[1][nc + 1][j + V1[i].second], dp2[1][nc][j] + V1[i].first);
					if (j + V2[i].second <= x[now])dp2[1][nc + 1][j + V2[i].second] = min(dp2[1][nc + 1][j + V2[i].second], dp2[1][nc][j] + V2[i].first);
				}
			}
			C[color]++;
		}
		int mn = inf;
		rep(i, x[now] + 1) {
			mn = min(mn, dp2[color][C[color]][i]);
		}
		return dp[color][now] = mn;
	}
	else {
		return dp[color][now] = 0;
	}
}

signed main() {
	int n; cin >> n;
	rep(i, n - 1) {
		cin >> p[i + 1];
		G[p[i+1]-1].push_back(i+1);
	}
	rep(i, n)cin >> x[i];
	rep(i, 2)rep(j, n)dp[i][j] = -1;
	rep(i, 2)rep(j, n + 1)rep(k, 5003)dp2[i][j][k] = inf;
	int res = min(memo(0, 0), memo(1, 0));
	if (res < inf)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}


Measured memory_bytes: 78976
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1 << 30;
class BiOp {
public:
	P operator()(P a, P b) const {
		return max(a, b);
	}
};

template<typename T, typename BiOp>
struct SegmentTree {
	vector<T> data;
	T e;
	BiOp op;
	int size;
	SegmentTree() {}
	SegmentTree(int n, T e, BiOp op) : e(e), op(op) {
		size = 1;
		while (size < n) size *= 2;
		data.resize(2 * size - 1);
		for (int i = 0; i < 2 * size - 1; i++) data[i] = e;
	}

	void update(int k, T v) {
		k += size - 1;
		data[k] = v;
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}

	T query(int a, int b, int k, int l, int r) const {
		if (b <= l || r <= a) return e;
		if (a <= l && r <= b) return data[k];
		return op(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}

	T query(int a, int b) {
		return query(a, b, 0, 0, size);
	}

	T get(int i) {
		return data[i + size - 1];
	}
};
SegmentTree<P, BiOp> seg[200];
ll B[5000][200];
ll dist[5000];
ll imos[5000][5000];
int N, M;
void solve(int l, int r, int x) {
	P opt = seg[x].query(l, r + 1);
	imos[opt.second][l] += opt.first;
	if (opt.second + 1 < N) imos[opt.second][opt.second + 1] -= opt.first;
	if (r + 1 < N) {
		imos[r + 1][l] -= opt.first;
		imos[r + 1][opt.second + 1] += opt.first;
	}
	if (l < opt.second) solve(l, opt.second - 1, x);
	if (opt.second < r) solve(opt.second + 1, r, x);
}
int main() {
	cin >> N >> M;
	for (int i = 0; i + 1 < N; i++) {
		ll A;
		cin >> A;
		dist[i + 1] = dist[i] + A;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) cin >> B[i][j];
	}
	for (int i = 0; i < M; i++) {
		seg[i] = SegmentTree<P, BiOp>(N, P(0, -1), BiOp());
		for (int j = 0; j < N; j++) {
			seg[i].update(j, P(B[j][i], j));
		}
	}
	for (int i = 0; i < M; i++) solve(0, N - 1, i);
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < N; j++) imos[i][j] += imos[i][j - 1];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < N; j++) imos[j][i] += imos[j - 1][i];
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			ans = max(ans, imos[j][i] - (dist[j] - dist[i]));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 254592
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M;
	int A;
	static int a[MAX], dp[MAX];
	
	dp[0] = 1;
	cin>>N>>M;
	
	for(int i = 0; i < M; i++){
		cin>>A;
		a[A] = 1;
	}
	
	for(int i = 0; i < N; i++){
		dp[i] %= MOD;
		if(!a[i+1]) dp[i+1] += dp[i];
		if(!a[i+2]) dp[i+2] += dp[i];
	}
	
	cout<<dp[N]%MOD<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader fs = new FastReader();
        long x =fs.nextLong();
        long years =0L;
        long principal = 100;
        while(principal <x){

            long interest = principal/100;
            principal += interest;
            years++;
        }
        System.out.println(years);


    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 25340
N = int(input())
P = list(map(int, input().split()))

I = [0] * N
for i in range(N):
    I[P[i]-1] = i

ans = 0
L = [i for i in range(-1, N-1)]
R = [i for i in range(1, N+1)]

for p in range(1,N+1):
    i = I[p-1]

    if R[i] < N:
        L[R[i]] = L[i]
    if L[i] >= 0:
        R[L[i]] = R[i]

    l1 = L[i]
    l2 = L[l1] if l1 >= 0 else -1
    r1 = R[i]
    r2 = R[r1] if r1 < N else N
    ans += p * ((r1-i)*(l1-l2) + (i-l1)*(r2-r1))

print(ans)


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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)

typedef long long ll;

int main(){
 string s; 
  cin >> s;
  bool flag=true;
  rep(i,0,s.size()){
   if(i%2==0 && s[i]=='L') flag=false;
   if(i%2==1 && s[i]=='R') flag=false;
  }
  
  if(flag) cout << "Yes"  << endl;
  
  else cout << "No"  << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int main(void){

  int n;
  n=0;
  scanf("%d",&n);
  int a[n];
  for(int k=0;k<n;k++){
    a[k]=0;
  }
  int i=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int l=a[0];
  int m=INT_MIN;

  for(int j=1;j<n;j++){
       if(m<a[j]-l){
      m=a[j]-l;
    }
    if(l>a[j]){
      l=a[j];
    }
   
    
  }
  printf("%d\n",m);
  return 0;
}


Measured memory_bytes: 2620
#include<iostream>
#include<string>
#include <numeric>
#include <algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int, int> P;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  
  long long sum=0, max=A[0];
  for(int i=1; i<N; i++){
    if(A[i] < max){
      sum += max-A[i]; 
    }else{
      max = A[i];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4624
import math

def conb(x,y):
    if x < y:
        return 0
    else:
        return (math.factorial(x) // math.factorial(x - y)) // math.factorial(y)


n,k = map(int,input().split())

for i in range(1,k + 1):
    print(conb(n - k + 1,i) * conb(k - 1,i - 1) % 1000000007)


Measured memory_bytes: 3316
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		String[] list = {"eraser", "erase", "dreamer", "dream"};
		for(String m : list){
			while(true){
				int index = S.indexOf(m);
				if(index == -1) break;
				S = S.replace(m, "");
			}
		}
		
		System.out.println(S.equals("") ? "YES" : "NO");
	}
}

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

void swap(int& a,int&b)
{
int tmp=a;
a=b;
b=tmp;
}

int main()
{
int a,b,c;
cin >> a >> b >> c;

if(b<a)
swap(a,b);
if(c<b)
swap(b,c);
if(b<a)
swap(a,b);

cout << a << " " << b << " " << c << endl;

return 0;
}

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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;
typedef pair<int,int>           P;
typedef vector<P>               vip; 
typedef vector<int>             vi;
typedef vector<vi>              vvi;






int main (){
    int h,w;
    cin >> h >> w;
    vvi dist(10, vi(10));
    REP(i,10){
        REP(j,10){
            cin >> dist.at(i).at(j);
        }
    }
    REP(k,10){
        REP(i,10){
            REP(j,10){
                dist.at(i).at(j) = min(dist.at(i).at(j), dist.at(i).at(k) + dist.at(k).at(j));
            }
        }
    }
    int total = 0;
    REP(i,h*w){
        int a;
        cin >> a;
        if(a == -1) continue;

        total += dist.at(a).at(1);

    }

    cout << total << endl;

    





    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R')count++;
        else count--;
    }
    cout << (count > 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Author: Deep Chaklasiya
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key




#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,k,t;
    cin>>n>>m;
    int minl=min({n,m});
    int maxl=max({n,m});
    for(int i=0;i<maxl;i++) cout<<minl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll x[55], y[55];

int main() {
    cin >> n;
    rep(i, n) cin >> x[i] >> y[i];

    map<pll, int> m;
    rep(i, n) rep(j, n) {
        if (i == j) continue;
        m[make_pair(x[i] - x[j], y[i] - y[j])]++;
    }

    int ans = n;
    int mi = 0;
    for (auto kv: m) chmax(mi, kv.second);
    cout << ans - mi << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int imap[301][301];

int main(void){

    string base = "E869120";
    string str;
    int n, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> str;
        if (str.size() == base.size() && str == base) {
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3212
n, m = [int(elem) for elem in input().split()]
lst = []
for i in range(0, n):
    a, b = [int(elem) for elem in input().split()]
    lst.append((a, b))
sort_lst = sorted(lst)

cost = 0
j = 0
while m != 0:
    a, b = sort_lst[j]
    if m >= b:
        m -= b
        cost += a * b
        j += 1
    else:
        cost += a * m
        break
print(cost)

Measured memory_bytes: 17736