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

using namespace std;

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}
long long gcd(long long num1, long long num2) {
	return num2 == 0 ? num1 : gcd(num2, num1 % num2);
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_T_or_T(void) {

	int N, A, B; cin >> N >> A >> B;

	cout << min(A * N, B) << endl;
	return;
}

int main(void) {

	cout << fixed << setprecision(15);

	A_T_or_T();
	return 0;
}


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

int main()
{   int a,b,x,y,i,n,m;
    scanf("%d",&a);
    printf("Christmas");
    for(i=1;i<=25-a;i++){
        printf(" Eve");
    }

    return 0;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    string S = "";
    string T = "";
    int A = 0;
    int B = 0;
    string U = "";
    
    cin >> S;
    cin >> T;
    cin >> A;
    cin >> B;
    cin >> U;
    
    if (S == U) {
        A = A - 1;
    } else {
        B = B - 1;
    }
    
    cout << A;
    cout << " ";
    cout << B;
    return 0;
}

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

int main(void){
    long long int x,y;
    long long int sum = 0;
    cin >> x >> y;
    for(long long int i = (y / x),j = 1;;j*=2){
        sum++;
        i -= j;
        //cout << i << endl;
        if(i <= 0)break;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
n, x = map(int,input().split())
a_l = list(map(int,input().split()))

a_l.sort()
count = 0
for val in a_l[:-1]:
    x -= val
    if x < 0:
        break
    count += 1
if x == a_l[-1]:
    count += 1
print(count)

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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int X, A;
  cin >> X >> A;
  if (X<A) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<queue>
#include<set>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef pair<int,int> P_ii;
typedef long long int ll;

const int MOD = 1e9+7;

void addM(ll &a, ll b){
    a = (a % MOD + b % MOD) % MOD;
}

void mulM(ll &a, ll b){
    a = (a % MOD * b % MOD) % MOD;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<int> A(N + 1); 
    map<int, int> mp;
    int l, r;
    REP(i, N + 1) {
        cin >> A[i];
        if(mp[A[i]]) {
            l = min(mp[A[i]], i + 1);
            r = max(mp[A[i]], i + 1);
        } else {
            mp[A[i]] = i + 1;
        }
    }

    COMinit();

    ll num = (l - 1) + (N + 1 - r);
    for(int i = 1; i <= N + 1; i++){
        ll ans;
        if(i == 1) {
            ans = N;
        } else {
            ans = (COM(N + 1, i) - COM(num, i - 1) + MOD) % MOD;
        }
        cout << ans << endl;
    }

	return 0;
}


Measured memory_bytes: 18304
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll R=2e6+69, INF=2e9+6969;

int n,A[R],D,M,lp[R];
vector <int> p;
set <int> s;
int NWD(int a, int b)
{
	while(a>0 && b>0)
	{
		if(a>b) a%=b;
		else b%=a;
	}
	return a+b;
}

int main()
{
	scanf("%d", &n);
	for(int i=0;i<n;++i)
	{
		scanf("%d", &A[i]);
		M = max(M,A[i]);
	}
	D = A[0];
	for(int i=1;i<n;++i) D = NWD(A[i],D);
	if(D>1)
	{
		puts("not coprime");
		return 0;
	}
	for(int i=2;i<=M;++i)
	{
		if(lp[i] == 0)
		{
			lp[i] = i;
			p.pb(i);
		}
		for(int j=0;j<p.size() && i*p[j]<=M && p[j]<=lp[i]; ++j)
		{
			lp[i*p[j]] = p[j];
		}
	}
	bool ok = 1;
	for(int i=0;i<n;++i)
	{
		int x = A[i];
		//  int d = INF;
		set <int> pom;
		pom.clear();
		while(x>1)
		{
			//  if(d!=lp[x]) 
			//  {
				//  d = lp[x];
				//  if(s.count(d))
				//  {
					//  ok = 0;
					//  break;
				//  }
				//  s.insert(d);
			//  }
			pom.insert(lp[x]);
			x/=lp[x];
		}
		for(auto e: pom)
		{
			if(s.count(e))
			{
				ok = 0;
				break;
			}
			s.insert(e);
		}
		if(!ok) break;
	}
	puts(ok ? "pairwise coprime" : "setwise coprime");
	return 0;
}


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
  }

  LL ans = 0;
  for (int i = 1; i < n; i ++) {
    int tmp = a.at(i) + a.at(i - 1);
    if (tmp > x) {
      int def = tmp - x;
      ans += def;
      if (def > a.at(i)) {
        a.at(i) = 0;
      } else {
        a.at(i) -= def;
      }
    }
  }

  cout << ans << endl;
}


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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 100100100100100100;
const int mod = 1e9;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
string alphabet = "abcdefghijklmnopqrstuvwxyz";


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */



signed main(){

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

    

    int n = input();

    string s, t;
    cin >> s >> t;

    int tmp = n;
    rep(i,0,n){
        bool isok = true;
        rep(j,0,n){
            if(i + j == n) break;
            if(s[i + j] != t[j]) isok = false;
        }
        if(isok){
            tmp = i;
            break;
        }

    }

    print(tmp + n);



    




    
    



    
    



 
    
    


    

    
   
    













}






    










    




    










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

const int N = 1e5+7, INF = 1e9;
int d[N];
int col[N];

struct Edge {
    int u, v, w;
    Edge(int u, int v) :u(u), v(v), w(INF) {}
    int other(int x) {return u^v^x;}
};

vector<int> adj[N];
vector<Edge> edges;

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

    int n, m;
    cin>>n>>m;

    vector<int> order;

    for (int i=1; i<=n; i++)    {
        cin>>d[i];
        order.push_back(i);
    }

    auto comp = [](int x, int y) {return d[x] < d[y];};
    sort(order.begin(), order.end(), comp);

    for (int i=1; i<=m; i++) {
        int u, v;
        cin>>u>>v;
        edges.emplace_back(u, v);
        adj[u].push_back(edges.size()-1);
        adj[v].push_back(edges.size()-1);
    }

    for (int u: order) {
        if (col[u])    continue;
        bool found = false;
        for (int e: adj[u]) {
            int v = edges[e].other(u);
            if (col[v])  {
                edges[e].w = d[u];
                found = true;
                col[u] = 3 - col[v];
                break;
            }
        }

        if (!found) {
            for (int e: adj[u]) {
                int v = edges[e].other(u);
                if (d[v] == d[u]) {
                    edges[e].w = d[u];
                    found = true;
                    col[u] = 1;
                    col[v] = 2;
                    break;
                }
            }
        }
        if (!found) {
            cout<<-1<<endl;
            return 0;
        }
    }

    for (int i=1; i<=n; i++)
        if (col[i] == 1)    cout<<"W";
        else                cout<<"B";
    cout<<endl;
    for (int i=0; i<edges.size(); i++)  cout<<edges[i].w<<"\n";
}

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

int min_ex_o(int a,int b){
  if((a==0)||(b==0)){
    return a>b?a:b;
  }else{
    return a>b?b:a;
  }
}
int main(){
  vector<int> rc;
  vector<vector<int> > mm;
  int n;

  cin >> n;
  rc.resize(n+1);
  mm.resize(n+1);
  for(int i=0;i<n+1;i++){
    mm[i].resize(n+1);
  }
  for(int i=1;i<=n;i++){
    mm[i][i]=0;
  }
  for(int i=1;i<=n;i++){
    cin >> rc[i-1] >> rc[i];
  }

  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      for(int k=i;k<=j-1;k++){
        mm[i][j]=min_ex_o(mm[i][j],mm[i][k]+mm[k+1][j]+rc[i-1]*rc[k]*rc[j]);
      }
    }
  }

  cout << mm[1][n] << endl;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  char s[h+2][w+2];
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> s[i+1][j+1];
    }
  }
  int chk=1;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(s[i+1][j+1]=='#'){
        if(s[i][j+1]!='#'&&s[i+2][j+1]!='#'&&s[i+1][j]!='#'&&s[i+1][j+2]!='#')chk=0;
      }
    }
  }
  if(chk==1)cout << "Yes";
  else cout <<"No";
  
}

Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 200000;

long long n,k,ans,cnt[N];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n>>k;
	// 0, 0, 0; x/2, x/2, x/2; //0, x/2, x/2.

	for (int i=1;i<=n;i++){
		cnt[i%k]++;
	}

	ans+=cnt[0]*cnt[0]*cnt[0];
	if (k%2==0){
		ans+=cnt[k/2]*cnt[k/2]*cnt[k/2];
//		ans+=cnt[k/2]*cnt[0]*cnt[k/2];
//		ans+=cnt[0]*cnt[k/2]*cnt[k/2];
	}
	cout<<ans<<endl;

//	cin.get(); cin.get();
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    if(100<=n&&n<=111)cout<<111<<endl;
    if(112<=n&&n<=222)cout<<222<<endl;
    if(223<=n&&n<=333)cout<<333<<endl;
    if(334<=n&&n<=444)cout<<444<<endl;
    if(445<=n&&n<=555)cout<<555<<endl;
    if(556<=n&&n<=666)cout<<666<<endl;
    if(667<=n&&n<=777)cout<<777<<endl;
    if(778<=n&&n<=888)cout<<888<<endl;
    if(889<=n&&n<=999)cout<<999<<endl;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, c, n, x, y;
  string s;
  vector<int> v(3);
  int p[3] = {5, 5, 7};

  rep(i, 3) cin >> v[i];
  sort(v.begin(), v.end());
  rep(i, 3)
  {
    if (v[i] != p[i])
    {
      NO();
      return 0;
    }
  }
  YES();
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1);
    vector<int> c(n);
    for (int i = 1;i <= n;i++) cin >> a[i];
    for (int i = 1;i <= n;i++) cin >> b[i];
    for (int i = 1;i <= n-1;i++) cin >> c[i];
    int sum = b[a[1]];
    for (int i = 2;i <= n;i++){
        if (a[i] == a[i-1]+1){
            sum += b[a[i]] + c[a[i-1]];
        }
        else {
            sum += b[a[i]];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, M;
	
	cin >> N >> M;

	int num[N];
	bool red[N];
	rep(i, N)
	{
		num[i] = 1;
		red[i] = false;
	}
	red[0] = true;
	rep(i, M)
	{
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		if (red[x])
		{
			red[y] =true;
		}

		if (num[x] > 0)
		{
			num[x]--;
			num[y]++;
			if (num[x] == 0)
			{
				red[x] = false;
			}
		}
	}

	int cnt = 0;
	rep(i, N)
	{
		if (red[i])
		{
			cnt++;
		}
	}

	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>

int main(void){

  char w[101];
  char i;
  int j=0;
  int cnt[26]={0};
  int k=0;

  scanf("%s", w);

  for(i='a'; i<='z'; i++){
    for(j=0; j<strlen(w); j++){
      if(i==w[j]){
        cnt[k]++;
      }
    }
    k++;
  }

  for(i=0; i<k; i++){
    if(cnt[i]%2!=0){
      printf("No\n");
      break;
    }
  }

  if(i==k)
    printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
N,M=map(int,input().split())
a=[]
for i in range(N):
    a.append([i for i in list(map(int,input().split()))])

answers=[]
for k in range(1,M+1):
    ans=0
    for i in range(N):
        for j in range(a[i][0]):
            if a[i][j+1]==k:
                ans+=1
    if ans==(N):
        answers.append(k)
print(len(answers))    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c - max(a, max(b, c)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main()
{

    ll N ,T ;
    cin >> N >> T;

    ll ans = 100000;
    rep(i,N){
        ll c, t;
        cin >> c >> t;
        if(t <= T){
            ans = min(ans, c);
        }
    }

    if(ans == 100000){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }


    return 0;
}

/*
/^[\w!\x22\#$%&@\'() * +,-.\/;:]+$/
*/


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

int main(){
  int N;
  cin>>N;
  
  vector<ll>T(N);
  int sum=0;
  
  for(int i=0;i<N;i++){
    cin>>T[i];
    sum+=T[i];
  }
  
  int M;
  cin>>M;
  vector<int>p(M);
  vector<ll>X(M);


  for(int i=0;i<M;i++){
    cin>>p[i]>>X[i];
   
  }
  

  
  for(int i=0;i<M;i++){
  
    
    cout<<sum-T[p[i]-1]+X[i]<<endl;
 
}
}
  
  
  

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
f=[1]*n
ans=[0]*n
ans[0]=1
for i in range(m):
  if ans[l[i][0]-1]==1:
    if f[l[i][0]-1]==1:
      ans[l[i][0]-1]=0
      ans[l[i][1]-1]=1
    else:
      ans[l[i][1]-1]=1
  f[l[i][0]-1]-=1
  f[l[i][1]-1]+=1
print(sum(ans))

Measured memory_bytes: 28964
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [int(x) for x in input().split()]
n, l = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re

def doit():
  m = 0
#  print(l, file=sys.stderr)
  if l > 0:
    m = l
  elif l + n - 1 < 0:
    m = n + l -1
  else:
    m = 0
  return (l + (l + n - 1)) * n // 2 - m

#print(doit([0] * 4))
#doit(s)
#print(doit())
try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)


Measured memory_bytes: 3956
#include <iostream>

// 奇数: 6, 17, 28,  ... 11n-5
// 偶数: 11, 22, 33 ... 11n

// 11n-5 >= x -> n >= (x+5)/11
// 11n >= x -> n >= x/11

int main(){
unsigned long int x;

std::cin >> x;

unsigned long int odd = (x+5)/11;
unsigned long int even = x/11;

if ((x+5)%11 != 0){
odd += 1;
}

if (x%11 != 0){
even += 1;
}

if (odd <= even){
std::cout << 2*odd-1 << std::endl;
}
else {
std::cout << 2*even << std::endl;
}

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  ll x, y;
  cin >> x >> y;
  ll cnt = 0;
  while (y >= x) {
    x *= 2;
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int N, M, total = 0, ans = 0 ;
  cin >> N >> M ;
  int A[N] ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
    total += A[i] ;
  }
  sort(A, A+N) ;
  total = (total - 1) / (4 * M) ;
  if(A[N-M] > total) ans = 1 ;
  if(ans){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  
  return 0 ;
}  

Measured memory_bytes: 256
input = raw_input

n = int(input())
As = map(int, input().split(" "))

if 0 in As:
    out = 0
else:
    m = 10 ** 18 
    for i, a in enumerate(As):
        if a > m:
            out = -1
            break

        if i == 0:
            out = a
        else:
            out *= a

        if out > m:
            out = -1
            break

print(out)

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

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
 
  
  if(a>=k) cout << k << endl;
  else if((a+b)>=k && a<k )  cout << a << endl;
  else if((a+b)<k) cout << 2*a+b-k << endl;
  
}


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

using namespace std;

const int N = 105;

int n;
int mx[N];
int dis[N][N];
int diam;
int maxdeg[N];
vector <int> g[N];

void dfs(int at, int par, int dep){
	int child = 0;
	for(auto u : g[at]){
		if(u == par) continue;
		dfs(u, at, dep + 1);
		child += 1;
	}
	maxdeg[dep] = max(maxdeg[dep], child);
}

long long calc(){
	long long ans = 1LL;
	for(int i = 1; maxdeg[i]; ++i) ans *= maxdeg[i];
	return ans;
}

int main(){
	int x, y;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			dis[i][j] = 1e9;
		}
		dis[i][i] = 0;
	}
	for(int i = 2; i <= n; ++i){
		scanf("%d %d", &x, &y);
		dis[x][y] = 1;
		dis[y][x] = 1;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int k = 1; k <= n; ++k){
		for(int i = 1; i <= n; ++i){
			for(int j = 1; j <= n; ++j){
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j){
			if(dis[i][j] > diam){
				diam = dis[i][j];
				x = i, y = j;
			}
		}
	}
	long long ans = LONG_LONG_MAX;
	if(diam % 2){
		int a, b;
		for(int i = 1; i <= n; ++i){
			for(int j = 1; j <= n; ++j){
				if(i == j) continue;
				if(dis[x][i] == dis[j][y] && dis[x][i] == diam / 2 && dis[i][j] == 1){
					a = i;
					b = j;
				}
			}
		}
		memset(maxdeg, 0, sizeof(maxdeg));
		dfs(a, b, 1);
		dfs(b, a, 1);
		ans = 2LL * calc();
	}
	else{
		int a, b;
		for(int i = 1; i <= n; ++i){
			if(dis[x][i] == dis[i][y] && dis[x][i] + dis[i][y] == diam){
				a = i, b = i;
			}
		}
		dfs(a, 0, 1);
		ans = calc();
		for(auto i : g[a]){
			memset(maxdeg, 0, sizeof(maxdeg));
			dfs(a, i, 1);
			dfs(i, a, 1);
			ans = min(ans, 2LL * calc());
		}
	}
	printf("%d %lld\n", (diam + 2) / 2, ans);
	return 0;
}



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

int main() 
{
    int N;
    cin >> N;
    int A[N+1], B[N];
    for (int i = 0; i < N+1; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];  

    int i = 0;
    int tmp = 0;
    long long total = 0;
    int prev = 0;
    while (true) 
    {       
        tmp = min(A[i], prev);
        total += tmp;
        A[i] -= tmp; // 前の残りを引く

        if (i == N) break; // Aのlastならここで終わり

        if (A[i] > 0) 
        {
            tmp = min(A[i], B[i]);
            total += tmp;
            A[i] -= tmp;
            prev = B[i]-tmp;
        }
        else prev = B[i];
        i++;
    }
    cout << total << endl;
}

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

int main(){
    int N;  cin >> N;
    vector<int> x(N), y(N);
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i];
    }
    vector<int> O(N);
    for(int i=0; i<N; i++)
        O[i] = i;
    
    double sum = 0;
    int cnt = 0;
    do {
        cnt++;
        double d = 0;
        for(int i=1; i<N; i++){
            d += sqrt( pow((x[O[i]] - x[O[i-1]]),2) + pow((y[O[i]] - y[O[i-1]]),2) );
        }
        sum += d;
    } while(next_permutation(O.begin(), O.end()));

    cout << setprecision(9) << sum/cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <complex>
#include <iomanip>
#include <cmath>

using namespace std;

typedef complex<double> Point;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const double eps = 1e-8, inf = 1e+8;

template<typename T> T sqr(T x){return x*x;}

double cross(const Point &a, const Point &b){
    return imag(conj(a) * b);
}

struct Line : vector<Point> {
    Line(const Point &a, const Point &b){
        push_back(a); push_back(b);
    }
};

bool interLS(const Line &l, const Line &s){
    return cross(l[1]-l[0], s[0]-l[0]) * cross(l[1]-l[0], s[1]-l[0]) < eps;
}

struct Circle : Point {
    double r;
    Circle(const Point &a, double r):Point(a), r(r){}
};

vector<Point> xptCC(const Circle &c1, const Circle &c2){
    vector<Point> res;
    double d = abs(c1-c2);
    if(d < eps)return res;
    double rc = (sqr(d) + sqr(c1.r) - sqr(c2.r)) / (2.*d);
    double rs = sqrt(sqr(c1.r) - sqr(rc));
    Point diff = (c2-c1) / d;
    res.push_back(c1 + diff * Point(rc, rs));
    res.push_back(c1 + diff * Point(rc, -rs));
    return res;
}

int n;
vector<Circle> cir;

double solve(){
    vector<Point> ps{cir[0]};
    rep(i, n-1){
        vector<Point> xpt(xptCC(cir[i], cir[i+1]));
        ps.insert(ps.end(), all(xpt));
    }
    ps.push_back(cir[n-1]);
    int m = (int)ps.size();
    vector<vector<pair<int, double> > > G(m);
    rep(i, m)rep(j, i){
        bool ok = true;
        int s = j|1, t = i - (!i&1);
        for(int k=s; k<t; k+=2){
            if(interLS(Line(ps[i], ps[j]), Line(ps[k], ps[k+1])))continue;
            ok = false;
            break;
        }
        if(ok)G[j].emplace_back(i, abs(ps[i] - ps[j]));
    }
    vector<double> mem(m, inf); mem[0] = 0;
    priority_queue<pair<double, int> > q;
    for(q.emplace(0, 0); !q.empty();){
        double c; int v;
        tie(c, v) = q.top(); q.pop();
        if(mem[v] + c < -eps)continue;
        for(auto e: G[v]){
            double nc = e.second - c;
            if(mem[e.first] + eps <= nc)continue;
            mem[e.first] = nc;
            q.emplace(-nc, e.first);
        }
    }
    return mem[m-1];
}

int main(){
    while(cin >> n, n){
        cir.clear();
        rep(i, n){
            int x, y, r;
            cin >> x >> y >> r;
            cir.emplace_back(Point(x, y), r);
        }
        cout << fixed << setprecision(6) << solve() << '\n';
    }
    return 0;
}

Measured memory_bytes: 1428
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    int n,c;

    cin >> n >> c;

    vector<vector<int>> d(c+1,vector<int>(c+1));

    for(int i = 1; i < c+1; i++){
        for(int j = 1; j < c+1; j++){
            cin >> d[i][j];
        }
    }

    vector<vector<int>> grid(n+1,vector<int>(n+1));

    for(int i = 1; i < n+1; i++){
        for(int j = 1; j < n+1; j++){
            cin >> grid[i][j];
        }
    }

    vector<vector<int>> color(3,vector<int>(c+1,0));

    for(int i = 1; i < n+1; i++){
        for(int j = 1; j < n+1; j++){
            color[(i+j)%3][grid[i][j]]++;
        }
    }


    LL mindist = INF;

    for(int i = 1; i < c+1; i++){
        for(int j = 1; j < c+1; j++){
            if(i == j){
                continue;
            }
            for(int k = 1; k < c+1; k++){
                if(i == k || j == k){
                    continue;
                }
                LL tmpdist = 0;
                for(int l = 1; l < c+1; l++){
                    tmpdist += d[l][i] * color[0][l];
                }
                for(int l = 1; l < c+1; l++){
                    tmpdist += d[l][j] * color[1][l];
                }
                for(int l = 1; l < c+1; l++){
                    tmpdist += d[l][k] * color[2][l];
                }
                if(mindist > tmpdist){
                    mindist = tmpdist;
                }
            }
        }
    }

    cout << mindist << endl;
    
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

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

	int h, w; cin >> h >> w;
	vector<vector<int>>dp(h, vector<int>(w, 0));
	vector<string>mat(h);
	for (auto &it : mat)
		cin >> it;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (mat[i][j] != '#')
			{
				if (i == 0 && j == 0)
					dp[i][j] = 1;
				else if (j == 0)
					dp[i][j] = dp[i - 1][j];
				else if (i == 0)
					dp[i][j] = dp[i][j - 1];
				else
					dp[i][j] = (dp[i - 1][j] + 0ll + dp[i][j - 1]) % MOD;
			}
		}
	}
	cout << dp[h - 1][w - 1];

	return 0;
}

Measured memory_bytes: 8500
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    lli a,b,c;
    cin>>a>>b>>c;

    lli p=c-a-b;
    lli q=4*a*b;
    lli pp=p*p;
    // cout<<cc<<" "<<c<<endl;
    
    (p>0 && pp>q)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//

map<pair<ll, ll>, int> m;
//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	ll h, w, n; cin >> h >> w >> n;

	
	ll ans[14];
	rep(i, 10) ans[i] = 0;
	ll a, b;
	rep(i, n)
	{
		cin >> a >> b;
		a--, b--;
		rep(loop,3)rep(loop2,3)
			if(a+loop-1>=1 && b + loop2 - 1 >= 1 && a + loop - 1 <= h-2 && b + loop2 - 1<= w-2)
				m[pair<ll,ll>(a + loop - 1, b + loop2 - 1)]++;
	}

	for (auto i : m)ans[i.second]++;

	ll sum = 0;
	rep(i, 10) sum += ans[i];
	ans[0] = (w - 2)*(h - 2)- sum;

	rep(i, 10) Print(ans[i]);

	//
	// your code finished



	return 0;
}

Measured memory_bytes: 56576
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
count = 0
n.times do |i|
    if a[i] <= b[i] && a[i] + a[i+1] >= b[i]
        count += b[i]
        a[i+1] = a[i+1] + a[i] - b[i]
        next
    end
    if a[i] <= b[i] && a[i] + a[i+1] < b[i]
        count += a[i] + a[i+1]
        a[i+1] = 0
        next
    end
    if a[i] > b[i]
        count += b[i]
        next
    end
end
puts count

Measured memory_bytes: 26856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder
{
    class ABC168C
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int h = int.Parse(str[2]);
            int m = int.Parse(str[3]);
            double c = Math.Abs(30*h-5.5*m)/180*Math.PI;
            double ans = Math.Sqrt(Math.Pow(a,2)+Math.Pow(b,2)-(2*a*b*Math.Cos(c)));
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27936
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
const int Maxn = 1e6;

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

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ll x, y;
	scanf("%lld %lld", &x, &y);
	int cnt = 1;
	ll g = GCD(x, y);
	for(ll i = 2; i * i <= g; i++) {
		if(g % i == 0)cnt++;
		while(g % i == 0) g /= i;
	}
	if(g > 1) cnt++;
	printf("%d\n", cnt);
	return 0;
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 2 * N;

int n, k;
int r, s, p;
char str[N];

int get(int c)
{
	if (c == 'r') return p;
	else if (c == 's') return r;
	else return s;
}

int main()
{
	cin >> n >> k;
	cin >> r >> s >> p;
	cin >> str + 1;
	
	LL res = 0;
	for (int i = 1; i <= k; i ++ )
	{
		string t;
		for (int j = i; j <= n; j += k) t += str[j];
		
		// cout << t << endl;
		
		for (int j = 0; j < t.size(); j ++ )
		{
			int k = j;
			while (k < t.size() && t[k] == t[j]) k ++ ;
			
			int len = k - j;
			// cout << j << ' ' << k << ' ';
			if (len % 2) res += (len / 2 + 1) * (LL)get(t[j]);
			else res += len / 2 * (LL)get(t[j]);
			
			j = k - 1;
			// cout << j << endl;
		}
	}
	
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        c = a % b
        return gcd(b, c)

def gcd_list(l):
    d = l[0]
    for i in range(len(l) - 1):
        d = gcd(d, l[i + 1])
    return d

def divisor(n):
    #nの約数のリストを返す
    import math
    m = int(math.sqrt(n))
    ans = []
    for i in range(1, m + 1):
        if n % i == 0:
            if i < n //i:
                ans += [i, n // i]
            else:
                ans += [i]
    ans.sort()
    return ans

n = int(input())
d = gcd_list(list(map(int, input().split())))

common_divs = divisor(d)
for i in common_divs:
    print(i)


Measured memory_bytes: 5664
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

typedef vector<long double> vec;
typedef vector<vec> mat;

vec gauss_jordan(const mat &A,const vec &b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  for(int i=0;i<n;i++)B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++){
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    }
    swap(B[i],B[pivot]);
    if(abs(B[i][i])<1e-8)return vec();
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++){
      if(i!=j){
	for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
      }
    }
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}
	
mat operator*(const mat &a,const mat &b){
  mat r(a.size(),vec(b[0].size()));
  for(int i=0;i<a.size();i++){
    for(int j=0;j<b[0].size();j++){
      for(int k=0;k<a[0].size();k++){
	r[i][j]+=a[i][k]*b[k][j];
      }
    }
  }
  return r;	  
}

mat pow(const mat &m,int n){
  if(n==0){
    mat e(m.size(),vec(m.size()));
    for(int i=0;i<m.size();i++){
      e[i][i]=1;
    }
    return e;
  }else{
    auto h=pow(m,n/2);
    return (n%2)?h*h*m:h*h;
  }
}

int main(){
  int S,N,K;
  cin>>S>>N>>K;
  if(N==1){
    S=abs(S);
    if(S%K){
      cout<<-1<<endl;
    }else{
      cout<<S/K<<endl;
    }
  }else{
    long double p[12][123]={};
    p[0][0]=1;
    for(int i=0;i<K;i++){
      for(int j=0;j<=100;j++){
	for(int k=1;k<=N;k++){
	  p[i+1][j+k]+=p[i][j]/N;
	}
      }
    }
    mat A(100,vec(100));
    A[0][0]=1;
    vec b(100);
    for(int i=1;i<100;i++){
      for(int j=1;j<=100;j++){
	A[i][abs(i-j)]+=p[K][j];
      }
      A[i][i]--;
      b[i]=-1;
    }
    auto r=gauss_jordan(A,b);
    if(r.empty()){
      cout<<-1<<endl;
    }else{
      mat M(101,vec(101));
      for(int i=0;i<100;i++){
	M[i][i+1]=1;
	M[99][99-i]=p[K][i+1];
      }
      M[100][100]=1;
      auto MP=pow(M,abs(S));
      long double ans=0;
      for(int i=0;i<100;i++){
	ans+=MP[0][i]*r[i];
      }
      cout.precision(9);
      cout<<fixed<<ans+MP[0][100]<<endl;
    }
  }
}

    
  
  

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

int main() {
  long n,ans=0;
  cin >> n;
  ans=n;
  vector<long> a(n);
  for(long i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  for(long i=1;i<n;i++) if(a[i-1]==a[i]) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
 vector<int> S(N);
  int checker=0;
  for(int i=0; i<N;i++){
    cin>>S.at(i);
    if(S.at(i)==1)
      checker++;
  }
  if(checker==0)
    cout<<-1<<endl;
  else{
   int Ans=0;
    int L=1;
    for(int i=0; i<N; i++){
      if(S.at(i)!=L)
        Ans++;
      else {
        L++;
      }
    }
    cout<<Ans<<endl;
  }
      
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int MAXN = 200000;
int K,N;
int A[MAXN];
bool ok(double mid) {
    int count = 0;
    rep(i,N) {
        count+=(int)(A[i]/mid);
        if((double)(A[i]/mid) != (int)(A[i]/mid)) {
            count++;
        }
        count--;
    }
    return (count <= K);
}

int up(double x) {
    if(x == int(x))return (int)x;
    else return int(x)+1;
}

int main(){
    cin >> N >> K;
    rep(i,N)cin >> A[i];
    long double mini,maxi,mid;
    mini = 0;
    maxi = 1000000001;
    while(1) {
        mid = (mini + maxi)/2;
        if(ok(mid)){
            maxi = mid;
        }else {
            mini = mid;
        }
        if(abs(maxi - mini) < 0.000001)break;
    }

    if(maxi > 1000000000)cout <<  1000000000 << endl;
    else cout<< up(mini) << endl;
    return 0;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;
const double ips = 0.1;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll a, ans = 0;
    double b;
 
    cin >> a >> b;
    while(b > 1) {
        ans += a;
        b -= 1;
    }
    ll tmp;
    tmp = ll((b+0.001)*100);
    tmp *= a;
    tmp /= 100;
    ans += tmp;

    cout << ans << endl;
    return 0;

}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3736