akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

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

	int n;
	cin >> n;
	int ans = 0;
	char t = '!';
	rep(i, n) {
		char c;
		cin >> c;
		if (c != t) ++ans;

		t = c;
	}

	cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main(void) {
    int a, b;
    cin >> a >> b;
    if (a + b >= 10) cout << "error"<<endl;
    else cout << a + b <<endl;
    return 0;
}

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

int main() {
    int N, M;
    while (cin >> N >> M) {
        if (N == 0 && M == 0) break;
        vector<int> tile;
        vector<int> me;
        for (int i = 0; i < N; i++) {
            int n; cin >> n;
            tile.push_back(n);
        }
        for (int i = 0; i < M; i++) {
            int m; cin >> m;
            me.push_back(m);
        }
        int curpos = 1;
        for (int i = 0; i < M; i++) {
            int m = me[i];
            curpos += m;
            if (curpos >= N) {
                cout << i+1 << endl;
                break;
            }
            curpos += tile[curpos-1];
            if (curpos >= N) {
                cout << i+1 << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    for(int i = 1, x; i <= n; i++) {
        x = i;
        if(x % 3 == 0) 
            cout << " " << i;
        else if(x % 10 == 3)
            cout << " " << i;
        else {
            for(x /= 10; x != 0; x /= 10)
                if(x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3096
use proconio::input;

// 1箇所に1個: シュミレーションすればいい
// 1箇所に2個以上: AならBCだとだめ。それ以外ならOK。
// 2箇所以上: OK

#[derive(PartialEq, Eq, Clone, Copy)]
enum Query {
    AB,
    AC,
    BC,
}

impl Query {
    fn to_ints(&self) -> (usize, usize) {
        use Query::*;

        match self {
            AB => (A, B),
            AC => (A, C),
            _ => (B, C),
        }
    }

    fn intersection(x: Query, y: Query) -> usize {
        use Query::*;

        match (x, y) {
            (AB, AC) | (AC, AB) => A,
            (AB, BC) | (BC, AB) => B,
            (AC, BC) | (BC, AC) => C,
            _ => x.to_ints().0,
        }
    }
}

const A: usize = 0;
const B: usize = 1;
const C: usize = 2;

const YES: &str = "Yes";
const NO: &str = "No";

fn main() {
    input! {
        n: usize,
        a: i64,
        b: i64,
        c: i64,
        queries: [String; n],
    }

    let mut state = vec![a, b, c];
    let mut ans = vec![];
    for i in 0..n {
        // dbg!(&state);

        let q = parse_query(&queries[i]);
        let (x, y) = q.to_ints();

        if state[x] == 0 && state[y] == 0 {
            println!("{}", NO);
            return;
        }

        // 選択肢がない場合
        if state[x] == 0 {
            state[x] += 1;
            state[y] -= 1;
            ans.push(int_to_char(x));
            continue;
        }
        if state[y] == 0 {
            state[y] += 1;
            state[x] -= 1;
            ans.push(int_to_char(y));
            continue;
        }

        // 選択肢がある場合
        if state[x] > 1 {
            state[y] += 1;
            state[x] -= 1;
            ans.push(int_to_char(y));
            continue;
        }
        if state[y] > 1 {
            state[x] += 1;
            state[y] -= 1;
            ans.push(int_to_char(x));
            continue;
        }

        // どちらも1

        // 最後ならどちらでも
        if i == n - 1 {
            state[x] += 1;
            state[y] -= 1;
            ans.push(int_to_char(x));
            continue;
        }

        // そうでないなら先読みする必要がある
        let next_q = parse_query(&queries[i + 1]);
        if next_q == q {
            // どっちでも
            state[x] += 1;
            state[y] -= 1;
            ans.push(int_to_char(x));
            continue;
        }
        let is = Query::intersection(q, next_q);
        let other = if x == is { y } else { x };
        state[is] += 1;
        state[other] -= 1;
        ans.push(int_to_char(is));
    }

    // dbg!(&state);

    println!("{}", YES);
    for &c in &ans {
        println!("{}", c);
    }
}

fn parse_query(s: &str) -> Query {
    use Query::*;

    match s {
        "AB" => AB,
        "AC" => AC,
        _ => BC,
    }
}

fn int_to_char(x: usize) -> char {
    match x {
        0 => 'A',
        1 => 'B',
        _ => 'C',
    }
}


Measured memory_bytes: 8324
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int MAX = 100005;
int n, dp[MAX][3], inf = 1e9;
int val[MAX][3];

int f(int i, int j){
    int &ans = dp[i][j];
    if(ans != -1)return ans;
    ans = 0;
    if(i+1 == n)return ans;
    forn(k, 0, 3){
        if(k == j)continue;
        ans = max(ans, f(i+1, k)+val[i+1][k]);
    }
    return ans;
}

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

  cin >> n;
  forn(i, 0, n){
      forn(j, 0, 3){
          cin >> val[i][j];
      }
  }
  memset(dp, -1, sizeof dp);
  int ans = 0;
  forn(i, 0, 3){
      ans = max(ans, f(0, i)+val[0][i]);
  }
  cout << ans << endl;




}





Measured memory_bytes: 13704
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var s = new string[n];
			for (int i = 0; i < n; i++) {
				s[i] = Console.ReadLine();
			}

			int m = int.Parse(Console.ReadLine());
			var t = new string[m];
			for (int i = 0; i < m; i++) {
				t[i] = Console.ReadLine();
			}

			int ans = 0;
			for (int i = 0; i < n; i++) {
				string ss = s[i];
				int cnt = 0;
				for (int j = 0; j < n; j++) {
					if (ss == s[j]) {
						++cnt;
					}
				}

				for (int j = 0; j < m; j++) {
					if (ss == t[j]) {
						--cnt;
					}
				}

				ans = Math.Max(ans, cnt);
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13140
n, k = map(int, input().split())
H = [int(input()) for i in range(n)]
H.sort(reverse=True)
ans = 10 ** 9

for i in range(n-k+1):
    h = H[i] - H[i+k-1]
    ans = min(ans, h)
    
print(ans)

Measured memory_bytes: 7436
#include <iostream>
#include <string>
#include <map>

#define p pair<string, string>
#define ll long long
using namespace std;

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

    map<string, ll> front;
    for (int i = 0; i < 1 << n; i++) {
        string a, b;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) > 0) a = a + s[j];
            else b = s[j] + b;
        }
        front[a + "-" + b]++;
    }
    map<string, ll> back;
    for (int i = 0; i < 1 << n; i++) {
        string a, b;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) > 0) a = a + s[n + j];
            else b = s[n + j] + b;
        }
        back[b + "-" + a]++;
    }

    ll ret = 0;
    for (auto x:front) ret += x.second * back[x.first];

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 84352
<?php

fscanf(STDIN, '%d', $w);
fscanf(STDIN, '%d', $n);

$ary = array();

for ($i = 0; $i < $w; $i += 1) {
    array_push($ary, $i + 1);
}

for ($i = 0; $i < $n; $i += 1) {
    $a = array_map(function ($arg) {
        return $arg - 1;
    }, fscanf(STDIN, '%d,%d'));
    $temp = $ary[$a[0]];
    $ary[$a[0]] = $ary[$a[1]];
    $ary[$a[1]] = $temp;
}
foreach ($ary as $value) {
    echo $value, PHP_EOL;
}



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



int main() {
int a,b;
  cin >> a >> b;
  
  if(a !=1 && b!=1){
cout << 1;
}

  if(a !=2 && b!=2){
cout << 2;
}

  if(a !=3 && b!=3){
cout << 3;
}
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        w_vec: [String; n],
    }

    let mut flag = true;
    let mut set: HashSet<String> = HashSet::new();
    set.insert(w_vec[0].to_string());
    let mut last_word = w_vec[0].to_string();
    for i in 1..n {
        if set.contains(&w_vec[i]) {
            flag = false;
            break
        }
        set.insert(w_vec[i].to_string());

        if w_vec[i].chars().nth(0) != last_word.chars().last() {
            flag = false;
            break;
        }

        last_word = w_vec[i].to_string();
    } 
    

    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
    
}


Measured memory_bytes: 2180
#include <iostream>


using namespace std;


int main()
{
  long long n, m;

  cin >> n >> m;

  long long x = m/2, sumv;
  if (n <= x){
    sumv = n + (x-n)/2;
  } else {
    sumv = x;
  }
  cout << sumv << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int minSumprice = 0;


	for (int c = 0; c <= (X + Y) * 2; c += 2) {
		int aCount = 0;
		int bCount = 0;
		int cCount = 0;
		if (X > c / 2)aCount = X - c / 2;
		if (Y > c / 2)bCount = Y - c / 2;
		cCount = c;
		int sumPrice = cCount * C + aCount * A + bCount * B;
		if (c == 0)minSumprice = sumPrice;
		else if (sumPrice < minSumprice)minSumprice = sumPrice;
		//			cout << sumPrice  << " " << aCount << " " << bCount << " " << cCount << endl;
		//			cout << sumPrice << endl;
	}
	cout << minSumprice << endl;

	return 0;
}

Measured memory_bytes: 764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//構造体を定義
type Process struct {
	name string
	time int
}

//構造体を使って、arrを作れる
type Queue struct {
	arr []Process
}

func (q *Queue) enqueue(p Process) {
	q.arr = append(q.arr, p)
}

func (q *Queue) dequeue() Process {
	res := q.arr[0]
	q.arr = q.arr[1:]
	return res
}

func (q *Queue) isEmpty() bool {
	return len(q.arr) == 0
}

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var N, quantum, totalTime int
	var q Queue
	N, quantum = nextInt(), nextInt()
	for i := 0; i < N; i++ {
		var name string
		var time int
		name, time = nextStr(), nextInt()

		//struct_name{v1, v2, ...}
		q.enqueue(Process{name, time})
	}
	for !q.isEmpty() {
		p := q.dequeue()
		t := min(quantum, p.time)
		p.time -= t
		totalTime += t
		if p.time > 0 {
			q.enqueue(p)
		} else {
			fmt.Printf("%s %d\n", p.name, totalTime)
		}
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}



Measured memory_bytes: 9232
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,i,j,k,a[1010],b[1010],s[1010],d[1010][1010]={};
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]);
  for(i=0;i<1010*1010;i++)d[i/1010][i%1010]=1e9+10;
  for(i=s[0]=0;i<n;i++)s[i+1]=s[i]+b[i];
  for(i=0;i<=n;i++){
    for(j=0;j+i<=n;j++){
      if(i==0)d[j][j+i]=0;
      if(i==1)d[j][j+i]=1;
      if(d[j+1][j+i]==1&&s[j+i]-s[j+1]<=a[j    ])d[j][j+i]=1;
      if(d[j][j+i-1]==1&&s[j+i-1]-s[j]<=a[j+i-1])d[j][j+i]=1;
      for(k=j+1;k<j+i;k++)d[j][j+i]=MIN(d[j][j+i],d[j][k]+d[k][j+i]);
      //printf("%d %d %d\n",j,j+i,d[j][j+i]);
    }
  }
  printf("%d\n",d[0][n]);
  return 0;
}



Measured memory_bytes: 5848
n, y = gets.split.map(&:to_i)
x = y / 1000

ans = []
(0..n).each do |i|
  tmp = x - n - 4 * i
  if tmp < 0 || 10 * n - x - 5 * i < 0
    break
  end
  if tmp % 9 == 0
    ans = [tmp / 9, i, n - i - tmp / 9]
    break
  end
end

ans = [-1, -1, -1] if ans.empty?
puts ans.join(' ')

Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t; using i64 = int64_t; using f64 = double_t; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(n, m, i) for (i32 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i32 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i32 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n, p[20000];
i32 a[20000], b[20000];
i32 c = 30000;

i32 main()
{
    cin >> n;
    times(n, i) {
        cin >> p[i];
        a[i] = (i+1)*c;
        b[i] = (n-i)*c;
    }

    times(n, i) {
        b[p[i]-1] += i+1;
    }

    cout << a[0];
    range(1, n, i) {
        cout << " " << a[i];
    }
    cout << endl;

    cout << b[0];
    range(1, n, i) {
        cout << " " << b[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
vector<int> divisor(int a){
  vector<int> res;
  for(int i=1;i*i<=a;i++){
    if(a%i==0){
      res.push_back(i);
      if(i!=a/i) res.push_back(a/i);
    }
  }
  return res;
}

int main()
{
  int n,k;cin >> n >> k;
  vector<int> a(n);
  int sum=0;
  rep(i,n){ cin >> a[i];sum += a[i];}
  vector<int> div = divisor(sum);
  int res = 0;
  rep(i,div.size()){
    int x = div[i];
    vector<int> mi(n),pl(n);
    rep(j,n){
      mi[j] = a[j]%x;
      pl[j] = x-mi[j];
    }
    sort(mi.begin(), mi.end());
    sort(pl.begin(), pl.end());
    vector<int> psum(n+1),msum(n+1);
    psum[0]=0;msum[0]=0;
    rep(l,n){
      msum[l+1] = msum[l]+mi[l];
      psum[l+1] = psum[l]+pl[l];
    }
    
    rep(l,n+1){
      if(msum[l]>k) break;
      if(msum[l]==psum[n-l]) res=max(res,x);
    }
    
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>

using namespace std;

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

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

    if (sum > n)
        cout << "-1" << endl;
    else
        cout << n - sum << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <iostream>
#include <cstdlib>
#include <typeinfo>

using namespace std;
int main() {
	long long int a;
	cin >> a;
	a = sqrt(a);
	a *= a;
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
function gcd(a, b) {
	while (true) {
		if (a > b) {
			a = a % b;
			if (a === 0) return b;
		} else {
			b = b % a;
			if (b === 0) return a;
		}
	}
}

function Main(input) {
const lines = input;
const NS = lines[0].split(' ');
const N = Number(NS[0]);
const S = Number(NS[1]);
 
console.log(3 * (N - gcd(N - S, S)));
}
 
Main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n'));
 


Measured memory_bytes: 7628
N = int(input())
S = {}
for i in range(N):
    tmp = input()
    if tmp not in S:
        S[tmp] = 0
    S[tmp] += 1

M = max(S.values())

L = list(S)
L.sort()
for i in L:
    if S[i] == M:
        print(i)

Measured memory_bytes: 32096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(400<=n&&n<600)printf("8");
	if(600<=n&&n<800)printf("7");
	if(800<=n&&n<1000)printf("6");
	if(1000<=n&&n<1200)printf("5");
	if(1200<=n&&n<1400)printf("4");
	if(1400<=n&&n<1600)printf("3");
	if(1600<=n&&n<1800)printf("2");
	if(1800<=n&&n<2000)printf("1");
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }
int main(void) {
    int n;
    cin >> n;
    cout << lcm(n, 2) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    int A = 0, B = 0;
    for(int i = (int)Math.sqrt(N); i >= 1 ; i--){
      if(N%i == 0){
        A = i;
        B = (int)(N/i);
        break;
      }
    }
    
    int C = A > B ? A : B;
    int ans = 0;
    while(C > 0){
      C /= 10;
      ans++;
    }
    System.out.println(ans);
  }
}


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

int main(){
    string S,T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < 3; i++){
        if (S.at(i) == T.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var n int
	fmt.Scan(&n)
	if n == 0 {
		fmt.Println("hon")
	}
	mod := n % 10
	
	if mod == 3 {
		fmt.Println("bon")
	} else if  mod == 0 || mod == 1 || mod == 6 || mod == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
double qwq[110];
int n;
int main()
{
	double ans=0.0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>qwq[i];
		qwq[i]=1/qwq[i];
		ans+=qwq[i];
	}
	ans=1/ans;
	printf("%lf",ans);
	return 0;
}

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

int H,W;
int main (){
    cin >> H >> W;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int a;
            string s;
            cin >> s;
            if( s == "snuke") {
                printf("%c%d\n",'A'+ j , i + 1);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
fn count_coins(x: usize) -> (usize, usize){
    let five_hundred = x / 500;
    let reminder = x % 500;
    let five = reminder / 5;
    (five_hundred, five)
}

fn main() {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    let n: usize = buffer.trim_right().parse().unwrap();

    let coins = count_coins(n);
    let five_hundred = coins.0;
    let five = coins.1;
    let happiness = 1000 * five_hundred + 5 * five;
    println!("{}", happiness);
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long A = scan.nextLong();
        long B = scan.nextLong();
        if (B == 1) {
            System.out.println(0);
            return;
        }
        System.out.println((long)Math.ceil((double)(B-1)/(double)(A-1)));
    }
}


Measured memory_bytes: 21716
import math
N = int(input())

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

point = 0
for i in range(N):

	point += (B[A[i] - 1])

	if i < N - 1 and A[i + 1] - A[i] == 1:
		point+=C[A[i] - 1]

print('%d' % point)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN =

int a, b, c;

int ans;
int mx;
int dif;

void fix (int x) {
    ans += (mx-x)/2;
    dif += (mx-x)%2;
}
/********** Good Luck :) **********/
int main () {
    IOS();

    cin >> a >> b >> c;
    mx = max({a, b, c});


    fix(a);
    fix(b);
    fix(c);

    if (dif == 2) {
        ans++;
    } else if (dif == 1) {
        ans +=2;
    }

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


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		if(x < a) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}

	}

}


Measured memory_bytes: 22228
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    n, k = map(int, input().split())
    ans = 0
    for i in range(k,n+2):
        ans += number(i,n) 
    print(ans%(10**9+7))

def number(i,n):
    minn = int((0 + i - 1)*i/2)
    maxn = int(((n-i+1)+n)*i/2)
    return maxn - minn + 1
if __name__ == '__main__':
    main()


Measured memory_bytes: 64844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
using vp = vector<pair<int,int>>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main(){
    int h,w,k;cin >> h >> w >> k;
    vector<vector<char>> in(h,vector<char>(w));
    rep(i,h) rep(j,w) cin >> in[i][j];
    int ans = 0;
    rep(tmp,(1 << h+w)){
        bitset<12> s(tmp);
        int sum = 0;
        rep(i,h){
            if(s.test(i)) continue;
            rep(j,w){
                if(s.test(h+j)) continue;
                if(in[i][j] == '#') sum++;
            }
        }
        if(sum == k) ans++;
    }
    cout << ans << endl;
}

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



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

	vector<int> a(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];
	
	for(int i = 1; i < n; ++i){

		a[0] ^= a[i];

	}

	if(a[0] == 0)
	cout << "Yes" << endl; 
	else
	{
		cout << "No" << endl;
	}
	
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
inline void re(int &x)
{
	x=0;bool flag=false;
	char c=getchar();
	while(c<'0'||c>'9'){
		flag= c=='-';
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+(c^'0');
		c=getchar();
	}
	if(flag)x=-x;
	return ;
}
int S[200010],num[200010];
int now;
void pt(int x)
{
	for(int i=1;i<=x;i++)
		printf(")");
	for(int i=1;i<=x;i++)
		printf("(");
	return ;
}
char st[200010];
int main()
{
	int A;
	scanf("%d",&A);
	S[0]=0;
	now=0;
	while(S[now]<A)
	{
		now++;
		S[now]=S[now-1]+now;
	}
	for(int i=0;i<now*2;i++)
		if(i<now)st[i]=')';
		else st[i]='(';
	int d=S[now]-A;
	swap(st[now-d],st[now]);
	printf("%s\n",st);
	return 0;
}


Measured memory_bytes: 3400
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  char c;
  cin >> c;
  cout << (char)(c + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from math import pi
# import bisect
# from collections import deque

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 998244353


# for _ in range(int(ri())):
r = int(ri())
print(2*pi*r)

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

int main(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	long long m = a+b;
	long long n = c+d;
	if(m > n)
		cout << "Left";
	else if(n > m)
		cout << "Right";
	else
		cout << "Balanced";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
	string str, typed="";
	cin>>str;
	int s=str.length();
	for(int i=0; i<s; i++){
		if(str[i]=='0'){
			typed+='0';
		}else if(str[i]=='1'){
			typed+='1';
		}else {
			typed=typed.substr(0, typed.length()-1);
		}
	}

	cout<<typed<<endl;
	return 0;

}

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

const int MAXN = 1e5+2;
int dp[MAXN], h[MAXN], n;

int main(){
//    freopen(".in", "r" , stdin);

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

    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> h[i];

    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i=3; i<=n; i++)
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]) );

    cout << dp[n] << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;

int main()
{  fast

int a,b;
cin>>a>>b;
cout<<a*b;

}

Measured memory_bytes: 3652
n,k=input().split()
n=int(n)
k=int(k)
d=input().split()
d=list(map(int,d))
a=[0]*10
flag=True
for i in d:
    a[i]+=1
while 1:
    flag=True
    tmp=n
    while tmp!=0:
        if(a[tmp%10]!=0):
            flag=False
            n+=1
            break
        tmp//=10
    if flag==True:
        print(n)
        break

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

using namespace std;

int main(){
  vector<int> h(10);
  for(int i=0;i<10;++i) cin>>h[i];
  sort(h.begin(),h.end());
  for(int i=0;i<3;++i) cout << h[10-(i+1)] << endl;
  
  return 0;
}



Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                String S = scan.next();


                int count = 0;
                int max = 0;

                for (int i = 0; i < 3; i++) {
                	if (S.substring(i,i+1).equals("R")) {
                		count++;
                		if (max < count) {
                			max = count;
                		}
                	} else {
                		if (max < count) {
                			max = count;
                		}
                		count = 0;
                	}
                }

                System.out.println(max);

                scan.close();

        }
}

Measured memory_bytes: 35580
# coding: utf-8
# Your code here!

# Your code here!
 
X = [x for x in input()]
A = int(''.join(X[:2]))
B = int(''.join(X[2:]))

def is_month(n):
    if 0 < n and n <= 12:
        return True
    return False
    
def is_year(n):
    return True
 
if is_month(A) and is_month(B):
    print('AMBIGUOUS')
elif is_month(A) and is_year(B):
    print('MMYY')
elif is_year(A) and is_month(B):
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b;
    cin>>a>>b;
    ll gg=gcd(a,b);
    vector<ll>div;
    for(ll i=1;i*i<=gg;i++){
        if(gg%i==0){
            div.push_back(i);
            if(gg/i!=i)div.push_back(gg/i);
            }
    }

    sort(div.rbegin(),div.rend());
    int k;
    cin>>k;
    cout<<div[k-1]<<endl;
    return 0;
    }


Measured memory_bytes: 256
program ABC151F
    use iso_fortran_env
    implicit none
    integer::N
    real(real128)::x,y
    complex(real128),allocatable,dimension(:)::Points
    complex(real128),allocatable,dimension(:,:,:)::cross
    real(real128)::ok,ng,med
    real(real128)::pi
    integer::i
    pi=4.0*atan(1.0)
    read*,N
    allocate(Points(N),cross(N,N,2))
    do i=1,N
        read*,x,y
        Points(i)=x+y*(0.0,1.0)
    end do
    ok=2000;ng=0
    med=(ok+ng)/2
    do while(ok-ng>=10**(-10.0))
        if(Rcheck(med))then
            ok=med
        else
            ng=med
        endif
        med=(ok+ng)/2
    end do
    print"(f0.20)",ok
contains
logical function Rcheck(R)
    real(real128)::R
    integer::i,j,k,l
    logical::Pcheck
    call getcross(R)
    Rcheck=.false.
    do i=1,N-1
        do j=i+1,N
            do l=1,2
                Pcheck=.true.
                do k=1,N
                    if(i==k.or.j==k)then
                        if(abs(Points(i)-Points(j))>R*2+0.0000001)Pcheck=.false.
                    else
                        if(abs(cross(i,j,l)-Points(k))>R)Pcheck=.false.
                    endif
                end do
                Rcheck=Rcheck.or.Pcheck
            end do
        end do
    end do
end function

subroutine getcross(R)
    real(real128)::R
    integer::i,j
    real(real128)::H
    cross=(5000,5000)
    do i=1,N-1
        do j=i+1,N
            if(abs(Points(i)-Points(j))>2.0*R)exit
            H=sqrt(R**2-ABS((Points(i)-Points(j))/2)**2)
            cross(i,j,1)=(Points(i)+Points(j))/2 + &
            & H*exp((0.0,1.0)*(atan2(AIMAG(Points(j)-Points(i)), REAL(Points(j)-Points(i)))+pi/2))
            cross(i,j,2)=(Points(i)+Points(j))/2  &
            & +H*exp((0.0,1.0)*(atan2(AIMAG(Points(j)-Points(i)), REAL(Points(j)-Points(i)))-pi/2))
        end do
    end do
end subroutine
end program ABC151F

Measured memory_bytes: 896
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int p = sc.nextInt();
    
    p += a*3;
    
    int ans = (int)p/2;
    System.out.println(ans);
  }
}

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

int main () {
  int n;

  cin >> n;


  vector<int> v(n), c(n);

  rep(i,n) cin >> v[i];
  rep(i,n) cin >> c[i];

  int ans = 0;
  rep(i,n) if(v[i] > c[i]) ans += v[i] - c[i];

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


Measured memory_bytes: 384
from collections import defaultdict as dd
N = int(input())
s = str(input())
maxlen = N//2

def solve(tgt):
    dic = dd(int)
    st = s[tgt:2*tgt]
    dic[st] += 1
    ls = [st]
    for char in s[2*tgt:]:
        st = st[1:]+char
        dic[st] += 1
        ls.append(st)
    st = s[:tgt]
    if dic[st] > 0:
        return True
    dic[ls[0]] -= 1
    for i,char in enumerate(s[tgt:N-tgt]):
        st = st[1:]+char
        if dic[st] > 0:
            return True
        dic[ls[i+1]] -= 1
    return False

ng = maxlen + 1
ok = 0
while ng-ok > 1:
    tgt = (ok+ng)//2
    if solve(tgt):
        ok = tgt
    else:
        ng = tgt
print(ok)


Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int x,y; 
    cin>>x>>y;
    cout<<gcd(x,y)<<endl;
    return 0;
}





Measured memory_bytes: 3104
#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    std::map<int, int> cnt;
    for (int i = 0; i < n; ++ i) {
        int a;
        scanf("%d", &a);
        cnt[a] ++;
    }
    std::vector<int> v;
    for (auto it : cnt) {
        v.push_back(it.second);
    }
    std::sort(v.begin(), v.end());
    int result = 0;
    for (int i = 0; i < (int)v.size() - m; ++ i) {
        result += v[i];
    }
    printf("%d\n", result);
}

Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

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

	return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a,b,mi=1000000,m,i;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a>>b;
		if(b<=m){
			mi=min(mi,a);
		}
	}
	if(mi==1000000){
		cout<<"TLE";
	}
	else{
		cout<<mi;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N,M,Y;
	Y = 0;
	cin >> N;
	M = N * 800;
	
	for (int  i = 1; i <= N; i++)
	{
		if (i % 15 == 0) {
			Y+=200;
		}
	}
	cout << M - Y << endl;



}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

ll hw[110][110];
int main(void) {
  ll h, w;
  vll a;

  cin >> h >> w;
  cin >> n;

  FOR(i, 0, n) {
	cin >> temp;
	a.push_back(temp);
  }

  ll x = 0;
  ll y = 0;
  flag = true;
  FOR(i, 0, n) {
	FOR(j, 0, a[i]) {
	  hw[y][x] = i + 1;
	  if (flag) {
		if (x != w-1) {
		  x++;
		}
		else {
		  y++;
		  flag = false;
		}
	  }
	  else {
		if (x != 0) {
		  x--;
		}
		else {
		  y++;
		  flag = true;
		}
	  }
	}
  }

  FOR(i, 0, h) {
	FOR(j, 0, w) {
	  cout << hw[i][j] << " ";
	}
	cout << endl;
  }

  return 0;
}

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

int main(){
  int i = 0;
  int L,R,d;
  int ans = 0;
  cin >> L >> R >> d;
  
  for(i = L ; i <= R ; i++){
    if(i % d == 0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

N, X, Y = map(int, input().split())

edge = [(i, i + 1, 1) for i in range(N - 1)]
edge.append((X - 1, Y - 1, 1))

edge1 = np.array(edge, dtype = np.int64).T
graph = csr_matrix((edge1[2], (edge1[:2])), (N, N))

# print (graph)

ans = dijkstra(graph, directed = False)
lst = [0] * N
for i in range(N - 1):
    # tmp = list(ans[i,:])
    # print (tmp)
    for j in range(i + 1, N):
        lst[int(ans[i,j])] += 1
    
print (*lst[1:], sep = '\n')
# print (ans)

Measured memory_bytes: 47460
N,X = map(int,input().split())
count = 0 #作成するドーナツの個数
tmp = 0 #お菓子の素の消費量
M = [] #ドーナツのリスト
for i in range(N):M.append(int(input()))
M.sort()
for i in range(N):
  tmp = tmp + M[i]
  if tmp > X:
    break
  count += 1
if X > tmp:count += (X-tmp)//M[0]
print(count)

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

def main():
    x, N = map(int, input().split())
    P = set(map(int, input().split()))
    d = 0
    while True:
        if x + d in P and x - d in P:
            d += 1
            continue
        else: break
    if x - d in P: print(x + d)
    else: print(x - d)
    

if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u) {
		cout << a - 1 << ' ' << b << endl;
	}
	else {
		cout << a << ' ' << b - 1 << endl;
	}
	return 0;
}

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

int main() {
  int A;
  int B;
  int ans;
  cin >> A >> B;
  if (A + B == 3)
    ans = 3;
  else if (A + B == 4)
    ans = 2;
  else
    ans = 1;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
int n;
int main(){
  scan(n);
  ll luc[90];
  luc[0]=2;
  luc[1]=1;
  for(int i=2;i<=n;i++){
    luc[i]=luc[i-1]+luc[i-2];
  }
  prin(luc[n]);

  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int n = sc.nextInt();
        int k = sc.nextInt();
        int h[] = new int[n];
        long ans = 0;
        int i;
        if(n <= k){
          System.out.println(ans);
          return;
        }
          
        for(i = 0;i < n;i++){
          h[i] = sc.nextInt();
        }
        Arrays.sort(h);
        for(i = n - 1;i >= n - k;i--){
          h[i] = 0;
        }
      
        for(i = 0;i < n;i++){
          ans += h[i];
        }
        System.out.println(ans);
        
    }
}

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

int main() {
  int N;
  int f_N = 0;
  int len;
  int mod;
  cin >> N;
  
  len = to_string(N).length();
  
  for ( int i = 0 ; i < len ; i++ ) {
    int ten_pow = 1;
    for ( int j = 0 ; j < i ; j++ ) {
      ten_pow *= 10;
    }
    f_N += (N % (ten_pow * 10) ) / ten_pow;
  }
  
  mod = N % f_N;
  
  if ( mod == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;

int main() {
    int x[5] = {}, y[5] = {};
    cin >> x[1] >> y[1] >> x[2] >> y[2];

    x[3] = x[2] - (y[2] - y[1]);
    y[3] = y[2] + x[2] - x[1];
    x[4] = x[1] - (y[2] - y[1]);
    y[4] = y[1] + x[2] - x[1];

    cout << x[3] << ' ' << y[3] << ' ' << x[4] << ' ' << y[4] << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main() {
    string s; cin >> s;
    if(s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba")
        cout << "Yes" << ln;
    else cout << "No" << ln;
}

    

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

//vecのk以下の要素のうち一番右のもの
int64_t right(vector<int64_t> vec, int64_t k){
  int64_t a = 0;
  int64_t b = vec.size()-1;
  if(vec.at(a) > k)
    return -1;
  else if(vec.at(b) == k)
    return b;
  else if(vec.at(b) < k)
    return b;
  else{
    bool bk = true;
    while(bk){
      int64_t c = (a+b)/2;
      if(vec.at(c) == k && vec.at(c+1) > k){
        return c;
        bk = false;
      }
      else if(vec.at(c+1) <= k)
        a = c;
      else if(vec.at(c) > k)
        b = c;
      else{
        return c;
        bk = false;
      }
    }
  }
}

int main() {
    int64_t n; cin >> n;
    vector<int64_t> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int64_t a_negative = right(a,-1)+1;
    int64_t a_zero = right(a,0)+1 - a_negative;
    rep(i,a_negative){
        a[i] *= -1;
    }
    sort(a.begin(),a.end());
    int64_t asum = 0;
    for(int64_t i : a) asum += i;
    if(a_negative%2 == 1) asum -= 2*a[0];
    cout << asum << endl;
}


Measured memory_bytes: 1920
X, K, D = map(int, input().split())

low = 0
high = K

while low <= high:
    mid = (low + high) //2
    i = mid
    j = K-mid
    ans_pre = (X + D*i - D*j)
    if ans_pre > 0:
        high = mid-1
    else:
        low = mid+1
        

if low > K :
    low = high
if high < 0:
    high = low
    
ans_h = min(abs((X + D*high - D*(K-high))), abs(X + D*(K-high)-D*high))
ans_l = min(abs((X + D*low - D*(K-low))), abs(X + D*(K-low)-D*low))
    
print(min(ans_l, ans_h))

Measured memory_bytes: 9228
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll = long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int mod = 1e9 + 7;

ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
	return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

void comb_init()
{
	int N = 200005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}

int N, K;

signed main()
{
	cin >> N >> K;
	comb_init();

	int r = N - K, b = K;

	for (int i = 1; i <= b; ++i) {
		if (r + 1 < i or b - 1 < i - 1) cout << 0 << endl;
		else cout << C(r  + 1, i) * C(b - 1, i - 1) % mod << endl;
	}
}




Measured memory_bytes: 4992