akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    double ans = (n % 2 == 0)
            ?0.5
            :(n / 2 + 1) / (double)n;
    co(ans);
    return 0;
}

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
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;

vector<pair<ll, ll>> bp(51);

// 返り値はPの数だけ
ll solve(ll n, ll x){
    if(n<=-1 || x<=0) return 0;
    ll n_size = bp[n].first+bp[n].second;
    if(x == n_size){
        // 全長の場合
        return bp[n].second;
    }
    if(x == n_size/2+1){
        // ちょっきり半分の場合
        return (bp[n].second-1)/2 + 1;
    }
    else if(x > n_size/2+1){
        // 半分を超える場合
        return (bp[n].second-1)/2 + 1 + solve(n-1, x-(n_size/2+1));
    }
    else{
        // 半分未満の場合
        return solve(n-1, x-1);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, x; cin >> n >> x;
    bp[0] = make_pair(0, 1);
    repf(i, 50){
        bp[i].first = bp[i-1].first*2+2;
        bp[i].second = bp[i-1].second*2+1;
    }
    cout << solve(n, x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        llong n;
        read n;
        int min = INF;
        for ( llong i = 1; i*i <= n; i++ ) {
            if ( n % i == 0 ) {
                String s = std::to_string(n/i);
                chmin ( min, s.size() );
            }
        }
        echo min fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int n; scanf("%d", &n);

	int ans = 0;
	for(int i = 1; i < n - i; i++) {
		if(i == n - i) continue;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

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

template <typename T> void add(T& a, T b, int mod) {
	a += b;
	if (a >= mod)
		a -= mod;
}

template <typename T> void mul(T& a, T b, int mod) {
	a = a * b % mod;
}

struct matrix {
	int n;
	vector<vector<ll>> mat;

	matrix(int _n, int p) {
		n = _n;
		mat.resize(n, vector<ll> (n, 0));
		if (p == 1) {
			for (int i = 0; i < n; i++) mat[i][i] = 1;
		}
	}

	matrix multiply(const matrix& b, int mod) {
		matrix p = matrix(n, 0);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					ll temp = 1;
					mul(temp, mat[i][k] * b.mat[k][j], mod);
					add(p.mat[i][j], temp, mod);
				}
			}
		}
		return p;
	}

	matrix expo(ll pow, const int mod) {
		matrix exp = matrix(n, 1);
		while (pow) {
			if (pow & 1) exp = multiply(exp, mod);
			*this = multiply(*this, mod);
			pow = pow >> 1;
		}
		return exp;
	}

};

const int mod = 1e9 + 7;

class TaskR {
public:
	void solve(std::istream& in, std::ostream& out) {
		int N;
		ll K;
		in >> N >> K;
		matrix adj = matrix(N, 0);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				in >> adj.mat[i][j];
			}
		}
		matrix res = adj.expo(K, mod);
		ll ans = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				add(ans, res.mat[i][j], mod);
			}
		}
		out << ans;
	}
};

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


Measured memory_bytes: 3672
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.io.*;
import java.util.*;
public class Main
{
    
    public static long func(long dp[][],char matrix[][], int h , int w)
    {
        
        dp[h-1][w-1]=1;
        
        for(int i =h-1;i>=0;i--)
        {
            
            for(int j=w-1;j>=0;j--)
            {
                
                if(i==h-1 && j==w-1)
                {
                    continue;
                }
                
                if(matrix[i][j]=='#')dp[i][j]=0;
                else{
                    dp[i][j]=(((i==h-1)?0:dp[i+1][j])+((j==w-1)?0:dp[i][j+1]))%1000000007l;
                    
                }
            }
        }
        return dp[0][0];        /*
        if((i>=h) ||(j>=w))
        {
            return 0;
        
        }
        if((i==h-1) && (j==w-1))
        {
            
            return 1;
        
        }
        
        if(dp[i][j]!=0)
        {
            return dp[i][j];
        }
        if(matrix[i][j]=='#')
        {  
            return 0;
        }
        long x=func(dp,matrix,i,j+1,h,w);
        long y=func(dp,matrix,i+1,j,h,w);
        
        
        //System.out.println(x+y);
        return dp[i][j]=(x+y)%1000000007l;
        */
        
        
        
    }
    
    
    
    
	public static void main(String[] args) throws Exception {
		//System.out.println("Hello World");
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		String ss[]=s.split(" ");
		int h=Integer.parseInt(ss[0]);
		int w=Integer.parseInt(ss[1]);
		char ch[];
		char matrix[][]=new char[h][w];
		for(int i=0;i<h;i++)
		{
		    s=br.readLine();
		    ch=s.toCharArray();
		    for (int j=0;j<w;j++)
		    {
		        
		        matrix[i][j]=ch[j];
		    }
		    
		    
		    
		}
		
		long dp[][]=new long[h][w];
            
		long ans =func(dp,matrix,h,w);
		
		long mod=1000000007l;
		System.out.println(ans%mod);
		
		
	}
}


Measured memory_bytes: 42348
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    S=list(map(lambda x:(x=='o')-0,input()))

    # 4パターン試す
    from itertools import product
    for a,b in product(range(2),repeat=2):
        ans=[None]*n
        ans[0]=a; ans[1]=b

        for i in range(2,n):
            if(S[i-1]==ans[i-1]): ans[i]=ans[i-2]
            else: ans[i]=1-ans[i-2]

        if((S[0]==ans[0])==(ans[1]==ans[-1]) and (S[-1]==ans[-1])==(ans[0]==ans[-2])):
            for s in ans: print('S' if(s) else 'W',end='')
            print()
            return
    print(-1)
resolve()

Measured memory_bytes: 57120
#include <stdio.h>

int main()
{
	int i, N, h[100001][3];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d %d", &(h[i][0]), &(h[i][1]), &(h[i][2]));
	
	int j, dp[100001][3] = {{}, {h[1][0], h[1][1], h[1][2]}};
	for (i = 2; i <= N; i++) {
		if (dp[i-1][1] + h[i][0] > dp[i][0]) dp[i][0] = dp[i-1][1] + h[i][0];
		if (dp[i-1][2] + h[i][0] > dp[i][0]) dp[i][0] = dp[i-1][2] + h[i][0];
		if (dp[i-1][0] + h[i][1] > dp[i][1]) dp[i][1] = dp[i-1][0] + h[i][1];
		if (dp[i-1][2] + h[i][1] > dp[i][1]) dp[i][1] = dp[i-1][2] + h[i][1];
		if (dp[i-1][0] + h[i][2] > dp[i][2]) dp[i][2] = dp[i-1][0] + h[i][2];
		if (dp[i-1][1] + h[i][2] > dp[i][2]) dp[i][2] = dp[i-1][1] + h[i][2];
	}
	
	int max = 0;
	for (j = 0; j <= 2; j++) if (dp[N][j] > max) max = dp[N][j];
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4080
using System;

namespace _0003 {

	public static class Program {

		public static void Main() {
			var dataCount = int.Parse(Console.ReadLine());
			var result = new string[dataCount];

			for (int i = 0; i < dataCount; i++) {
				var splitStr = Console.ReadLine().Split(' ');
				var inarray = new int[3];
				inarray[0] = int.Parse(splitStr[0]);
				inarray[1] = int.Parse(splitStr[1]);
				inarray[2] = int.Parse(splitStr[2]);
				Array.Sort(inarray);

				if (CheckLength(inarray[0]) && CheckLength(inarray[1]) && CheckLength(inarray[2])) {
					result[i] = inarray[0] * inarray[0] + inarray[1] * inarray[1] == inarray[2] * inarray[2] ? "YES" : "NO";
				} else {
					result[i] = "NO";
				}
			}

			for (int i = 0; i < dataCount; i++) {
				Console.WriteLine(result[i]);
			}
		}

		private static bool CheckLength(int x) {
			return 1 <= x && x <= 1000;
		}

	}

}

Measured memory_bytes: 9284
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long 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;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n, i, p, sum = 0,j;
	cin >> n;
	for (i = 1; i <= n; i++) {
		sum += i;
		if (sum >= n) {
			p = sum - n;
			for (j = 1; j <= i; j++)
				if (j != p)
					cout << j << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int n,ans=0;
int a[200020],ra[200020];

signed main(){
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
        ra[a[i]]=i;
    }
    set<int>s;
    s.insert(-1);s.insert(n);
    repe(d,1,n){
        int i=ra[d];
        //cout<<i<<endl;
        auto it=s.lower_bound(i);
        int r=*it;
        //cout<<r<<endl;
        it--;
        int l=*it;
        //cout<<l<<endl;
        ans+=(d)*(i-l)*(r-i);
        //cout<<ans<<endl;
        s.insert(i);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
  // RRRRWWWWW のような状態に至る必要がある
  // 一番左のRより前のWをRにする
  // 一番右のRをWにする
  // RとR, WとWは入れ替える必要がない
  //
  int n;
  string c;
  cin >> n >> c;
  int ans_r = 0, ans_w = 0;
  int count_r = 0;
  for (int i = 0; i < n; i++)
  {
    if (c.at(i) == 'R')
    {
      count_r++;
    }
  }
  for (int i = 0; i < count_r; i++)
  {
    if (c.at(i) == 'W')
    {
      ans_w++;
    }
  }
  for (int i = count_r; i < n; i++)
  {
    if (c.at(i) == 'R')
    {
      ans_r++;
    }
  }
  cout << (min(ans_w, ans_r)) << endl;
}


Measured memory_bytes: 3724
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var max = arrayOf(1, 0)
    var second_max = arrayOf(1, 0)
    for (i in 1..N) {
        val A = readLine()!!.toInt()
        when (i) {
            1 -> max[1] = A
            else -> {
                if (max[1] < A) {
                    second_max = max
                    max = arrayOf(i, A)
                }else if (second_max[1] < A){
                    second_max = arrayOf(i, A)
                }
            }
        }
    }
    for (i in 1..N) {
        when (i) {
            max[0] -> {
                println(second_max[1])
            }
            else -> {
                println(max[1])
            }
        }
    }
}


Measured memory_bytes: 47564
fun main(args: Array<String>) = yorukatsu9e()

fun yorukatsu9e() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val keys = Array(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        val cList = readLine()!!.split(' ').map { it.toInt() }
        val canOpen = cList.map { 1 shl (it - 1) }.reduce { acc, i -> acc or i }
        Key(a, canOpen)
    }

    val inf = Long.MAX_VALUE / 1000
    val dp = LongArray(10000) { inf }
    dp[0] = 0

    for ((price, canOpen) in keys) {
        for (box in 0 until (1 shl n)) {
            val or = box or canOpen
            dp[or] = Math.min(dp[or], dp[box] + price)
        }
    }

    val answer = dp[(1 shl n) - 1].let { if (it < inf) it else -1 }

    println(answer)
}

private data class Key(val price: Int, val canOpen: Int)


Measured memory_bytes: 41600
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int x;
  cin >> x;
  vector<bool> v(1001, false);
  v[1] = true;
  rep(i, 2, 51) {
    int a = i * i;
    while (a <= 1000) {
      v[a] = true;
      a *= i;
    }
  }

  repr(i, 1, x + 1) {
    if (v[i]) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("Sunny")){
            System.out.println("Cloudy");
        }else if(s.equals("Cloudy")){
            System.out.println("Rainy");
        }else{
            System.out.println("Sunny");
        }
    }
}


Measured memory_bytes: 23764
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 n: usize = read();
    let q: usize = read();
    let mut tree = vec![vec![]; n];
    for _ in 0..(n - 1) {
        let a: usize = read::<usize>() -1;
        let b: usize = read::<usize>() -1;
        tree[a].push(b);
        tree[b].push(a);
    }
    let mut add_values = vec![0; n];
    for _ in 0..q {
        // operation vertex
        let p: usize = read::<usize>() - 1;
        // add value
        let x: usize = read::<usize>();
        add_values[p] += x;
    }
    let mut ans = vec![0; n];
    get_values(&tree, &add_values, 0, 0, 0, &mut ans);
    println!(
        "{}",
        ans
            .iter()
            .map(|i| i.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}
fn get_values(
    tree: &Vec<Vec<usize>>,
    add_values: &Vec<usize>,
    vertex: usize,
    before: usize,
    plus_val: usize,
    ans: &mut Vec<usize>,
) {
    let mut plus_val = plus_val;
    plus_val += add_values[vertex];
    ans[vertex] =  plus_val;
    for vert in &tree[vertex] {
        if *vert == before {
            continue;
        }
        get_values(&tree, &add_values, *vert, vertex, plus_val, ans)
    }
}


Measured memory_bytes: 50812
#include<stdio.h>
   typedef struct {
    char mark;
    int value;
  } card;

  void swap(card * , card *);
  void SelectionSort(card * ,int N);
  void BubbleSort(card * , int N);



  int main() {
    int i,N,flag=1;

     while(1) {
      scanf("%d ",&N);
      if(1<=N && N<=36) break;
    }

     card  C1[100],C2[100];
    for(i=0;i<N;i++)  {
      scanf("%c%d ",&C1[i].mark , &C1[i].value);
        //printf("%c%d",C1[i].mark,C1[i].value);
      C2[i] = C1[i];
    }

    BubbleSort(C1,N);
    SelectionSort(C2,N);

    for(i=0;i<N;++i) {
      if(0 < i)printf(" ");
      printf("%c%d",C1[i].mark,C1[i].value);
    }
    printf("\n");
    printf("Stable\n");

    for(i=0;i<N;i++){
      if(0<i)printf(" ");
      printf("%c%d",C2[i].mark,C2[i].value);
      if(!(C2[i].mark == C1[i].mark && C2[i].value == C1[i].value))flag = 0;
    }
    printf("\n");
    if(flag) printf("Stable\n");
    else printf("Not stable\n");

    return 0;
  }

  void swap( card *a,   card *b)
  {
    card t;
    t = *a;
    *a  = *b;
    *b =t;
  }


   void BubbleSort(  card *C, int N)
   {
     int i,j;
     for(i=0;i < N-1;i++) {
       for(j =N-1;j>=i;j--) {
         if(C[j].value < C[j-1].value) swap(&C[j],&C[j-1]);
       }
     }
   }

  void SelectionSort( card *C, int N)
   {
     int i,j,minj;
     for(i=0;i<N;i++) {
       minj = i;
       for(j=i;j<N;j++){
         if(C[j].value < C[minj].value)minj =j;
       }
         swap( &C[i] , &C[minj]);
     }
   }

Measured memory_bytes: 616
#include <iostream>
#include <cstring>
#include <vector>
#define NUM 1000
#define MOD 1000000007
using namespace std;

vector<string> s;
int m, n;
bool visited[NUM][NUM] = {false};
long long int memo[NUM][NUM] = {0};

long long int ways(int x, int y)
{
    if (visited[x][y])
    {
        return memo[x][y];
    }
    else
    {
        visited[x][y] = true;
        if (s[x][y] == '#')
        {
            memo[x][y] = 0;
        }
        else
        {
            if (y == 0)
            {
                if (x == 0)
                {
                    memo[x][y] = 1;
                }
                else
                {
                    memo[x][y] = ways(x-1, y) % MOD;
                }
            }
            else
            {
                if (x == 0)
                {
                    memo[x][y] = ways(x, y-1) % MOD;
                }
                else
                {
                    memo[x][y] = (ways(x-1, y) % MOD + ways(x, y-1) % MOD) % MOD;
                }
            }
        }
        return memo[x][y];
    }
}

int main()
{
    string temp;
    cin>>m>>n;
    
    for(int i=0; i<m; i++)
    {
        cin>>temp;
        s.push_back(temp);
    }
    
    cout<<ways(m-1, n-1);
    return 0;
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
#define int         int64_t
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mi        map<int,int>
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,sum=0,flag=0,t,a[200005],ans=0;
void solve(){
    vector<string> v={"Sunny", "Cloudy", "Rainy"};
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        if(v[i]==s){
            cout<<v[(i+1)%3]<<endl;
        }
    }
}
signed main()
{
    ios
    int test=1;
    //cin>>test;
    while(test--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL n, m, i, j, k, a[55], c[55];
LL dfs(LL n, LL k){
	if(k <= 0 || n < 0) return 0;
	if(k >= c[n]) return a[n];
	LL s = dfs(n-1, k-1);
	if(k > c[n-1]+1) s++;
	s += dfs(n-1, k-c[n-1]-2);
	return s;
}
int main(){
	scanf("%lld%lld", &n, &k);
	a[0] = c[0] = 1;
	for(i=1; i<=n; i++){
		a[i] = a[i-1] * 2 + 1;
		c[i] = c[i-1] * 2 + 3;
	}
	printf("%lld\n", dfs(n, k));
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)
INF = 10 ** 10

class edge:
    def __init__(self, fr, to, cost): self.fr, self.to, self.cost = fr, to, cost

def input(): return sys.stdin.readline().strip()
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M, P = ZZ()
    es = []
    for _ in range(M):
        a, b, c = ZZ()
        a -= 1
        b -= 1
        es.append(edge(a, b, -(c-P)))

    d = [INF] * N
    d[0] = 0
    for i in range(N-1):
        for e in es:
            if d[e.fr] != INF and d[e.to] > d[e.fr] + e.cost:
                d[e.to] = d[e.fr] + e.cost
    n = [False] * N
    for i in range(N):
        for e in es:
            if d[e.fr] != INF and d[e.to] > d[e.fr] + e.cost:
                d[e.to] = d[e.fr] + e.cost
                n[e.to] = True
            if n[e.fr] == True: n[e.to] = True
    print(-1 if n[N-1] else max(0, -d[N-1]))

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 42992
#include<stdio.h>
int main(void)
{
  int A,B;
  
  scanf("%d",&A);
  scanf("%d",&B);
  
  if(A > 2*B){
    printf("%d",A - 2*B);
  }
  else{
    printf("0");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define F 44

  int main(){
    int i, n;

    scanf("%d", &n);
    printf("%d\n", fibonacci(n));

    return 0;
  }

  int fibonacci(int n){
    int i;
    int a = 1, b = 1, temp = 1;

    for(i = 2; i <= n; i++){
      temp = a + b;
      a = b;
      b = temp;
    }
    return temp;
  }

Measured memory_bytes: 596
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> imos(n,0);
    int l,r;
    for(int i=0; i<m; i++){
        cin >> l >> r;
        imos[l-1]++;
        imos[r]--;
    }
    int ans=0;
    for(int i=1; i<n; i++){
        imos[i]+=imos[i-1];
    }
    for(int i=0; i<n; i++){
        if(imos[i]==m)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
n = int(input())
arr = list(map(int,input().split()))
ok = 'Yes'
arr[0] -= 1

for i in range(1,n):
    if arr[i] < arr[i-1]:
        ok = 'No'
        break
    elif arr[i] == arr[i-1]:
        continue
    else:
        arr[i] -= 1

print(ok)

Measured memory_bytes: 14252
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define makep make_pair
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 150005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll gpow2(ll x) {
    ll i=0;
    while(x>=pow(2, i)) {
        i++;
    }
    
    return pow(2, i);
}



int main(void) {
    ll N;
    cin >> N;
    ll i;
    ll t;
    vector<ll> v;
    ll ans=0;
    Map mp;
    
    for(i=0; i<N; i++) {
        cin >> t;
        v.push_back(t);
        mp[t]++;
    }
    sort(v.begin(), v.end());
    
    for(i=v.size()-1; i>=0; i--) {
        if(binary_search(v.begin(), v.end(), gpow2(v[i])-v[i]) && mp[v[i]]>0 && mp[gpow2(v[i])-v[i]]>0) {
            if(gpow2(v[i])-v[i]==v[i] && mp[v[i]]==1) continue;
            
            mp[gpow2(v[i])-v[i]]--;
            mp[v[i]]--;
            ans++;
        }
        
        
        
    }
    
    
    pr(ans);
    
    
    
    
    
}




Measured memory_bytes: 16368
#include <bits/stdc++.h>
using namespace std;
int a[500005];
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int x;
        cin>>x;
        a[x]++;
        a[x-1]++;
        a[x+1]++;
    }
    int maxv=0;
    for(int i=0;i<=500000;i++)
        if(a[i]>maxv)
            maxv=a[i];
    cout<<maxv;
    return 0;
 } 

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#define INF 0x3f3f3f3f
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
#define exp 1e-10
#define clr(a) memset(a, 0, sizeof(a))
#define fi first
#define se second
//#define debug
const double pi = acos(-1.0);
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

const int maxn = 1e5 + 10;
int a[maxn];
LL  p[maxn << 1];
int main() {
    int n, m;
    LL tot = 0;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    for (int i = 1; i < n; i++) {
        int l = a[i - 1], r = a[i];
        if (l > r) r += m;
        tot += r - l;
        if (r - l > 1) {
            p[l + 2] += 1;
            p[r + 1] -= r - l;
            p[r + 2] += r - l - 1;
        }
    }
    LL ans = 0;
    for (int i = 1; i <= m << 1; i++)
        p[i] += p[i - 1];
    for (int i = 1; i <= m << 1; i++)
        p[i] += p[i - 1];
    for (int i = 1; i <= m; i++)
        ans = max(ans, p[i] + p[i + m]);
    cout<<tot - ans<<endl;
    return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  map<int, int> cm;
  for(int i=0; i<n; i++){
    int a;
    cin>>a;
    cm[a]++;
  }
  int lp=(int)cm.size()-k;
  if(lp<=0){
    cout<<0<<endl;
    return 0;
  }
  vector<int> ct;
  for(auto a : cm) ct.push_back(a.second);
  sort(ct.begin(), ct.end());
  int cnt=0;
  for(int i=0; i<lp; i++) cnt+=ct[i];
  cout<<cnt<<endl;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll m;
  cin >> m;
  VLL d(m),c(m);
  ll ans = -1;
  ll sum = 0;


  rep(i,m) {
    cin >> d[i] >> c[i];
    ans += c[i];
    sum += d[i] * c[i];
  }

  
  while(sum >= 10){
    ans += sum/10;
    sum = sum % 10 + sum / 10;
  }

  cout << ans << endl;

 
  return 0;
}


Measured memory_bytes: 3456
def c_reconciled(MOD=10**9 + 7):
    from math import factorial
    N, M = [int(i) for i in input().split()]

    if N == M:
        return (factorial(N) * factorial(M) * 2) % MOD
    elif abs(N - M) == 1:
        return (factorial(N) * factorial(M)) % MOD
    return 0

print(c_reconciled())

Measured memory_bytes: 5192
import numpy as np
#文字列をASCII codeのリストで管理
S = np.array([ord(i) - 97 for i in input()], dtype=int)
T = np.array([ord(i) - 97 for i in input()], dtype=int)
ls = len(S)
lt = len(T)
#S[i] == T[j]であれば、i * j行列の[i,j]成分が1となる行列
equal = np.equal.outer(S,T).astype(int)
#print(equal)
 
dp = [np.zeros(lt + 1,dtype = int)]
#print(dp)
for i in range(ls):
  #追加された最後のdp列をx,newDPとする
  x = dp[-1].copy()
  newDP = x.copy()
  #一致しているところで1を足し、そうでないところはそのまま
  newDP[1:] = np.maximum(x[:-1] + equal[i],newDP[1:])
  #dp[i] = i以前のdpの最大値に更新
  np.maximum.accumulate(newDP, out = newDP)
  #最大共通部分を計算するだけなら一列のdp列を使い回せば良いが
  #文字列の復元のために、dp列を追加する
  dp.append(newDP)
  #print(dp)
 
 
ans = ""
i, j = ls, lt
#数列の復元と文字列への復元
while i > 0 and j > 0:
  if S[i - 1] == T[j - 1]:
    ans += chr(S[i - 1] + 97)
    i -= 1
    j -= 1
    continue
  if dp[i][j] == dp[i - 1][j]:
    i -= 1
  else:
    j -= 1

#リバース
print(ans[::-1])


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

using namespace std;

const int N = 1e5 + 9;

vector<int>V[N];
int l[N], r[N], n, k, col[N];

void Dfs (int u, int fa) {
	for (auto v: V[u]) if (v != fa) {
		Dfs(v, u);
		if (r[v] + 1 < r[u]) r[u] = r[v] + 1;
		if (l[v] - 1 > l[u]) l[u] = l[v] - 1;
		if (l[u] > r[u]) puts("No"), exit(0);
	}
}

void Dfs2 (int u, int fa) {
	for (auto v: V[u]) if (v != fa) {
		col[v] = col[u] - 1 >= l[v] && col[u] - 1 <= r[v] ? col[u] - 1 : col[u] + 1;
		if (col[v] < l[v] || col[v] > r[v]) puts("No"), exit(0);
		Dfs2(v, u);
	}
}

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) l[i] = -1e9, r[i] = 1e9;
	for (int i = 1, a, b; i < n; ++i) scanf("%d%d", &a, &b), V[a].push_back(b), V[b].push_back(a);
	scanf("%d", &k);
	for (int i = 1, v, p; i <= k; ++i) scanf("%d%d", &v, &p), l[v] = r[v] = p;
	Dfs(1, 0);
	col[1] = l[1]; Dfs2(1, 0);
	puts("Yes");
	for (int i = 1; i <= n; ++i) if (!(col[i] >= l[i] && col[i] <= r[i]))
	puts("A");
	for (int i = 1; i <= n; ++i) printf("%d\n", col[i]);
	return 0;
}

Measured memory_bytes: 13824
import java.util.*;

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

		final int INF = 1000000000;
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] d = new int[N][N];
		for(int i=0; i<N; i++) {
			Arrays.fill(d[i], INF);
			d[i][i] = 0;
		}
		int[] a = new int[M];
		int[] b = new int[M];
		int[] c = new int[M];
		for(int i=0; i<M; i++) {
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
			c[i] = sc.nextInt();
			d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
		}
		
		for(int k=0; k<N; k++)
			for(int i=0; i<N; i++)
				for(int j=0; j<N; j++)
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
		
		int ans = 0;
		for(int i=0; i<M; i++)
			if(d[a[i]][b[i]]<c[i])
				ans ++;
		
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 14192
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n, m, flag;
int a[200005], b[200005];
int main()
{
	flag = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	scanf("%d", &m);
	for(int i = 1; i <= m; i++) scanf("%d", &b[i]);
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + m);
	int ans = 1;
	if(n < m) flag = 1;
	for(int i = 1; i <= m; i++)
	{
		if(flag == 1) break;
		if(a[ans] == b[i]) {
			ans++;
		}
		else if(a[ans] > b[i]) {
			flag = 1;
		}
		else if(a[ans] < b[i]) {
			while(true)
			{
				if(ans > 200000) {
					flag = 1;
					break;
				}
				ans++;
				if(a[ans] == b[i]) {
					ans++;
					break;
				}
				else if(a[ans] > b[i]) {
					flag = 1;
					break;
				}
			}
			if(flag == 1) break;
		}
	}
	if(flag == 1) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 1664
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    N = I()
    print(pow(N, 3))
    return


# B
def B():
    N = I()
    A = LI()
    B = LI()
    C = LI()
    a_p = -1
    ans = 0
    for a in A:
        if (a - a_p == 1):
            ans += B[a - 1] + C[a - 2]
        else:
            ans += B[a - 1]
        a_p = a
    print(ans)
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    B()
    return


# Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 38384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
a = list(map(int, input().split()))
one_index = a.index(1)
l_min = max(0, one_index - k + 1)
l_max = one_index

ans = 10 ** 7
for i in range(l_min, l_max + 1):
    r = min(n - 1, i + k - 1)
    l_ans = ((i + (k - 1) - 1) // (k - 1))
    r_ans = ((((n - 1) - r) + (k - 1) - 1) // (k - 1))
    ans = min(ans, l_ans + r_ans + 1)
print(ans)


Measured memory_bytes: 84056
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,z,w;
  cin>>n>>z>>w;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  int ans;
  if(n>=2){
    ans = max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));
  }else{
    ans = abs(a[n-1]-w);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

const int INF = 1000000000;

int main(void)
{
	int edge[21][21];
	int n, m, a, b, c, d;
	int x1, x2, y1, y2;
	int i, j, k;
	
	scanf("%d", &n);
	scanf("%d", &m);
	
	for (i = 0; i <= n; i++){
		for (j = 0; j <= n; j++){
			edge[i][j] = INF;
		}
	}
	
	for (i = 0; i < m; i++){
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		edge[a][b] = c;
		edge[b][a] = d;
	}
	 
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	
	for (k = 1;  k <= n; k++){
		for (i = 1; i <= n; i++){
			for (j = 1; j <= n; j++){
				
				if (edge[i][j] > edge[i][k] + edge[k][j]){
					edge[i][j] = edge[i][k] + edge[k][j];
				}
			}
		}
	}
	
	printf("%d\n", y1 - y2 - edge[x1][x2] - edge[x2][x1]);
	
	return (0);
}

Measured memory_bytes: 600
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let A: Vec<Vec<usize>> = sc.mat(2, N);
    let mut ans = 0;
    for i in 0..N {
        let mut y = 0;
        let mut score = 0;
        for j in 0..N {
            score += A[y][j];
            if j == i {
                y += 1;
                score += A[y][j];
            }
        }
        ans = max(ans, score);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

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

int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    
    double Hx, Hy, Mx, My;
    
    int fun = H * 60 + M;
    fun %= 720;
    
    
    Hx = sin((double) fun / 720 * 2 * M_PI) * A;
    Hy = cos((double) fun / 720 * 2 * M_PI) * A;
    Mx = sin((double) M / 60 * 2 * M_PI) * B;
    My = cos((double) M / 60 * 2 * M_PI) * B;
    
    /*
    cout << fun << endl;
    cout << Hx << " " << Hy << " " << Mx << " " << My << endl;
    */
    
    double ans = sqrt(pow(Hx - Mx, 2) + pow(Hy - My, 2));
    
    printf("%.16lf\n", ans);
    
}

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

typedef long long ll;
typedef int ii;
typedef vector<int> vi;

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for1(i,a,b) for(i=a;i<b;i++)
#define pb push_back
//#define mp make_pair

ii main()
{
    
    string s,t; cin>>s>>t; ii f=0,i;
    
    
    for1(i,0,s.length())
    {
        
        if(s[i]!=t[i]) f++;
        
        
     
        
    }
    

    cout<<f<<"\n";
    
}


Measured memory_bytes: 3892
N = int(input())
H = list(map(int, input().split()))
Highest = 0
CNT = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        CNT += 1
    else:
        Highest = max(CNT, Highest)
        CNT = 0
Highest = max(CNT, Highest)
print(Highest)            

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

int main(){

    int n,c,k;
    cin >> n >> c >> k;
    vector<int> t(n);
    
    for(int i = 0; i < n; i++)
      cin >> t.at(i); 

    sort(t.begin(), t.end());

    int ans = 1;
    int count = 1;
    int ht = t.at(0);
    for(int i = 0; i < n; i++){
      
          if( count == c+1 ){
                ans++;
                ht = t.at(i);
                count = 1;
          }else if( t.at(i) > ht+k ){
                ans++;
                ht = t.at(i);
                count = 1; 
          }
              
          count++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
	using namespace std;
	#define mp make_pair
	#define ll long long
	#define pb push_back
	#define mp make_pair
	#define M LONG_LONG_MAX
	#define IM INT_MAX
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int32_t main()
    {
		IOS;
	    string s;
	    ll n,i,j;
	    cin>>s;
	    for(i=1;i<s.length();i++)
	    {
	        if(s.at(i)==s.at(i-1))
	        {
	            cout<<"Bad";
	            return 0;
	        }
	    }
	    cout<<"Good";
		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	int ans=0;
	if(a==0) cout<<1;
	if(b==0) cout<<2;
	if(c==0) cout<<3;
	if(d==0) cout<<4;
	if(e==0) cout<<5;
}

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

#define rotate_swap(x,a,b,c,d) swap(x.a,x.b);swap(x.b,x.c);swap(x.c,x.d);

struct dice{
  int top,front,right,left,back,bottom;
};
void rotate_r(dice &x){rotate_swap(x,top,left,bottom,right);}
void rotate_l(dice &x){rotate_swap(x,top,right,bottom,left);}
void rotate_f(dice &x){rotate_swap(x,top,back,bottom,front);}
void rotate_b(dice &x){rotate_swap(x,top,front,bottom,back);}

int main()
{
  int n;
  while(cin >> n){
    if(n==0)break;

    dice d;
    d.top = 1;
    d.front = 2;
    d.left = 3;
    d.bottom = 6;
    d.back = 5;
    d.right = 4;
    for(int i = 0; i < n; ++i){
      string in;
      cin >> in;
      if(in=="north"){
        rotate_f(d);
      }else if(in=="east"){
        rotate_r(d);
      }else if(in=="west"){
        rotate_l(d);
      }else if(in=="south"){
        rotate_b(d);
      }

    }
    cout << d.top << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1212