akhauriyash/Code-Regression huggingface dataset:
//K-OS WITH THE OCDE

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll p1 = a * c;
    ll p2 = a * d;
    ll p3 = b * c;
    ll p4 = b * d;

    p1 = max(p1 , p2);
    p3 = max(p3 , p4);
    cout << max(p1 , p3);

}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    //TEST
    solve();
}



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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    lint x;
    cin >> n >> x;
    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }
    a.push_back(0);
    lint ans = 0;
    REP(i, 1, n){
        lint tmp = a[i] + a[i-1] - x;
        if(tmp > 0){
            a[i] = max(a[i] - tmp, 0LL);
            ans += tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = []
if 1 <= N <= 9:
    print("Yes")
else:
    for i in range(9):
        if int(N/(i+1)) == N/(i+1):
            A.append(N/(i+1))
    if min(A) <= 9:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b/a>=c){
        cout<<c<<endl;
        return 0;
    }
    else 
    cout<<b/a<<endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;
typedef long long ll;

ll n, m, a[10], ans=0;
string ID;
vector<ll> v;

void dfs(ll sum, int pos = 0){
	if( pos == v.size() ){
		if( sum % 10 == 0 ) ans++;
	}else{
		int f = (v[pos] % 2 == 0)? 1 : 2 ;
		
		for(int i=0 ; i < m ; i++ ){
			int num = a[i] * f;
			int add = num / 10 + (num % 10);
			dfs(sum + add, pos + 1);
		}
	}
}

int main(){
	
	cin >> n >> ID >> m;
	for(int i=0 ; i < m ; i++ ){
		cin >> a[i];
	}
	reverse(ID.begin(), ID.end());
	
	ll sum = 0;
	for(int i=0 ; i < ID.size() ; i++ ){
		if( ID[i] == '*' ){
			v.push_back( i );
		}else{
			if( i % 2 == 0 ){
				sum += ID[i] - '0';
			}else{
				int num = (ID[i] - '0') * 2;
				int add = num / 10 + (num % 10);
				sum += add;
			}
		}
	}
	dfs(sum);
	cout << ans << endl;
}

Measured memory_bytes: 1348
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, m, r) = get!(usize, usize, usize);
    let rs: Vec<usize> = util::gets::<usize>().into_iter().map(|v| v - 1).collect();
    let abc = get!(usize, usize, u64; m);

    let mut d = vec![vec![u64::max_value() / 2; n]; n];

    for &(a, b, c) in &abc {
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    let mut dp = vec![vec![vec![u64::max_value() / 2; 1 << r]; r]; r];

    for i in 0..r {
        dp[0][i][1 << i] = 0;
    }

    for i in 1..r {
        for k in 0..r {
            for j in 0..1 << r {
                for w in 0..r {
                    dp[i][w][j | 1 << w] =
                        min(dp[i][w][j | 1 << w], dp[i - 1][k][j] + d[rs[k]][rs[w]]);
                }
            }
        }
    }

    println!(
        "{}",
        (0..r).map(|i| dp[r - 1][i][(1 << r) - 1]).min().unwrap()
    );
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}




int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int x;
    cin >> x;
    Yes(x >= 30);

    

}


Measured memory_bytes: 3656
from collections import defaultdict


def sum_counter(N, adj_nodes, counter_roots, root=0):
    parents = [-1 for _ in range(N)]
    counter = [0 for _ in range(N)]
    frontier = [root]
    counter[root] += counter_roots[root]
    parents[root] = root
    while len(frontier) > 0:
        parent = frontier.pop()
        for child in adj_nodes[parent]:
            if parents[child] >= 0:
                continue
            frontier.append(child)
            parents[child] = parent
            counter[child] += counter[parent] + counter_roots[child]
    return counter


def main():
    N, Q = list(map(int, input().split(' ')))
    adj_nodes = defaultdict(list)
    for _ in range(N - 1):
        a, b = list(map(int, input().split(' ')))
        a -= 1
        b -= 1
        adj_nodes[a].append(b)
        adj_nodes[b].append(a)
    counter_roots = [0 for _ in range(N)]
    for _ in range(Q):
        p, x = list(map(int, input().split(' ')))
        p -= 1
        counter_roots[p] += x
    c = sum_counter(N, adj_nodes, counter_roots)
    print(' '.join(map(str, c)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 93624
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int n,m,c;
    cin>>n>>m>>c;
    vector<vector<int> >a(n);
    vi b(m);
    REP(i,0,m)cin>>b[i];
    ll ct=0;
    REP(i,0,n){
        ll ans=0;
        a[i].resize(m);
        REP(j,0,m){
            cin>>a[i][j];
            ans+=a[i][j]*b[j];
        }
        ans+=c;
        if(ans>0)ct++;
    }
    cout<<ct<<"\n";




	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
const int maxn=1e5+5;
int main()
{
    int r,g,b,n;
    int s=0;
    scanf("%d%d%d%d",&r,&g,&b,&n);
    loop(i,0,n/r)
    loop(j,0,n/g)
    {
        int ans=n-(i*r+j*g);
        if(ans%b==0&&(ans/b)>=0&&(ans/b)<=(n/b)) s++;
    }
    printf("%d\n",s);
}


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


int main() {
    int N, K;
    cin >> N;
    cin >> K;
    int xi[N];
    for(int i = 0; i < N; i++)
        cin >> xi[i];

    int sum = 0;
    for(int i = 0; i < N; i++)
        sum += (xi[i] < (K - xi[i])) ? 2*xi[i] : 2*(K - xi[i]);
    cout << sum;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s.size() >= 4 && (s.at(0) == 'Y' && s.at(1) == 'A' && s.at(2) == 'K' && s.at(3) == 'I')) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

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

	vector<int> a(N);
	int max = -100;
	int min = 100;
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		if (a[i] > max)max = a[i];
		if (a[i] < min)min = a[i];
	}

	int minCost = 1000000;

	for (int i = min; i <= max; i++)
	{
		int cost = 0;
		for (int j = 0; j < N; ++j)
		{
			cost += (a[j] - i)*(a[j] - i);
		}
		if (cost < minCost)minCost = cost;
	}

	cout << minCost << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int ans=a[n-1]-a[0];
    cout << ans << '\n';
}

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

int main() {
	int h, w;
	cin >> h >> w;
	int a[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	vector<vector<int>> ans;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w-1; j++) {
			if (a[i][j] & 1) {
				a[i][j]--;
				a[i][j+1]++;
				ans.push_back({i+1, j+1, i+1, j+2});
			}
		}
	}
	for (int i = 0; i < h-1; i++) {
		int j = w-1;
		if (a[i][j] & 1) {
			a[i][j]--;
			a[i+1][j]++;
			ans.push_back({i+1, j+1, i+2, j+1});
		}
	}
	cout << ans.size() << endl;
	for (auto x : ans) {
		cout << x[0] << ' ' << x[1] << ' ' << x[2] << ' ' << x[3] << endl;
	}
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define MOD DEKAI
#define DEKAI (int)(1e9+7)
#define rep(i,n) lps(i,0,n)
#define lp(i,n) lps(i,0,n)
#define lps(i,j,n) for(int i = j; i < n; i++)
#define atoi(c) c-'0'

int main(){ 
  string A,B,C;
  int a,b,c;
  long long int plus1[55],plus0[55],pl11,pl10,pl01,pl00;
  while(1){
    cin>>A;
    if(A=="0") break;
    cin>>B>>C;
    for(int i=0;i<55;i++){
      plus1[i]=plus0[i]=0;
    }
    plus1[A.size()]=0;
    plus0[A.size()]=1;
    for(int i=A.size()-1;i>=0;i--){
      pl11=pl10=pl01=pl00=0;
      for(int j=0;j<=9;j++){
	if(A[i]!='?') j=atoi(A[i]);
	else if(j==0 && i==0) continue;
	for(int k=0;k<=9;k++){
	  if(B[i]!='?') k=atoi(B[i]);
	  else if(k==0 && i==0) continue;
	  //insert birou
	  if(C[i]!='?'){
	    if((j+k)>9){
	       if((j+k)%10==atoi(C[i])) pl01++;
	       if((j+k+1)%10==atoi(C[i])) pl11++;
	    }else if((j+k)==9){
	      if((j+k+1)%10==atoi(C[i])) pl11++;
	      if((j+k)%10==atoi(C[i])) pl00++;
	    }else{
	      if((j+k+1)%10==atoi(C[i])) pl10++;
	      if((j+k)%10==atoi(C[i])) pl00++;
	    }
	  }else{
	    if((j+k)>9){
	      pl11++;
	      pl01++;
	    }else if((j+k)==9){
	      pl11++;
	      pl00++;
	    }else{
	      pl10++;
	      pl00++;
	    }
	  }
	  //insaato abobu
	  if(B[i]!='?') break;
	}
	if(A[i]!='?') break;
      }
      plus1[i]=((pl11*plus1[i+1])%DEKAI+(pl01*plus0[i+1])%DEKAI)%DEKAI;
      plus0[i]=((pl10*plus1[i+1])%DEKAI+(pl00*plus0[i+1])%DEKAI)%DEKAI;
    }  
    cout<<plus0[0]<<endl;
  }
  
  
  return 0;
}
  



Measured memory_bytes: 3008
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	if(((abs(a-b)) % 2) == 1) cout << "Borys" << endl;
	else cout << "Alice" << endl;
	return 0;
}


Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    /////////////////////
    // Write code below /
    /////////////////////
    
    // input
    int numberOfBlueCard;
    cin >> numberOfBlueCard;
    vector<string> stringOfBlueCards(numberOfBlueCard);
    for (int blueCard_i = 0; blueCard_i < numberOfBlueCard; blueCard_i++) {
        cin >> stringOfBlueCards.at(blueCard_i);
    }
    
    int numberOfRedCard;
    cin >> numberOfRedCard;
    vector<string> stringOfRedCards(numberOfRedCard);
    for (int redCard_i = 0; redCard_i < numberOfRedCard; redCard_i++) {
        cin >> stringOfRedCards.at(redCard_i);
    }
    
    // process
    int maxValue = 0;
    for (int blueCard_i = 0; blueCard_i < numberOfBlueCard; blueCard_i++) {
        int currentValue = 0;
        // blueCardの探索
        for (int blueCard_j = 0; blueCard_j < numberOfBlueCard; blueCard_j++) {
            if (stringOfBlueCards.at(blueCard_i) == stringOfBlueCards.at(blueCard_j)) {
                currentValue++;
            }
        }
        // redCardの探索
        for (int redCard_j = 0; redCard_j < numberOfRedCard; redCard_j++) {
            if (stringOfBlueCards.at(blueCard_i) == stringOfRedCards.at(redCard_j)) {
                currentValue--;
            }
        }
        maxValue = max(maxValue, currentValue);
    }
    
    cout << maxValue << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

struct Edge {
  int now, to, cost;
  Edge() {}
  Edge(int now, int to, int cost) : now(now), to(to), cost(cost) {}
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;
  cin>>N>>M;
  vector<vector<Edge>> edges(N);
  vector<int> points(N,INF);
  REP(i,M){
    int l,r,d;
    cin>>l>>r>>d;
    l--;r--;
    edges[l].emplace_back(l,r,d);
    edges[r].emplace_back(r,l,-d);
  }

  queue<Edge> q;

  bool ans=true;
  for(int i=0;i<N;i++){
    if(points[i]==INF){
      points[i]=0;
      for(Edge e : edges[i])q.push(e);
    }
    while(!q.empty()) {
      Edge edge=q.front();q.pop();
      int now=edge.now;
      int to=edge.to;
      if(points[to]==INF){
        points[to]=edge.cost+points[now];
        for(Edge e : edges[to])q.push(e);
      }else{
        if(points[to]!=edge.cost+points[now])ans=false;
      }
    }
  }

  cout<<(ans?"Yes":"No")<<endl;

}


Measured memory_bytes: 13876
import java.util.*;

public class Main{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		Set<String> set=new HashSet<>();
		int ans=0;
		for(int i=0;i<n;i++) {
			String s=sc.next();
			if(!set.contains(s)) {
				set.add(s);
				ans++;
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 77044
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  ll A;
  ll B;
  cin >>A>>B;
  ll x=__gcd(A,B);
  ll y=A*B;
  ll z=y/x;
  cout<<z<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll gcd; cin >> gcd;

    for(ll i=1; i<n; i++){
        ll a; cin >> a;
        gcd = __gcd(gcd, a);
    }

    ll cnt = 0;
    while(gcd%2 == 0){
        cnt++;
        gcd /= 2;
    }

    cout << cnt << endl;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, 1000){
      string a = to_string(i);
      while(sz(a) != 3){
        a = '0' + a;
      }
      int j = 0;
      int k = 0;
      while(true){
        if(a[j] == s[k]){
          j++;
          k++;
        } else {
          k++;
        }
        if(j == 3){
          ans++;
          break;
        }
        if(k == sz(s)) break;
      }
    }
    print(ans);
    

}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n;
  cin>> n;
  ll a[n],ans[n];
  for(ll i=0;i<n;i++) cin>>a[i];
  
  ans[n-2] = abs(a[n-1]- a[n-2]);
  ans[n-1]= 0;
  for(ll i=n-3;i>=0;i--)
  {
    ans[i] = min(ans[i+1]+abs(a[i]- a[i+1]), ans[i+2] + abs(a[i] - a[i+2]));
  }
  cout<<ans [0]<<endl;
}
              

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

string n, s;

bool check(){
    if (sz(s) < sz(n)) return 1;
    for (int i = sz(n)-1; i >= 0; i--){
        if (n[i] > s[i]) break;
        if (n[i] < s[i]) return 0;
    }
    return 1;
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    reverse(all(n));
    int k;
    cin >> k;
    int l = sz(n);
    int ans = 0;
    if (k == 1){
        for (int i = 0; i < l; i++){
            s += "0";
            for (s[i] = '1'; s[i] <= '9'; s[i]++){
                ans += check();
                //if (check())cout<<s<<endl;
            }
            s[i] = '0';
        }
    }
    if (k == 2){
        for (int i = 0; i < l; i++){
            s += "0";
            for (s[i] = '1'; s[i] <= '9'; s[i]++){
                for (int j = 0; j < i; j++){
                    for (s[j] = '1'; s[j] <= '9'; s[j]++){
                        ans += check();
                    }
                    s[j] = '0';
                }
            }
            s[i] = '0';
        }
    }
    if (k == 3){
        s = "0";
        for (int i = 0; i < l-1; i++){
            ans += i * (i-1) / 2 * 9*9*9;
            s+="0";
        }
        for (s[l-1] = '1'; s[l-1] <= '9'; s[l-1]++){
            if (s[l-1] < n[l-1]){
                ans += (l-1) * (l-2) / 2 * 81;
                continue;
            }
            for (int i = 0; i < l-1; i++){
                for (s[i] = '1'; s[i] <= '9'; s[i]++){
                    for (int j = 0; j < i; j++){
                        for (s[j] = '1'; s[j] <= '9'; s[j]++){
                            ans += check();
                        }
                        s[j] = '0';
                    }
                }
                s[i] = '0';
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import math

A, B = map(int, input().split())

def f(n):
  p_lis = []
  temp = n

  for i in range(2, int(math.sqrt(n)) + 1):
    if temp % i == 0:
      while temp % i == 0:
        temp //= i
      p_lis.append(i)
  
  if temp != 1:
    p_lis.append(temp)

  if p_lis == []:
    p_lis.append(n)

  return p_lis

ans = set(f(A)) & set(f(B))
ans.add(1)

print(len(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long n, a[200005], cnt = 0;
void dfs(int len, int x, long long num)
{
	if(len == 10) return;
	long long tmp;
	for(int i = -1; i <= 1; i++)
	{
		int y = x + i;
		if(0 <= y && y <= 9)
		{
			tmp = 10 * num + y;
			a[++cnt] = tmp;
			dfs(len + 1, y, tmp);
		}
	}
	return;
}

int main()
{
	cin >> n;
	for(int i = 1; i <= 9; i++)
	{
		a[++cnt] = i;
		dfs(1, i, i);
	}
	sort(a + 1, a + cnt + 1);
	cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

signed main() {
	int n;
	int a[100005];
	cin >> n;
	rep(i, n) cin >> a[i];
	sort(a, a + n), reverse(a, a + n);
	int plcnt = 0, cnt = 0;
	rep(i, n) {
		if (a[i] > 0) plcnt++;
		else break;
	}
	plcnt = max((int)1, min(plcnt, n - 1));
	vector<int>pl, mi;
	rep(i, plcnt) {
		pl.push_back(a[i]);
		cnt += a[i];
	}
	for (int i = plcnt; i < n; i++) {
		mi.push_back(a[i]);
		cnt -= a[i];
	}
	cout << cnt << endl;
	for (int i = 0; i < pl.size() - 1; i++) {
		cout << mi[0] << " " << pl[i] << endl;
		mi[0] = mi[0] - pl[i];
	}
	for (int i = 0; i < mi.size(); i++) {
		cout << pl[pl.size() - 1] << " " << mi[i] << endl;
		pl[pl.size() - 1] = pl[pl.size() - 1] - mi[i];
	}

	return 0;
}


Measured memory_bytes: 3576
import sys
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()


def log(k, b):
    a = 0
    while b ** a <= k:
        a += 1
    return a - 1



N = int(input())
if N % 2 == 1:
    print(0)
else:
    k = N // 2
    a = log(k, 5)
    ans = 0
    for i in range(1, a + 1):
        ans += k // (5 ** i)
    print(ans)

Measured memory_bytes: 38384
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	x := nextInts(m)
	sort.Ints(x)
	y := make([]int, m-1)
	for i := 0; i < m-1; i++ {
		y[i] = x[i+1] - x[i]
	}
	sort.Ints(y)
	var ans int
	for i := 0; i < m-1-(n-1); i++ {
		ans += y[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3072
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  if(a % MOD < 0) return MOD + (a % MOD);
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  string s; cin >> s;
  if((s[0] == s[1] and s[1] == s[2]) or
     (s[1] == s[2] and s[2] == s[3])){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 3604
#![allow(non_snake_case, unused_imports)]

// Input
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, 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") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: u32,
        I: u32,
    }
    println!("{}",N-I+1);
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
public class ABC126B {
    public static void Main() {
        string str = System.Console.ReadLine();
        int all = int.Parse(str);
        bool YYMM = false, MMYY = false;
        int first = all / 100;
        int second = all - first * 100;

        if (second != 0 && second <= 12) YYMM = true;
        if (first != 0 && first <= 12) MMYY = true;

        if (YYMM) {
            if (MMYY) System.Console.WriteLine("AMBIGUOUS");
            else System.Console.WriteLine("YYMM");
        } else {
            if (MMYY) System.Console.WriteLine("MMYY");
            else System.Console.WriteLine("NA");
        }

    }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(){
	int n, k, x, y;
	scanf("%d %d %d %d", &n, &k, &x, &y);
	int sum;
	if(n <= k) sum = n * x;
	else sum = k * x + (n - k) * y;
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+4;
int n;
struct Node {
	int v,id;
	friend bool operator < (const Node &a,const Node &b) {
		return a.v<b.v;
	}
}stu[N];
int main() {
	scanf("%d",&n);
	for (register int i=1;i<=n;++i) {
		scanf("%d",&stu[i].v);
		stu[i].id=i;
	}
	sort(stu+1,stu+n+1);
	for (register int i=1;i<=n;++i)
		printf("%d ",stu[i].id);
	return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}
 
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

void solve(){
	ll h,w,a,b;
	cin >> h >> w >> a >> b;
	forn(i,h+1){
		forn(j,w+1){
			if(i*a+(h-i)*(w-a) == j*b+(w-j)*(h-b)){
				ll req[w];
				forn(k,j) req[k]=b;
				forsn(k,j,w) req[k]=h-b;
				forn(p,i){
					ll tot = a;
					forn(k,w){
						if(req[k]>0 && tot>0){
							cout << 1;
							req[k]--;
							tot--;
						}
						else{
							cout << 0;
						}
					}
					cout << ln;
				}
				forsn(p,i,h){
					ll tot = w-a;
					forn(k,w){
						if(req[k]>0 && tot>0){
							cout << 1;
							req[k]--;
							tot--;
						}
						else{
							cout << 0;
						}
					}
					cout << ln;
				}
				return;
			}
		}
	}
	cout << -1 << ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
	// cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int solve(
    int n,
    const std::vector<int>& menus,
    const std::vector<int>& levels,
    const std::vector<int>& bonuses)
{
  int result = 0;
  for (int i = 0; i < n; ++i) {
    const auto current = menus[i];
    result += levels[current - 1];
    if (i >= 1) {
      const auto prev = menus[i - 1];
      if (prev + 1 == current) {
        result += bonuses[prev - 1];
      }
    }
  }
  return result;
}

int main()
{
  int n;
  std::cin >> n;

  std::vector<int> menus(n);
  for (auto& a : menus) {
    std::cin >> a;
  }

  std::vector<int> levels(n);
  for (auto& b : levels) {
    std::cin >> b;
  }

  std::vector<int> bonuses(n - 1);
  for (auto& c : bonuses) {
    std::cin >> c;
  }

  std::cout << solve(n, menus, levels, bonuses) << std::endl;
}


Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
  var K = nextInt();
  myout(s[K - 1]);
}



Measured memory_bytes: 30032
#include<cstdio>
#include<cstring>

char s[55], t[55], s2[55], ans[55] = "0";

int main()
{
    scanf("%s %s", s, t);

    int slng = strlen(s);
    int tlng = strlen(t);

    for (int i = 0; i < slng - tlng + 1; i++) {
        bool con = true;
        for (int j = 0; j < slng; j++) s2[j] = s[j];

        for (int j = 0; j < tlng; j++) 
            if (s2[i + j] == '?' || s2[i + j] == t[j]) 
                s2[i + j] = t[j];
            else {
                con = false;
                break;
            }

        for (int j = 0; j < slng; j++) if (s2[j] == '?') s2[j] = 'a';

        
        if (con) {
            if (strcmp(ans, "0") == 0) 
                for (int k = 0; k < slng; k++) ans[k] = s2[k];
            else
                for (int k = 0; k < slng; k++)
                    if (s2[k] < ans[k]) {
                        for (int l = 0; l < slng; l++) ans[l] = s2[l];
                        break;
                    }
                    else if (s2[k] > ans[k])
                        break;
        }
    }

    if (strcmp(ans, "0") == 0) printf("UNRESTORABLE");
    else printf("%s", ans);

}

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

int S[10000];

int linearSearch(int n, int key){
  int i = 0;
  S[n] = key;
  while ( S[i] != key ) i++;
  if ( i == n ) return 0;
  return 1;
}


int main(){
  int n, q, T, cnt = 0;

  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> S[i];
  cin >> q;
  for ( int i = 0; i < q; i++ ){
    cin >> T;
    cnt += linearSearch(n, T);
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3120
#include<iostream>
using namespace std;
int n;
long a[1<<17],L;
main()
{
	cin>>n>>L;
	for(int i=0;i<n;i++)cin>>a[i];
	int id=-1;
	for(int i=1;i<n;i++)
	{
		if(a[i-1]+a[i]>=L)
		{
			id=i;
			break;
		}
	}
	if(id<0)
	{
		cout<<"Impossible"<<endl;
		return 0;
	}
	cout<<"Possible"<<endl;
	for(int i=1;i<id;i++)cout<<i<<endl;
	for(int i=n-1;i>=id;i--)cout<<i<<endl;
}


Measured memory_bytes: 1664
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end
  attr_reader :heap
 
  def push(x)
    i = @node_num # 自分のノード番号
    @node_num += 1
    while i > 0
      par = (i - 1) / 2 # 親のノード番号
      break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end
 
  alias_method(:<<, :push)
 
  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while (a = i * 2 + 1) < @node_num
      # 子どうしを比較
      b = a + 1
      a = b if b < @node_num && @comp.call(@heap[b], @heap[a])
      break unless @comp.call(@heap[a], x)
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end
 
  def get
    @node_num == 0 ? nil : @heap[0]
  end
 
  def empty?
    return get.nil?
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = PriorityQueue.new { |x, y| x > y }
a.each do |e|
  q.push e
end

m.times do
  q.push(q.pop / 2)
end
puts q.heap.inject(:+)


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define mps 1000000007
int n,m;
vector <int> vec[100005];
int main()
{
    int u,v;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&u,&v);
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
    {
        if(vec[i].size()%2)
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 5376
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int n;
string s, t;
bool judge(int x) {
    for (int i = x; i < n; ++ i) {
        if (s[i] != t[i - x]) return 0;
    }
    return 1;
}
int main() {

    cin >> n;
    cin >> s >> t;
    for (int i = 0; i < n; ++ i) {
        if (judge(i)) {
            cout << n * 2 - (n - i);
            return 0;
        }
    }
    cout << 2 * n << endl;
    return 0;
}


Measured memory_bytes: 256
// tokiomarine2020_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


Measured memory_bytes: 3508