akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

string S;
ll DP[100001][13];

int main() {
	cin >> S;
	DP[0][0] = 1;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '?') {
			for (int j = 0; j < 13; ++j) {
				DP[i][j] %= mod;
				for (int k = 0; k < 10; ++k) {
					DP[i + 1][(j * 10 + k) % 13] += DP[i][j];
				}
			}
		}
		else {
			for (int j = 0; j < 13; ++j) {
				DP[i][j] %= mod;
				DP[i + 1][(j * 10 + S[i] - '0') % 13] += DP[i][j];
			}
		}
	}
	cout << DP[S.size()][5] % mod << endl;
}

Measured memory_bytes: 10624
//temp##############################################

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

//temp##############################################

//don't forget free(data);

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if((a+b)%2!=0)printf("IMPOSSIBLE");
    else printf("%d",(a+b)/2);
    return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# s1, s2の入力
s1 = input()
s2 = input()
# メモ化
memo = [[i for i in range(len(s1) + 1)] if j == 0 else [j if i == 0 else -1 for i in range(len(s1) + 1)] for j in range(len(s2) + 1)]
for i in range(1, len(s2) + 1):
    for j in range(1, len(s1) + 1):
        # 置換が必要かどうか判断
        cng = memo[i - 1][j - 1] if s1[j - 1] == s2[i - 1] else memo[i - 1][j - 1] + 1
        # 3種類の操作のうち最適のものを求める
        memo[i][j] = min(cng, memo[i][j - 1] + 1, memo[i - 1][j] + 1)
# 解答の出力
print(memo[len(s2)][len(s1)])


Measured memory_bytes: 42896
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
 string s;
  cin >> s;
  s.at(3)='8';
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(r) r.begin(),r.end()
typedef int64_t ll;
typedef std::vector<ll> vll;
using namespace std;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        vll a(N);
        rep(i, N) {
            in >> a[i];
        }
        sort(all(a));
        reverse(all(a));
        ll l = 0;
        ll r = 0;
        rep(i, N - 1) {
            if (a[i + 1] == a[i]) {
                if (l == 0) {
                    l = a[i];
                }
                else {
                    r = a[i];
                    break;
                }
                i++;
            }
        }
        out << l*r << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 1024
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

def solve(s):
    ans = 0
    tmp = 0
    for ss in s:
        if ss == 'R':
            tmp += 1
            ans = max(ans,tmp)
        else:
            tmp = 0
    print(ans)

            

def main():
    s = input().rstrip()
    solve(s)


if __name__ == "__main__":
    main()

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

typedef long long ll;

int main(){

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

    int n;
    cin >> n;
    int x;
    int count=0;
    for(int i=1; i<=n; i++){
        cin >> x;
        if((x&1)==1 && (i&1)==1) count++;
    }
    cout<<count<<'\n';
    return 0;
}


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

#define fi first
#define se second
#define pb push_back

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

string s;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    clock_t ck;
    ck = clock();
    cin >> s;
    ll sum = 0;
    for (int i = 0; i < s.length(); i++)
    {
        sum += s[i] - '0';
    }
    cout << (sum%9 == 0 ? "Yes" : "No") << '\n';
    ck = clock()-ck;
    cerr << "It took " << 1.0*ck/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int runlength = 0;
  int res = 0;
  for (int i = 1; i <= N; i++) {
    int p;
    cin >> p;
    if (p == i) {
      ++runlength;
    } else {
      res += (runlength + 1) / 2;
      runlength = 0;
    }
  }
  res += (runlength + 1) / 2;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a,b] <- getIntList
    print $ if b < a then a-1 else a

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

main(){
  // 入力
  int h,w; cin >> h >> w;
  vs s(h); rep(i,h) cin >> s[i];

  // 黒の数
  int black = 0;
  rep(i,h) rep(j,w) if(s[i][j] == '#') black++;

  vvi checked(h,vi(w,0)),cost(h,vi(w,1<<29));
  queue<pii> q;
  q.push(pii(0,0));
  checked[0][0]=1;
  cost[0][0]=0;
  while(!q.empty()){
    int x,y;
    x = q.front().first;
    y = q.front().second;
    q.pop();
    rep(k,4){
      int i = x + dx[k];
      int j = y + dy[k];
      if((0<=i)and(i<h)and(0<=j)and(j<w)and(s[i][j]=='.')and(checked[i][j]==0)){
	checked[i][j]=1;
	cost[i][j]=cost[x][y]+1;
	q.push(pii(i,j));
      }
    }
  }
  //rep(i,h){ rep(j,w) cout << checked[i][j] << " "; cout << endl;}

  if(cost[h-1][w-1]==1<<29) cout << -1 << endl;
  else cout << h*w - black - cost[h-1][w-1] - 1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n, R[200000], max, min;


  scanf("%d", &n);
  for(int i = 0; i< n; i++){
//    printf("loop 0\n");
    scanf("%d", &R[i]);
    if(i > 0){
        int d;
//        printf("%d - %d\n", R[i], min);
        d = R[i] - min;
        if(d > max || i == 1) max = d;
    }
    if(i == 0 || min > R[i]){
      min = R[i];
    }
  }

  printf("%d\n", max);


  return 0;
}



Measured memory_bytes: 2500
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string.h>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int i, j, k, ans=0, n=1;
	char s[100], t[100], temp;

	cin >> s; cin >> t;

	for (j = 0; j < strlen(s)+1; j++) {
		ans = 0;
		for (i = 0; i < strlen(s)-1; i++) {
			temp = s[i];
			s[i] = s[i + 1];
			s[i + 1] = temp;
		}
		for (k = 0; k < strlen(s); k++) {
			if (s[k] == t[k])
				ans++;
		}
		if (ans == strlen(s))
			n = 0;
	}
	if(n)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;
const int MAX_N = 2e5;
int prime[MAX_N];
bool is_prime[MAX_N + 1];
void sieve(int n){
   int p = 0;
   for(int i = 0; i <= n; i++) is_prime[i] = true;
   is_prime[0] = is_prime[1] = false;
   for(int i = 2; i <= n; i++){
   if(is_prime[i]){
           prime[p++] = i;
           for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
       }
   }
}

struct CumulativeSum{
    vector<int> data;
    CumulativeSum(int sz) : data(sz, 0) {};
    void add(int k, int x){
        data[k] += x;
    }
    void build(){
        for(int i = 1; i < data.size(); i++){
            data[i] += data[i - 1];
        }
    }
    //区間[0,k]の和
    int query(int k){
        if(k < 0) return 0;
        return (data[min(k, (int)data.size() - 1)]);
    }
    //区間[l.r)の和
    int query(int l, int r){
        return query(r - 1) - query(l - 1);
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    sieve(MAX_N);
    int q;
    cin >> q;
    CumulativeSum s(100001);
    rep(i, 1, 100001){
        if(i % 2 && is_prime[i] && is_prime[(i + 1) / 2]){
            s.add(i, 1);
        }
    }
    s.build();
    rep(i, 0, q){
        int l, r;
        cin >> l >> r;
        cout << s.query(l, r + 1) << endl;
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>

using namespace std;

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

    int b=a.length();
    if(b==2)
        cout<<a<<endl;
    if(b==3)
    {
        reverse(a.begin(),a.end());
        cout<<a<<endl;
    }
    return 0;
}


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

bool detKaibun(string S){
    int len = S.length();
    bool isKaibun = true;
    REP(i,int(len/2)){
        if(S[i]!=S[len-i-1]){
            isKaibun = false;
        }
    }
    return isKaibun;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    string par1, par2;
    par1 = S.substr(0,int(S.length()-1)/2);
    par2 = S.substr(int(S.length()+3)/2-1);
    if(detKaibun(S) && detKaibun(par1) && detKaibun(par2)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main() {
	int N;
	cin >> N;
	int Num[100000];
	int E[100000];

	for (int i = 0; i < N; i++)	{
		cin >> Num[i];
		E[Num[i] - 1] = i + 1;
	}

	for (int i = 0; i < N; i++) {
		cout << E[i] << " ";
	}

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N;
    string s;
    cin >> N >> s;

    int now[3];
    int ans = 0;
    rep (i, 10)
    {
        rep (j, 10)
        {
            rep (k, 10)
            {
                int count = 0;
                now[0] = i; now[1] = j; now[2] = k;
                rep (idx, N)
                {
                    if (s[idx] - '0' == now[count])
                    {
                        ++count;
                    }
                    if (count == 3) break;
                }
                if (count == 3) ++ans;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int a, b;
   cin >> a >> b;
   rep(c, 1, 100000) {
      int d = (int)(c * 0.08);
      int e = (int)(c * 0.10);
      
      if (d == a && e == b) {
         cout << c << endl;
         return 0;
      }
   }
   cout << -1 << endl;
   return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        string abcd = Console.ReadLine();
        int a = int.Parse(abcd[0].ToString());
        int b = int.Parse(abcd[1].ToString());
        int c = int.Parse(abcd[2].ToString());
        int d = int.Parse(abcd[3].ToString());

        StringBuilder ans = new StringBuilder("");
        var op1 = "";
        var op2 = "";
        var op3 = "";

        if (a + b + c + d == 7)
        {
            op1 = "+";
            op2 = "+";
            op3 = "+";
        }

        if (a + b - c + d == 7)
        {
            op1 = "+";
            op2 = "-";
            op3 = "+";
        }

        if (a + b - c - d == 7)
        {
            op1 = "+";
            op2 = "-";
            op3 = "-";
        }

        if (a + b + c - d == 7)
        {
            op1 = "+";
            op2 = "+";
            op3 = "-";
        }

        if (a - b + c + d == 7)
        {
            op1 = "-";
            op2 = "+";
            op3 = "+";
        }

        if (a - b - c + d == 7)
        {
            op1 = "-";
            op2 = "-";
            op3 = "+";
        }

        if (a - b - c - d == 7)
        {
            op1 = "-";
            op2 = "-";
            op3 = "-";
        }

        if (a - b + c - d == 7)
        {
            op1 = "-";
            op2 = "+";
            op3 = "-";
        }

        ans.Append(a);
        ans.Append(op1);
        ans.Append(b);
        ans.Append(op2);
        ans.Append(c);
        ans.Append(op3);
        ans.Append(d);
        ans.Append("=7");
        Console.WriteLine(ans);
    }
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
//	freopen("in.txt","rt",stdin);
	int n;
	cin>>n;
	int x,y;
	cin>>x;
	int counter=0;
	for(int i=1;i<n;i++){
		cin>>y;
		if(x==y){counter++;x=0;}
        else x=y;
	}
	cout<<counter<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,K;
	cin>>N>>K;
	cout<<(N%K==0?0:1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int i;
	string s;
	cin >> s;
	if(s.size()&1){
		cout << "No" << endl;
		return 0;
	}
	for(i=0;i<s.size();i++){
		if(i&1){
			if(s[i]!='i'){
				cout << "No" << endl;
				return 0;
			}
		}else{
			if(s[i]!='h'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}
	

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

int A[N], B[N], C[N];
int minValue;
long cnt;

struct circleX {
	int n;
	int sum;
	int minOfThis;
	circleX() {
		clear();
	}
	void clear() {
		n = 0;
		sum = 0;
		minOfThis = INT_MAX;
	}
};

int main(void) {
	cnt = 0;
	int n, i, index;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> A[i];
		B[i] = A[i];
		C[i] = 0;
	}
	sort(B, B + n);
	minValue = B[0];
	circleX cir;
	int *p;
	for (i = 0; i < n; i++) {
		index = i;
		cir.clear();
		while (C[index] == 0) {
			C[index] = 1;
			cir.n++;
			cir.sum += A[index];
			cir.minOfThis = min(cir.minOfThis, A[index]);
			p = lower_bound(B, B + n, A[index]);
			index = distance(B, p);
		}
		if (cir.n > 1) {
			int x1 = (cir.sum + (cir.n - 2) * cir.minOfThis);
			int x2 = (cir.sum + cir.minOfThis + (cir.n + 1) * minValue);
			if (x1 <= x2)
				cnt += x1;
			else 
				cnt += x2;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
const ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
long long gcd(long long a,long long b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
// lcm = (a*b)/gcd(a,b)
//freopen("input.txt" ,"r",stdin );
//freopen("output.txt","w",stdout);
int n,k;
vector<int>a;
int memo[100005];
int fun(int idx)
{
	if (idx >= n-1)
		return 0;
	int &ret = memo[idx];
	if (~ret)
		return ret;
    ret=1e9;
    for(int i=1;i<=k&&idx+i<n;i++)
    {
        ret=min(ret,fun(idx+i)+abs(a[idx+i]-a[idx]));
    }
    return ret;
}
void fast();
int main()
{
    fast();
    cin>>n>>k;
    a.resize(n);
    memset(memo,-1,sizeof memo);
    loop(n)cin>>a[i];
    cout<<fun(0);
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 5760
_, n = gets.split(' ').map(&:to_i)
arr = gets.split(' ').map(&:to_i)
queue = [1]
ord = { 1 => 0 }

n.times do |i|
  c = arr[queue.last - 1]
  break unless ord[c].nil?
  queue << c
  ord[c] = i + 1
end
if ord[arr[queue.last - 1]].nil?
  p queue.last
  return
end
i = ord[arr[queue.last - 1]]
l = queue.drop(i)
p l[(n - i) % l.count]


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

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const ll OO = LLONG_MAX;
using namespace std;
struct point {
    ll w, price;
} arr[105];
ll n, w, dp[105][N];

ll solve(ll i, ll have) {
    if(have < 0) re LLONG_MIN;
    if (i >= n || have == 0) {
        re 0;
    }
    ll &ret = dp[i][have];
    if (~ret) re ret;
    ret = max(arr[i].price + solve(i + 1, have - arr[i].w), solve(i + 1, have));
    re ret;
}

int main() {
    IO;
    cin >> n >> w;
    rep(i, 0, n) {
        cin >> arr[i].w >> arr[i].price;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, w);
}

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

int Mod =  998244353;
vector<long long> fact,invfact;

long long exp(long long a,long long b) {
  if (b == 0) return 1;
  else if (b == 1) return a;
  else {
    long long temp = exp(a,b/2);
    temp *= temp;
    temp %= Mod;
    if (b%2 == 0) return temp;
    else return (temp*a)%Mod;
  }
}

long long combi(long long a,long long b) {
  return (((fact[a]*invfact[b])%Mod)*invfact[a-b])%Mod;
}

int main() {
  int n,a,b;
  long long k,ans = 0;
  cin >> n >> a >> b >> k;

  for (int i = 0;i < n+1;++i) {
    fact.push_back(0);
    invfact.push_back(0);
  }
  fact[0] = 1;
  invfact[0] = 1;
  
  for (int i = 1;i < n+1;++i) {
    fact[i] = (fact[i-1]*i)%Mod;
    invfact[i] = exp(fact[i],Mod-2);
  }
  
  for (int i = 0;i < n+1;++i) {
    long long j = k-a*i;
    if (j >= 0 && j%b == 0 && j/b <= n) {
      ans += (combi(n,i)*combi(n,j/b))%Mod;
      ans %= Mod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9952
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var S = sc.next();
        if (DateTime.Parse(S) <= new DateTime(2019, 4, 30)) {
            WriteLine("Heisei");
        } else {
            WriteLine("TBD");
        }
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13664
# -*- coding: utf-8 -*-

class Info():
    def __init__(self, x, y, h):
        self.X = x
        self.Y = y
        self.H = h

def main():
    N = int(input())
    infos = []
    for i in range(N):
        x, y, h = list(map(int, input().split(" ")))
        infos.append(Info(x, y, h))
    
    # [0, 100]に座標があるのでMAXを定義する
    MAX = 100
    for posY in range(0, MAX+1):
        for posX in range(0, MAX+1):
            # 頂上がどれくらいの高さであってほしいか。
            # -1はまだよくわからないとき。0以上は確定してるとき
            # -2はだめだとわかったとき
            ans_h = -1

            for i in range(N):
                # 各座標について考える
                if infos[i].H > 0:
                    H = infos[i].H + abs(posY - infos[i].Y) + abs(posX - infos[i].X)
                    if ans_h == -1:
                        ans_h = H
                    else:
                        if ans_h != H:
                            ans_h = -2
                            break
            
            # ダメだったら別の場所を探す
            if ans_h == -2:
                continue
            
            is_ok = True
            for i in range(N):
                # 各座標について、高さが0の場合に矛盾していないか調べる
                if infos[i].H == 0:
                    if ans_h - abs(posY - infos[i].Y) - abs(posX - infos[i].X) <= 0:
                        continue
                    else:
                        is_ok = False
                        break
            
            if is_ok:
                print(posX, posY, ans_h)
                return
            

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#define rep(i, n) for(int i = 0; i < (n); i ++)
using namespace std;

int main()
{
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> p(n, 0);
  
  int a;
  rep(i, q)
  {
    cin >> a;
    a --;
    p.at(a) ++;
  }
  
  rep(i, n)
  {
    if (p.at(i) + k - q > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::string > origin, std::pair< int64_t, std::string > another )
{
    return origin.first < another.first;
}


int main()
{

    int a,b,c,d;
    
    std::cin>> a;
    std::cin>> b;

    std::cin>> c;
    std::cin>> d;
    std::vector< std::vector<int> > v ( a, std::vector<int>( b, 0 ) );
    int current = 0;
    bool finish = false;
    int count = 0;

    int cc = c;
    int dd = d;
    /*
    if( cc == 0 )
    {
        cc = d;
    }
    */

    if( c != 0 )
    {
    for( int i = 0; i < v.size(); i++ )
    {
        //std::cout<< i <<"\n";
        for( int r = 0; r < cc; r++ )
        {
            if( b <= current + r )
            {
                finish = true;
                break;
            }
            else
            {
                v[i][ current + r ] = 1;
            }
        }
        
        count += 1;

        if( a - count <= dd )
        {
            //std::cout<< a - ( i + 1 )<<"\n";
            count = 0;
            current += cc;
        }
        
        if( finish )
        {
            break;
        }
    }


    if( current + cc != b
        && cc != 0
        && dd != 0)
    {
        for( int i = a - dd; i < a; i++ )
        {
            //std::cout<< i << "\n";
            for( int r = current; r < b; r++ )
            {
                v[i][r] = 1;
            }
        }
    }


    if( !finish )
    {
        for( int i = 0; i < v.size(); i++ )
        {
            for( int r = 0; r < v[i].size(); r++ )
            {
                std::cout<< v[i][r];
            }
            
            std::cout<< "\n";
        }
    }
    else
    {
        std::cout<< "No";
    }
    }
    else
    {
        if( b != 1 )
        {
            for( int i = 0; i < d; i++ )
            {
                for( int r = 0; r < v[i].size(); r++ )
                {
                    v[i][r] = 1;
                }
            }

            for( int i = 0; i < v.size(); i++ )
            {
                for( int r = 0; r < v[i].size(); r++ )
                {
                    std::cout<< v[i][r];
                }
                
                std::cout<< "\n";
            }

        }
        else
        {
            for( int i = 0; i < d; i++ )
            {
                std::cout<< "1\n";
            }

            for( int i = 0 ;i < a - d; i++ )
            {
                std::cout<< "0\n";
            }
        }
    }

}


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

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

    int n;
    cin >> n;

    map<int, int> rate;
    int cnt = 0;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        if (tmp >= 1 && tmp <= 399) rate[0]++;
        if (tmp >= 400 && tmp <= 799) rate[1]++;
        if (tmp >= 800 && tmp <= 1199) rate[2]++;
        if (tmp >= 1200 && tmp <= 1599) rate[3]++;
        if (tmp >= 1600 && tmp <= 1999) rate[4]++;
        if (tmp >= 2000 && tmp <= 2399) rate[5]++;
        if (tmp >= 2400 && tmp <= 2799) rate[6]++;
        if (tmp >= 2800 && tmp <= 3199) rate[7]++;
        if (tmp >= 3200) cnt++;
    }
    if (rate.size() == 0)
        cout << 1 << ' ' << cnt << '\n';
    else
        cout << rate.size() << ' ' << rate.size() + cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    flag=False
    x=int(input())
    for i in range(-200,200):
        for j in range(-200,200):
            if i**5-j**5==x:
                flag=True
                print(i,j)
                break
        if flag:
            break
resolve()

Measured memory_bytes: 9188
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)

	if v := b - a; v <= 0 {
		fmt.Println("delicious")
	} else if v <= x {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int mod = 1000000007;



int main()
{
  ll n;
  cin>>n;
  ll ans=0;
  rep(i,n){
    ans+=i;
  }
cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  int a; cin>>a;
  
  if(a%10==2||a%10==4||a%10==5||a%10==7||a%10==9) cout<<"hon" <<endl;
  else if(a%10==0||a%10==1||a%10==6||a%10==8)cout<<"pon"<<endl;
  else cout<<"bon"<<endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	int m,d,ans=0;
	cin>>m>>d;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			int d1=j%10;
			//cout<<d1;//
			int d10=(j/10)%10;
			//cout<<d10;//
			if(d1>=2 && d10>=2 && d1*d10==i){
				//cout<<"OK";//
				ans++;
			}
			//cout<<endl;//
		}
	}
	cout<<ans;
	return 0;
}

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

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

    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        ans += i * (n / i) * (n / i + 1) / 2;
    }

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


Measured memory_bytes: 3624
N, M = map(int,input().strip().split())

As = []
for i in range(N):
    As.append(input())

Bs = []
for i in range(M):
    Bs.append(input())


for x in range(N):
    for y in range(N):
        if x + M > N or y + M > N:
            break

        flag = True
        for tx in range(M):
            for ty in range(M):
                if As[x + tx][y + ty] != Bs[tx][ty]:
                    flag = False

        if flag:
            print("Yes")
            exit()


print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
using namespace std;
const int INF = 2147483647;

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
graph prim(const graph &g, const int size, const int init)
{
  int mincost[size] = {};
  bool used[size] = {};

  REP(i, size)
  {
    mincost[i] = INF;
  }

  mincost[init] = 0;
  graph res(size);
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> q;
  for (auto v : g[init])
  {
    q.push(make_pair(v.cost, make_pair(init, v.to)));
  }
  used[init] = true;

  while (!q.empty())
  {
    auto p = q.top();
    q.pop();
    auto e = p.second;

    if (used[e.second])
      continue;

    res[e.first].push_back({e.second, p.first});
    res[e.second].push_back({e.first, p.first});

    for (auto v : g[e.second])
    {
      q.push(make_pair(v.cost, make_pair(e.second, v.to)));
    }
    used[e.second] = true;
  }
  return res;
}

void dfs(graph &ans, graph &ming, int now, int parent)
{
  if (parent == -1)
  {
    for (auto v : ming[now])
    {
      dfs(ans, ming, v.to, now);
    }
    return;
  }
  if (ming[now].size() == 1)
  {
    if (ans[now].size() % 2 == 0)
    {
      ans[parent].push_back({now, 1});
    }
    else
    {
      ans[now].push_back({parent, 1});
    }
    return;
  }

  for (auto v : ming[now])
  {
    if (v.to == parent)
      continue;
    dfs(ans, ming, v.to, now);
  }

  if (ans[now].size() % 2 == 0)
  {
    ans[parent].push_back({now, 1});
  }
  else
  {
    ans[now].push_back({parent, 1});
  }
  return;
}

int main()
{
  int n, m;
  cin >> n >> m;
  graph g(n);
  REP(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back({b, 1});
    g[b].push_back({a, 1});
  }
  if (m % 2 == 1)
  {
    cout << -1 << endl;
    return 0;
  }

  // 最小全域木を構成する
  graph ming = prim(g, n, 0);
  graph ans(n);

  REP(i, n)
  {
    for (auto v : g[i])
    {
      bool flag = false;
      // 高々2回
      for (auto pr : ming[i])
      {
        if (pr.to == v.to)
          flag = true;
      }
      if (flag)
        continue;

      if (i > v.to)
        ans[i].push_back(v);
    }
  }

  dfs(ans, ming, 0, -1);

  REP(i, n)
  {
    for (auto v : ans[i])
    {
      cout << i + 1 << " " << v.to + 1 << endl;
    }
  }
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
struct myhash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<string,ll> psl;
typedef vector<psl> vpsl;
typedef vector<int> vi;

#define fur(i,a,b) for(ll (i)=(a);i<(b);++(i))
#define revf(i,a,b) for(ll (i)=(a)-1;(i)>=(b);--(i))
#define mp make_pair
#define mod 1000000007
#define inf 2000000007
#define pb push_back
#define eps 1e-5
#define X first
#define Y second


ll modpow(ll base, ll exp, ll modulus) {
  base %= modulus;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

ll modinv(ll a, ll m) { 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    } 
    if (x < 0)
       x += m0;
    return x;
}


int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
  ll x,a;
  cin>>x>>a;
  if(x<a)cout<<0;
  else cout<<10;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int N;
  cin >> N;
  if(N%2==0)
  {
    cout << N/2 << endl;
  }
  else
  {
    cout << N/2+1 <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int p = sc.nextInt();
    int q = sc.nextInt();
    int r = sc.nextInt();
    sc.close();
    int[] val = {p, q, r};
    Arrays.sort(val);
    System.out.println(val[0] + val[1]);
  }
}

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

namespace ABC150C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Replace(" ", "");
            var q = Console.ReadLine().Replace(" ", "");

            var num = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 }.Take(n).ToArray();

            var pp = Get(num, 0, p, "");
            var qq = Get(num, 0, q, "");

            Console.WriteLine(Math.Abs(pp - qq));
        }

        static int Get(int[] num, int cnt, string target, string now)
        {
            if (!num.Any())
            {
                if (target == now)
                {
                    return -(cnt + 1);
                }
                else
                {
                    return cnt + 1;
                }
            }

            for (int i = 0; i < num.Length; i++)
            {
                cnt = Get(num.Where(x => x != num[i]).ToArray(), cnt, target, now + num[i]);
                if (cnt < 0) break;
            }

            return cnt;
        }
    }
}


Measured memory_bytes: 15440
function main(input) {
    var args = input.split("\n");
	var count = 1;
	var len = args[0];
	var exp = 0;
	var exp_p = 0;
	var zumi = 0;
	
	while (count <= len) {
		if (exp < parseInt(args[count])) {
			exp = parseInt(args[count]);
			exp_p = count;
			
		}
		count++;
		
	}
	
	var total = 0;
	
	count = 1;
	while (count <= len) {
		if (count != exp_p ) {
			total += parseInt(args[count]);
			
		} else if (zumi == 0) {
			total += exp / 2;
			zumi = 1;
			
		}
		count ++;
		
	}
	console.log("" + total);
	
	
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
    int a, b;
    ci >> a >> b;

    if(b % a == 0) co << a + b << en;
    else co << b -a << en;
    
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
double X[10], Y[10];

double dist(int i, int j){
  double ans = (X[i] - X[j]) * (X[i] - X[j]);
  ans += (Y[i] - Y[j]) * (Y[i] - Y[j]);
  return sqrt(ans);
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];

  double ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      ans += dist(i, j);
    }
  }
  ans *= 2;
  ans /= (double) N;

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

  return 0;
}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll n,i,ans=0;
    cin>>n;
    ll a[n+1]={0},b[n+1]={0},c[n+1]={0};
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=n;i++) cin>>b[i];
    for(i=1;i<n;i++) cin>>c[i];
    for(i=1;i<=n;i++) {
        ans+=b[a[i]];
        if(i>1 and a[i]-1==a[i-1]) ans+=c[a[i-1]];
    }
    cout<<ans el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

int main() {
    string st;
    cin>>st;
    int s=0,ans=0;
    for(int i=0;i<st.size();i++) {
        if(st[i]=='R') s++;
        else {
            ans=max(s,ans);
            s=0;
        }
    }
    ans=max(s,ans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
file = $stdin
line = file.readlines
file.close
size = line[1].split(" ").collect!{|item| item.to_i}.sort!
ans = 1
pow = Array.new(line[0].to_i-1)
pow[0] = size[0]
for i in 1..line[0].to_i-2
pow[i] = pow[i-1] + size[i]
end
for i in 0..line[0].to_i-2
if size[line[0].to_i-i-1] <= 2*pow[line[0].to_i-i-2]
    ans += 1
else
    break
end
end

p ans

Measured memory_bytes: 8824
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int, int> pii;

int main() {
    int n, m;
    cin >> n >> m;
    pii ab[m];
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        ab[i] = pii(a, b);
    }
    sort(ab, ab+m);

    int l = ab[0].first, r = ab[0].second;
    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (ab[i].first < r) {
            l = ab[i].first;
            r = min(r, ab[i].second);
        } else {
            l = ab[i].first;
            r = ab[i].second;
            ans++;
        }
    }

    cout << ans + 1 << endl;

    return 0;
}

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

int main() {
  int n; cin>>n;
  vector<long long> a(n), acc(n);
  for (int i = 0; i < n; i++) cin>>a[i];

  acc[0] = a[0];
  for (int i = 1; i < n; i++) acc[i] = acc[i-1] + a[i];

  map<long long, int> ma;
  for (int i = 0; i < n; i++) ++ma[acc[i]];

  long long ans = 0;
  for (auto x: ma) {
    if (x.first == 0) ans += x.second;
    ans += (long long)x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}

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

#define int long long
#define mp make_pair
#define pb push_back
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define EPS 0.00000001

const int inf = 4e18; ///
const int mod2 = 1e9+7;

using namespace std;
void print(vector<int> & v){
    for(auto it:v) cout << it << " ";
    cout << "\n";
}

signed main(){
    int n;
    cin >> n;
    map<int,int> m;
    for(int i= 1;i<n;i++){
        int x;
        cin >> x;
        m[x]++;
    }
    for(int i =1;i<=n;i++) cout << m[i] << endl;
}


Measured memory_bytes: 16124
N = int(input())
A = list(map(int, input().split()))
cnt = 0

for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    if i is not minj:
        A[i], A[minj] = A[minj], A[i]
        cnt += 1

print(' '.join(map(str, A)))
print(cnt)

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007

int main()
{
    boost
    int n, m;
    cin >> n >> m;

    vi arr(n + 1, 0), pe(n + 1, 0);

    int p;
    string s;

    ll corr = 0, pen = 0;
    while(m--)
    {
        cin >> p >> s;
        if(arr[p] == 0 && s == "AC")
        {
            corr++;
            arr[p] = 1;
        }
        else if(arr[p] == 0 && s == "WA")
        {
            pe[p]++;
        }
    }

    for(int i = 1; i < n + 1; i++) if(arr[i]) pen += pe[i];

    cout << corr << " " << pen << nl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3744