akhauriyash/Code-Regression huggingface dataset:
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 5
#define MIN -100001
#define _MAX 8
#define ONE 1
#define TWO 2
#define THREE 3
#define FOUR 6
#define FULL 5
#define STRAIT 4
int main(void)
{
	char *a[_MAX] = { "null","one pair","two pair","three card","straight","full house","four card" };
	int card[5], cou[5] = { 0 }, ans;
	int bo = 1, x;
	while (scanf_s("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3], &card[4 ]) != EOF) {
		ans = 0;
		for (int i = 0; i < MAX; ++i) {
			cou[i] = 0;
			for (int j = MAX - 1; j > i; --j) {
				if (card[j] < card[j - 1]) {
					x = card[j]; card[j] = card[j - 1]; card[j - 1] = x;
				}
			}
		}
		for (int i = 0; i < MAX - 1; ++i) 
			if (card[i] == card[i + 1]) ++cou[i + 1] += cou[i];

		for (int i = 0; i < MAX; ++i) {
			if (i + 1 == MAX || cou[i + 1] == 0) {
				if (cou[i] > 0) {
					//1...one, 2...1.1, 3...2 4...3,5...2,1
					if (ans == 0) {
						//??????????????????1???
						if (cou[i] == 1) ans = ONE;
						else if (cou[i] == 2) ans = THREE;
						else if (cou[i] == 3) { ans = FOUR; break; }
					}
					else if (ans == ONE) {
						if (cou[i] == 1) { ans = TWO; break; }
						else if (cou[i] == 2) { ans = FULL; break; }
					}
					else if (ans == THREE) {
						if (cou[i] == 1) { ans = FULL; break; }
					}
				}
			}
		}
		if (ans == 0) {
			for (int i = MAX - 1; i >= 1; --i) {
				if (i == 1) {
					if (card[i] == card[i - 1] + 1) ans = STRAIT;
					else {
						if (card[4] == 13 && card[0] == 1) ans = STRAIT;
					}
				}
				if (card[i] != card[i - 1] + 1) break;
			}
		}
		printf("%s\n",a[ans]);
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i = 1; i <= n; i++) cin >> a[i];
  vector<int> b(n+1);
  
  for(int i = 1; i <= n; i++){
  b[a[i]] = i;
}
  
  for(int i = 1; i <= n; i++){
    cout << b[i] << " ";
  }
  
  cout << endl;
  
}

Measured memory_bytes: 1664
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn print_dp<T: Debug>(dp : &Vec<Vec<T>>){
    for row in dp{
        println!("{:?}", row);
    }
}

/*

AA A
   B
   C

AB A
   B
   C

AC A
   B
   C
*/

fn main(){
    let s = read_as_string();

    let mut dp: Vec<Vec<u64>> = vec![vec![0;3];s.len()+1];
    let m: u64 = 1_000_000_007;
    let mut pow: u64 = 1;
    for (i, ch) in s.chars().enumerate(){
        let i = i+1;
        let is_wild = ch == '?';
        if ch == 'A'  || is_wild {
            dp[i][0] += dp[i-1][0] + pow;
            dp[i][1] += dp[i-1][1];
            dp[i][2] += dp[i-1][2];
        }

        if ch == 'B' || is_wild{
            dp[i][0] += dp[i-1][0];
            dp[i][1] += dp[i-1][1] + dp[i-1][0];
            dp[i][2] += dp[i-1][2];
        }

        if ch == 'C' || is_wild{
            dp[i][0] += dp[i-1][0];
            dp[i][1] += dp[i-1][1];
            dp[i][2] += dp[i-1][2] + dp[i-1][1];
        }

        for j in 0..3{
            dp[i][j] %= m;
        }
        if is_wild{
            pow *= 3;
            pow %= m;
        }
    }

    println!("{}", dp[s.len()][2]);
    //print_dp(&dp);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    unordered_map<string, long long> mp;
    for (int i = 0; i < N; i++)
    {
        string S;
        cin >> S;
        sort(S.begin(), S.end());
        ++mp[S];
    }
    long long ans = 0;
    for (auto p : mp)
    {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
// �f��������O(n^(1/2))
map<ll, ll> prime_factor(ll n){
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++){
        while (n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}
int main() {
    ll N;
    cin >> N;
    map<ll, ll> primes = prime_factor(N);
    ll res = 0;
    int ans = 0;
    for (auto it = primes.begin(); it != primes.end(); ++it){
        int p = it->first;
        //fprintf(stderr, "%d, %d\n", it->first, it->second);
        rep(j, 100){
            if (j * (j + 1)/2 > it->second){
                ans += j - 1;
                break;
            }
        }
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

void solve() {
    int h, w;
    cin >> h >> w;
    vector<string> board(h);
    rep(i, h) cin >> board[i];
    int ans = 0;
    rep(sy, h) rep(sx, w) {
        if (board[sy][sx] == '#') continue;
        int dist[20][20];
        rep(i, 20) rep(j, 20) dist[i][j] = INF;
        dist[sy][sx] = 0;
        queue<pii> que;
        que.emplace(sy,sx);
        while(!que.empty()) {
            int y, x;
            tie(y, x) = que.front();
            que.pop();
            rep(d, 4) {
                int ny = y + dy[d];
                int nx = x + dx[d];
                if (ny < 0 || ny >= h || nx < 0 || nx >= w || board[ny][nx] == '#') continue;
                if (chmin(dist[ny][nx], dist[y][x] + 1)) {
                    que.emplace(ny, nx);
                }
            }
        }
        rep(i, h) rep(j, w) {
            if (board[i][j] == '#') continue;
            chmax(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3664
a, b = map(int, input().split())
s = [[0 for _ in range(100)] for _ in range(100)]
for i in range(100):
    for j in range(100):
        if j == 0:
            s[i][j] = "."
        elif j == 99:
            s[i][j] = "#"
        else:
            if i % 2 == 0:
                s[i][j] = "#"
            else:
                s[i][j] = "."
c, d = 0, 2
while b != 1:
    s[c][d] = "."
    b -= 1
    d += 2
    if d > 95:
        c += 6
        d = 2
c, d = 3, 97
while a != 1:
    s[c][d] = "#"
    a -= 1
    d -= 2
    if d < 4:
        c += 6
        d = 97
print(100, 100)
for t in s:
    print("".join(t))

Measured memory_bytes: 3188
n = int(input())

# 動的計画法
def fibonacci(n):
    F = [0]*(n+1)
    F[0] = 1
    F[1] = 1
    for i in range(2, n+1):
        F[i] = F[i-2] + F[i-1]
    return F

f = fibonacci(n)
print(f[n])


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

int main()
{
  char one, two, three;
  int n;
  string s;
  
  cin >> n;
  cin >> s;
  
  int count = 0;
  for (int i = 0; i < n; i ++)
  {
    three = two;
    two = one;
    one = s.at(i);
    
    if (one == 'C' && two == 'B' && three == 'A') count ++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cstdlib>
using namespace std;
#define rep(i,l,r) for(i=l;i<=r;i++)
#define ll long long
const int INF = 0x7fffffff;
const int N = 1e6 + 7;
const int mod = 1e9 + 7;
ll a[N];
ll ask(ll x, ll y)
{
	if (x < 0 && y < 0) return -min(x, y);
	if (x > 0 && y > 0) return max(x, y);
	return abs(x) + abs(y) + min(abs(x), abs(y));
}
int main()
{
	ll i, j, k;
	ll n, m, t;
	ll chi=0,ans;
	cin >> n >> k;
	rep(i, 1, n)
	{
		cin >> a[i];
		if (a[i] < 0)chi = i;
	}
	ll p1 = chi,p2=chi;
	if (p2 < k)p2 = p1 = k;
	ll cnt = 1;
	while (cnt < k && p1>1)p1--, cnt++;
	if (cnt == k) ans = ask(a[p1], a[p2]);
	while (p2 < n)
	{
		p1++;
		p2++;
		ans = min(ask(a[p1], a[p2]), ans);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
	int i=0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str_n = br.readLine();
	String str_A = br.readLine();
	String str_q = br.readLine();
	String str_M = br.readLine();

	int n = Integer.parseInt(str_n);
	int q = Integer.parseInt(str_q);

	int[] A = new int[n];
	int[] M = new int[q];

	Scanner sc_A = new Scanner(str_A).useDelimiter("\\s* \\s*");
	Scanner sc_M = new Scanner(str_M).useDelimiter("\\s* \\s*");

	while(sc_A.hasNext()){
	    A[i] = sc_A.nextInt();
	    i++;
	}

	i = 0;//カウント初期化

	while(sc_M.hasNext()){
	    M[i] = sc_M.nextInt();
	    i++;
	}

	for(i=0;i<q;i++){
	    int m = M[i];
	    System.out.println(exhausitiveSearch(n,A,q,m));
	}

	sc_A.close();
	sc_M.close();
    }
    
    private static String exhausitiveSearch(int n,int A[], int q, int m){
	int i = 0;
	if(solve(n,i,A,m) == true) return "yes";
	else return "no";
    }

    private static boolean solve(int n,int i,int A[],int m){
	if(m == 0) return true;
	if(i >= n) return false;
	boolean res = solve(n,i+1,A,m) || solve(n,i+1,A,m-A[i]);
	return res;
    }
}



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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 1000000007

typedef vector<int> vint;
typedef long long ll;



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

        string s;
        cin>>s;

        int size=s.size();

        if(s[size-1]=='s'){ cout << s << "es"<<endl;}
        else{cout<<s<<"s"<<endl;}


        return 0;
}


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

int main() {
  string S;
  cin >> S;
  int s1, s2, s3, s4;
  s1=S.at(0)-'0';
  s2=S.at(1)-'0';
  s3=S.at(2)-'0';
  s4=S.at(3)-'0';
  int ss1=s1*10+s2;
  int ss2=s3*10+s4;
  if ((ss1>0)&&(ss1<13)) {
    if ((ss2>0)&&(ss2<13)) {
      cout <<"AMBIGUOUS" << endl;
      return 0;
    } 
    cout <<"MMYY" << endl;
    return 0;
  }
  if ((ss2>0)&&(ss2<13)) {
    cout <<"YYMM" << endl;
    return 0;
  }
  cout <<"NA" <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
const ll INF_LL = 1000000000000;
#define fir first
#define sec second


int main()
{
    ll n;
    std::cin >> n;
    std::vector<ll> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];

    ll max = 0;
    //正 -> 負 -> 正 -> 負
    ll cur = (a[0] > 0 ? a[0] : 1);
    ll cnt = (a[0] > 0 ? 0 : 1 - a[0]);
    for(int i = 1; i < n; i++){
        if(i & 1){ //合計が負であるとき
            cnt += (cur + a[i] < 0 ? 0 : cur + a[i] + 1);
            cur = (cur + a[i] < 0 ? cur + a[i] : - 1);
        }else{
            cnt += (cur + a[i] > 0 ? 0 : -(cur + a[i]) + 1);
            cur = (cur + a[i] > 0 ? cur + a[i] : 1);
        }
    }
    max = cnt;


    cur = (a[0] < 0 ? a[0] : -1 );
    cnt = (a[0] < 0 ? 0 : a[0] + 1);
    for(int i = 1; i < n; i++){
        if(!(i & 1)){ //合計が負であるとき
            cnt += (cur + a[i] < 0 ? 0 : cur + a[i] + 1);
            cur = (cur + a[i] < 0 ? cur + a[i] : - 1);
        }else{
            cnt += (cur + a[i] > 0 ? 0 : -(cur + a[i]) + 1);
            cur = (cur + a[i] > 0 ? cur + a[i] : 1);
        }
    }
    std::cout << std::min(max, cnt) << std::endl;
}


Measured memory_bytes: 1024
using System;

namespace ABC095C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s1 = Console.ReadLine().Trim();

            string[] ss = s1.Split(' ');
            int pizaA = int.Parse(ss[0]);
            int pizaB = int.Parse(ss[1]);
            int pizaC = int.Parse(ss[2]);
            int x = int.Parse(ss[3]);
            int y = int.Parse(ss[4]);

            int total = 0;
            //int Azan = 0;
            //int Bzan = 0;
            //int C = 0;
            if (pizaA + pizaB > pizaC * 2)
            {
                if (x < y)
                {
                    total += pizaC * 2 * x;
                    y = y - x;

                    if (pizaB <= pizaC * 2)
                    {
                        total += pizaB * y;
                    }
                    else
                    {
                        total += pizaC * 2 * y;
                    }
                }
                else if (x > y)
                {
                    total += pizaC * 2 * y;
                    x = x - y;

                    if (pizaA <= pizaC * 2)
                    {
                        total += pizaA * x;
                    }
                    else
                    {
                        total += pizaC * 2 * x;
                    }
                }
                else
                {
                    total += pizaC * 2 * x;
                }
            }
            else
            {
                if (pizaA <= pizaC * 2)
                {
                    total += pizaA * x;
                }
                else
                {
                    total += pizaC * 2 * x;
                }
                if (pizaB <= pizaC * 2)
                {
                    total += pizaB * y;
                }
                else
                {
                    total += pizaC * 2 * y;
                }
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<cctype>
using namespace std;


int main(){
    string s;
    int m;

    while(true){
        cin >> s;
        if(s == "-") break;

        cin >> m;
        int h;

        for(int i=0;i<m;i++){
            cin >> h;
            string tmp = s.substr(0, h);
            s = s.substr(h) + tmp;
        }
        cout << s << endl;
    }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const ll MOD = 583964556541679;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

// combinationの計算
long long com[51][51];

void cominit(){
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }
}
    

int main()
{
    cout << fixed << setprecision(20);
    ll N, A, B;
    cin >> N >> A >> B;

    vector<ll> V(N);

    REP(i, N){
        cin >> V[i];
    }
    
    sort(V.rbegin(), V.rend());

    // 前処理
    com[0][0] = 1;
    cominit();

    ll t = V[A-1];
    bool flag = true;
    ll check = 0;
    ll count = 0;
    REP(i, N){
        if(V[i] == t){
            if(flag){
                check = i;
                flag = false;
            }
            count++;
        }
    }

    ll ans = 0;
    if(V[0] == V[check]){
        for(ll i=A; i<=B; i++){
            ans += com[count][i] ;
            // cout << "nCr:" << com[count][i] << endl;
            // cout << ans << endl;
        }
        // cout << count << endl;
        cout << V[0] << endl;
        cout << ans << endl;
        return 0;
    }

    ans += com[count][A-check];
    
    ll total = 0;
    REP(i, A){
        total += V[i];
    }
    
    cout << double(total)/double(A) << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
function Main(x) {
    tmp0 = x[0],v = x[1].split(" "),s = x[2].split(" ")
    var a = 0;
	for(var i = 0 ; i <= v.length ; i++)if(v[i]-s[i] > 0) a += v[i]-s[i];
	console.log(a);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));


Measured memory_bytes: 7372
n, x, y = map(int,input().split())

ans = [0]*(n-1)
for i in range(1,n+1):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(y-j))-1] += 1
        #ans.append(min(j-i,abs(x-i)+1+abs(y-j)))
for k in range(n-1):
    print(ans[k])


Measured memory_bytes: 46044
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll n,i,j=-1,cc=0;
    cin>>n;
    ll ara[n];for(i=0;i<n;i++)cin>>ara[i];
    for(i=n-1;i>=1;i--){
        if(ara[i-1]<ara[i])j=max(cc,j),cc=0;
        else cc++;
    }
    j=max(cc,j);
    cout<<j<<endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	double R;
	cin >> R;
	cout << setprecision(10) << R * 2 * M_PI  << endl;
	return 0;
}


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

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

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void) {
	int n, m;
	int a[1000][100] = { 0 };
	int b[100] = { 0 };
	int i, j;
	int ans[100] = { 0 };

	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d ", &a[i][j]);
		}
	}

	for (i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			ans[i] += a[i][j] * b[j];
		}
	}
	
	for (i = 0; i < n; i++)
		printf("%d\n", ans[i]);

	

	return 0;
}


Measured memory_bytes: 2248
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int k;
string s;
int main()
{
    cin>>k>>s;
    for(int i=0;i<min(k,(int)s.length());i++) cout<<s[i];
    if(s.length()>k) cout<<"...";
    cout<<endl;
	return 0;
}


Measured memory_bytes: 3636
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};


// abcde
fn read_string() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_string();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_string();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_string();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"),
        elems[1].parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"),
        elems[1].parse().ok().expect("failed to parse"),
        elems[2].parse().ok().expect("failed to parse"),
    )
}

fn main() {
    let n: i32 = read_as_primitive();
    let mut hs: Vec<i32> = read_as_collection();
    let mut max_h: i32 = hs.iter().max().unwrap().clone();
    let mut ans = 0;

    while max_h > 0 {
        let mut contiguous = false;
        for h in & mut hs {
            if *h == max_h {
                *h -= 1;
                if !contiguous {
                    contiguous = true;
                    ans += 1;
                }
            } else {
                contiguous = false;
            }
        }
        max_h -= 1;
    }

    println!("{}", ans);

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define debug(a,b,c) cout << a << " " << b << " " << c << endl;
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
#define endl "\n";
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>
 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int n; cin >> n;
	vi a(n), b(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0;i<=n-3;i++){
		int t = 1, f = 1;
		for(int j=i;j<(i+3);j++){
			if(t!=(a[j]==b[j])) {f = 0; break;}
		}
		if(f) {cout <<"Yes"<< endl; return 0;}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[101] = {0};

int main()
{
	long long int a, num=100, t=0;
	cin >> a;
	while(num < a)
	{
		num += num/100;
		t++;
	}
	cout << t;
}



Measured memory_bytes: 3636
from collections import deque
import sys
sys.setrecursionlimit(200000)
n,e = map(int,input().split())
g = [[] for i in range(n)]
for i in range(e):
  a,b,c = map(int,input().split())
  g[a].append([b,c,len(g[b])])
  g[b].append([a,0,len(g[a])-1])
  
def bfs(s,t):
  global level
  que = deque([s])
  level[s] = 0
  while que:
    v = que.popleft()
    lv = level[v] +1
    for y, cap, rev in g[v]:
      if cap and level[y] is None:
        level[y] = lv
        que.append(y)
  return level[t] if level[t] else 0
def dfs(x,t,f):
  if x == t:
    return f
  for j in range(it[x],len(g[x])):
    it[x] = j
    y, cap, rev = g[x][j]
    if cap and level[x] < level[y]:
      d = dfs(y,t,min(f,cap))
      if d:
        g[x][j][1] -= d
        g[y][rev][1] += d
        return d
  return 0
 
flow = 0
f = INF = float("inf")
level = [None]*n
while bfs(0,n-1):
  it = [0]* n
  f = INF
  while f:
    f = dfs(0,n-1,INF)
    flow += f
  level = [None]*n
print(flow)


Measured memory_bytes: 6248
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
int n;
double a[3001];
double dp[3001][3001];
int vis[3001][3001];
double val;
double getans(int ind,int head)
{
if(ind==n)
{
	return (head*2>=n);
}
if(vis[ind][head]!=0)
{
	return dp[ind][head];
}
vis[ind][head]=1;
double ans=1;
ans=a[ind]*getans(ind+1,head+1);
ans+=(1-a[ind])*getans(ind+1,head);
return dp[ind][head]=ans;
}
int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
double ans=getans(0,0);
	cout<<fixed<<setprecision(12)<<ans;
	
}





Measured memory_bytes: 77524
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	string S;
	string T;
	int ans = 0;
	cin >> S >> T;
	for (int i = 0; i <= 2; i++) {
		if (S[i] == T[i])ans++;
	}
	cout << ans;
}


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

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << " " << ((B + A - N > 0) ? (B + A - N) : 0);
	return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N + 1), D(N + 1);
  D.at(0) = 0;
  L.at(0) = 0;
  int ans = 1;
  for (int i = 1; i <= N; i++) {
    cin >> L.at(i);
    D.at(i) = D.at(i - 1) + L.at(i);
    if (D.at(i) <= X) {
      ans++;
    }
    else {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define rep(i,n) for(int i = 0;i<(int)(n);i++);
using namespace std;
using ll = long long;
const ll INF = 100100100100100;
ll keta(ll x) {
	ll sum = 0;
	while (x) {
		x /= 10;
		sum++;
	}
	return sum;
}
int main() {
	ll S;
	cin >> S;
	ll size = 0;
	ll ans = 0;
	ll now = 0;
	size = keta(S);
	vector<ll> num(size);//入力された数字を１つずつ配列に入れる
	for (int i = 0; i < size; i++) {
		num[size - 1 - i] = S % 10;
		S /= 10;
	}
	for (int i = 0; i < (1 << (size - 1)); i++) {
		bitset<9> s(i); {//０の時は+は無し１の時は+とする
			for (int j = 0; j < size - 1; j++) {
				now = now * 10 +num[j];
				if (s.test(j)) {//１の場合
					ans += now;
					now = 0;
				}
			}
			now = now * 10 + num[size - 1];
			ans += now;
			now = 0;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int A, B, C, X;
  sc.scan(A, B, C, X);

  int res = 0;

  foreach (i; 0 .. A + 1) {
    foreach (j; 0 .. B + 1) {
      foreach (k; 0 .. C + 1) {
        if ((i * 500) + (j * 100) + (k * 50) == X)
          res++;
      }
    }
  }

  writeln(res);
}



Measured memory_bytes: 256
n,k = [int(i) for i in input().split()]
ans = 0
for i in range(k+1,n+1):
  m = (n+1)//i
  ans += (i-k)*m
  if m*i+k <= n:
    ans += (n+1-m*i-k)
if k == 0:
  ans -= n
print(ans)

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

using ll = long long;
#define sz(x) ((int)x.size())
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int n;
vector<vector<int>> adj;

ll f(ll u, int p = -1) {
	ll ans = (u+1LL)*(ll(n)-u);
	for(ll v : adj[u])if(v!=p){
		ans += f(v,u);
		if(u<v){
			ans -= (ll(n)-v)*(u+1LL);
		}
		else{
			ans -= (ll(n)-u)*(v+1LL);
		}
	}
	return ans;
}

int main() {
	fastio();
	cin>>n;
	adj.resize(n);
	for(int i=0;i<n-1;++i){
		int u,v;
		cin>>u>>v;
		u--;v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	cout<<f(0)<<endl;
}


Measured memory_bytes: 33016
#include<iostream>
#include<string>
using namespace std;
int main (){

	int c=0;
	int i=0;
	
	string O;
	string E;
	string A;

        cin>>O>>E;
	
	for(i=0;i<O.size();i++){
		A[i*2]=O[i];
		A[i*2+1]=E[i];
	}
	
	for(i=0;i<O.size()+E.size();i++){
		cout<<A[i];
        }

}

Measured memory_bytes: 256
#include <stdio.h>

long long gcd(long long A, long long B) {
    long long t, r;
    if (A<B) {
        t=A;
        A=B;
        B=t;
    }
    r = A%B;
    while (r!=0) {
        A=B;
        B=r;
        r=A%B;
    }
    return B;
}
int main(void) {
    long long A, B;
    scanf("%lld%lld", &A, &B);
    printf("%lld", A*B/gcd(A, B));
    return 0;
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define inf 1e18
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    fastio();
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    while (a>0 || c>0) {
    	c -= b;
    	if (c<=0) {
    		cout << "Yes";
    		break;
    	}
    	a -= d;
    	if (a<=0) {
    		cout << "No";
    		break;
    	}

    }

    return 0;
}


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

#define lli long long int
#define ld long double
#define DEFO(n) lli n = 0;
#define MAX_L lli max = 9000000000000000000;
#define MIN_L lli min = 9000000000000000000;
#define MAX_D ld max = 4500;
#define MIN_D ld min = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n) \
  ld n;       \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LLIV2(a, b, n)         \
  vector<lli> a(n), b(n);      \
  for (lli i = 0; i < n; i++)  \
  {                            \
    cin >> a.at(i) >> b.at(i); \
  };
#define LDV(a, n)             \
  vector<ld> a(n);            \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define SUM(n) accumulate(n.begin(), n.end(), 0);
#define SORT(n) sort(n.begin(), n.end());
#define REVE(n) reverse(n.begin(), n.end());
#define yes              \
  cout << "Yes" << endl; \
  return 0;
#define no              \
  cout << "No" << endl; \
  return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(lli n)
{
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(n) LLIV(a, n)
  map<lli, lli> math;
  for(lli i = 0;i < n;i++) {
    if(math.count(a[i])){}
    else {
      math[a[i]] = 1;
    }
  }
  OUT(math.size())
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

const map<int, int> nn = { {1,2},{2,5},{3,5},{4,4},{5,5},{6,6},{7,3,},{8,7},{9,6} };
bool used[10];
int A[10];
string dp[10010];

bool comp(string A, string B)
{
	if (SZ(A) < SZ(B))return true;
	else if (SZ(A) > SZ(B))return false;

	rep(i, 0, SZ(A))
	{
		if (A[i] > B[i])
		{
			return false;
		}
		else if (A[i] < B[i])
		{
			return true;
		}
	}
	return false;
}

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

	int N, M;
	cin >> N >> M;
	rep(i, 0, M)
	{
		cin >> A[i];
	}

	sort(A, A + M);

	vector<int> P;
	int nm = 0;
	rrep(i, 0, M)
	{
		if (!used[nn.at(A[i])])
		{
			used[nn.at(A[i])] = true;
			P.push_back(A[i]);
			nm++;
		}
	}

	fill(dp, dp + N + 1, "-1");
	dp[0] = "";

	rep(i, 1, N + 1)
	{
		rep(j, 0, nm)
		{
			if (nn.at(P[j]) <= i && dp[i - nn.at(P[j])] != "-1")
			{
				string ts = to_string(P[j]) + dp[i - nn.at(P[j])];
				if (dp[i] == "-1" || comp(dp[i],ts))
				{
					dp[i] = ts;
				}
			}
		}
	}

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 33024
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (n*a < b) {
            System.out.println(n*a);
        } else {
            System.out.println(b);
        }

    }

}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
#define int long long
const int INF = 1e18;
const int MOD = 1000000007;


ll add(int a, int b){
  return (a + b) % MOD;
}

ll mult(int a, int b){
  return (a * b) % MOD;
}


void solve(){
  int n;
  cin >> n;
  int dp[n][4];
  memset(dp, 0, sizeof dp);
  dp[0][0] = 8LL;
  dp[0][1] = 1LL;
  dp[0][2] = 1LL;

  for (int i = 1; i < n; i++){
    dp[i][0] = mult(dp[i-1][0], 8LL);
    dp[i][1] = add(mult(dp[i-1][1], 9LL), dp[i-1][0]);
    dp[i][2] = add(mult(dp[i-1][2], 9LL), dp[i-1][0]);
    dp[i][3] = add(mult(dp[i-1][3], 10LL), add(dp[i-1][1], dp[i-1][2]));
    //cerr << i << '\n';
  }

  cout << dp[n-1][3] << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    solve();

    return 0;
}


Measured memory_bytes: 34820
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n;
    R(n);
    int now=1;
    FOR(i,1,n){
        int x;R(x);
        if(x==now)now++;
    }
    if(now==1)W(-1);
    else W(n-(now-1));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int fnd = 0;
    if (s.charAt(0) == 'A') {
      if (Character.isLowerCase(s.charAt(1))) {
        for (int i=2;i<s.length()-1;i++) {
          if (s.charAt(i)=='C') { fnd++;
          } else if (Character.isUpperCase(s.charAt(i))) {
            System.out.println("WA"); return;
          }
        }
        if (fnd==1) {
          if (Character.isLowerCase(s.charAt(s.length()-1))) {
            System.out.println("AC");
          } else {System.out.println("WA");}
        } else {System.out.println("WA");}
      } else {System.out.println("WA");}
    } else {System.out.println("WA");}
  }
}


Measured memory_bytes: 21844
use std::collections::VecDeque;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[derive(Debug, Clone, Copy)]
struct Cell {
    x: usize,
    y: usize,
    w: usize,
    c: usize,
}

fn main() {
    input! {n:usize, ps:[usize; (n * n)]};
    let w = n + 2;

    let mut cells = vec![
        vec![
            Cell {
                x: 0,
                y: 0,
                w: 0,
                c: 0,
            };
            w
        ];
        w
    ];

    for y in 1..(n + 1) {
        for x in 1..(n + 1) {
            cells[y][x].x = x;
            cells[y][x].y = y;
            cells[y][x].w = 1;
            cells[y][x].c = *[x, n - x + 1, y, n - y + 1].iter().min().unwrap();
        }
    }

    let mut cost = 0;
    let mut queue = VecDeque::new();

    for p in ps {
        let x = (p - 1) % n + 1;
        let y = (p - 1) / n + 1;

        cells[y][x].c -= 1;
        cells[y][x].w = 0;
        cost += cells[y][x].c;

        queue.push_front(x + y * w);

        while !queue.is_empty() {
            let q = queue.pop_back().unwrap();
            let (qx, qy) = (q % w, q / w);

            for [ax, ay] in [[1, 0], [-1, 0], [0, 1], [0, -1]].iter() {
                let nx = (qx as isize + ax) as usize;
                let ny = (qy as isize + ay) as usize;
                let c = cells[qy][qx].c + cells[ny][nx].w;

                if cells[ny][nx].c > c {
                    cells[ny][nx].c = c;
                    queue.push_front(nx + ny * w);
                }
            }
        }
    }

    println!("{}", cost);
}


Measured memory_bytes: 13408
/// awoooooo

# include <bits/stdc++.h>

# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)3e5 + 5;
const int inf = (int)1e9 + 7;

int n;
int c[N];
int ans[N];
int sum[N];
vector < int > p;

int main(){
  scanf("%d", &n);
  p.push_back(0);
  for(int i = 1; i <= n; ++i){
    scanf("%d", c + i);
    if(p.empty() || p.back() != c[i]){
      p.push_back(c[i]);
    }
  }
  ans[0] = 1;
  for(int i = 1; i < sz(p); ++i){
    (sum[p[i]] += ans[i - 1]) %= inf;
    ans[i] = sum[p[i]];
  }
  printf("%d\n", ans[sz(p) - 1]);
  return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

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

  if(s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256