akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

ll inf=1e18;

int main() {
  ll n,a,b,c;
  cin >> n >> a >> b >> c;
  vector<ll> l(n);
  for(ll i=0;i<n;i++) {
    cin >> l[i];
  }
  ll ans=inf;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      if(i==j) {
        continue;
      }
      for(ll k=0;k<n;k++) {
        if(k==i||k==j) {
          continue;
        }
        ll tans=inf;
        if(n-3>-1) {
          vector<ll> check(n-3);
          ll count=0;
          for(ll m=0;m<n;m++) {
            if(m!=i&&m!=j&&m!=k) {
              check[count]=m;
              count++;
            }
          }
          for(ll m=0;m<(1<<2*(n-3));m++) {
            ll ttans=0;
            count=0;
            ll temp=m;
            ll t1=l[i],t2=l[j],t3=l[k];
            while(temp) {
              if(temp%4==1) {
                ttans+=10;
                t1+=l[check[count]];
              }
              if(temp%4==2) {
                ttans+=10;
                t2+=l[check[count]];
              }
              if(temp%4==3) {
                ttans+=10;
                t3+=l[check[count]];
              }
              count++;
              temp/=4;
            }
            ttans+=abs(a-t1)+abs(b-t2)+abs(c-t3);
            tans=min(tans,ttans);
          }
        }
        else {
          tans=abs(a-l[i])+abs(b-l[j])+abs(c-l[k]);
        }
        ans=min(ans,tans);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Ohajiki Game
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int i = parseInt(line);
			if (i == 0) break;

			int[] a = new int[i];

			words = br.readLine().split(" ");
			for (int j = 0; j < i; j++) {
				a[j] = parseInt(words[j]);
			}

			int n = 32, j = 0;
			while (true) {
				n -= (n - 1) % 5;
				System.out.println(n);
				if (n <= 0) break;

				if (n >= a[j % i]) {
					n -= a[j % i];
				} else {
					n = 0;
				}
				j++;
				System.out.println(n);
				if (n <= 0) break;
			}

		} //ene while
	}//end main
}

Measured memory_bytes: 25320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
N,T  = map(int,input().split())
ct = [list(map(int,input().split())) for _ in range(N)]

ans = 10**6
for n in range(N):
  if ct[n][1] <= T:
    if ct[n][0] <= ans:
      ans = ct[n][0]
if ans != 10**6:
  print(ans)
else:
  print("TLE")


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s,t;
    cin>>s>>t;

    if(s.size() < t.size()) swap(s,t);
    s+="$";
    t+="#";
    int n = s.size();
    int m = t.size();

    vector<vi> dp(n+1, vi(m+1, 0));
    REP(i,n){
        REP(j,m){
            if(s[i]==t[j]){
                chmax(dp[i+1][j+1], dp[i][j]+1);
            }

            chmax(dp[i+1][j], dp[i][j]);
            chmax(dp[i][j+1], dp[i][j]);
        }
    }

    string ans="";
    int y = n-1;
    int x = m-1;
    while(true){
        //DEBUG2(y,x);
        if(dp[y][x]==0) break;

        if(dp[y][x] == dp[y-1][x]){
            y--;
            continue;
        }else if(dp[y][x] == dp[y][x-1]){
            x--;
            continue;
        }else{
            y--;
            x--;
            ans += s[y];
        }
    }
    
    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i = i + 2) cout << s[i];
  return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X (N, vector<int> (D, 0));
    REP (i, N) REP (j, D) cin >> X[i][j];
    int ans = 0;
    REP (i, N) {
        FOR (j, i + 1, N) {
            int num = 0;
            REP (k, D) num += pow (X[j][k] - X[i][k], 2);
            double dbl = sqrt (num);
            if (dbl == floor (dbl))
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int N, T, S, **dp, A, B, temp, out = 0;

	scanf("%d %d %d",&N, &T, &S);
	dp = new int *[N];
	for(int f1 = 0; f1 < N; f1++){
		dp[f1] = new int[T + 1];
		if(f1 == 0)
		for(int f2 = 0; f2 <= T; f2++){
			dp[f1][f2] = 0;
		}
	}
	for(int f1 = 0; f1 < N; f1++){
		scanf("%d %d", &A, &B);
		if(f1 == 0){
			dp[f1][B] = A;
			for(int f2 = B; f2 <= S; f2++)
				dp[f1][f2] = A;
		}
		else{
			for(int f2 = 0; f2 <= T; f2++)
				dp[f1][f2] = dp[f1 - 1][f2];
			for(int f2 = 0; f2 <= T - B; f2++){
				temp = (f2 + B > S && f2 < S) ? S : f2;
				if(temp != S)
					dp[f1][temp + B] = max(dp[f1 - 1][f2] + A, dp[f1 - 1][temp + B]);
				else
					dp[f1][temp + B] = max(dp[f1 - 1][S] + A, dp[f1 - 1][temp + B]);
			}
		}
	}
	for(int f1 = 0; f1 <= T; f1++){
		if(dp[N-1][f1] > out)
			out = dp[N-1][f1];
	}
	printf("%d\n", out);
	return 0;
}

Measured memory_bytes: 36416
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n; cin >> n;
    vector<int> t(n); repeat(i, n) cin >> t[i];
    int m; cin >> m;
    vector<int> p(m), x(m); repeat(i, m) cin >> p[i] >> x[i];
    
    repeat(i, m) {
        vector<int> c(n);
        c = t;
        int idx = p[i] - 1;
        c[idx] = x[i];
        cout << accumulate(c.begin(), c.end(), 0) << endl;
    }
    return 0;
        
}
            
    

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

int main()
{
  int n, m, a, tmp = 0;
  int64_t M = 1e9 + 7, ans = 1;
  cin >> n >> m;
  vector<int> A(n + 1, 1), dp(n + 1);
  dp[0] = 1;
  for (int i = 0; i < m; i++)
  {
    cin >> a;
    A[a] = 0;
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j <= min(n, i + 2); j++)
    {
      if (A[j])
      {
        dp[j] += dp[i];
        dp[j] %= M;
      }
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

static const ll MAX = 200000;
static const ll waz = 76543217;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

ll selectionSort(ll A[], ll N) {
    ll i, t, j, jj = 0, minj;
    rep(i, N - 1) {
        minj = i;
        rpt(j, i, N) {
            if (A[j] < A[minj]) minj = j;
        }
        t = A[i]; A[i] = A[minj]; A[minj] = t;
        if (i != minj) ++jj;
    }
    return jj;
}

int main()
{
    IO;

    ll N, jj; cin >> N;
    ll A[100];
    rep(i, N) cin >> A[i];

    jj = selectionSort(A, N);

    rep(i, N) {
        if (i) {
            cout << " " << A[i];
        }
        else {
            cout << A[i];
        }
    }
    cout << endl;
    cout << jj << endl;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
using namespace std;

typedef long long ll;
int modulo = 1000000007; // 10^9 + 7


int main() {
	int N, M; cin >> N >> M;
	bool first[N+1]; // 島１から島iに行けるかどうか
	bool second[N+1]; // 島ｊから島Nに行けるかどうか
	for (int i = 0; i < N + 1; i++) {
		first[i] = false; second[i] = false;
	}

	for (int i = 0; i < M; i++) {
		int departure, destination;
		cin >> departure >> destination;
		if (departure == 1) first[destination] = true;
		if (destination == N) second[departure] = true;
	}
	int ans = 0;
	for (int i = 1; i < N + 1 && ans == 0; i++) ans += (first[i] * second[i]);

	if (ans >= 1) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}

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


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int count = 0;
    int sum;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        sum = 0;
        int tmp = i;
        while (tmp > 0) {
            sum += tmp%10;
            tmp /= 10;
        }
        if (a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;


int main(){
    int N; cin >> N;
    vector<queue<int>> Q(N);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N-1; j++) {
            int x; cin >> x; x--;
            Q[i].push(x);
        }
    }

    ll ans = 0;
    vector<int> B1(N);

    queue<int> Q2;
    for(int i = 0; i < N-1; i++){
        int x = Q[i].front();
        if(Q[i].empty() || B1[i] == 1) continue;
        int y = Q[x].front();
        if(Q[x].empty() || B1[x] == 1) continue;
        if(i == y){
            Q[i].pop(); Q[x].pop();
            Q2.push(i);Q2.push(x);
            B1[i] = 1; B1[x] = 1;
            //cout << ans << "  " << i << " " << x << endl;
        }
    }
    if(Q2.empty()){ cout << -1 << endl; return 0;}
    ans++;

    while(1){
        vector<int> B(N);
        bool flag = true;
        queue<int> Q3 = Q2, q;
        swap(Q2, q);
        while(!Q3.empty()){
            int i = Q3.front(); Q3.pop();
            if(Q[i].empty() || B[i] == 1) continue;
            int x = Q[i].front();

            if(Q[x].empty() || B[x] == 1) continue;
            int y = Q[x].front();
            if(i == y){
                B[i] = 1; B[x]=1;
                Q[i].pop(); Q[x].pop();
                Q2.push(i);Q2.push(x);
                //cout << ans << " " << i << " " << x << endl;
                flag = false;
            }
        }
        if(flag) break;
        ans++;
    }

    for(int i = 0; i < N; i++) {
        if(!Q[i].empty()){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {
	int N;
	cin >> N;
	
	for (int i=1; i<10; i++) {
		if (N % i == 0 && N / i < 10) {
			cout << "Yes";
			return 0;
		}
	}
	
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
import math
import collections
n=int(input())
m=int(math.sqrt(n)+1)
a=[]
for x in range(1,m):
  for y in range(1,m):
    for z in range(1,m):
      if x**2+y**2+z**2+x*y+y*z+z*x<=n:
        a.append(x**2+y**2+z**2+x*y+y*z+z*x)
c=collections.Counter(a)
for i in range(1,n+1):
  print(c[i])

Measured memory_bytes: 19640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll kaijo[200010];
ll dp[200010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i < 200010;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	//if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)) % N) % N;
}

int main(void){
    ll n,a,b,c;
    cin>>n>>a>>b>>c;
    init();
    ll k=inv(a+b);
    for(ll i=0;i<=2*n-1;i++){
        dp[i+1]=(dp[i]+(100*k)%N)%N;
    }
    ll ans=0;
    ll A=1,B=1,ab=1;
    for(ll i=0;i<n;i++){
        A=(A*a)%N;
        B=(B*b)%N;
        ab=(ab*k)%N;
    }
    ll x=1,y=1;
    for(ll i=0;i<n;i++){
        ll num=(((Comb(n+i-1,n-1)*dp[n+i])%N)*ab)%N;
        ll num1=(A*x)%N;
        ll num2=(y*B)%N;
        num=(num*((num1+num2)%N))%N;
        ans=(ans+num)%N;
        x=(x*b)%N;
        y=(y*a)%N;
        ab=(ab*k)%N;
    }
    cout<<(ans+N)%N<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
/* 素数判定 */
int isPrime(int x) {
  int i;
  if ( x < 2 ) return 0;
  else if ( x == 2 ) return 1;   // 2 は素数
  if ( x % 2 == 0 ) return 0;    // 2以外の偶数は素数ではない
  for ( i = 3; i*i <= x; i+=2 )  // i が x の平方根以下の間
    if ( x % i == 0) return 0;
  return 1;
}

int main() {
  int n, x, i;
  int cnt = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &x);
    if ( isPrime(x) ) cnt++;
  }
  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, l;
    cin >> n >> l;
    vector<ll> v(n);
    rep(i, n) v[i] = l + i;
    sort(all(v), [](ll a, ll b){ return abs(a) < abs(b); });
    ll ans = 0;
    reps(i, 1, n) ans += v[i];
    cout << ans << endl;
    return 0;
}


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

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

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

   ll gcd(int a,int b){return b?gcd(b,a%b):a;};

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

ll N;
vector<ll> Num[2][2][2] = {};

vector<ll> func(vector<ll> v){
  if (v.empty()) return {0};
  vector<ll> ans;
  ans.pb(0);
  vector<ll> sets[11];
  sets[0] = {0};
  REP(d, 10){
    for (auto &e : sets[d]){
      for (auto &m : v){
        if(e * 10 + m <= N){
          sets[d + 1].pb(e * 10 + m);
        }
      }
    }
  ans.insert(ans.end(), sets[d + 1].begin(), sets[d + 1].end());
  }
  return ans;
}
int main(){
  cin >> N;
  REP(i, 2){
    REP(j, 2){
      REP(k, 2){
        vector<ll> v = {};
        if(i == 1) v.pb(3);
        if(j == 1) v.pb(5);
        if(k == 1) v.pb(7);
        Num[i][j][k] = func(v);
        SORT(Num[i][j][k]);
//        printf("i = %lld, j = %lld, k = %lld, %lld\n", i, j, k, Num[i][j][k].size());
      }
    }
  }
  ll ans = 0;
  REP(i, 2){
    REP(j, 2) {
      REP(k, 2){
        ans += (((i + j + k) % 2) * 2 - 1) * (Num[i][j][k].size());
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1020
package main

import "fmt"

func main() {
	var card string

	for {
		fmt.Scan(&card)
		if card == "-" {
			break
		}

		var m, h int
		fmt.Scan(&m)
		for i := 0; i < m; i++ {
			fmt.Scan(&h)
			card = card[h:]+card[:h]
		}
		fmt.Println(card)
	}
}



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

int main(){
  int n,i,j,k1,k2,k3,ans=0,m;
  vector<int> p={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47},a(15);
  cin >> n;
  for(i=1; i<=n; i++){
    m=i; j=0;
    while(m>1){
      if(m%p[j]==0){
        m/=p[j]; a[j]++;
      }else{
        j++;
      }
      if(j>14) break;
    }
  }
    
  for(k1=0; k1<15; k1++){
    for(k2=k1+1; k2<15; k2++){
      for(k3=k2+1; k3<15; k3++){
        if(a[k1]>=4 && a[k2]>=4 && a[k3]>=2) ans++;
        if(a[k1]>=4 && a[k2]>=2 && a[k3]>=4) ans++;
        if(a[k1]>=2 && a[k2]>=4 && a[k3]>=4) ans++;
      }
    }
  }
  for(k1=0; k1<15; k1++){
    for(k2=k1+1; k2<15; k2++){
        if(a[k1]>=24 && a[k2]>=2) ans++;
        if(a[k1]>=2 && a[k2]>=24) ans++;
        if(a[k1]>=4 && a[k2]>=14) ans++;
        if(a[k1]>=14 && a[k2]>=4) ans++;
    }
  }
  for(k1=0; k1<15; k1++){
        if(a[k1]>=74) ans++;
  }
/*  for(i=0; i<15; i++){
    cout << a[i] << ' ';
  }
*/
  cout << ans;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int norm_1d(int* a, int n, int p){
  int i, res=0;
  for(i=0; i<n; i++){
    res += (a[i]-p)*(a[i]-p);
  }
  return res;
}

int main(int argc, char const *argv[]) {
  int n, i, sum=0;
  int ave;
  int* a;
  scanf("%d", &n);
  a = malloc( sizeof(int) * n );
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
    sum += a[i];
  }
  if(sum>=0)
    ave = (int)( (double)sum/n + 0.5 );
  else
    ave = (int)( (double)sum/n - 0.5 );
  printf("%d\n", norm_1d(a, n, ave));
  return 0;
}


Measured memory_bytes: 128
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ');
   let result = "";    
     for(let i =0; i<xs.length; i++){
   	    result +=xs[i].match(/[A-Z]/);
      }
   console.log(result);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 11468
// She is Pretty pretty!
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e6 + 100;
namespace bit {
ll c[N];
inline int lowbit(int x) { return x & -x; }
void add(int x, ll v) {
    for (int i = x; i < N; i += lowbit(i)) c[i] += v;
}
ll sum(int x) {
    ll ret = 0;
    for (int i = x; i > 0; i -= lowbit(i)) ret += c[i];
    return ret;
}
int kth(ll k) {
    int p = 0;
    for (int lim = 1 << 20; lim; lim /= 2) {
        if (p + lim < N && c[p + lim] < k) {
            p += lim;
            k -= c[p];
        }
    }
    return p + 1;
}
ll sum(int l, int r) { return sum(r) - sum(l - 1); }
void add(int l, int r, ll v) { add(l, v), add(r + 1, -v); }
}  // namespace bit
struct node {
    int l, r, pos;
    friend int operator<(const node& a, const node& b) { return a.r < b.r; }
} q[N];
using namespace bit;
int vis[N], cc[N], ans[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, qq;
    cin >> n >> qq;
    for (int i = 1; i <= n; i++) {
        cin >> cc[i];
    }
    for (int i = 1; i <= qq; i++) {
        cin >> q[i].l >> q[i].r;
        q[i].pos = i;
    }
    sort(q + 1, q + 1 + qq);
    int st = 1;
    for (int i = 1; i <= qq; i++) {
        for (int j = st; j <= q[i].r; j++) {
            if (vis[cc[j]]) add(vis[cc[j]], -1);  // 删除之前只保留一个颜色
            add(j, 1), vis[cc[j]] = j;            // 标记该颜色现在位置
        }
        st = q[i].r + 1;
        ans[q[i].pos] = sum(q[i].l, q[i].r);
    }
    for(int i = 1; i <= qq; i++)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 19380
N,M= map(int, input().split())
class UnionFind:
    def __init__(self, n):
        self.data = [-1] * n
    def union(self, x, y):
        x,y = self.root(x), self.root(y)
        if x != y :
            if self.data[y] < self.data[x]:
                x,y = y,x
            self.data[x] += self.data[y]
            self.data[y] = x
        return x != y
    def root(self, x):
        if self.data[x] < 0 :
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    def findSet(self, x, y):
        return self.root(x) == self.root(y)
uf = UnionFind(N)
for _ in range(M):
    x,y,z= map(int, input().split())
    x-=1
    y-=1
    uf.union(x,y)
visited = set()
ans = 0
for v in range(N):
    if uf.root(v) not in visited:
        ans +=1
    visited.add(uf.root(v))
print(ans)


Measured memory_bytes: 12780
main = do
    [sx, sy, tx, ty] <- map read . words <$> getLine
    let dx = tx - sx
        dy = ty - sy
    putStr $ replicate dx 'R'
    putStr $ replicate dy 'U'
    putStr $ replicate dx 'L'
    putStr $ replicate dy 'D'
    putStr $ "D"
    putStr $ replicate (dx + 1) 'R'
    putStr $ replicate (dy + 1) 'U'
    putStr $ "LU"
    putStr $ replicate (dx + 1) 'L'
    putStr $ replicate (dy + 1) 'D'
    putStr $ "R"
    putStrLn ""

Measured memory_bytes: 1020
#include <stdio.h>

#define BUF_SIZE 30

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  int i, j;
  int a[3][3];
  int min = 101;
  int argmin_x, argmin_y;
  for(i = 0; i < 3; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    sscanf(line, "%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
    for(j = 0; j < 3; j++) {
      if(a[i][j] < min) {
        min = a[i][j];
        argmin_x = i; argmin_y = j;
      }
    }
  }
  int flag = 1;
  for(i = 0; i <= min; i++) {
    //a_i = i
    int b1 = a[i][0] - i;
    int b2 = a[i][1] - i;
    int b3 = a[i][2] - i;
    flag = 1;
    // probe
    for(j = 0; j < 3; j++) {
      int tmp1 = b1 - a[j][0];
      int tmp2 = b2 - a[j][1];
      int tmp3 = b3 - a[j][2];
      if(tmp1 == tmp2 && tmp1 == tmp3) {
        continue;
      } else {
        flag = 0;
        break;
      }
    }
    if(flag) break;
  }
  printf("%s\n", flag ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, Q;
	cin >> N >> Q;

	string s;
	cin >> s;

	vector<vector<Int>> lr(Q, vector<Int>(2, 0));
	for (Int i = 0; i < Q; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> lr[i][j];
			lr[i][j]--;//0Indexed
		}
	}

	//配列acの作成
	vector<Int> ac(N, 0);
	for (Int i = 0; i < N-1; i++) {
		if (i == 0) {
			if (s[0] == 'A' && s[1] == 'C') {
				ac[0] = 1;
				continue;
			}
			else continue;
		}

		else if (s[i] == 'A') {
			if (s[i + 1] == 'C') {
				ac[i] = ac[i - 1] + 1;
				continue;
			}
			else {
				ac[i] = ac[i - 1];
				continue;
			}
		}
		
		//else {
			ac[i] = ac[i - 1];
			//continue;
		//}
	}
	ac[N - 1] = ac[N - 2];

	//解の出力
	Int ans = 0;
	for (Int i = 0; i < Q; i++) {
		if (lr[i][0] == 0) {//区間の左端が0番目の場合
			ans = ac[lr[i][1]];
			if ((lr[i][1] != N - 1) && (s[lr[i][1] + 1] == 'C') && (s[lr[i][1]] == 'A')) {
				ans = max(0LL, ans - 1);
			}
			printf("%lld\n", ans);
			continue;
		}

		else {
			ans = ac[lr[i][1]] - ac[lr[i][0] - 1];
			if ((lr[i][1] != N - 1) && (s[lr[i][1] + 1] == 'C') && (s[lr[i][1]] == 'A')) {
				ans = max(0LL, ans - 1);
			}
			printf("%lld\n", ans);
		}
	}

}




Measured memory_bytes: 7248
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll dp[1000000];
int solve(){
  int n;
  cin>>n;
  dp[0] = 0;
  dp[1] = 1;
  REP(i,2,1000000)dp[i] = INF;
  REP(i,1,n+1){
    for(int j = 6; j <= i; j *= 6){
      dp[i] = min(dp[i - j] + 1,dp[i]);
    }
    for(int k = 9; k <= i; k *= 9){
      dp[i] = min(dp[i - k] + 1,dp[i]);
    }
    dp[i] = min(dp[i],dp[i - 1] + 1);
  }
  cout << dp[n] << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B; cin >> A >> B;

    rep (value, 1, 1009) {
        int a = floor(0.08 * (double)value);
        int b = floor(0.10 * (double)value);
        if (a == A && b == B) {
            cout << value << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int N;
    cin >> N;
    int data[N];
    rep(i, N)
    {
        cin >> data[i];
    }
    int count = 0;
    int next_n = 1;

    while (true)
    {
        next_n--;
        next_n = data[next_n];
        count++;
        if (next_n == 1 || next_n == 2)
        {
            break;
        }
        if (count > N)
        {
            break;
        }
    }

    if (next_n != 2)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] d_x = sc.intarr;
            int d = d_x[0];
            int x = d_x[1];

            int[] array = new int[n];

            for(int i=0; i<n; i++)
            {
                array[i] = sc.intarr[0];
            }

            int sum = x;

            for(int i=0; i<n; i++)
            {
                sum += ((d - 1) / array[i]);
                sum++;
            }

            wr.wri(sum);

        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cmath>

using namespace std;

bool is_prime(long long x) {
	if(2 > x) 
		return false;
	
	if(2 == x) 
		return true;
	
	if(0 == x % 2) 
		return false;

	double sqrt_num = sqrt(x);

	for(long long i = 3;i <= sqrt_num;i += 2) {
		if(0 == x % i) 
			return false;
	}

	return true;
}

int main() {
	int n, cnt = 0;
	long long tmp;

	cin >> n;

	for(int i = 0;i < n;i++) {
		cin >> tmp;

		if(is_prime(tmp))
			cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var N = r[0].ToInt();
            var X = r[1].ToInt();
            var Y = r[2].ToInt();
            X--;Y--;
            var INF = 10010010;
            var ans = new int[N];
            for (int i = 0; i < N; i++)
            {
                var dist = new List<int>();
                for (int j = 0; j < N; j++)
                {
                    dist.Add(INF);
                }
                var q = new List<int>();
                var Add = new Action<int, int>((v, d) => {
                    if (dist[v] != INF) return;
                    dist[v] = d;
                    q.Add(v);
                    });
                Add(i, 0);
                while (q.Any())
                {
                    int v = q[0]; q.RemoveAt(0);
                    int d = dist[v];
                    if (v - 1 >= 0) Add(v - 1, d + 1);
                    if (v + 1 < N) Add(v + 1, d + 1);
                    if (v == X) Add(Y, d + 1);
                    if (v == Y) Add(X, d + 1);
                }
                for (int j = 0; j < N; j++)
                {
                    ans[dist[j]]++;
                }
            }
            for (int i = 0; i < N; i++)
            {
                ans[i] /= 2;
            }
            for (int i = 1; i <= N - 1; i++)
            {
                Write(ans[i]);
            }
            Read();
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 40640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  int count=0;
  while(A>=B) {
    B*=2;
    count++;
  }
  while(B>=C) {
    C*=2;
    count++;
  }
  if(count<=K) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define fori(i, a, b) for(int i = (int) a; i <= (int) b; ++i)
#define rofi(i, b, a) for(int i = (int) b; i >= (int) a; --i)
#define foreach(tt, a) for(auto &tt: a)
#define all(a) begin(a), end(a)
#define csz(a) (int) a.size()
#define pb push_back
#define epb emplace_back
#define load(a, v) fill(begin(a), end(a), v)
#define load_mem(a, v) memset(a, v, sizeof(a));
#define iostream_optimize() ios::sync_with_stdio(false); cin.tie(0);
using ll = long long;
const ll MOD = 1e9+7, LINF = 1e16+1;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const ll P1 = 31, P2 = 37, M1 = 1e9+7, M2 = 1e9+9;

// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<< END TEMPLATE >>>>>>>>>>>>>>>>>>>>>>>>>>> */
const int N = 2e5+1;

int n, a[N];
map<int, int> mp;
ll ans;
int main() {
	iostream_optimize();
	cin >> n;
	fori(i, 0, n-1) cin >> a[i];
	if(a[0] != 0) cout << -1, exit(0);
	fori(i, 1, n-1) if(a[i] - a[i-1] > 1) cout << -1, exit(0);
	rofi(i, n-1, 0) {
		if(mp.count(i)) ans += mp[i] - i;
		if(!mp.count(i - a[i])) mp[i - a[i]] = i;
	}
	cout << ans;
}

Measured memory_bytes: 10368
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

alias Edge = Tuple!(int, "to", int, "cost");
alias Node = Tuple!(int, "num", int, "d");

void main() {
    int k;
    scan(k);

    auto adj = new Edge[][](k, 0);

    foreach (i ; 0 .. k) {
        adj[i] ~= Edge((i + 1) % k, 1);
        adj[i] ~= Edge((i * 10) % k, 0);
    }

    int ans = dijkstra(k, adj) + 1;

    writeln(ans);
}

int dijkstra(int k, Edge[][] adj) {
    auto minhp = new BinaryHeap!(Array!Node, "a.d > b.d")();
    auto d = new int[](k);
    d[] = 100;
    d[1] = 0;

    minhp.insert(Node(1, 0));

    while (!minhp.empty) {
        auto v = minhp.front;
        minhp.popFront();

        if (d[v.num] < v.d) continue;

        if (v.num == 0) return v.d;

        foreach (e ; adj[v.num]) {
            if (d[v.num] + e.cost < d[e.to]) {
                d[e.to] = d[v.num] + e.cost;
                minhp.insert(Node(e.to, d[e.to]));
            }
        }
    }

    assert(0);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 10152
#include <stdio.h>
#include <string.h>
char s[110];
int main(){
	int k,n,i;
	scanf("%d%s",&k,s+1);
	n=strlen(s+1);
	if(n<=k)printf("%s\n",s+1);
	else{
		for(i=1;i<=k;i++)printf("%c",s[i]);
		printf("...\n");
	}
}

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

#define debug(x) cerr << #x << ": " << x << endl;

#define iosbase ios_base::sync_with_stdio(false)
#define tie cin.tie();cout.tie();

#define endl '\n'

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

int n, m;
string s;

int memo[5010][5010];

int dp(int i, int j){
  if(j>=n) return 0;
  if(memo[i][j]!=-1) return memo[i][j];

  if(s[i]!=s[j]) return memo[i][j] = 0;
  else return memo[i][j] = min(j-i, 1+dp(i+1, j+1));

}

int main(){
  iosbase;
  tie;
  cin >> n;
  cin >> s;
  memset(memo, -1, sizeof memo);
  int ans = -1;

  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      ans = max(ans, dp(i, j));
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 98560
#include <iostream>
#include <set>
#include <string>
#include <algorithm> 
using namespace std;

int main(void){
	int n;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		set<string> ans;
		for(int i=1;i<s.size();i++){
			string a = s.substr(0,i);
			string b = s.substr(i);
			string ra=a,rb=b;
			reverse(ra.begin(), ra.end());
			reverse(rb.begin(), rb.end());
			ans.insert( a+ b);
			ans.insert( a+rb);
			ans.insert(ra+ b);
			ans.insert(ra+rb);
			ans.insert( b+ a);
			ans.insert( b+ra);
			ans.insert(rb+ a);
			ans.insert(rb+ra);
		}
		cout << ans.size()<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll k, n;std::cin >> k >> n;
  vll a(n);re(i, n) std::cin >> a[i];
  ll ans = 0;
  for(int i=1;i<n;i++){
    ans = max(ans, a[i] - a[i-1]);
  }
  ll las = a[0] + (k - a[n-1]);
  ans = max(ans, las);
  std::cout << k - ans << '\n';
  return 0;
}


Measured memory_bytes: 2424
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] a = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] b = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] c = ReadLine().Split(' ').Select(int.Parse).ToArray();

            long ans = b[a[0]-1];
            int tmp = a[0];
            for (int i = 1; i < n; i++)
            {
                ans += b[a[i]-1];
                if (a[i] - tmp == 1) ans += c[a[i]-2];
                tmp = a[i];
            }
            WriteLine(ans);
        }

    }
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    cout<<n*(n-1)/2<<endl;
}

Measured memory_bytes: 256
//for(int i=0;i<n;i++)cin>>arr[i];
//for(int i=0;i<n;i++)cout<<arr[i]<<" ";

#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<3;i++)
  { 
      
     
      if(n%10==7){cout<<"Yes";return 0;}
      n=n/10;
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static int n = 0;
    static int m = 0;
    static int r = 0;
    static int c = 0;
    static int x = 0;
    static int y = 0;
    static int[] arr;
    static string s = "";
    static string[] ss;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static char[,] map;
    static int[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static int Int(string s)
    {
        return int.Parse(s);
    }
    static long Max(long a, long b)
    {
        return Math.Max(a, b);
    }
    static long Min(long a, long b)
    {
        return Math.Min(a, b);
    }
    static long Abs(long a)
    {
        return Math.Abs(a);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(int def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new int[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        n = Int(rl());
        ss = rls();
        arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = Int(ss[i]);
        }

        int ans = 1;
        for (int i = 0; i < n; i++)
        {
            if (arr[i] != ans)
            {
                cnt++;
            }
            else
            {
                flg = true;
                ans++;
            }
        }

        if (!flg)
            wl(-1);
        else
            wl(cnt);
    }


}



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

int main(){
  int N;
  int R[101];
  cin>>N;
  int sum=0;
  int left=0;
  for(int i=0;i<N;i++){
    cin>>R[i];
    sum+=R[i];
  }
  int ans=1e9;
  for(int i=0;i<N;i++){
    left=0;
    for(int j=0;j<i;j++){
      left+=R[j];
    }
    ans=min(ans,abs(sum-2*left));
  }

   
  cout<<ans<<endl;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var res = a.GroupBy(x => x).Sum(x => x.Count() >= x.Key ? x.Count() - x.Key : x.Count());
        Console.WriteLine(res);
    }
}


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

long long X;

int main()
{
  cin >> X;

  int N = 0;
  long long C = 100;
  while (C < X)
  {
    N++;
    C = std::floor(C * 1.01);
  }
  cout << N << endl;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, M, K;

    cin >> N >> M >> K;

    vector<ll> A(N+1, 0);
    vector<ll> B(M+1, 0);

    for(int i = 1; i <= N; i++ ){
       ll a;
       cin >> a;
       A[i] = A[i-1] + a;
    }
    for(int i = 1; i <= M; i++ ){
       ll b;
       cin >> b;
       B[i] = B[i-1] + b;
    }

    ll a = 0;
    ll b = B.size()-1;
    ll count = 0;
    while( a < A.size() && b >= 0){
        ll current = A[a] + B[b];
        if( current <= K ){
           count = max(count, a+b);
           a++;
        }else{
           b--;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 6428