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

#define ff              first
#define ss              second
#define int              long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fast()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

}
void file(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m)
{
    int res=1;
    a=a%m;
    while(b>0){
        if(b&1){
            res=(res*a)%m;
        }
        a=(a*a)%m;
        b=b>>1;
    }
    return res;
}


int p[1000006];
vi prime;
//int mrp[1000000];
void seive(){
    for(int i=2;i<1000006;i++) {
        if(p[i]){
            prime.pb(i);
            for(int j=i*i;j<=1000006;j=j+i){
                p[j]=0;
            }
        }
    }

}

int dp[1005][1005];



int32_t main()
{
    // memset(prime,0,sizeof(prime));
    //memset(p,1,sizeof(p));   
    //seive();
    //file();
    fast();
    //int mo=1000000007;
    int n,m;
    cin>>n>>m;
    memset(dp,0,sizeof(dp));
    char mat[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>mat[i][j];
        }
    }

    dp[0][0]=1;
    for(int i=1;i<m;i++){
        if(mat[0][i]=='#')
            dp[0][i]=0;
        else
            dp[0][i]=dp[0][i-1];
    }
    for(int i=1;i<n;i++){
        if(mat[i][0]=='#')
            dp[i][0]=0;
        else
            dp[i][0]=dp[i-1][0];
    }

    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(mat[i][j]=='#') dp[i][j]=0;
            else dp[i][j]=((dp[i][j-1]+dp[i-1][j])%mod);
        }
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<m;j++) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }

    cout<<dp[n-1][m-1];





    return 0;
    
    
}



Measured memory_bytes: 12504
#include<iostream>
#include<vector>
using namespace std ;
using vi = vector<int> ;
using vii = vector<vi> ;

int main(){
    int r,c ;
    cin >> r >> c ;
    vii a(r,vi(c)) ;
    for(int i=0;i<r;i++)
    for(int j=0;j<c;j++)
    cin >> a.at(i).at(j) ;
    int sum = 0 ;
    for(auto i:a){
        int cnt = 0 ;
        for(auto j:i){
            cout << j << " " ;
            cnt += j ;
        }
        cout << cnt << endl ;
        sum += cnt ;
    }
    for(int i=0;i<c;i++){
        int cnt = 0 ;
        for(int j=0;j<r;j++) cnt += a.at(j).at(i) ;
        cout << cnt << " " ;
    }
    cout << sum << endl ;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

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

}

Measured memory_bytes: 26424
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
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, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: usize,
        T: [usize; N],
        M: usize,
        PX: [(usize1, usize); M]
    }
    let origin: usize = T.iter().sum();
    for (p, x) in PX {
        println!("{}", origin - T[p] + x);
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#define L 100000

typedef struct a
{
  char name[100];
  int time;
} P;

P p[L];
int h, t, n;

void enq(P x)
{
  p[t] = x;
  t = (t + 1) % L;
}

P deq()
{
  P x = p[h];
  h = (h + 1) % L;
  return x;
}

int min(int a, int b)
{
  if(a > b)
    {
      return b;
    }
  else
    {
      return a;
    }
}

int main()
{
  int el = 0, c, i, q;
  P u;
  scanf("%d %d", &n, &q);
  for(i = 1; i <= n; i++)
    {
      scanf("%s", p[i].name);
      scanf("%d", &p[i].time);
    }
  h = 1; t = n + 1;

  while(h != t)
    {
      u = deq();
      c = min(q, u.time);
      u.time -= c;
      el += c;
      if(u.time > 0)
	{
	  enq(u);
	}
      else
	{
	  printf("%s %d\n", u.name, el);
	}
    }
  return 0;
}



Measured memory_bytes: 11868
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    cin >> N;

    vector<int64_t> h(N);
    for (auto &hi: h) cin >> hi;

    vector<int64_t> dp(N);
    for (size_t i = 1; i < N; ++i) {
        if (i == 1) {
            dp[i] = abs(h[i] - h[i - 1]);
        } else {
            int64_t value1 = dp[i - 1] + abs(h[i] - h[i - 1]);
            int64_t value2 = dp[i - 2] + abs(h[i] - h[i - 2]);
            dp[i] = min(value1, value2);
        }
    }

    cout << dp[N - 1] << "\n";

    return 0;
}


Measured memory_bytes: 1792
from collections import deque

n = int(input())

queue = deque()
queue.append(0)
ans = 0

while queue:
    a = queue.pop()
    if a > n:
        continue
    if all(str(a).count(str(i)) for i in [7, 5, 3]):
        ans += 1
    [queue.append(a * 10 + i) for i in [7, 5, 3]]

print(ans)

Measured memory_bytes: 3316
N = int(input())
D = [[int(_) for _ in input().split()] for _ in range(N)]
for i in range(N - 2):
    f = 1
    for j in range(3):
        if D[i + j][0] != D[i + j][1]:
            f = 0
            break
    if f:
        print('Yes')
        exit()
print('No')


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

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	for (ll i = 0; i < s.size() / 2; ++i) {
		if (s[i] != s[s.size() - i - 1])++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

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

int main(void){
	int n;
	cin>>n;
	int a;
	vector<int> A;
	A.push_back(0);
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	vector<int> B;
	B.push_back(0);
	reps(i,n){
		B.push_back(A[i]);
	}

	REPS(i,n){
		int count = 0;
		int bi = i * 2;
		while(bi <= n){
			count += B[bi];
			count %= 2;
			bi += i;
		}
		B[i] += count;
		B[i] %= 2;
	}

	int m = 0;
	reps(i,n){
		if(B[i] == 1){
			m++;
		}
	}

	cout<<m<<endl;
	reps(i,n){
		if(B[i] == 1){
			cout<<i<<endl;
		}
	}



	return 0;
}


Measured memory_bytes: 2548
N, L = map(int, input().split())

Ts = []
for idx in range(1, N+1):
    taste = idx + L - 1
    Ts.append(taste)

min_t = 20000000000
total = sum(Ts)
for t in Ts:
    if abs(t) < abs(min_t):
        min_t = t
print(total-min_t)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    ll a = 0, b = 0;
    rep(i, n) {
        ll c; cin >> c;
        (a += c) %= MOD;
        (b += c*c%MOD) %= MOD;
    }
    ll ans = a * a % MOD;
    ans -= b;
    if(ans < 0) ans += MOD;
    (ans *= (MOD + 1) / 2) %= MOD;
    cout << ans << endl;;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin>>s;
    if(s[0] == 'R'&&s[1] == 'R'&&s[2] == 'R')
    {
        cout<<3<<endl;
    }
    else if((s[0] == 'R'&&s[1] == 'R') || (s[1] == 'R'&&s[2] == 'R') )
    {
        cout<<2<<endl;
    }
    else if(s[0] == 'R'|| s[1] == 'R' || s[2] == 'R')
    {
        cout<<1<<endl;
    }
    else if(s[0] == 'S'&&s[1] == 'S'&&s[2] == 'S')
    {
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    reverse(all(s));
    const int n = 13;
    ll d = 1;
    vector<ll> dp(n);
    dp[0] = 1;
    rep(i, s.size()){
        vector<ll> nextDp(n);
        if (s[i] == '?'){
            for(ll k = 0; k <= 9; k++){
                for(ll r = 0; r < n; r++){
                    nextDp[(k * d + r) % n] += dp[r];
                    nextDp[(k * d + r) % n] %= mod;
                }
            }
        }else{
            ll k = s[i] - '0';
            for(ll r = 0; r < n; r++){
                nextDp[(k * d + r) % n] += dp[r];
                nextDp[(k * d + r) % n] %= mod;
            }
        }
        dp = nextDp;
        d *= 10;
        d %= n;
    }   
    cout << dp[5] << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>

int main(){
   int K;
   int A,B;
   int i;
   scanf("%d",&K);
   scanf("%d %d",&A,&B);
   for(i = A;i<=B;i++){
      if(i%K==0){
         printf("OK\n");
         return 0;
      }
   }
   printf("NG\n");
      
   return 0;
}
            

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    ll x;
    cin >> x;

    for(int i = -120; i <= 120; i++) for(int j = -120; j <= 120; j++) {
        ll a = 1, b = 1;
        rep(x, 5) a *= i;
        rep(y, 5) b *= j;
        if(a - b == x) {
            cout << i << " " << j << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3680
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
int main(){
  ll N;cin>>N;string S;cin>>S;
  bool b[1000];REP(i,1000)b[i]=false;
  bool done_i[10],done_j[10],done_k[10];
  REP(i,10)done_i[i]=done_j[i]=done_k[i]=false;
  REP(i,N-2){
    int I=S[i]-'0';
    if(done_i[I])continue;
    done_i[I]=true;
    REP(i,10)done_j[i]=false;
    FOR(j,i+1,N-1){
      int J=S[j]-'0';
      if(done_j[J])continue;
      done_j[J]=true;
      REP(i,10)done_k[i]=false;
      FOR(k,j+1,N){
        int K=S[k]-'0';
        if(done_k[K])continue;
        done_k[K]=true;
        b[I*100+J*10+K]=true;
      }
    }
  }
  int cnt=0;
  REP(i,1000)if(b[i])cnt++;
  cout<<cnt<<"\n";
  
      
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define lint long long
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define tracea(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define print(arr, n) for (int iDx = 0; iDx < (n); iDx++) cout << arr[iDx] << " \n"[iDx == (n)-1]
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return make_tuple(a, b) < make_tuple(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return make_tuple(a, b, c) < make_tuple(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;

int arr[MAXN];

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

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d%d", &N, &K);
	int now, maks;
	now = maks = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &arr[i]);
		now = gcd(now, arr[i]);
		maks = max(maks, arr[i]);
	}
	if (K%now == 0 && K <= maks) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	
	return 0;
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll n,u,v;
    cin >> n >> u >> v;
    vll deg(n+1, 0), dis1(n+1, -1), dis2(n+1, -1);
    vll G[n+1];
    for(ll i=0;i<n-1;i++) {
    	ll x,y;
    	cin >> x >> y;
    	deg[x]++;
    	deg[y]++;
    	G[x].pb(y);
    	G[y].pb(x);
    }
    dis1[u] = 0;
    stack<ll> st;
    st.push(u);
    while(!st.empty()) {
    	ll cur = st.top();
    	st.pop();
    	for(ll ad: G[cur]) {
    		if(dis1[ad] == -1) {
    			dis1[ad] = dis1[cur] + 1;
    			st.push(ad);
    		}
    	}
    }
    dis2[v] = 0;
    stack<ll> st2;
    st2.push(v);
    while(!st2.empty()) {
    	ll cur = st2.top();
    	st2.pop();
    	for(ll ad: G[cur]) {
    		if(dis2[ad] == -1) {
    			dis2[ad] = dis2[cur] + 1;
    			st2.push(ad);
    		}
    	}
    }
    ll ans = 0;
    for(ll i=1;i<=n;i++) {
    	if(deg[i] == 1 && dis1[i] < dis2[i]) {
    		ans = max(ans, dis2[i] - 1);
    	}
    }
    cout << ans << "\n";
}	

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
double cnt[4],n;
const int N = 310;
long double memo[N][N][N];
bool vis[N][N][N];
long double dp(double a, double b, double c, double empty) {
    if (empty == n) return 0;
    if (!vis[(int)a][(int)b][(int)c]) {
        vis[(int)a][(int)b][(int)c] = true;
        long double res = 0;
        if (a) res += (dp(a-1, b, c, empty+1)+1)*(a/n);
        if (b) res += (dp(a+1, b-1, c, empty)+1)*(b/n);
        if (c) res += (dp(a, b+1, c-1, empty)+1)*(c/n);
        res += (empty/n);
        res /= (1-(empty/n));
        memo[(int)a][(int)b][(int)c] = res;
    }
    return memo[(int)a][(int)b][(int)c];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int x;
    for (int i=0; i < n; i++) {
        cin >> x;
        cnt[x]++;
    }
    cout << setprecision(12) << fixed << dp(cnt[1], cnt[2], cnt[3], 0) << "\n";
    return 0;
}

Measured memory_bytes: 481536
#include<bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
 
const int maxn = 55;
const int base = maxn * maxn * maxn;
const ll INF = 0x3f3f3f3f3f3f3f3f;
 
class Item{
public:
	int v, id, lim;
	ll w, cnt;
	inline bool operator < (const Item &oth)const{ return MP(v * oth.w, lim) > MP(oth.v * w, oth.lim); } 
}dat[maxn];
 
int n, x, d;
int sz[maxn], a[maxn];
ll ans = 0;
ll dp[maxn][base];
int f[maxn][base];
ll sum[maxn];
vector<int> g[maxn];
 
inline int _(int x){ return x + base; }
 
inline void dfs(int u){
	FOR(i, 0, g[u].size()){
		int v = g[u][i];
		dfs(v);
		sz[u] += sz[v];
		sum[u] += sum[v];
	}
	++sz[u];
	sum[u] += a[u];
	return;
}
 
inline void umin(ll &x, ll y){ x = min(x, y); }
inline void umax(ll &x, ll y){ x = max(x, y); }
 
int main(){
	scanf("%d%d%d%d", &n, &x, &d, a + 0);
	
	FOR(i, 1, n){
		int p; scanf("%d%d", a + i, &p); --p;
		g[p].PB(i);
	}
	
	dfs(0);
	
	FOR(i, 0, n)
		dat[i].v = sz[i], dat[i].w = sum[i], dat[i].id = i, dat[i].lim = (i ? d : INF);
	sort(dat, dat + n);

	memset(dp, 0x3f, sizeof(dp));
//	memset(f, 0x3f, sizeof(f));
	dp[0][0] = 0;
	FOR(i, 0, n) REP(j, 0, 50 * 50 * 50) if(dp[i][j] != 0x3f3f3f3f){
		REP(k, 0, min(dat[i].lim, 50)) if(j + k * dat[i].v < base && (dp[i + 1][j + k * dat[i].v] > dp[i][j] + k * dat[i].w || dp[i + 1][j + k * dat[i].v] == dp[i][j] + k * dat[i].w && f[i + 1][j + k * dat[i].v] < k)){
			dp[i + 1][j + k * dat[i].v] = dp[i][j] + k * dat[i].w;
			f[i + 1][j + k * dat[i].v] = k;
		}
	}
	
	REP(j, 0, 50 * 50 * 50) if(x - dp[n][j] >= 0){
		FOR(i, 0, n)
			dat[i].cnt = 0;
		for(int i = n, j_ = j; i >= 0; --i){
			dat[i - 1].cnt = dat[i - 1].lim - f[i][j_]; 
			j_ -= f[i][j_] * dat[i - 1].v;
		}
		int nx = x - dp[n][j];
		ll res = 0;
		FOR(i, 0, n){
			dat[i].cnt = min(dat[i].cnt, nx / dat[i].w);
			res += dat[i].cnt * dat[i].v;
			nx -= dat[i].cnt * dat[i].w;
		}
		res += j;
		ans = max(ans, res);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 83740
n, m = map(int, input().split(" "))
nac = 0
npe = 0
cp = 0
is_ac = [False]*n
np_list = [0]*n
for i in range(m):
  p_s, s = input().split(" ")
  p = int(p_s)-1
  cis_ac = is_ac[p]
  
  if cis_ac:
    continue
  if s == "AC":
    nac += 1
    is_ac[p]=True
  else:
    np_list[p] += 1

for i, a in enumerate(is_ac):
  if a:
    npe += np_list[i]
print(str(nac)+" "+str(npe))


Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

ll ans[100100];

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	vector<int> st;
	st.push_back(0);
	for(int i = 1; i < N; i++) {
		if(a[st.back()] < a[i]) st.push_back(i);
	}
	priority_queue<int> que;
	int idx = st.size()-1;
	ll q, r;
	q = r = 0;
	rrep(i,N) {
		que.push(a[i]);
		if(st[idx] == i) {
			int b = (idx == 0) ? 0 : a[st[idx-1]];
			ans[st[idx]] = q*(a[st[idx]] - ((idx==0)?0:a[st[idx-1]]));
			while(que.size() && b <= que.top()) {
				q++;
				r += que.top() - b;
				que.pop();
			}
			ans[st[idx]] += r;
			r = 0;
			idx--;
		}
	}
	rep(i,N)
		cout << ans[i] << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    int n=stoi(s),sum=0;
    for(int i=0;i<(int)s.length();i++){
        sum += s[i]-'0';
    }
    if(n%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int n, m, q;
ll a[MAXN], b[MAXN];
set<ll> g, h;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m >> q;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,m) cin >> b[i];
    FOR(i,1,n) g.insert(a[i]);
    FOR(i,1,m) h.insert(b[i]);

    while (q--) {
        ll x;
        cin >> x;
        set<ll>::iterator itrg = g.lower_bound(x);
        set<ll>::iterator itlg = itrg;
        ll lg = -1e18;
        ll rg = 1e18;
        if (itlg != g.begin()) {
            itlg--;
            lg = *itlg;
        }
        if (itrg != g.end()) rg = *itrg;

        set<ll>::iterator itrh = h.lower_bound(x);
        set<ll>::iterator itlh = itrh;
        ll lh = -1e18;
        ll rh = 1e18;
        if (itlh != h.begin()) {
            itlh--;
            lh = *itlh;
        }
        if (itrh != h.end()) rh = *itrh;

        // cout << lg << ' ' << rg << " --- " << lh << ' ' << rh << endl;

        ll res = max(x - lg, x - lh);
        res = min(res, max(rg - x, rh - x));
        res = min(res, min(x - lg + rh - lg, rh - x + rh - lg));
        res = min(res, min(x - lh + rg - lh, rg - x + rg - lh));

        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 12288
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


vector<ll> s(5);
ll ans = INF;
int main() {
	REP(i, 5)cin >> s[i];
	sort(ALL(s));
	do {
		ll now = 0;
		REP(i, 5) {
			now += s[i];
			if (i != 4)now = (now + 9) / 10 * 10;
		}
		ans = min(ans, now);
	} while (next_permutation(ALL(s)));
	cout << ans << endl;
}




Measured memory_bytes: 256
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
    #ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    ll n, k, l, r, maxi, zero;
    string str; cin >> n >> k >> str;

    vector<pair<ll, ll>> v;
    l = r = zero = 0;
    while(l<=r && r<n){
        if(r<n) while(str[r]==str[l]) r++;
        v.push_back({l, r-1}), l = r;
    }

    n = v.size(), l = r = maxi = 0;
    if(str[0]=='1')
        while(l<=r && r<n){
            if(r&1) zero++;
            if(zero>k){
                if(l%2==0) zero--, l+=2;
                else zero--, l++;
            }
            maxi = max(maxi, v[r].second-v[l].first+1);
            r++;
        }
    else
        while(l<=r && r<n){
            if(r%2==0) zero++;
            if(zero>k){
                if(l&1) zero--, l+=2;
                else zero--, l++;
            }
            maxi = max(maxi, v[r].second-v[l].first+1);
            r++;
        }
   cout << maxi;

    return 0;
}

unsigned long long pow(long long base, long long power){ /// mod?
    if(power==0) return 1;
    if(power==1) return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1) return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
        if(isPrime[i]) c++;
    return c; /// primeCount [1:n]
}

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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;


void solve()
{
	int n, m, k;
	cin >> n >> m >> k;
	int a[n], b[m];
	loop(i, 0, n) cin >> a[i];
	loop(i, 0, m) cin >> b[i];
	vi a1(n + 1, 0);
	vi b1(m + 1, 0);
	loop(i, 1, n + 1) a1[i] = a1[i - 1] + a[i - 1];
	loop(i, 1, m + 1) b1[i] = b1[i - 1] + b[i - 1];

	int ans = 0;
	loop(i, 0, n + 1)
	{
		int cnt = i;
		int s1 = a1[i];
		if (s1 > k) continue;
		int s2 = k - s1;

		int x = lower_bound(all(b1), s2) - b1.begin();
		if (b1[x] == s2) cnt += x;
		else cnt += (x - 1);

		ans = max(ans, cnt);

	}
	cout << ans;

	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

Measured memory_bytes: 9516
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if(500*i+100*j+50*k==X):
                count+=1
print(count)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int on = n;
	int sn = 0;
	while(1){
		sn += n % 10;
		n /= 10;
		if(n == 0) break;
	}
	
	if(on % sn == 0){
		cout << "Yes" <<endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    rep(i, 0, N) {
        int id, k;
        cin >> id >> k;
        id--;
        rep(j, 0, k) {
            int u;
            cin >> u;
            u--;
            G[id].push_back(u);
        }
    }

    const auto inf = 1 << 30;
    vector<int> dist(N, inf);
    dist[0] = 0;
    queue<P> q;
    q.push(make_pair(0, 0));
    while (!q.empty()) {
        auto pi = q.front();
        q.pop();
        auto u = pi.first, cost = pi.second;
        for (auto& to : G[u]) {
            if (chmin(dist[to], cost + 1)) {
                q.push(make_pair(to, dist[to]));
            }
        }
    }

    rep(i, 0, N) {
        cout << i + 1 << " " << (dist[i] == inf ? -1 : dist[i]) << "\n";
    }
}



Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    char field[55][55];
    int dist[55][55];
    Fill(dist, -1);
    dist[0][0] = 0;
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};

    int cnt = 0;
    rep(i,0,H){
        rep(j,0,W){
            cin >> field[i][j];
            if(field[i][j] == '.'){
                if(i == 0 && j == 0) continue;
                cnt++;
            }
        }
    }
    
    queue<pair<int,int>> que;
    que.push({0,0});

    while(!que.empty()){
        auto v = que.front();
        que.pop();
        rep(t,0,4){
            int nx = v.first + dx[t];
            int ny = v.second + dy[t];
            if(nx >= 0 && nx < H && ny >= 0 && ny < W && field[nx][ny] == '.' && dist[nx][ny] == -1){
                que.push({nx,ny});
                dist[nx][ny] = dist[v.first][v.second] + 1;
            }
        }
    }
    if(dist[H-1][W-1] == -1){
        cout << -1 << endl;
    }else{
        cout << cnt - dist[H-1][W-1] << endl;
    }
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;
#define mod 1000000007

vector<vector<lli> > adj;
lli dp[100005][2];

lli func(lli in,lli c,lli p){
    if(dp[in][c]!=-1) return dp[in][c];
    
    if(c==0){
        lli a=1,i,j=0,l;
        for(i=0;i<adj[in].size();i++){
            if(adj[in][i]==p) continue;
            a=a*((func(adj[in][i] , 0 , in))%mod + func(adj[in][i] , 1, in)%mod);
            a%=mod;
        }
        //if(j==0) a=1;
        return dp[in][c]=a;
    }
    else{
        lli a=1,i,j=0,l;
        for(i=0;i<adj[in].size();i++){
            if(adj[in][i]==p) continue;
            a=a*func(adj[in][i] , 0 , in);
            a%=mod;
            j=1;
        }
        //if(j==0) a=1;
        return dp[in][c]=a;
    }
}

int main(){
    lli n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    lli i,j,l;
    lli ans=0;
    adj.resize(n+1);
    for(i=0;i<n-1;i++){
        lli x,y;
        cin>>x>>y;
        adj[x].push_back(y);adj[y].push_back(x);
    }
    ans = func(1,0,-1) + func(1,1,-1);
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14208
using System;

namespace EDPCA
{
    class Program
    {
        // 動的計画法の練習問題Ａ
        public static int[] h;
        public static int[] cost;
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());//足場の数
            string[] input_h = Console.ReadLine().Split(' ');//それぞれの足場の高さ
            h = new int[N+1];
            for (int i = 1; i <= N; i++)
            {
                h[i] = int.Parse(input_h[i-1]);//各足場の高さを配列に記録する
            }
            cost = new int[N + 1];
            for (int i = 1; i <= N; i++)
            {
                cost[i] = 10000;
            }
            cost[1] = 0;
            cost[2] = Math.Abs(h[1] - h[2]);
            if (N == 2)
            {
                Console.WriteLine(cost[2]);
            }
            else
            {
                Console.WriteLine(DP(N));
            }
        }
        public static int DP(int n)
        {
            for (int i = 3; i <= n; i++)
            {
            cost[i]=Math.Min(cost[i - 1] + Math.Abs(h[i] - h[i - 1]), cost[i - 2] + Math.Abs(h[i] - h[i - 2]));
            }
            return cost[n];
        }
    }
}


Measured memory_bytes: 18912
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

int N, M;
vector<int> A;
vector<pair<int, int> > BC;

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

    int tmp;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        A.push_back(tmp);
    }

    int tmpb, tmpc;
    for(int i = 0; i < M; i++){
        cin >> tmpb >> tmpc;
        BC.push_back(make_pair(tmpc, tmpb));
    }

    stable_sort(A.begin(), A.end()); // マージソート
    stable_sort(BC.begin(), BC.end()); // マージソート

    int indA = 0; // A インデックス指定用
    int indBC = M - 1; // BC インデックス指定用
    long ans = 0; // 解答用
    int num = 0; // 各 BC 階層でのカウント用
    bool fin = true; // 交換リストが残っているか

    while(indA < N){
        if(!fin) ans += (long) A[indA];
        else if(A[indA] < BC[indBC].first){
            ans += (long) BC[indBC].first;
            num++;
        }
        else{
            ans += (long) A[indA];
            fin = false;
        }

        indA++;

        if(fin){
            if(BC[indBC].second == num){
            indBC--;
            num = 0;
            }
            if(indBC == -1) fin = false;
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>

int main(void){

  int A,B;
  scanf("%d %d",&A,&B);
  if(A<=5){
    printf("0\n");
  }else if(A<=12){
    printf("%d\n",B/2);
  }else {printf("%d\n",B);}
  return 0;
}


Measured memory_bytes: 128
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

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

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	ans := 1
	for ans*2 <= N {
		ans *= 2
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

int main (){ int a; int b;
    cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){cout<<"Possible";
}
else {cout<<"Impossible";}

     return 0;
}


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

int main(void){
    int n, x = 0, ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') x++;
        if (s[i] == 'D') x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
    int a,b;cin>>a;
    if(a>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
from collections import defaultdict

def main():
  n = int(input())
  d = defaultdict(int)

  for num in map(int, input().split()):
    d[num] += 1

  q = int(input())

  total = sum([k * v for k, v in d.items()])

  for _ in range(q):
    b, c = map(int, input().split())
    total += (c - b) * d[b]
    d[c] += d[b]
    d[b] = 0
    print(total)



main()


Measured memory_bytes: 22084
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a;
  int n;
  cin>>n;
  a.push_back(n);
  cin>>n;
  a.push_back(n);
  cin>>n;
  a.push_back(n);
  sort(a.begin(),a.end());
  int ans = abs(a[0]-a[1])+abs(a[1]-a[2]);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  ll num = 100;
  for (int i = 1; ; i++) {
    num += num/100;
    if (num >= x) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3668
N = int(input())
D = []
for _ in range(N):
    d1, d2 = map(int, input().split())
    D.append([d1, d2])


for i in range(N):
    if i + 2 > N - 1:
        break
    if D[i][0] == D[i][1] and D[i + 1][0] == D[i + \
        1][1] and D[i + 2][0] == D[i + 2][1]:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 9196
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  if ( (N-0) % 1000 == 0 || (N-111)%1000 == 0 || (N-222)%1000 == 0 || (N-333)%1000 == 0 || (N-444)%1000 == 0 ||(N-555)%1000 == 0 || (N-666)%1000 == 0 || (N-777)%1000 == 0 || (N-888)%1000 == 0 || (N-999)%1000 == 0 || (N-0) % 1110 ==0 || (N-1)%1110 == 0 ||(N-2)%1110 == 0 || (N-3)%1110 == 0 || (N-4)%1110 == 0 || (N-5)%1110 == 0 || (N-6)%1110 == 0 || (N-7)%1110 == 0 || (N-8)%1110 == 0 || (N-9)%1110 == 0 ){
  cout << "Yes" << endl;
  }
 else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 3596