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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll n;
	ll d[100];
  
    cin >> n;
  
  	REP(i, n){
          cin >> d[i];
    }
	
    ll ans = 0;
    REP(i, n){
        FOR(j, i+1, n){
            ans += d[i] * d[j];
        }
    }

    cout << setprecision(20) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
while 1:
	inp = raw_input()
	if inp == ".": break
	a = ""
	for i in inp:
		if i == "(" or i == ")" or i == "[" or i == "]":
			a += i
	while len(a) > 0:
		if   "()" in a: a = a.replace("()","")
		elif "[]" in a: a = a.replace("[]","")
		else: break
	print "yes" if len(a) == 0 else "no"

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var total = 0;

            for (var i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();

                if (tmp[0] == tmp[1]) total++;
                else total += tmp[1] - tmp[0] + 1;
            }
            Console.WriteLine(total);
        }
    }
}


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

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		int R = Integer.parseInt(BR.readLine());
		System.out.println((double)2 * (double)R * (double)3.1415);
	}
}


Measured memory_bytes: 25412
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}


int main()
{
    int N = inputValue();
    vector<int> L;
    inputVector(&L, N);
    sort(L.begin(), L.end(), std::greater<int>());
    ll ans = 0;
    REP(i, N-2){
        FOR(j, i+1, N-1){
            FOR(k, j+1, N){
                int a = L[i];
                int b = L[j];
                int c = L[k];
                if(a<(b+c)){
                    ans++;
                }else{
                    break;
                }
            };
        };
    };

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int Aa,Bb;
  
  int judge = 0;
  
  
    cin >> Aa;
    cin >> Bb;
  
  if(Aa >= 13){
    judge = Bb;
  }
  else if(Aa >= 6){
    judge = Bb/2;
  }
  else{
    judge = 0;
  }
  
      cout << judge << endl;
  
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b,c; cin >> a >> b >> c;
    yn(a<=b*c);
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
long mod = 998244353;
long INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    long N, K; 
    cin>> N >> K;
    vector<plong> S(K);
    REP(i, 0, K){
        long l, r;
        cin >> l >> r;
        S[i] = {l, r};
    }
    vl C(K, 0);
    sort(S.begin(), S.begin());
    vl DP(N + 1, 0);
    DP[1] = 1;
    REP(i, 2, N + 1){
        REP(j, 0, K){
            if(i - S[j].first <= 0) continue;
            else if(i - S[j].second <= 0){
                C[j] += DP[i - S[j].first];
                DP[i] += C[j];
                
            }else{
                C[j] = C[j] + DP[i - S[j].first] - DP[i - S[j].second - 1];
                DP[i] += C[j];
            }
            C[j] %= mod;
            DP[i] %= mod;
            if(DP[i] < 0) DP[i] += mod;
        }
    }
    cout << DP[N] << endl;
}

Measured memory_bytes: 4832
#include <stdio.h>

int N, p[212345];
int r[212345], ans[2][212345];

int main(void)
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) { scanf("%d", &p[i]); }

	for (int i = 0; i < N; ++i)
	{
		r[p[i] - 1] = (i + 1);
	}
	for (int i = 0; i < N; ++i)
	{
		ans[0][i] = 20000 * (i + 1);
		ans[1][i] = 20000 * (N - (i + 1)) + r[i];
	}

	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < N - 1; ++j)
		{
			printf("%d ", ans[i][j]);
		}
		printf("%d\n", ans[i][N - 1]);
	}
	return 0;
}

Measured memory_bytes: 896
n,m=map(int,input().split())
li1=[list(map(int,input().split())) for i in range(n)]
li2=[list(map(int,input().split())) for i in range(m)]
for i in li1:
  a=i[0]
  b=i[1]
  mini=float("inf")
  ans=0
  for j in range(m):
    c=li2[j][0]
    d=li2[j][1]
    if abs(a-c)+abs(b-d)<mini:
      ans=j+1
    mini=min(mini,abs(a-c)+abs(b-d))
  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>

#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <random>
#include <complex>
#include <utility>
#include <tuple>
#include <memory>

#include <array>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <csignal>
#include <cstdint>
#include <cstddef>

#ifdef ONLINE_JUDGE
#define NDEBUG
#endif
#include <cassert>
#include <stdexcept>
#include <exception>

// << pair
template <typename T1, typename T2>
std::ostream&operator<<(std::ostream&os,const std::pair<T1,T2>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
// << container
template <typename C>
std::ostream&_debug_go(std::ostream&os,const C&v) {bool first=true;os<<"[";for(auto i:v){if(!first)os<<", ";os<<i;first=false;}return os<<"]";}
// << {vector, set, map} delegating to _debug_go
template<typename T> std::ostream&operator<<(std::ostream&os,const std::vector<T>&v){return _debug_go(os, v);}
template<typename T> std::ostream&operator<<(std::ostream&os,const std::set<T>&v){return _debug_go(os, v);}
template<typename T1, typename T2> std::ostream&operator<<(std::ostream&os,const std::map<T1,T2>&v){return _debug_go(os, v);}
struct Debugger{template<typename T>Debugger&operator,(const T&v){std::cerr<<v<<" "; return *this;}} dbg;
#ifndef NDEBUG
#define debug(args...) do {dbg,args; cerr << "\n";} while(0)
#else
#define debug(args...)
#endif

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ITER(i, s, e) for (auto i((s)); i != (e); ++i)
#define IT(i, c) ITER(i, (c).begin(), (c).end())

using namespace std;

using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
template <typename T = int> using Pt = complex<T>;

template <typename T>
T cross(const Pt<T>& a, const Pt<T>& b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <typename T>
bool cmpPt(const Pt<T>& a, const Pt<T>& b) {
    return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag());
}
// END TEMPLATE


constexpr int MAX_S = 2e5 + 10;

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

    string S; cin >> S;

    static int DP[MAX_S][7];
    FOR(i, 1, int(S.size()) + 1) FOR(k0, 1, min(i, 5)+1) FOR(k1, 0, min(i-k0, 5)+1) {
        if (S.substr(i-k0, k0) == S.substr(i-k0-k1, k1)) continue;
        DP[i][k0] = max(DP[i][k0], DP[i-k0][k1] + 1);
    }
    cout << *max_element(DP[S.size()], DP[S.size()]+6) << '\n';

    return 0;
}


Measured memory_bytes: 6036
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision
#include <chrono>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

int d = 365;

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

  cin >> d;
	int c[26];
	rep(i,26) cin >> c[i];

	vector<vector<int>> s(d, vector<int>(26));
	vector<int> t(d);
	set<int> last[26];
	rep(i,26) last[i].insert(-1);
	auto prevday = [&last, &t](int day,int contest) {
	  auto it = last[contest].lower_bound(day);
	  if (it == last[contest].end() || *it != day) return *prev(it);
	  else /*(*it == day)*/ return day;
	};

	rep(i,d) { 
	  int maxt = -1, maxcontest = -1;
	  rep(j,26) { 
		  cin >> s[i][j];
			if (chmax(maxt, s[i][j] + c[j]*(i - prevday(i,j)))) maxcontest = j;
		}
		t[i] = maxcontest;
		last[t[i]].insert(i);
	}

	chrono::system_clock::time_point start, end;

	start = chrono::system_clock::now();

	auto score = [&last, &c, &s, &t, prevday]() {
		ll ret = 0;
		rep(i, d) {
		  ret += s[i][t[i]];
			rep(j,26) ret -= (ll) c[j]*(i - prevday(i,j));
		}
		return ret;
	};

	ll ans = score();

	auto modify = [&](int day, int q) {
	  ll ans0 = 0;
	  ans0 -= s[day][t[day]];
		ans0 += c[t[day]]*(day - prevday(day,t[day]));
		last[t[day]].erase(day);
		last[q].insert(day);
		ans0 += s[day][q];
		ans0 -= c[q] * (day - prevday(day, q));

		if (ans0 >= 0) { ans += ans0;
		t[day] = q;
		}
	};

	end = chrono::system_clock::now();
	while (static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) < 1950) {
	  rep(i,d) rep(j,26) modify(i,j);
		end = chrono::system_clock::now();
	}
	for(auto ti : t) cout << ti+1 << endl;
}


Measured memory_bytes: 4160
#coding:utf-8

N = int(input())

A = [int(i) for i in input().split()]

ans = 1
flag = True

for i in A:
    if i == 0:
        ans = 0
        flag = False

if flag:
    for i in A:
        ans = ans * i
        if ans > (10 ** 18):
            ans = -1
            break   

print("{}".format(ans))

Measured memory_bytes: 21792
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
X=sorted([(A[i],B[i]) for i in range(N)],key=lambda x:x[1])
A=[X[i][0] for i in range(N)]
B=[X[i][1] for i in range(N)]
C=sorted([(A[i],i) for i in range(N)],key=lambda x:x[0])
for i in range(N):
    if C[i][0]>B[i]:
        print("No")
        exit()
if len(set(A))<N:
    print("Yes")
    exit()
Y=[0 for i in range(N)]
j=0
for i in range(N):
    Y[j]=1
    j=C[j][1]
    
if sum(Y)==N:
    #A:C[i][0]
    #B:X[i][1]
    for i in range(N-1):
        if C[i+1][0]<=X[i][1]:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")


Measured memory_bytes: 36640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int r; cin >> r;
	out(r*r);
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  scanf("%d\n", &n);
  int nums[n];
  for (int i=0;i<n;i++)scanf("%d",&nums[i]);
  for (int i=0;i<n-1;i++)printf("%d ",nums[i]);
  printf("%d\n",nums[n-1]);
  for(int i=1;i<n;i++){
    //logic
    int target = nums[i];
    int compInt = i-1;
    int fronttarget = nums[compInt];
    while(compInt>=0 && nums[compInt]>target){
      nums[compInt+1] = nums[compInt];
      compInt -= 1;
    }
    nums[compInt+1] = target;
    //logic
    for (int i=0;i<n;i++){
      if(i==n-1){
          printf("%d",nums[i]);
      }else{
        printf("%d ",nums[i]);
      }
    }
    if(!(i==n)){
      printf("\n");
    }
  }
}



Measured memory_bytes: 2084
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()

    val dp = BooleanArray(111)
    dp[0] = true
    repeat(100) {
        if(dp[it]) {
            dp[it+4] = true
            dp[it+7] = true
        }
    }
    if(dp[n]) "Yes" else "No"

})


Measured memory_bytes: 31756
#include<iostream>
//#include<fstream>
using namespace std;

bool binarySearch(int s[], int begin, int end, int t);

int main() {
	int i, j, n, q, s[100001], t, cnt = 0;
	//ifstream fin("ALDS1_4_B-in8.txt");
	//if (!fin) {
	//	cout << "failed to open the file.";
	//	return 1;
	//}
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;
	for (j = 0; j < q; j++) {
		cin >> t;
		if (binarySearch(s, 0, n, t) == true)cnt++;
	}
	cout << cnt << endl;
	//fin.close();
	return 0;
}

bool binarySearch(int s[], int begin, int end, int t) {
	int mid = (begin + end) / 2;
	if (t == s[mid])return true;
	else if (begin >= end)return false;
	else if (t < s[mid])return binarySearch(s, begin, mid - 1, t);
	else if (t > s[mid])return binarySearch(s, mid + 1, end, t);
}

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

using namespace std;

#define int long long 
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, A[2][100];
int dp[3][101];

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

    cin >> N;
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < N; ++j) cin >> A[i][j];
    }
    for(int i = 1; i < 3; ++i) {
        for(int j = 1; j < N + 1; ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + A[i - 1][j - 1];
        }
    }
    cout << dp[2][N] << endl;
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;


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

	long long int a, b, c;
	cin >> a >> b >> c;
	if (c - a - b > 0) {
		if (4 * a*b < (c - a - b)*(c - a - b)) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a, b, c;
int main()
{
	cin >> a >> b >> c;
	if(a == b && b == c){
		cout << '1';
	}else if(a == b || b == c || a == c){
		cout << '2';
	}else{
		cout << '3';
	}
    return 0;
}


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


int main(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    rep(i,n) cin>>a[i];

    bool flag = true;
    int cnt = 0;
    rep(i,n){
        if(a[i] != i){
            ++cnt;
            if(a[a[i]] != i) flag = false;
        }
    }

    cout<< ((flag && (cnt/2<=1)) ? "YES" : "NO") <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define fastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define scan(a) scanf("%d", &a)
#define scanll(a) scanf("%lld", &a)
#define scanD(a) scanf("%lf", &a)
#define print(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printD(a) printf("%lf\n", a)
#define printTwo(a) printf("%.2lf\n", a);
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */



void solve() {
	ll sum = 0, n;
	scanll(n);
	REP(i, 1, n) {
		REP(j, 1, n) {
			REP(k, 1, n) {
				sum += gcd(i, gcd(j, k));
			}
		}
	}
	print(sum);
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif

	solve();

	// __test {
	// 	solve();
	// }

	showTime;
	return 0;
}




Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define PI 3.141592653589793238
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in2.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T = 1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		int n; cin >> n;
		int freq[n+1];
		mset(freq, 0);
		FOR1(i, n-1){
			int x; cin >> x;
			++freq[x];
		}
		FOR1(i, n){
			cout << freq[i] << "\n";
		}
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 2147483647//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    string s;
    cin >> s;
    rep(i,s.length()){
        if(i%2 == 0)cout << s[i];
    }
    cout << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 512
# ABC 109: B – Shiritori
n = int(input())
w = [input() for _ in range(n)]

isShiritori = 'Yes'

for i in range(len(w) - 1):
    if w.count(w[i]) > 1 or w[i][-1] != w[i + 1][0]:
        isShiritori = 'No'
        break

print(isShiritori)

Measured memory_bytes: 3060
s=input()
a=int(s[0:2])
b=int(s[2:4])
if(0<a<13):
    if(0<b<13):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if(0<b<13):
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
/*
@Author: nonameless
@Date:   2020-05-19 09:48:26
@Email:  2835391726@qq.com
@Blog:   https://www.cnblogs.com/nonameless/
*/
#include <bits/stdc++.h>
#define first x
#define second y
#define push_back pb
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const double PI  = acos(-1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll  gcd(ll  a, ll b)  { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }


int main(){

    int n;
    cin >> n;
    int m = n % 10;
    if(m == 3) puts("bon");
    else if(m == 0 || m == 1 || m == 6 || m == 8) puts("pon");
    else puts("hon");
    
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	double a, b, x, ans;
	cin >> a >> b >> x;
	x /= a;
	if (x > a* b / 2) {
		double rem = a * b - x;
		double brem = rem * 2 / a;
		ans = atan2(brem, a) / M_PI * 180;
	}
	else {
		double arem = x * 2 / b;
		ans = 90.0 - atan2(arem, b) / M_PI * 180;
	}
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
void quick(int *A, int left, int right);

int main(void)
{
	unsigned size,min_gap,temp;
	int *Array,*pointer,*end;
	    
	
	while (fscanf(stdin,"%u",&size), 0 != size)
	{
		Array = (int *)malloc(sizeof(int) * size);
		end = Array + size; pointer = Array;
		while (pointer <  end) fscanf(stdin,"%d",pointer++);
		
		// debug ??¨?¢?????????????
		// end = Array + size; pointer = Array;
		// while (pointer <  end) printf("%d ", *pointer++);
		// fputc('\n',stdout);
		
		quick(Array,0,size -1);
		// unsigned min_gap
		min_gap = -1; 
		pointer = Array; end -= 1;
		while (pointer < end)
		{
			temp = *(pointer +1) - *pointer;
			if (min_gap > temp ) min_gap = temp;
			pointer++;
		}
		fprintf(stdout,"%d\n",min_gap);
		free(Array);
	}
	return 0;
}



void quick(int *A, int left, int right) {
    int i,j,
        pivot,
        work, flag; 

    if (left < right) {
        pivot = A[left];
        i = left +1;
        j = right;
        flag = 1;
        while (flag == 1)
    	{
            while (A[i] <= pivot && i < right) i++;
            while (A[j] >= pivot && j > left) j--;
            if (i >= j) flag = 0;
            else
    		{
                work = A[i];
                A[i] = A[j];
                A[j] = work;
            }
        }
        A[left] = A[j];     
        A[j] = pivot;       
        quick(A, left, j -1);    
        quick(A, j +1, right);   
    }
}

Measured memory_bytes: 620
class Point
  attr_reader :x, :y
  def initialize(x, y)
    @x = x
    @y = y
  end
end
class Line
  attr_reader :p1, :p2, :maxx, :minx, :maxy, :miny, :x, :y
  def initialize(x1, y1, x2, y2)
    @p1 = Point.new(x1, y1)
    @p2 = Point.new(x2, y2)
    @maxx = (x1 > x2)? x1 : x2
    @minx = (x1 > x2)? x2 : x1
    @maxy = (y1 > y2)? y1 : y2
    @miny = (y1 > y2)? y2 : y1
    @x = x1 - x2
    @y = y1 - y2
  end
  def parallel?(other)
    return (x * other.y) == (y * other.x)
  end
  def over_x?(other)
    return (x ** 2 + other.x ** 2 >= (maxx - other.maxx) ** 2 + (minx - other.minx) ** 2)
  end
  def over_y?(other)
    return (y ** 2 + other.y ** 2 >= (maxy - other.maxy) ** 2 + (miny - other.miny) ** 2)
  end
  def get_xy(other)
    return (y * other + (x * p2.y - y * p2.x))
  end
  def get_yx(other)
    return (x * other + (y * p2.x - x * p2.y))
  end
  def diff_xx(point)
    return (x * point.y - get_xy(point.x))
  end
  def diff_yy(point)
    return (y * point.x - get_yx(point.y))
  end
  def cross_x?(other)
    return (other.x * p1.y - other.get_xy(p1.x)) * (other.x * p2.y - other.get_xy(p2.x)) <= 0
  end
  def cross_y?(other)
    return (other.y * p1.x - other.get_yx(p1.y)) * (other.y * p2.x - other.get_yx(p2.y)) <= 0
  end
  def get_cross_x(other)
    #p ["x" , other.p1.x, other.p2.x, diff_xx(other.p2), diff_xx(other.p1)]
    return ((other.p1.x * diff_xx(other.p2).abs + other.p2.x * diff_xx(other.p1).abs) / (diff_xx(other.p1).abs + diff_xx(other.p2).abs))
  end
  def get_cross_y(other)
    #p ["y", other.p1.y, other.p2.y, diff_yy(other.p2), diff_yy(other.p1)]
    return ((other.p1.y * diff_yy(other.p2).abs + other.p2.y * diff_yy(other.p1).abs) / (diff_yy(other.p1).abs + diff_yy(other.p2).abs))
  end
  def get_cross_point(other)
    if (y == 0)
      return get_cross_x(other), p1.y
    elsif (x == 0)
      return p1.x, get_cross_y(other)
    else
      return get_cross_x(other), get_cross_y(other)
    end
  end
end
def main(input = STDIN)
  q = input.gets.to_i
  q.times do
    arg = input.gets.split(" ").map(&:to_f)
    l1 = Line.new(*arg[0...4])
    l2 = Line.new(*arg[4..-1])
    puts l1.get_cross_point(l2).join(" ")
  end
end
main

Measured memory_bytes: 9056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


int ans[1000000];
int sum[1000000];
vector<ll> v;
ll N;

int bfs(ll num){
  if(num > N) return 0;
  else{
    v.push_back(num);
    bfs(num*10+3);
    bfs(num*10+5);
    bfs(num*10+7);
  }
  return 0;
}

int main(){
  cin >> N;
  bfs(0);
  ll ans = 0;
  rep(i,v.size()){
    bool a = false;
    bool b = false;
    bool c = false;
    ll n = v[i];
    while(n){
      if(n%10 == 3) a = true;
      if(n%10 == 5) b = true;
      if(n%10 == 7) c = true;
      n /= 10;
    }
    if(a && b && c) ans++;
  }
  cout << ans << endl;
  
  return 0;
}




Measured memory_bytes: 640
program d
 integer(8) :: a(0:9)=(/0,1,2,4,7,12,20,29,38,52/),f(10)=0
 read(*,*) n
 f(3)=1
 do i=4,n
 f(i)=f(i-1)*(a(i-2)+a(i-3)+1)
 enddo
 do i=1,n
  do j=1,n
   write(*,'(i0)') merge(0_8,f(max(i,j))*a(min(i,j))+1,i==j)
  enddo
 enddo
end program d

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

int main(){
	int W, H, x, y, r;
	
	cin>> W >> H >> x >> y >> r;
	
	if(x - r < 0 || x + r > W || y - r < 0 || y + r > H){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
		
	}
    return 0;
}

Measured memory_bytes: 3104
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

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

ub = B - B // C - B // D + B // lcm(C, D)

A -= 1
ua = A - A // C - A // D + A // lcm(C, D)

print(ub - ua)


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

int main(void) {

  int n;
  int S[131072];
  int q;
  int T[65536];

  std::cin >> n;
  for(int i = 0; i < n; ++i) {
    std::cin >> S[i];
  }
  std::cin >> q;
  for(int i = 0; i < q; ++i) {
    std::cin >> T[i];
  }

  int ans = 0;
  for(int i = 0; i < q; ++i) {
    int num = T[i];
    int index = 0;
    for(int j = 30; j >= 0; --j)  {
      int temp = (1 << j);
      if( S[index] == num ) {
        ans += 1;
        break;
      }
      if( index + temp < n ) {
        if( S[index + temp] == num ) {
          ans += 1;
          break;
        }
        if( S[index + temp] < num ) {
          index += temp;
        }
      }
    }
  }

  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 1756
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            String s[] = new String[n];
            for (int i = 0; i < n; i++) {
                s[i] = in.next();
            }
            Arrays.sort(s);
            Map<String, Integer> m = new HashMap<>();
            int cnt = 0;

            for (int i = 0; i < n; i++) {
                if (m.get(s[i]) == null) {
                    m.put(s[i], 0);
                } else {
                    cnt = m.get(s[i]) + 1;
                    m.put(s[i], cnt);
                }
            }

            List<String> t = new ArrayList<>();
            int tmp = 0;
            for (int i = 0; i < n; i++) {
                tmp = Math.max(tmp, m.get(s[i]));
            }

            for (Map.Entry<String, Integer> e : m.entrySet()) {
                if (tmp == e.getValue()) {
                    t.add(e.getKey());
                }
            }
            Collections.sort(t);
            for (int i = 0; i < t.size(); i++) {
                out.println(t.get(i));
            }
        }

    }
}



Measured memory_bytes: 72864
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	int c=0,f;
	cin>>s;
	for(int i=0;i<s.size();i++) {
		char ch=s[i];
		if(ch=='C') {
			if(!c) {
				c=1;
				continue;
			}
		}
		if(ch=='F') {
			if(c) {
				printf("Yes");
				return 0; 
			}
		}
	}
	printf("No");
	return 0;
} 

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

int main() {
  int a, b, k; cin >> a >> b >> k;
  int d = min(a, b);
  int cnt = 0;
  while (d > 0) {
    if (a % d == 0 && b % d == 0) cnt++;
    if (cnt == k) {
      cout << d << endl;
      return 0;
    }
    d--;
  }
  return 0;
}

Measured memory_bytes: 256
// Created by Bingoo on 7/8/2020.
#include"bits/stdc++.h"
using namespace std ;
#define ll  long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

template <class ...Args>
auto &see(const Args &...args) {return ((cerr << " " << args), ...) << '\n';}
#define bug(...)  cerr << "[ "#__VA_ARGS__" ] = "; see(__VA_ARGS__) << '\n';
//C++17
template<typename... Args>
void read(Args&... args){((cin >> args), ...);}
template<typename... Args>
void write(Args... args){((cout << args << " "), ...);}

ll mod = 1e6 +3 ;
ll power(ll a, ll b)	//a is base, b is exponent
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    if (b % 2 == 1)
        return (power(a, b - 1) * a) % mod;
    ll q = power(a, b / 2);
    return (q * q) % mod;
}

bool comp(pair<int,int>&a ,pair<int,int>&b)
{
    return a.second > b.second ;
}



int a ,b ,n ;



int main(){
    cin >> n ;

    int a[n];

    for (int i = 0; i < n; ++i) {
        cin >> a[i] ;
    }

    int Prefix[n + 2];
    int Suffix[n + 2];

    Prefix[1] = a[0];
    for (int i = 2; i <= n; i += 1) {
        Prefix[i] = __gcd(Prefix[i - 1], a[i - 1]);
    }


    Suffix[n] = a[n - 1];


    for (int i = n - 1; i >= 1; i -= 1) {
        Suffix[i] = __gcd(Suffix[i + 1], a[i - 1]);
    }


    int ans = max(Suffix[2], Prefix[n - 1]);

    for (int i = 2; i < n; i += 1) {
        ans = max(ans, __gcd(Prefix[i - 1], Suffix[i + 1]));
    }
    
    cout << ans << '\n' ;




}


Measured memory_bytes: 4776
n = input()
k = int(input())
ln = len(n) + 1

dp=[[[0]* (ln) for _ in range(2)] for i in range(ln)]
dp[0][0][0] = 1
for i in range(len(n)):
  for smaller in range(2):
    x = int(n[i])
    t = 9 if smaller else x
    for j in range(t+1):
      for knum in range(ln-1):
        if j == 0:
          dp[i+1][int(smaller or j < x)][knum] += dp[i][smaller][knum]
        else:
          dp[i+1][int(smaller or j < x)][knum+1] += dp[i][smaller][knum]
try:
  print(dp[-1][0][k] + dp[-1][1][k])
except:
  print(0)

Measured memory_bytes: 9296
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

int main()
{
    int N, M;
    cin >> N >> M;
    int min = 1;
    int max = N;
    REP(i, M)
    {
        int l, r;
        cin >> l >> r;
        if (min < l)
            min = l;
        if (max > r)
            max = r;
    }

    int ret = std::max(max - min + 1, 0);
    cout << ret << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
b = list(map(int, input().split()))

count = 0
for i in range(n - 1, -1, -1):
    if i == n-1:
        count += b[i-1]
    elif i == 0:
        count += b[i]
    else:
        count += min(b[i], b[i-1])

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}

const int Max=1e6+9;
const int OO=-1e6;
int st[4]= {1,0,0,-1};
int nt[4]= {0,1,-1,0};
int n,m;
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
ll mem[Max];
void init()
{
    memset(mem,-1,sizeof mem);
}
//////////////////////////////////////////////////////////

ll a[Max];

ll solve (int i )
{
    if(i==n-1)return 0;
    if(i>=n)
        return Max;

    ll &ret=mem[i];
    if(~ret)return ret;
    ret=1e9;
    for(int j=0;j<=m;j++)
    ret=min(ret,(solve(i+j)+abs(a[i]-a[i+j])));

     return mem[i]=ret;
}

void Fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
   init();
   n =D();
m =D();
   for(int i=0; i<n;i++)
   {
       a[i]=llD();
   }
   printf("%lld",solve(0));

}


Measured memory_bytes: 18496
n=int(input())
l=[list(map(int,input().split())) for _ in range(3)]

count_num=0
for i in l[0]:
    count_num += l[1][i-1]
for j in range(n-1):
    if (l[0][j])+1 == l[0][j+1]:
        count_num += l[2][(l[0][j])-1]
    
print(count_num)

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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    rep(i, h){
        cin >> c[i];
    }
    vector<string> px(h * 2);
    rep(i, h * 2){
        int num = ((i) / 2);
        px[i] = c[num];
    }

    rep(i, h * 2){
        cout << px[i] << endl;
    }
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    long long ans=0;
    char last=s[0];
    for(int i=1;i<n;i++){
        if(s[i] != last){
            last = s[i];
            ans++;
        }
    }
    cout<<ans+1;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    private static final int MAX = 1000;

    public static void main(String[] args) {
        int base = calc(MAX, 1, 1);

        try(Scanner scn = new Scanner(System.in)) {
            int lmt = scn.nextInt();
            for(int i = 0; i < lmt; i++) {
                System.out.println(base - calc(scn.nextInt(), scn.nextInt(), scn.nextInt()));
            }
        }
    }

    public static int calc(int y, int m, int d) {
        int rslt = 0;

        rslt += ~-y / 3 * 590;
        rslt += ~-y % 3 * 195;
        if(y % 3 == 0) {
            rslt += ~-m * 20;
        } else {
            rslt += ~-m / 2 * 39;
            rslt += ~-m % 2 * 20;
        }
        rslt += d;

        return rslt;
    }
}

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


int main() {

	int n, q;
	vector<int> S, T;
	int s, t = 0;
	cin >> n;
	rep(i, n) { cin >> s; S.push_back(s);}
	cin >> q;
	rep(i, q) { cin >> t; T.push_back(t); }

	//Main
	int ans = 0;
	rep(i, q) {
		rep(j, n) {
			if (T[i] == S[j]) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int *weight;
int *value;
long long int **dp_arr;
int N, W;

void display_dp_table()
{
    for(int i = 0; i < N+1; i++)
    {
        for(int j = 0; j < W+1; j++)
        {
            cout << dp_arr[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
}
long long int recursive(int index, int curr_w)
{
    if(index >= N) return 0;
    if(curr_w + weight[index] > W) return 0;

    return max(recursive(index + 1, curr_w + weight[index]) + value[index], recursive(index + 1, curr_w));
}

long long int dp()
{
    for(int i = 0; i < N + 1; i++) dp_arr[i][0] = 0;
    for(int i = 0; i < W + 1; i++) dp_arr[0][i] = 0;
    

    // display_dp_table();
    for(int i = 1; i < N + 1; i++)
    {
        for(int j = 1; j < W + 1; j++)
        {
            if(weight[i-1] <= j) 
                dp_arr[i][j] = max(value[i-1] + dp_arr[i-1][j-weight[i-1]], 
                                    dp_arr[i-1][j]);
            else
                dp_arr[i][j] = dp_arr[i-1][j];
        }
        // display_dp_table();
    }

    return dp_arr[N][W];
}
int main()
{

    cin >> N >> W;

    weight = new int[N];
    value = new int[N];
    dp_arr = new long long int*[N + 1];
    for(int i = 0; i< N; i++)
    {
        dp_arr[i] = new long long int[W + 1];
        cin >> weight[i] >> value[i];
    }
    dp_arr[N] = new long long int[W + 1];
    
    // cout << recursive(0, 0)<< endl;

    cout << dp() << endl;



}


Measured memory_bytes: 82712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace AtCoder
{
    class Abc162F
    {
        static long[] A = new long[200010];
        static int[] ans = new int[200010];
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            for(int i=1;i<=a.Length;i++)
            {
                A[i] = a[i-1];
            }

            for (int i = 1; i < n; i++)
            {
                ans[A[i]]++;
            }

            for(int i=1;i<n+1;i++)
            {
                Console.Write(ans[i]);
                Console.WriteLine();
            }

        }
    }
}


Measured memory_bytes: 42576