akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new LinkedList<int>();
            var N = GetNumber();
            for (int i = 0; i < N; i++)
            {
                var line = GetStrings();
                switch (line[0])
                {
                    case "insert":
                        list.AddFirst(int.Parse(line[1]));
                        break;
                    case "delete":
                        list.Remove(int.Parse(line[1]));
                        break;
                    case "deleteFirst":
                        list.RemoveFirst();
                        break;
                    case "deleteLast":
                        list.RemoveLast();
                        break;
                    default:
                        break;
                }
            }

            System.Console.WriteLine(string.Join(" ", list.Select(x => x.ToString()).ToArray()));
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 85720
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int a, b;
    cin >> a >> b;
    int sum = 0;
    rep(i, b - a) {
        sum += i;
    }
    cout << sum-a << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,m;
    cin>>n>>m;
    Yay(n<9 && m<9)
    return  0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();

    let mut ans = "No";
    'outer_loop: for i in 0..s.len() {
        for j in 0..t.len() {
            let k = if i + j < s.len() { i + j }
                    else               { i + j - s.len() };
            if s[k] != t[j] { continue 'outer_loop; }
            if j == t.len() - 1 {
                ans = "Yes";
                break 'outer_loop;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 505, mod = (int) 0;
int dp[N][N], a[N], b[N];
int main() {
	int n, w;
	cin >> n >> w;
	int fst = 0;
	memset(dp, -63, sizeof dp);
	dp[0][0] = 0;
	for (int j = 0; j < n; ++j) {
		cin >> a[j] >> b[j];
		if (j == 0) fst = a[j];
		a[j] -= fst;
		for (int pick = n; pick >= 1; --pick)
			for (int sw = a[j]; sw < N; ++sw)
				dp[pick][sw] = max(dp[pick - 1][sw - a[j]] + b[j], dp[pick][sw]);
	}
	int res = 0;
	for (int pick = 0; pick <= n; ++pick)
		for (int sw = 0; sw < N; ++sw)
			if ((long long) pick * fst + sw <= w)
				res = max(res, dp[pick][sw]);
	cout << res << endl;
			
}



Measured memory_bytes: 1408
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    input!{
        s: chars,
    }
    let mut flagn = false;
    let mut flagw = false;
    let mut flags = false;
    let mut flage = false;

    for ite in s {
        match ite {
            'N' => flagn = true,
            'W' => flagw = true,
            'S' => flags = true,
            'E' => flage = true,
            _ => (),
        }
    }
    if flagn == flags && flagw == flage {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int pow2[31];
    pow2[0]=1;
    rep(i,30) pow2[i+1]=pow2[i]*2;
    int N,ans=0;
    cin >> N;
    multiset<int> ball;
    rep(i,N){
        int X;
        cin >> X;
        ball.insert(X);
    }
    while(ball.size()>1){
        auto itr=ball.end();
        itr--;
        bool check=false;
        rep(i,30){
            if(ball.count(pow2[i+1]-*itr)){
                auto itr2=ball.find(pow2[i+1]-*itr);
                if(itr==itr2 && ball.count(pow2[i+1]-*itr)==1) continue;
                else if(itr==itr2) itr2++;
                ans++;
                ball.erase(itr);
                ball.erase(itr2);
                check=true;
                break;
            }
        }
        if(!check) ball.erase(itr);
    }
    cout << ans << endl;
}

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

const int MAXN = 1111;
const int MAXW = 21111;
const ll INF = 0x3f3f3f3f3f3f3f3f;
int n;
int w[MAXN], s[MAXN], v[MAXN];
ll ans[MAXW];
bool comp(int i, int j) { //comparator to sort elements
  return s[i] + w[i] < s[j] + w[j];
}
int main(){ // we may put w[i] on top of some s[i]
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n;
  for(int i=0;i<n;i++) cin >> w[i] >> s[i] >> v[i];
  vector<int> items(n);
  iota(items.begin(), items.end(),0);
  sort(items.begin(),items.end(), comp);
  for(int j=20000;j;j--) {
    ans[j] = -INF;
  }
  for(auto i : items) {
    //cerr << "@ " << i <<endl;
    for(int j=s[i];j>=0;j--) {
      if (j+w[i] <= 20000) ans[j+w[i]] = max(ans[j+w[i]], ans[j] + v[i]);
    }
  }
  ll bestans = 0;
  for(int j=20000;j;j--) {
    bestans = max(bestans, ans[j]);
  }
  cout << bestans <<endl;
}


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

int main(){


    int test_cases;
    cin>>test_cases;

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    

    for (int i = 0; i < test_cases; i++){
        
        string s;
        cin>>s;

        if (s == "AC"){
            ac++;
        }
        else if (s == "WA"){
            wa++;
        }
        else if (s == "TLE"){
            tle++;
        }
        else if(s == "RE"){
            re++;
        }


    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;






}


Measured memory_bytes: 3228
#include <iostream>
#include <vector>

int main() {
  int N, M;
  std::cin >> N >> M;

  std::vector<std::vector<int>> sij(M);
  std::vector<int> p(M);

  for (int i = 0; i < M; ++i) {
    int k, s;
    std::cin >> k;
    sij[i].reserve(k);
    for (int j = 0; j < k; ++j) {
      std::cin >> s;
      sij[i].push_back(s - 1);
    }
  }
  for (int i = 0; i < M; ++i) {
    std::cin >> p[i];
  }

  int result = 0;
  for (int sw = 0, end = 1 << N; sw < end; ++sw) {
    bool ok = true;
    for (int i = 0; i < sij.size(); ++i) {
      auto &sj = sij[i];
      int sum = 0;
      for (auto s : sj) {
        sum += sw >> s;
      }
      if ((sum % 2) != p[i]) {
        ok = false;
        break;
      }
    }

    if (ok) {
      ++result;
    }
  }
  std::cout << result << std::endl;

  return 0;
}

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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    int N;
    cin >> N;

    if (N == 1) {
        cout << "Hello World" << endl;
    }
    else {
        int A, B;
        cin >> A >> B;
        cout << (A + B) << endl;
    }

    
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define llint long long
#define inf 1e9

using namespace std;
typedef pair<llint, llint> P;

struct BIT{
	int size;
	vector<llint> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	llint query(int i){
		llint ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, llint x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};


llint n;
char c[4005];
int a[4005];
int bpos[2005], wpos[2005];
llint dp[2005][2005];
BIT bbit(4005), wbit(4005);

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= 2*n; i++) cin >> c[i] >> a[i];
	
	for(int i = 1; i <= 2*n; i++){
		if(c[i] == 'B') bpos[a[i]] = i;
		else wpos[a[i]] = i;
	}
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	
	for(int i = 0; i <= n; i++){
		wbit.init();
		for(int j = 0; j <= n; j++){
			if(i == n && j == n) continue;
			if(i+1 <= n) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (bpos[i+1]-1) - bbit.query(bpos[i+1]) - wbit.query(bpos[i+1]));
			if(j+1 <= n) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (wpos[j+1]-1) - bbit.query(wpos[j+1]) - wbit.query(wpos[j+1]));
			if(j+1 <= n) wbit.add(wpos[j+1], 1);
		}
		if(i+1 <= n) bbit.add(bpos[i+1], 1);
	}
	cout << dp[n][n] << endl;
	
	return 0;
}

Measured memory_bytes: 31744
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    ai = list(map(int, input().split()))
    assert len(ai) == n
    num_odd = len([a for a in ai if a % 2 == 1])
    print("YES" if num_odd % 2 == 0 else "NO")

main()


Measured memory_bytes: 14832
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
vector<long long> mf = {1};
vector<long long> mfi = {1};
long long modfact(int n){
  if (mf.size() > n){
    return mf[n];
  } else {
    for (int i = mf.size(); i <= n; i++){
      long long next = mf.back() * i % MOD;
      mf.push_back(next);
      mfi.push_back(modinv(next));
    }
    return mf[n];
  }
}
long long modfactinv(int n){
  if (mfi.size() > n){
    return mfi[n];
  } else {
    return modinv(modfact(n));
  }
}
long long modbinom(int n, int k){
  return modfact(n) * modfactinv(k) % MOD * modfactinv(n - k) % MOD;
}
int main(){
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  long long p = A * modinv(A + B) % MOD;
  long long ans = 0;
  for (int i = 0; i < N; i++){
    long long tmp = modbinom(N - 1 + i, i);
    tmp *= modpow(p, N - 1);
    tmp %= MOD;
    tmp *= modpow(1 - p + MOD, i);
    tmp %= MOD;
    tmp *= p;
    tmp %= MOD;
    ans += tmp * (N + i) % MOD;
  }
  for (int i = 0; i < N; i++){
    long long tmp = modbinom(N - 1 + i, i);
    tmp *= modpow(1 - p + MOD, N - 1);
    tmp %= MOD;
    tmp *= modpow(p, i);
    tmp %= MOD;
    tmp *= (1 - p + MOD);
    tmp %= MOD;
    ans += tmp * (N + i) % MOD;
  }
  ans %= MOD;
  ans *= modinv(1 - (C * modinv(100) % MOD) + MOD);
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 6572
def Sum_xxor(ans_tmp,A,tmp,saiteki,ind_max):

    ans_ret = 0
    ans_x = ans_tmp

    for i in range(41):
        if i < ind_max:
            if tmp[i] <= N-tmp[i]:
                ans_x += bits[i]*1
            else:
                ans_x += bits[i]*0
    for a in A:
        ans_ret += ans_x ^ a

    return ans_ret

N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))

if K == 0:
    ans = sum(A)
    print(ans)
    exit()

tmp   = [0 for _ in range(41)]
bits  = [0 for _ in range(41)]
saiteki = [0 for _ in range(41)]

for i in range(41):
    if i == 0:
        bit = 1
    else:
        bit *= 2
    bits[i] = bit

    tmp_i = 0

    for a in A:
        if a & bit:
            tmp_i += 1

    tmp[i] = tmp_i
    saiteki[i] = max(tmp_i,N-tmp_i)*bit

t,ans = bit, 0
ind = 41
ans_tmp = 0
ch = 0
while t:
#    print(t,ans_tmp)
    if ch == 0:
        if not(t & (K+1)):
            ans_tmp += 0
        else:
            ch = 1

            ind_max = ind - 1
            ans = max(ans, Sum_xxor(ans_tmp,A,tmp,saiteki,ind_max))

            ans_tmp += t

    else:
        if t & (K+1):

            ind_max = ind - 1
            ans = max(ans, Sum_xxor(ans_tmp,A,tmp,saiteki,ind_max))

            ans_tmp += t


    t  //= 2
    ind -= 1


print(ans)


Measured memory_bytes: 14748
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;

int main(){
string a,b,c;
cin >>a>>b>>c;
int na=a.length();
int nb=b.length();
int nc=c.length();
int ia=0,ib=0,ic=0;
char next='a';
while(1){
  if(next=='a'){
    if(ia==na) {cout<<'A'<<endl; return 0;}
    next=a[ia];
    ia++;
  }
  if(next=='b'){
    if(ib==nb) {cout<<'B'<<endl; return 0;}
    next=b[ib];
    ib++;
  }
  if(next=='c'){
    if(ic==nc) {cout<<'C'<<endl; return 0;}
    next=c[ic];
    ic++;
  }

}}


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

using namespace std;

typedef long long ll;

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

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int H1,M1,H2,M2,K;
    int time1, time2;
    cin >> H1>> M1>> H2>> M2>> K;
    time1 = H1 * 60 + M1;
    time2 = H2 * 60 + M2;
    res = time2 - time1 - K;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3636
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

kyori = abs(a-b)
sokudo = (v-w)

if sokudo > 0:
    if (kyori/sokudo)<=t:
        print("YES")
        exit()
elif sokudo == 0:
    if kyori == 0:
        print("YES")
        exit()

print("NO")

Measured memory_bytes: 9188
from collections import deque
import sys
sys.setrecursionlimit(20000000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N-1)]
routes = [[] for _ in range(N)]

for i in range(len(ab)):
    routes[ab[i][0]-1].append([ab[i][1]-1, i])
    routes[ab[i][1]-1].append([ab[i][0]-1, i])

route_color = [-10e+10 for _ in range(len(ab))]

route_num = [0]*N
max_route = 0
for i in range(N):
    num = len(routes[i])
    route_num[i] = num
    if max_route < num:
        max_route = num

seen = [False for _ in range(N)]

def function(num,pre_color):
    color_num = -1
    for route in routes[num]:
        color_num += 1
        if color_num == pre_color:
            color_num+=1
        if route_color[route[1]] != -10e+10:
            color_num-=1
            pass
        else:
            route_color[route[1]] = color_num
            
        if seen[route[0]] == False:
            seen[route[0]] = True
            function(route[0],route_color[route[1]])
    return

function(0,-1)
print(max_route)
for color in route_color:
    print(color+1)

Measured memory_bytes: 121560
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

ll qmult(ll X, ll Y, ll M) {    
    return X * Y % M;
}

ll qexp(ll A, ll B, ll M) {
    if (B == 0) return 1;
    ll half = qexp(A, B/2, M); 
    half = qmult(half, half, M);
    half %= M;
    if (B%2==1) half *= A%M;
    return half%M;
}

int modinv(int x){
	return qexp(x,MOD-2,MOD);
}

int f[MAXN], invf[MAXN];
int choose(int n, int r){
	int ans=f[n];
	ans*=invf[r]; ans%=MOD;
	ans*=invf[n-r]; ans%=MOD;
	return ans;
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	f[0]=1;
	invf[0]=1;
	FOR(i,1,MAXN-1){
		f[i]=(f[i-1]*i)%MOD;
		invf[i]=modinv(f[i]);
	}
	int N,K;cin>>N>>K;
	int ans=0;
	FOR(r,max(0LL,N-K),N){
		//db(choose(N,r));
		//db(choose(N-1,r-1));
		ans += (choose(N,r)*choose(N-1,r-1))%MOD;
		ans %= MOD;
	}
	cout<<ans;
}


Measured memory_bytes: 3328
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)//少数出力
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

#include <iostream>

using namespace std;

void scans(string & str) {
	char c;
	scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	int n;
	scanf("%d", &n);
	int ans = 0;
	for (ans = 0; ans * (ans + 1) / 2 < n; ++ans);
	repr(i, ans) {
		if(i != 0 && i != ans * (ans + 1) / 2 - n)printf("%d\n", i);
	}

 	return 0;
}


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

int main() {
    int n,k;cin>>n>>k;
    long long dp[n+k],h[n+k];
    for(int i=0;i<n+k;i++) h[i]=1000000;
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n+k;i++) dp[i]=10000000000000;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void){
  //入力
  int spite_number, spite_length[200], i=0;
  //spite_number:串の数 spite_length[100]:串の長さ
  cin >> spite_number;
  spite_number *= 2;
  while(i<spite_number){
    cin >> spite_length[i];
    i++;
  }

  //ソート
  int tmp;
  for(int j=0; j<(spite_number-1); j++){
    for(int k=(spite_number-1); k>j; k--){
      if(spite_length[k-1] > spite_length[k]){
        tmp = spite_length[k-1];
        spite_length[k-1] = spite_length[k];
        spite_length[k] = tmp;
      }
    }
  }

  //短い串からペアを作っていく
  int sum=0;
  //sum:具材の合計
  for(i=0; i<spite_number; i+=2){
    sum += spite_length[i];
  }

  cout << sum;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<bits/stdc++.h>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

constexpr unsigned Mod = 1000000007;

constexpr unsigned Add(unsigned a, unsigned b) { return (a + b) % Mod; }

int main() {
  int N;
  scanf("%d", &N);
  static char S[3000];
  scanf("%s", S);
  static unsigned F[3000];
  fill(F, F + N, 1);
  for (auto i = 1; i < N; ++i) {
    if (S[i - 1] == '<')
      for (auto j = 1; j < N - i; ++j)
        F[j] = Add(F[j - 1], F[j]);
    else {
      auto f = exchange(F[N - i - 1], F[N - i]);
      for (auto j = N - i - 2; j >= 0; --j)
        f = exchange(F[j], Add(f, F[j + 1]));
    }
  }
  printf("%u\n", F[0]);
  return 0;
}


Measured memory_bytes: 256
line_count,limit_time=gets.split.map(&:to_i)
array=[]
line_count.times do |i|
  name,time=gets.split
  array.push [name,time.to_i]
end
total=0
while !array.empty?
  p,t=array.shift
  if t<=limit_time
    total+=t
    puts "#{p} #{total}"
  else
    t-=limit_time
    total+=limit_time
    array.push [p,t]
  end
end

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx;
	int dy = ty - sy;
	cout << string(dy, 'U') << string(dx, 'R');
	cout << string(dy, 'D') << string(dx + 1, 'L');
	cout << string(dy + 1, 'U') << string(dx + 1, 'R');
	cout << "DR" << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U' << endl;
	return 0;
}


Measured memory_bytes: 256
A, B, H, M = map(int, input().split())

import math

sita = min(abs(30*H-11*M/2), 360-abs(30*H-11*M/2))

# print(sita)

# print(math.cos(math.radians(sita)))

print((A**2 + B**2 - 2*A*B*math.cos(math.radians(sita)))**(1/2))

Measured memory_bytes: 62640
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.concurrent.fixedRateTimer
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val A = nal(N)
    var money = 1000L
    var stock = 0L
    for (i in 0 until N) {
      money += stock * A[i]
      stock = 0
      for (j in i + 1 until N) {
        if (A[i] > A[j]) break
        if (A[i] < A[j]) {
          val v = money / A[i]
          stock += v
          money -= v * A[i]
        }
      }
      debug{"$money $stock"}
    }

    out.println(money)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 34720
#include <iostream>
#include <cstdio>

using namespace std;

void print_time(int sec) {
    printf("%02d:%02d:%02d\n", sec/3600, sec/60%60, sec%60);
}

int main() {
    while(true) {
        int h, m, s;
        cin >> h >> m >> s;
        if(h == -1 && m == -1 && s == -1) break;

        int rem = 120*60 - (h*3600 + m*60 + s);
        print_time(rem);
        print_time(rem*3);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

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

	int sum = 0;
	if (a == 1) {
		sum += 300000;
	}
	else if (a == 2) {
		sum += 200000;
	}
	else if (a == 3) {
		sum += 100000;
	}
	if (b == 1) {
		sum += 300000;
	}
	else if (b == 2) {
		sum += 200000;
	}
	else if (b == 3) {
		sum += 100000;
	}

	if (a == 1 && b == 1) sum += 400000;

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>

using namespace std;
typedef long long ll;
const int MAXN = 305;
struct { int v, next; ll w; } e[MAXN * MAXN];
int head[MAXN], cnt_edge;
inline void add_edge(int u, int v, ll w) {
    e[cnt_edge] = { v, head[u], w };
    head[u] = cnt_edge++;
}
int n;
struct Item {
    ll val;
    int u, v;
    bool operator > (const Item &item) const {
        return val > item.val;
    }
};
ll dis[MAXN];
bool inque[MAXN];
void spfa(int s) {
    queue<int> que;
    dis[s] = 0;
    inque[s] = true;
    que.push(s);
    while(!que.empty()) {
        int u = que.front(); que.pop();
        inque[u] = false;
        for(int i = head[u]; i != -1; i = e[i].next) {
            if(dis[e[i].v] > dis[u] + e[i].w) {
                dis[e[i].v] = dis[u] + e[i].w;
                if(!inque[e[i].v]) {
                    inque[e[i].v] = true;
                    que.push(e[i].v);
                }
            }
        }
    }
}
priority_queue<Item, vector<Item>, greater<Item>> que;
int main() {
    memset(head, 0xff, sizeof(head));
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) {
        ll val; scanf("%lld", &val);
        if(i < j) {
            que.push((Item){val, i, j});
        }
    }
    ll ans = 0;
    while(!que.empty()) {
        Item item = que.top(); que.pop();
        memset(dis, 0x3f, sizeof(dis));
        spfa(item.u);
        if(dis[item.v] < item.val) {
            printf("-1\n");
            return 0;
        }
        else if(dis[item.v] > item.val) {
            add_edge(item.u, item.v, item.val);
            add_edge(item.v, item.u, item.val);
            ans += item.val;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
if n == 2:
    print(b[0] * 2)
else:
    res = [0] * n
    res[0] = b[0]
    for i in range(n-2):
        res[i+1] = min(b[i], b[i+1])
    res.append(b[-1])
    print(sum(res))


Measured memory_bytes: 3060
if __name__ == "__main__":
    K, N = list(map(int, input().split()))
    a = list(map(int, input().split()))
    d = [0 for i in range(N)]
    for i in range(N):
        if i == N - 1:
            d[i] = K - a[i] + a[0]
        else:
            d[i] = a[i+1] - a[i]
    print(sum(d) - max(d))

Measured memory_bytes: 26444
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string S;
  i64 K;
  std::cin >> N >> S >> K;
  --K;

  std::transform(S.begin(), S.end(), S.begin(), [&S, &K](const char S_i) { return S_i == S[K] ? S_i : '*'; });
  std::cout << S << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

// iまでみてサイズがjであるときの最小値
ll dp[310][310];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

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

  vector<ll> h(N+1, 0);
  for(int i=1; i<=N; i++) cin >> h[i];

  
  REP(i,N+2) REP(j,N+2) dp[i][j] = (1LL<<60);

  for(int i=1; i<=N; i++){
    dp[i][1] = h[i];
  }
  dp[0][0] = 0;
  for(int i=2; i<=N; i++){

    for(int j=2; j<=i; j++){
      for(int k=1; k<i; k++){
        dp[i][j] = min(dp[i][j], dp[k][j-1] + max(0LL, h[i]-h[k]));
      }
    }
  }
  ll ans = (1LL<<60);
  for(int i=1; i<=N; i++){
    ans = min(ans, dp[i][N-K]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4404
import sys
from collections import defaultdict

sys.setrecursionlimit(10**7)

n, u, v = map(int, input().split())

graph = defaultdict(list)

for _ in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)


def dfs(u):
    dist = [-1] * (n + 1)
    stack = [u]
    dist[u] = 0
    while stack:
        u = stack.pop()
        nxt = dist[u] + 1
        for v in graph[u]:
            if dist[v] >= 0:
                continue
            dist[v] = nxt
            stack.append(v)
    return dist


dist_u = dfs(u)
dist_v = dfs(v)

# 高橋くん（u）の方が近い頂点のうち、青木くん（v）から最も遠い頂点の一つ手前
ans = 0
for x, y in zip(dist_u, dist_v):
    if x < y:
        ans = max(ans, y - 1)

print(ans)

Measured memory_bytes: 37436
while True:
  lst = []
  for i in range(12):
    ls = []
    s = input()
    for j in range(12):
      ls.append(int(s[j]))
    lst.append(ls)
  xd = [0,1,0,-1]
  yd = [1,0,-1,0]
  count = 0
  def check(pt):
    if 11 < pt[0] or pt[0] < 0 or 11 < pt[1] or pt[1] < 0:
      return False
    elif(lst[pt[0]][pt[1]] == 1):
      lst[pt[0]][pt[1]] = 0
      for i in range(4):
        check([pt[0]+xd[i],pt[1]+yd[i]])
      return True
    else:
      return False
  def printMap():
    for i in range(12):
      st = ""
      for j in range(12):
        st = st + str(lst[i][j])
      print(st)
    print()
  for x in range(12):
    for y in range(12):
      if lst[x][y]:
        check([x,y])
        count += 1
        #printMap()
  print(count)
  try:
    input()
  except EOFError:
    break


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

int main() {

	int h, w;

	cin >> h >> w;

	string all;

	for (int i = 0; i < h; i++) {

		string str;

		cin >> str;

		all += str;
	}

	for (int i = 0; i < all.size(); i++) {

		if (all.at(i) == '#') {

			cout << "#";

		}
		else {

			int leftUp = i - (w + 1);
			int up = i - w;
			int rightUp = i - (w - 1);

			int left = i - 1;
			int right = i + 1;

			int leftBottom = i + (w - 1);
			int bottom = i + w;
			int rightBottom = i + (w + 1);



			int how = 0;

			if (left % w != w -1 && left >= 0) {

				if (all.at(left) == '#') {

					how++;

				}

				if (leftUp >= 0 && all.at(leftUp) == '#') {


					how++;

				}

				if (leftBottom < h * w && all.at(leftBottom) == '#') {

					how++;

				}

			}

			if (right % w != 0 && right < h * w) {

				if (all.at(right) == '#') {

					how++;

				}

				if (rightUp >= 0 && all.at(rightUp) == '#') {

					how++;

				}

				if (rightBottom < h * w && all.at(rightBottom) == '#') {

					how++;

				}

			}

			if (up >= 0 && all.at(up) == '#') {

				how++;

			}

			if (bottom < h * w && all.at(bottom) == '#') {

				how++;

			}

			cout << how;

		}

		if ((i + 1) % w == 0) {

			cout << endl;

		}



	}



}


Measured memory_bytes: 3152
#include <stdio.h>

const int MAX_V = 1000000;

int p[MAX_V+1];
int data[MAX_V];
int main() {
    int i,k,a;
    for(i = 2;i<=MAX_V;i++) {
        p[i] = 1;
    }
    for(i = 2;i*i<=MAX_V;i++) {
        if(p[i]) {
            for(k = 2*i;k<=MAX_V;k+=i) {
                p[k] = 0;
            }
        }
    }
    for(i = 0;i<=MAX_V;i++){
        data[i+1] = data[i]+p[i];
    }
    while(scanf("%d",&a) != EOF){
        printf("%d\n", data[a + 1]);
    }
    return  0;
}

Measured memory_bytes: 8836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&b==c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

Measured memory_bytes: 256
#include <cstdio>

long long a,b,c,k;

int main()
{
  scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
  if(k&1)
    {
      printf("%lld\n",b-a);
    }
  else
    {
      printf("%lld\n",a-b);
    }
  return 0;
}


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

int k, a, b;
bool flag = false;

int main() {
  cin >> k;
  cin >> a >> b;

  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      flag = true;
    }
  }

  if (flag) {
    printf("OK");
  } else {
    printf("NG");
  }

  return 0;
}

Measured memory_bytes: 3704
#include <iostream>

using namespace std;

int main () {
    int w, h, x, y, r;

    cin >> w >> h >> x >> y >> r;

    if (x - r < 0 || x + r > w) cout << "No" << endl;
    else if (y - r < 0 || y + r > h) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std ;
int s[55] ;

int main()
{
	
	int n , k , sum = 0 ;
	cin >> n >> k ;
	for ( int i = 1 ; i <= n ; i++ )
	{
		cin >> s[i] ;
	}
	sort ( s + 1 , s + 1 + n ) ;
	for ( int i = n - k + 1 ; i <= n ; i++ )
	{
		sum = sum + s[i] ;
	}
	
	cout << sum << endl ;
	return 0 ;
	
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define y1 y11
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define skip continue
#define all(x) x.begin(), x.end()
#define NAME "code"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;

const ll inf = 1e9;
const ll maxn = 2e5 + 11;

ll a, b, c, d, n, ans;

int main(){

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

cin >> a >> b >> c >> d >> n;
b = min(a * 2, b); // 0.5
c = min(b * 2, c); // 1
d = min(c * 2, d); // 2

ans = (n / 2) * d + (n & 1) * c;

cout << ans;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "../../Template.cpp"

class SegmentTree {
public:
    vector<int> tree;
    int n;
    SegmentTree(int size) {
        n = size;
        tree.assign(4*n+1, 0);
    }
    void update(int curr, int l, int r, int pos, int val) {
        if(l == r) {
            tree[curr] = max(tree[curr], val);
        }
        else {
            int mid = (l+r)/2;
            if(pos <= mid)
                update(curr*2, l, mid, pos, val);
            else
                update((curr*2)+1, mid+1, r, pos, val);
            tree[curr] = max(tree[curr*2], tree[(curr*2)+1]);
        }
    }
    int query(int curr, int l, int r, int i, int j) {
        if (j < l || i > r)
            return 0;
        if (i <= l && r <= j)
        {
            return tree[curr];
        }
        else {
            int mid = (l+r)/2;
            int left = query(curr*2, l, mid, i, j);
            int right = query((curr*2)+1, mid+1, r, i, j);
            return max(left, right);
        }
    }
};

int n;
vector<int> height;
vector<int> arr;

void solve() {
    int size = 1e6;
    SegmentTree tree(size);
    vector<int> dp(n+1, 0);
    for(int i = 0; i < n; i ++) {
        int best = tree.query(1, 1, size, 1, height[i]-1);
        dp[i] = best + arr[i];
        tree.update(1, 1, size, height[i], dp[i]);
    }
    int ans = 0;
    for(auto i : dp) {
        ans = max(ans, i);
    }
    cout << ans << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    height.assign(n+1, 0);
    arr.assign(n+1, 0);
    for(int i = 0; i < n; i ++) {
        cin >> height[i];
    }
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 36224