akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int dfs(int n,vector<vector<int>> s,vector<int> push,vector<int> p,int now){
	if (now==n-1) {
		vector<int> tp(p.size(),0);
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < s[i].size(); j++) {
				tp[i]+=push[s[i][j]];
				tp[i]%=2;
			}
		}
		if (tp==p) {
			return 1;
		}else {
			return 0;
		}
	}else {
		vector<int> push0,push1;
		push0=push;
		push0[now+1]=0;
		push1=push;
		push1[now+1]=1;
		return dfs(n,s,push0,p,now+1)+dfs(n,s,push1,p,now+1);
	}
}

int main(){
	int n,m;
	cin>>n>>m;
	int tk,ts;
	vector<vector<int>> s(m);
	for (int i = 0; i < m; i++) {
		cin>>tk;
		for (int j = 0; j < tk; j++) {
			cin>>ts;
			s[i].push_back(ts-1);
		}
	}
	vector<int> p(m);
	for (int i = 0; i < m; i++) {
		cin>>p[i];
	}
	vector<int> push(n);
	cout<<dfs(n,s,push,p,-1);
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Applicative((<$>))
import Control.Monad
import Data.Map ((!))
import qualified Data.Map as M
import qualified Data.List as L
import Data.Maybe (catMaybes)
-- import qualified Data.Char as C
-- import qualified Data.IntSet as I
import Debug.Trace
--------------------------------------------
readInt    = read :: String -> Int
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
int2bin 0 =  []
int2bin n =  n `mod` 2 : int2bin (n `div` 2)
----------------------------------------------

main :: IO ()
main = do
  [q,h,s,for2] <- getIntList
  n <- getInt
  let for05 = min (2*q) h
      for1  = min (2*for05) s
  if for1*2 <= for2 then
    print (n*for1)
  else
    let (sho,amari) = n `quotRem` 2
    in print $ sho*for2 + amari*for1


Measured memory_bytes: 508
n=int(input())
s=input()

E=[0]*n
W=[0]*n
if s[-1]=="E": E[-1]=1
if s[0]=="W" : W[0]=1


for i in range(n-1):
  E[n-2-i]=E[n-1-i]+1 if s[n-2-i]=="E" else E[n-1-i]
  W[i+1]= W[i]+1 if s[i+1]=="W" else W[i]
  
ans=min(E[1] , W[-2] )
for i in range(n-2):
  ans=min(ans,E[i+2]+W[i])
  
print(ans)
    

Measured memory_bytes: 17640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

namespace PaizaSkillCheck
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] line = Console.ReadLine().Split(' ');

            int sum = 0;
            int max = 0;

            for (int i = 0; i < line.Length; i++)
            {
                int v = int.Parse(line[i]);

                sum += v;
                max = Math.Max(max, v);
            }

            sum -= max;

            Console.WriteLine((sum > max) ? "Yes" : "No");
            Console.ReadLine();
        }
    }

}


Measured memory_bytes: 11092
//    >File Name: at.cpp
//    > Author: Webwei

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		if(s[i]==',')
			s[i]=' ';
		cout<<s[i];
	}
	return 0;
}


Measured memory_bytes: 256
import os, sys, re, math

(N, M) = [int(i) for i in input().split()]
prefs = []
cities = []
for i in range(100000):
    prefs.append([])

for i in range(M):
    (p, y) = [int(j) for j in input().split()]
    city = [i, p, y, -1]
    prefs[p - 1].append(city)
    cities.append(city)

for pref in prefs:
    pref.sort(key=lambda x: x[2])
    for i in range(len(pref)):
        pref[i][3] = i

for c in cities:
    print ('%06d%06d' % (c[1], c[3] + 1))


Measured memory_bytes: 37724
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/


ll n,k,a[110],dp[100010]={},ru[100010],mod=1e9+7;

int main(void){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	//
	dp[0]=1;
	//
	rep(i,n){
		ru[0]=dp[0]%mod;
		reg(j,1,k)ru[j]=(dp[j]+ru[j-1])%mod;
		reg(j,0,k){
			dp[j]=ru[j];
			if(j-a[i]-1>=0)dp[j]=(dp[j]-ru[j-a[i]-1]+mod)%mod;
		}
	}
	//
	// reg(j,0,k)cout<<dp[j]<<" ";
	// cout<<endl;
	//
	cout<<dp[k]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

ll lcm(ll a,ll b){
	ll a_=a,b_=b;
	ll r=0;
	do{
		r=a%b;
		a=b;
		b=r;
	} while (r!=0);
	return a_/a*b_;
}
int main(){
	ll a; cin>>a;
	ll b; cin>>b;
	ll n; cin>>n;
	if(a*n>=(b-1)*a){
		cout<<((b-1)*a)/b<<endl;
	}else{
		cout<<(a*n)/b<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var ps = Input.ar;
        var res = 0;
        for (var i = 0; i < num; i++)
        {
            if (ps[i] == i + 1) res++;
            if (i!=num-1&&ps[i] == i + 1 && ps[i + 1] == i + 2)
                i++;
        }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 19040
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	int N, K;
	cin >> N;
	cin >> K;
	int c = 1;
	for (int i = 0; i < N; i++) {
		c = min(2 * c, c + K);	
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
unordered_set<ll>white;
unordered_map<ll,vector<ll>>seen;
bool visited[100001];
ll dp[100001];
void dfs(ll i)
{
    visited[i]=true;
    if(white.find(i)!=white.end())
    {
        dp[i]+=1;
    }
    for(ll j=0;j<seen[i].size();j++)
    {
        if(!visited[seen[i][j]])
        {
            dfs(seen[i][j]);
            dp[i]+=dp[seen[i][j]];
        }
    }
}
int main(){
    // Your code here!
    
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
        cout<<k;
    }
    else
    {
        k=k-a;
        if(k<=b)
        {
            cout<<a;
        }
        else
        {
            k=k-b;
            cout<<a-k;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
N, M = gets.split.map(&:to_i)
As = gets.split.map(&:to_i)

sum = As.inject(:+)
cond_num = sum.to_f / (4.to_f * M.to_f)
res = 0

As.each do |target|
  res += 1 if cond_num <= target 
end

puts (res >= M) ? 'Yes' : 'No'


Measured memory_bytes: 1788
n,m = map(int,input().split())
war = []
for i in range(m):
    a,b = map(int,input().split())
    war.append([a,b])
war.sort(key = lambda x: x[1])
ans = 1
now = war[0][1]
k = 1
while k < m:
    if war[k][0] >= now:
        ans += 1
        now = war[k][1]
    k += 1
print(ans)

Measured memory_bytes: 21340
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define int long long
 
const int N = 2e6 + 7;
const int mod = 1e9 + 7;
 
void add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
    if (a < 0) a += mod;
}
 
int mul(int a, int b) {
    return (a * (ll) b) % mod;
}
 
int pw(int x, int n) {
    int res = 1;
    while (n > 0) {
        if (n % 2 == 1) {
            res = mul(res, x);
            n--;
        }
        x = mul(x, x);
        n /= 2;
    }
    return res;
}
 
int fact[N];
int rfact[N];
 
int C(int n, int k) {
    return mul(fact[n], mul(rfact[n - k], rfact[k]));
}
 
int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = mul(fact[i - 1], i);
    }
    rfact[N - 1] = pw(fact[N - 1], mod - 2);
    for (int i = N - 2; i >= 0; i--) {
        rfact[i] = mul(rfact[i + 1], i + 1);
    }
    int m;
    cin >> m;
    string s;
    cin >> s;
    int n = s.size();
    vector <int> f(n + m + 7, 0);
    f[n - 1] = 1;
    int kek = 25;
    for (int i = n; i <= n + m; i++) {
        int cnt = n;
        int ind = i - (n - 1) + 1;
        int orz = C(cnt - 1 + ind - 1, ind - 1);
        f[i] = mul(orz, kek);
        kek = mul(kek, 25);
    }
    vector <int> t(n + m + 7, 0);
    t[n] = 1;
    for (int i = n + 1; i <= n + m; i++) {
        add(t[i], f[i - 1]);
        add(t[i], mul(26, t[i - 1]));
    }
    cout << t[n + m] << '\n';
    return 0;
}

Measured memory_bytes: 66796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k, q;
    cin >> k >> q;
    vector<ll> d(k);
    rep(i, 0, k) cin >> d[i];
    rep(t, 0, q) {
        ll n, x, m;
        cin >> n >> x >> m;
        x %= m;
        vector<ll> c = d;
        ll zcnt = 0, sum = 0;
        rep(i, 0, k) {
            c[i] %= m;
            sum += c[i];
            if (c[i] == 0) zcnt++;
        }
        debug(c, sum, zcnt);
        sum *= (n - 1) / k;
        zcnt *= (n - 1) / k;
        rep(i, 0, n - 1 - (n - 1) / k * k) {
            sum += c[i];
            if (c[i] == 0) zcnt++;
        }
        debug(sum, zcnt);
        sum = (sum + x) / m - x / m;
        cout << n - 1 - sum - zcnt << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    cin >> S;
    sort( ALL( S ) );
    set<char> tmp;
    REP( i, (int)S.size() )
    {
        tmp.emplace( S[ i ] );
    }
    string E;
    for( auto &x : tmp )
    {
        E += x;
    }
    const string D{"abcdefghijklmnopqrstuvwxyz"};
    REP( i, (int)D.size() )
    {
        if( E[ i ] != D[ i ] || E.empty() )
        {
            cout << D[ i ] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;





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


    ll a, b, k;
    cin >> a >> b >> k;
    if (a + b <= k) {
        cout << "0 0";
        return 0;
    }
    ll h = min(a, k);
    cout << a - h << ' ' << b - (k - h);



}


Measured memory_bytes: 256
// AUTHOR - RUTVIK KOTHARI
// DAIICT , GANDHINAGAR

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

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e6 + 5;
const ll M = 3e5 + 5;
const ll mod = 1e9 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 20;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}


int main()
{
    FIO;
    //pre();

    ll i,j;

    ll x;
    cin>>x;
    
    ll ans = x*x*x;
    
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
const int size=4000;
vi graph[size];
int lineDistances[size][size];
bool visited[size][size];
vi vertexA, vertexB;
int number, diameter;
void dfs(int root, int start, int distanceInLines)
{
	//commandsBeforeVisitRecursion.
	visited[root][start]=true;
	lineDistances[root][start]=distanceInLines;
	for(int next : graph[start])
	{
		if(!visited[root][next])
		{
			dfs(root, next, distanceInLines+1);
		}
	}
	//commandsAfterVisitRecursion.
	return;
}
void usingDFS()
{
	cin>>number>>diameter;
	int vertex0, vertex1;
	for(int i=1; i<number; ++i)
	{
		cin>>vertex0>>vertex1;
		graph[vertex0].push_back(vertex1);
		graph[vertex1].push_back(vertex0);
		vertexA.push_back(vertex0);
		vertexB.push_back(vertex1);
	}
	for(int vertex=1; vertex<=number; ++vertex)
	{
		dfs(vertex, vertex, 0);
	}
	if(diameter%2==0)
	{
		int minimum=4000;
		for(int i=1; i<=number; ++i)
		{
			int counter=0;
			for(int j=1; j<=number; ++j)
			{
				if(lineDistances[i][j]>diameter/2)
				{
					++counter;
				}
			}
			minimum=min(minimum, counter);
		}
		cout<<minimum<<endl;
	}
	else
	{
		int dotA, dotB, tempMaxDist, minimum=4000;
		for(int i=0; i<vertexA.size(); ++i)
		{
			int counter=0;
			dotA=vertexA[i];
			dotB=vertexB[i];
			for(int j=1; j<=number; ++j)
			{
				tempMaxDist=min(lineDistances[j][dotA], lineDistances[j][dotB]);
				if(tempMaxDist>diameter/2)
				{
					++counter;
				}
			}
			minimum=min(minimum, counter);
		}
		cout<<minimum<<endl;
	}
	return;
}
int main()
{
    usingDFS();
	return 0;
}

Measured memory_bytes: 42880
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
using System.Text;

namespace ABC122C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var Q = ReadInt;
            var S = Console.ReadLine();

            int[] count = new int[N];
            for (int i = 0; i < N - 1; i++)
            {
                if (S[i] == 'A' && S[i + 1] == 'C') count[i + 1] = count[i] + 1;
                else count[i + 1] = count[i];
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < Q; i++)
            {
                var l = ReadInt - 1;
                var r = ReadInt - 1;

                int ans = count[r] - count[l];
                sb.AppendLine(ans.ToString());
            }

            Console.Write(sb);


        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 32836
package main

import(
    "fmt"
)



func main() {
    var a,b,c int
    fmt.Scan(&a,&b,&c)
    ans := "No"
    if a<=c && c<=b{
        ans = "Yes"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){

int i,j,H,W;
char H_c,W_c;
while(1){

H_c='#';
scanf("%d %d",&H,&W);

if((H==0) && (W==0)){break;}

for(i=0;i<H;i++){
   W_c = H_c;
   for(j=0;j<W;j++){
      printf("%c",W_c);
      if(W_c=='#'){W_c='.';}else{W_c='#';}
      }

   if(H_c=='#'){H_c='.';}else{H_c='#';}
   printf("\n");
   }
   printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
#define MOD 998244353
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

int main() {

    int n, m;cin >> n >> m;
    /// firstがto secondがcost
    const ll INF = 1001001001;
    struct Edge {ll to; ll cost;};
    vector<Edge> g[n];


    rep(i,m) {
        ll l, r; cin >> l >> r;
        ll c; cin >> c;
        Edge edge1 = {r-1, c};
        g[l-1].push_back(edge1);
    }
    rep(i, n-1) {
        Edge edge = {i, 0};
        g[i+1].push_back(edge);
    }
    priority_queue<P, vector<P>, greater<P>> pq;
    ll d[n];
    fill(d, d + n, 1e15);
//    vector<ll> d(n, 1e15);
    d[0] = 0;
    pq.push(P(0, 0));

    while(! pq.empty()){
        P p = pq.top(); pq.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
//            auto e = g[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(P(d[e.to], e.to));
            }
        }
    }

    ll ans = d[n-1];
    if (ans >= 1e15) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 9340
from math import factorial as fac

def binom(a,b):
    return(fac(a) // (fac(a-b) * fac(b)))

def main():
    S = int(input())
    count = 0
    for n in range(1,S//3 + 1):
        s = S - 3 * n
        count += binom(s+n-1,n-1)
    print(count % (10**9 + 7))
        

main()


Measured memory_bytes: 9156
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        String s=sc.next();
        if(x>=3200) {
        	System.out.println(s);
        		
        }else {
        	System.out.println("red");
        }
    }
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    vector<string> s(3);
    REP(i,3) cin>>s[i];
    REP(i,3) cout<<s[i][i];
    cout<<endl;
    return 0;
}

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

using namespace std;

int main() {
  int n, k;
  string s;

  cin >> n >> k;
  cin >> s;

  vector<int> size(n+2*k+1, 0);
  int c = 0;
  int group_num = 0;
  bool is_zero_first = s[0] == '0';
  bool is_zero_group = is_zero_first;

  for (int i = 0; i < n; i++) {
    if ((is_zero_group && s[i] == '1') || (!is_zero_group && s[i] == '0')) {
      size[group_num] = c;
      is_zero_group = !is_zero_group;
      c = 0;
      group_num++;
    }
    c++;
    if (i == (n - 1)) {
      size[group_num] = c;
      group_num++;
    }
  }

  int max_sum = 0;
  for (int i = 0; i < group_num; i+=2) {
    int sum = 0;
    int init;
    if (is_zero_first) {
      init = i - 1;
    } else {
      init = i;
    }

    for (int j = init; j < (init + 2*k + 1); j++) {
      if (j < 0) {
        continue;
      }
      sum += size[j];
    }
    if (sum > max_sum) {
      max_sum = sum;
    }
  }

  cout << max_sum << endl;

  return 0;
}

Measured memory_bytes: 1664
def main():
    n, k = map(int, input().split())

    cnt = 0
    for b in range(k+1, n+1):
        p = n // b + 1
        cnt += p * (b-k)

        if p * b > n + 1:
            cnt -= p * b - max((p-1)*b+k, n+1)

        if k == 0:
            cnt -= 1

    print(cnt)


if __name__ == '__main__':
    main()


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

#ifdef LOCAL
 #include <bits/debugger.hpp>
 // #define __int64 __int64_t
#else 
 #define debug(a...) //
#endif

#define __int64 long long int

const int maxa = 1e5 + 1;
vector<int> c(maxa , 0);

int main()
{
 ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
 int n;
 cin >> n;
 __int64 sum = 0; 
 for(int i = 0; i < n; i++) {
  int x;
  cin >> x;
  sum += x;
  c[x]++;
 }
 int q;
 cin >> q;
 while(q--) {
  int b , c1;
  cin >> b >> c1;
  int cnt = c[b];
  sum += (c1 - b) * cnt;
  c[b] = 0;
  c[c1] += cnt;
  cout << sum << '\n';
 }
 return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
int main(void){
    char c[10000];
    int i;
    scanf("%s", c);
    for ( i = 0; i < strlen(c); i++ ) {
        if ( 0X44 <= c[i] ) c[i] -= 3;
        else if ( 0X41 <= c[i] && c[i] <= 0X43 ) c[i] += 23;
    }
    printf("%s\n", c);
    return 0;
}

Measured memory_bytes: 1772
import sys
for line in sys.stdin:
#while True:
#	line=raw_input()
	l=map(int,line.split(","))
	dis=l[10]/float(l[10]+l[11])*sum(l[:10])
	suml=0
	for i in xrange(10):
		suml+=l[i]
		if dis<=suml:
			print i+1
			break

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
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...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code
int main(int argc, char const* argv[])
{
	vector<string> s = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string ss;
	cin >> ss;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == ss) {
			cout << 7-i << endl;
			return 0;
		}
	}
	return 0;
}



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

int main(){
  int H,W;
  cin >> H >> W;
  string S[50];
  rep(i,H){
    cin >> S[i];
  }


  //爆弾の数を数える関数を定義
  auto getbomb = [&](int i, int j){
    int count = 0;
    for (int k = i-1; k <= i+1; k++) {
      for (int l = j-1; l <= j+1; l++) {
        if (k == i && l == j) continue;
        if (k < 0 || k >= H) continue;
        if (l < 0 || l >= W) continue;
        if (S[k][l] == '#') {
          count++;
        }
      }
    }
    return count;
  };

  rep(i,H){
    rep(j,W){
      if (S[i][j] == '.') {
        S[i][j] = char(getbomb(i,j) + '0');
      }else{
        S[i][j] == '#';
      }
    }
  }

  rep(i,H){
    cout << S[i] << endl;
  }

  return 0;

}


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

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

void upd(ll &a, ll b) {
    a = (a + b) % mod;
}

int n, a[N], b[N];

int main() {
    ios :: sync_with_stdio(0);
    cin >> n;
    ll s = 0;
    for(int i = 1 ; i <= n ; ++ i) {
        cin >> a[i];
        s += a[i];
    }
    ll num = s / 2;
    for(int i = 2 ; i <= n ; i += 2) {
        s -= a[i] << 1;
    }
    cout << s << ' ';
    for(int i = 2 ; i <= n ; ++ i) {
        s = (a[i - 1] << 1) - s;
        cout << s << ' ';
    }
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll H;
    Scll(H);

    ll ans = 0;
    ll tmp = 1;

    while( H ){
        ans += tmp;
        tmp *= 2;
        H /= 2;
    }

    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
typedef struct complex complex;
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define SWAPCP(a,b) (a=Add(a,b),b=Add(a,Minus(b)),a=Add(a,Minus(b)))
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=(c==45),c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?~x+1:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
struct complex{double real,imag;}A[524288];
static inline complex Add(complex x,complex y){complex z;z.real=x.real+y.real;z.imag=x.imag+y.imag;return z;}
static inline complex Minus(complex x){x.real=-x.real;x.imag=-x.imag;return x;}
static inline complex Mul(complex x,complex y)
{
  complex z;z.real=x.real*y.real-x.imag*y.imag;
  z.imag=x.real*y.imag+x.imag*y.real;return z;
}
const int MOD=200003,len=524288,bit=19;
const double pi=3.141592653589793238462643383;
int rev[524288];
static inline void FFT(int t)
{
  rep(i,len)if(rev[i]>i){SWAPCP(A[rev[i]],A[i]);}
  for(int i=1;i<len;i<<=1)
  {
    complex v;v.real=cos(pi/i),v.imag=t*sin(pi/i);
    for(int j=0;j<len;j+=i<<1)
    {
      complex w;w.real=1;w.imag=0;
      rep(k,i)
      {
        complex x=A[k+j],y=Mul(w,A[k+j+i]);
        A[k+j]=Add(x,y);A[k+j+i]=Add(x,Minus(y));
        w=Mul(v,w);
      }
    }
  }
  if(t==-1)rep(i,len){A[i].real/=len;A[i].imag/=len;}
} 
int main(void)
{
  int N=IN(),temp=1,to[200003];long total=0;
  rep(i,MOD-2){temp=2*temp%MOD;to[temp]=i+1;}
  rep(i,N)
  {
    int x=IN();
    total-=1l*x*x%MOD;
    if(!x)continue;
    x=to[x];A[x].real+=1.0;A[x].imag=0;
  }
  rep(i,len){rev[i]=(rev[i>>1]>>1)|((i&1)<<(bit-1));}
  FFT(1);rep(i,len){A[i]=Mul(A[i],A[i]);}FFT(-1);
  temp=1%MOD;rep(i,400004){total+=(long)(A[i].real+0.5)*temp;temp=2*temp%MOD;}
  return OUT(total/2),0;
}

Measured memory_bytes: 13276
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n;
  cin >> n;
  vector<int> vc(n);
  for (int i = 0; i < n; i++) cin >> vc[i];
  int ans = 0;
  vector<int> frq(n + 1, 0);
  for (int i = 0; i < n; i++) {
    frq[vc[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    ans += ((frq[i] * ( frq[i] - 1 )) / 2);
  }
  for (int i = 0; i < n; i++) {
    if (frq[vc[i]] == 1) {
      cout << ans << endl;
      continue;
    } 
    int p = ans - ((frq[vc[i]] * ( frq[vc[i]] - 1 )) / 2);
    p += (((frq[vc[i]] - 1) * ( frq[vc[i]] - 2 )) / 2);
    cout << p << endl;
  }
  // cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    
    set<int> mochi;
    
    for(int i = 0; i < n; i++)
    {
        int buf;
        cin >> buf;
        
        mochi.insert(buf);
    }
    
    cout << mochi.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    cin>>N;
    int top=0,second=0,topidx=-1;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(top<a){
            second=top;
            top=a;
            topidx=i;
        }else if(second<a){
            second=a;
        }
    }
    for(int i=0;i<N;i++){
        cout<<((i==topidx)?second:top)<<endl;
    }
}


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

int main()
{
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;

  queue<int> color;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < a[i]; j++) {
      color.push(i + 1);
    }
  }

  vector<vector<int>> grid(h, vector<int>(w));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      grid[i][i % 2 == 0 ? j : w - 1 - j] = color.front();
      color.pop();
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << grid[i][j];
      if (j != w - 1) cout << ' ';
    }
    cout << endl;
  }
}


Measured memory_bytes: 384
H,W,K=map(int,input().split())
C=[1,1,2,3,5,8,13,21]
Amida=[[0]*W for h in range(H+1)]
for h in range(H+1):
  if W==1:
    break
  for w in range(W):
    if h==0:
      if w==0:
        Amida[h][w]=1
      else:
        Amida[h][w]=0
    elif w==0:
      Amida[h][w]=C[W-2]*Amida[h-1][w+1]+C[W-1]*Amida[h-1][w]
    elif w==W-1:
      Amida[h][w]=C[W-2]*Amida[h-1][w-1]+C[W-1]*Amida[h-1][w]
    else:
      Amida[h][w]+=(C[w-1]*C[W-w-1]*Amida[h-1][w-1])
      Amida[h][w]+=(C[w]*C[W-w-1]*Amida[h-1][w])
      Amida[h][w]+=C[w]*C[W-w-2]*Amida[h-1][w+1]
    Amida[h][w]=Amida[h][w]%1000000007
if W==1:
  if K==1:
    print(1)
  else:
    print(0)
else:
  print(Amida[H][K-1])


Measured memory_bytes: 3064
n = int(input())
A = list(map(int, input().split()))
goukei = sum(A)
jama = 0

for i in range(n // 2):
    jama += A[2 * i + 1]

ans = [0] * n

ans[0] = goukei - jama * 2

for i in range(1, n):
    ans[i] = 2 * A[i - 1] - ans[i - 1]

print(*ans, sep=" ")


Measured memory_bytes: 14092
/**
*   author:  akifpathan
*   created: Sunday 13.09.2020 03:56:48 PM
**/

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

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const ll base=31;

ll ara[6000],power[6000];

void solve()
{
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	
	s='.'+s;
	
	power[0]=1LL;
	for(int i=1;i<=n;i++) power[i]=power[i-1]*base;
	
	for(int i=1,j=n-1;i<=n;i++,j--)
	{
		ara[i]=ara[i-1]+power[j]*s[i];
	}
	
	int hi=n/2;
	int lo=1;
	int ans=0;
	
	while(hi>=lo)
	{
		int mid=(hi+lo)/2;
		
		map<ll,vector<int>>indx;
		
		for(int i=1;i+mid-1<=n;i++)
		{
			ll temp=ara[i+mid-1]-ara[i-1];
			temp*=power[i-1];
			indx[temp].push_back(i);
		}
		
		bool flag=false;
		
		for(auto it: indx)
		{
			if(it.second.size()>=2)
			{
				//debug(it.first,it.second,mid);
				flag|=(it.second[0]+mid<=it.second.back());
			}
		}
		
		if(flag)
		{
			ans=mid;
			lo=mid+1;
		}
		else hi=mid-1;
	}
	
	cout<<ans;
	
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}



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

int main () {
    int n, x;
    cin >> n >> x;
    int count = 1;
    int sum = 0;
    int l;
    for (int i=0; i < n; i++) {
        cin >> l;
        sum += l;
        if (sum <= x) {
            count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#define N 2005
using namespace std;
int a[N],l[N],n,o,q,r[N],s[N],t,x;bool w[N],z[N];
inline bool cmp(int u,int v){return a[u]<a[v];}
int main()
{
	scanf("%d%d%d",&n,&o,&q),x=0x7fffffff,w[n+1]=true;
	for(int i=1;i<=n;i++)scanf("%d",a+i),r[i]=n+1;
	for(int i=1,j,k,u;i<=n;i++)
	{
		u=t=0,j=1;
		while(w[j])j++;
		while(j<=n)
		{
			k=j;
			while(!w[k])s[++t]=k++;
			if(k-j<o)t-=k-j;
			else sort(s+t+1-k+j,s+t+1,cmp),t-=o-1;
			j=k;
			while(w[j])j++;
		}
		if(t<q)break;
		sort(s+1,s+t+1,cmp);
		if(a[s[q]]-a[s[1]]<x)x=a[s[q]]-a[s[1]];
		w[s[1]]=true;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+100;
int arr[N];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(false);
	cout.tie(false);
	
	LL n,m;
	while(cin>>n>>m){
		LL ans=0;
		if(2*n<=m){
			ans+=n;
			m-=2*n;
			
			ans+=m/4;
		}else{
			ans+=m/2;
			n-=m/2;
		}
		cout<<ans<<endl;
	}


	return 0;
}


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

using namespace std;
using ll = long long;
const int N = 100;
int ar[N], b[N], c[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i];
  }
  int res = b[0];
  for(int i = 1; i < n; ++i) {
    if(ar[i] == ar[i - 1] + 1) res += c[ar[i - 1] - 1];
    res += b[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         int N=gi();
         int X=gi();
         int Y=gi();
         List<Edge>[] G=new ArrayList[N];
         for (int i=0; i<N;i++) {
        	 G[i]=new ArrayList<Edge>();
         }
         for (int i=0; i<N-1;i++) {
        	 G[i].add(new Edge(i, i+1, 1l));
        	 G[i+1].add(new Edge(i+1, i, 1l));
         }
         G[X-1].add(new Edge(X-1, Y-1, 1l));
    	 G[Y-1].add(new Edge(Y-1, X-1, 1l));

    	 long[][] d=new long[N][N];
    	 for (int i=0; i<N;i++) {
    		 for (int j=0; j<N;j++) {
        		 if(i==j) {
        			 d[i][j]=0;
        		 } else {
        			 d[i][j]=Long.MAX_VALUE;
        		 }
        	 }
    	 }
    	 for (int i=0; i<N;i++) {
    	     PriorityQueue<Pair<Long, Integer>> q=new PriorityQueue<Pair<Long, Integer>>();
    	     q.add(new Pair<Long,Integer>(0l, i));
    	     while(!q.isEmpty()) {
    	    	 Pair<Long, Integer> p=q.poll();
    	    	 int v=p.getValue();
    	    	 long cost=p.getKey();
    	    	 if(d[i][v]<cost)continue;
    	    	 for (int j=0; j<G[v].size(); j++) {
    	    		 Edge e=G[v].get(j);
    	    		 if(d[i][e.to]>d[i][v]+e.cost && e.cost!=Integer.MAX_VALUE) {
    	    		     d[i][e.to]=Math.min(d[i][e.to], d[i][v] + e.cost);
    	    		     q.add(new Pair<Long,Integer>(d[i][e.to], e.to));
    	    		 }
    	    	 }
    	     }
    	 }

    	 int[] c=new int[N-1];
    	 for (int i=0; i<N;i++) {
    		 for (int j=i+1; j<N;j++) {
        	     long ind=d[i][j]-1;
        	     c[(int)ind]++;
        	 }
    	 }

    	 StringBuilder sb=new StringBuilder();
    	 for (int i=0; i<N-1;i++) {
    		 sb.append(c[i]);
    		 sb.append(System.lineSeparator());
    	 }
         System.out.println(sb);
     }

     public static class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> implements Comparable<Pair<K, V>> {
    		/** serialVersionUID. */
    	    private static final long serialVersionUID = 6411527075103472113L;

    	    public Pair(final K key, final V value) {
    	        super(key, value);
    	    }

    		@Override
    		public int compareTo(Pair<K, V> o) {

    			Comparable key = (Comparable)this.getKey();
    			Comparable key2 = (Comparable)o.getKey();

    			return key.compareTo(key2);
    		}

    	}

     public static class Edge {
    	    private int from;
    	    private int to;
    	    private long cost;

    	    public Edge(int f, int t, long c) {
    	    	this.from=f;
    	    	this.to=t;
    	    	this.cost=c;
    	    }
    	}

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

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

using namespace std;

const int N = 100000;

int n;
int f[N + 1];
int v[13] = {0, 1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    memset(f, 127, sizeof(f));
    f[0] = 0;
    for(int i = 1; i <= 12; i++)
        for(int j = v[i]; j <= n; j++)
            if(f[j - v[i]] || !(j - v[i]))
                f[j] = min(f[j], f[j - v[i]] + 1);
    printf("%d\n", f[n]);
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
	
	int n,i,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i;
		if(i%3==0 || i%10==3){
			printf(" %d",i);
		} else {
			while(1){
				x/=10;
				if(x%10==3){
					printf(" %d",i);
					break;
				}
				if(x==0)break;
			}
			
		}
	}
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 2108
N = int(input())
S = input()
R, G, B = [],[],[]
for i,s in enumerate(S):
    if s=='R':
        R.append(i)
    elif s=='G':
        G.append(i)
    else:
        B.append(i)

R.sort()
G.sort()
B.sort()

from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
 
ans = len(R)*len(G)*len(B)
if ans > 0:
    for r in R:
        for g in G:
            for p in [r*2-g,g*2-r,(r+g)/2]:
                if p<=B[-1] and p>=B[0]:
                    ind = bisect_left(B,p)
                    if p == B[ind]:
                        ans -= 1

print(ans)



Measured memory_bytes: 74996
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    print(a + a * a + a * a * a);
    
}


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

using namespace std;


int main() {
	string str = "";
	cin >> str;
	int ret = 7;
	// SUN,MON,TUE,WED,THU,FRI,SAT
	if (str == "MON") {
		ret -= 1;
	} else if (str == "TUE") {
		ret -= 2;
	} else if (str == "WED") {
		ret -= 3;
	} else if (str == "THU") {
		ret -= 4;
	} else if (str == "FRI") {
		ret -= 5;
	} else if (str == "SAT") {
		ret -= 6;
	}

	cout << ret;

	return 0;
}


Measured memory_bytes: 256