akhauriyash/Code-Regression huggingface dataset:
x = int(input())
if int(x**0.2)==int(x)**0.2:
  print(int(x**0.2),0)
  exit()
for i in range(1,10**5):
  b = i
  c = -i
  x1 = x + b**5
  x2 = x + c**5
  if x1>=0 and int(x1**0.2)**5==x1:
    print(int(x1**0.2),b)
    exit()
  if x2>=0 and int(x2**0.2)**5==x2:
    print(int(x2**0.2),c)
    exit()
  if x2<0:
    for j in range(1,10**3):
      v = -j
      if v**5==x2:
        print(v,c)
        exit()

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

int main(){
  int H,N;
  cin >> H >> N;
  
  int sum=0;
  rep(i,N){
    int A;
    cin >> A;
    sum += A;
  }
  
  if(H <= sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
dishes = [int(input()) for _ in range(5)]

time = 0 # 最後の料理が届く時刻

# 最後に頼む料理を決める
max = 0
j = -1 # 最後に頼む料理
for i in range(5):
    if dishes[i] % 10 != 0:
        point = 10 - (dishes[i] % 10)
    else:
        point = 0
    if point >= max:
        max = point 
        j = i

# 最後に頼む料理以外を頼む
for i in range(5):
    if i == j:
        continue 
    time += dishes[i]
    if dishes[i] % 10 != 0: # 10の倍数に合わせる
        time += 10 - (dishes[i] % 10)

print(time + dishes[j])

Measured memory_bytes: 3064
import bisect

n = int(input())

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

A.sort(); B.sort(); C.sort()

ans = 0
b_li = [0 for i in range(n)]

for b in range(n):    
    index = bisect.bisect_left(C, B[b]+1)
    b_li[b] = n-index

for b in range(n-2,-1,-1):
    b_li[b] += b_li[b+1]
b_li.append(0)

for a in range(n):    
    index = bisect.bisect_left(B, A[a]+1)

    ans += b_li[index]
    
        
    

print(ans)




Measured memory_bytes: 24180
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let n: usize = read();

    let mut ans = 0;
    for i in 1..n+1 {
        ans += i;
        for j in i+1..n+1 {
            let gcd_j = gcd(i, j);
            ans += gcd_j * 6;
            for k in j+1..n+1 {
                ans += gcd(gcd_j, k) * 6;
            }
        }
    }

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


Measured memory_bytes: 2156
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

// M is large primary number
const M = 1046527

func main() {
	fmt.Println(answer(os.Stdin))
}

func answer(r io.Reader) string {
	H := make([]string, M)
	sc := bufio.NewScanner(r)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	buf := bytes.Buffer{}
	for i := 0; i < n; i++ {
		sc.Scan()
		ss := strings.Fields(sc.Text())
		switch ss[0] {
		case "insert":
			insert(H, ss[1])
		case "find":
			if find(H, ss[1]) {
				buf.WriteString("yes\n")
			} else {
				buf.WriteString("no\n")
			}
		}
	}
	return strings.TrimRight(buf.String(), "\n")
}

func atoi(char byte) int {
	switch char {
	case 'A':
		return 1
	case 'C':
		return 2
	case 'G':
		return 3
	case 'T':
		return 4
	default:
		return 0
	}
}

func getKey(str string) int {
	sum, p := 0, 1
	for i := 0; i < len(str); i++ {
		sum += p * atoi(str[i])
		p *= 5
	}
	return sum
}

func h1(key int) int {
	return key % M
}

func h2(key int) int {
	return 1 + key%(M-1)
}

func find(H []string, str string) bool {
	key := getKey(str)
	h := 0
	for i := 0; ; i++ {
		h = (h1(key) + i*h2(key)) % M
		if H[h] == str {
			return true
		} else if len(H[h]) == 0 {
			return false
		}
	}
}

func insert(H []string, str string) []string {
	key := getKey(str)
	for i := 0; ; i++ {
		h := (h1(key) + i*h2(key)) % M
		if H[h] == str {
			return H
		} else if len(H[h]) == 0 {
			H[h] = str
			return H
		}
	}
}



Measured memory_bytes: 46224
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.zeros(N+1)
for i in range(1, N+1):
    A[i::i] += 1

A = A[1::2]
answer = (A==8).sum()
print(answer)


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

int main(){

    int a,b;
    cin >> a >> b;
    a--;b--;
    int c[3]={0,0,0};

    c[a]++;c[b]++;

    rep(i,3){
        if(c[i]==0){
            cout << i+1 << endl;
        }
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,x,y;
pi b1[800005],b2[800005];

map <pi,vector<pi>> m;

set<pi> q;

pi mn(pi a, pi b){
    if(a.x<b.x) return a;
    else return b;
}

void Upd1(int nod, int l, int r, int pos, int val){
    if(l>pos || r<pos) return;
    if(l==r){
        b1[nod]={val,pos};
        return;
    }
    int mid=(l+r)/2;
    Upd1(2*nod,l,mid,pos,val);
    Upd1(2*nod+1,mid+1,r,pos,val);
    b1[nod]=mn(b1[2*nod],b1[2*nod+1]);
}

pi Qry1(int nod, int l, int r, int lt, int rt){
    if(l>rt || r<lt) return {1e9,1e9};
    if(l>=lt && r<=rt) return b1[nod];
    int mid=(l+r)/2;
    return mn(Qry1(2*nod,l,mid,lt,rt),Qry1(2*nod+1,mid+1,r,lt,rt));
}

void Upd2(int nod, int l, int r, int pos, int val){
    if(l>pos || r<pos) return;
    if(l==r){
        b2[nod]={val,pos};
        return;
    }
    int mid=(l+r)/2;
    Upd2(2*nod,l,mid,pos,val);
    Upd2(2*nod+1,mid+1,r,pos,val);
    b2[nod]=mn(b2[2*nod],b2[2*nod+1]);
}

pi Qry2(int nod, int l, int r, int lt, int rt){
    if(l>rt || r<lt) return {1e9,1e9};
    if(l>=lt && r<=rt) return b2[nod];
    int mid=(l+r)/2;
    return mn(Qry2(2*nod,l,mid,lt,rt),Qry2(2*nod+1,mid+1,r,lt,rt));
}

pi Find(int l, int r, int p){
    if(p){
        pi x=Qry1(1,1,n,l,r);
        pi y=Qry2(1,1,n,x.second+1,r);
        pi t,g={x.first,y.first};
        if(x.second-1>=l) t=Find(l,x.second-1,p), m[g].push_back(t);
        if(y.second-1>=x.second+1) t=Find(x.second+1,y.second-1,!p), m[g].push_back(t);
        if(r>=y.second+1) t=Find(y.second+1,r,p), m[g].push_back(t);
        return g;
    }
    else{
        pi x=Qry2(1,1,n,l,r);
        pi y=Qry1(1,1,n,x.second+1,r);
        pi t,g={x.first,y.first};
        if(x.second-1>=l) t=Find(l,x.second-1,p), m[g].push_back(t);
        if(y.second-1>=x.second+1) t=Find(x.second+1,y.second-1,!p), m[g].push_back(t);
        if(r>=y.second+1) t=Find(y.second+1,r,p), m[g].push_back(t);
        return g;
    }
}


int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x;
        if(i%2) Upd1(1,1,n,i,x),Upd2(1,1,n,i,1e9);
        else Upd1(1,1,n,i,1e9),Upd2(1,1,n,i,x);
    }
    pi t=Find(1,n,1);
    q.insert(t);
    while(q.size()){
        t=*(q.begin());
        q.erase(q.begin());
        for(pi i : m[t]){
            q.insert(i);
        }
        cout << t.first << ' ' << t.second << ' ';
    }
}


Measured memory_bytes: 35712
use std::collections::HashMap;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<usize>();
    let mut an = vec![];
    for _ in 0..n{ 
        an.push(read::<i64>());
    }
    let ans = an.into_iter().fold(HashMap::new(),|mut map,x|{
        let y = map.get(&x).map(|t| t+1).unwrap_or(1);
        map.insert(x,y);
        map
    }).into_iter().collect::<Vec<(_,_)>>()
    .into_iter()
    .filter(|x| x.1%2 != 0)
    .count();
    println!("{}",ans);
}

Measured memory_bytes: 12540
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 510;
string f[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, m;
    cin >> n >> m;
    forn(i, n) cin >> f[i];

    forn(k, 2) {
        forn(i, n) {
            forn(j, m) {
                bool force = false;
                if (i % 2 == k && (j != 0 && j + 1 != m)) force = true;
                if (k && j == 0) force = true;
                if (!k && j + 1 == m) force = true;
                if (force) cout << '#';
                else cout << f[i][j];
            }
            cout << '\n';
        }
        if (!k) cout << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int d[200005];
int f(int x){
  if(d[x] != 0) return d[x];
  if(x == 0) return 0;
  int pop_count = 0;
  int n = x;
  while(n >0){
    if(n&1) ++pop_count;
    n /=2;
  }
  return d[x] = f(x %pop_count) +1;
}

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for(int i=0; i<n; ++i){
    cnt += s[i] - '0';
  }
  int zero_rev = cnt +1;
  vector<int> zero_d(n);
  int zero_tot = 0, keta = 1;
  for(int i=n-1; i>=0; --i){
    zero_tot += (s[i] -'0') *keta;
    zero_tot %= zero_rev;
    zero_d[i] = keta;
    keta *= 2;
    keta %= zero_rev;
  }
  int one_rev = cnt -1;
  vector<int> one_d(n);
  int one_tot = 0;
  keta = 1;
  if(one_rev > 0) for(int i=n-1; i>=0; --i){
    one_tot += (s[i] -'0') *keta;
    one_tot %= one_rev;
    one_d[i] = keta;
    keta *= 2;
    keta %= one_rev;
  }
  for(int i=0; i<n; ++i){
    if(s[i] == '1' && one_rev == 0) cout << 0 << endl;
    else if(s[i] == '1'){
      int x = one_tot -one_d[i];
      if(x<0) x += one_rev;
      cout << f(x)+1 << endl;
    }else{
      int x = (zero_tot +zero_d[i]) %zero_rev;
      cout << f(x)+1 << endl;
    }
  }
}

Measured memory_bytes: 5568
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();
    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let t: Vec<char> = iterator.next().unwrap().chars().collect();

    let lcm = lcm(n, m);
    // let mut x: Vec<char> = vec!['*'; lcm];
    let mut x: HashMap<usize, char> = HashMap::new();
    for i in 0..n {
        // x[lcm / n * i] = s[i];
        x.insert(lcm / n * i, s[i]);
    }
    for j in 0..m {
        // if x[lcm / m * j] != '*' && x[lcm / m * j] != t[j] {
        //     return "-1".to_string();
        // }
        if x.contains_key(&(lcm / m * j)) && *x.get(&(lcm / m * j)).unwrap() != t[j] {
            return "-1".to_string();
        }
    }
    // for i in 0..n {
    //     for j in 0..m {
    //         if lcm / n * i != lcm / m * j {
    //             continue;
    //         }
    //         if s[i] != t[j] {
    //             return "-1".to_string();
    //         }
    //     }
    // }

    return lcm.to_string();
}

fn lcm(m: usize, n: usize) -> usize {
    return m / gcd(m, n) * n;
}

fn gcd(mut m: usize, mut n: usize) -> usize {
    while n != 0 {
        let r = m % n;
        m = n;
        n = r;
    }
    m
}


Measured memory_bytes: 12540
/* 
	بسم الله الرحمن الرحیم
		
	(; طلا یک جهانی
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second

const int MAX_N = 10 * 1000 + 5;
int n, it, c[MAX_N], p[MAX_N];
vector<int> adj[MAX_N];

void read_input() {
	cin >> 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);
	}
	for (int i = 0; i < n; i++)
		cin >> c[i];
}

void dfs(int v, int pr = -1) {
	p[v] = c[it++];
	for (int u: adj[v])
		if (u ^ pr)
			dfs(u, v);
}

void solve() {
	sort(c, c + n, greater<int>());
	dfs(0);
	int ans = 0;
	for (int i = 1; i < n; i++)
		ans += c[i];
	cout << ans << endl;
}

void print_output() {
	for (int i = 0; i < n; i++)
		cout << p[i] << ' ';
}

int32_t main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n, cntr = 0;
    double d;
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        double x, y;
        cin >> x >> y;
        double ans = sqrt(x * x + y * y);
        if(ans <= d) cntr++;
    }
    cout << cntr;
    return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
int N;
cin >> N;
vector<int> a(N);
REP(i, N) cin >> a[i];
vector<int>A(9, 0);


REP(i, N){ 
  int x = a.at(i) / 400;
  if(x > 8) {
    x = 8;
  }
  A.at(x)++;
}
int ans1 = 0;
REP(i, 8){
  if(A.at(i)) ans1++;
}

int ans2 = ans1 + A.at(8);

// if(ans2 > 8) ans2 = 8;
if(ans1 == 0) ans1 = 1;
cout << ans1 << ' ' << ans2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
    int n;cin>>n;
    if(n>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int graphs[300][300] = {};
int main() {
	iostream::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> edges;
	for (int i = 1; i <= n; ++i) {
		int q = i/2;
		graphs[i][i] = 1;
		while (q != 0) {
			graphs[i][q] = 1;
			graphs[q][i] = 1;
			edges.push_back(make_pair(i, q));
			q /= 2;
		}
	}
	cout << edges.size() << endl;
	REP(i, edges.size()) {
		cout << edges[i].first << " " << edges[i].second << endl;
	}
	REP(cnter, k) {
		int game_grid[600] = {};
		for (int q = 1; q <= n; ++q) {
			game_grid[q] = 1;
		}
		for (int i = 0; i <= 10; ++i) {
			int decided_itr = 0;
			int maximum_determination = -1;
			for (int q = 1; q <= n; ++q) {
				if (game_grid[q] == 0) continue;
				int cnta = 0;
				int cntb = 0;
				for (int j = 1; j <= n; ++j) {
					if (graphs[q][j] == 1) {
						cnta += game_grid[j];
					}
					else {
						cntb += game_grid[j];
					}
				}
				if (min(cnta,cntb) > maximum_determination) {
					maximum_determination = min(cnta,cntb);
					decided_itr = q;
				}
			}
			cout << decided_itr << endl;
			string s;
			cin >> s;
			if (s == "Yes") break;
			if (s == "Near") {
				for (int q = 1; q <= n; ++q) {
					if (graphs[decided_itr][q] == 0) {
						game_grid[q] = 0;
					}
				}
				game_grid[decided_itr] = 0;
			}
			if (s == "No") {
				for (int q = 1; q <= n; ++q) {
					if (graphs[decided_itr][q] == 1) game_grid[q] = 0;
				}
				game_grid[decided_itr] = 0;
			}
		}
	}
	return 0;
}


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

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

long double dist(long double rx, long double ry, int x, int y) {
    long double dx = (rx - x) * (rx - x);
    long double dy = (ry - y) * (ry - y);

    return sqrt(dx + dy);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    long double N;
    cin >> N;

    vi x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

    long double rx = accumulate(ALL(x), 0.) / N, ry = accumulate(ALL(y), 0.) / N;
    long double r;
    long double lambda = 1e-1;
    REP(i, 10000) {
        int x0, y0;
        r = 0;
        REP(j, N) {
            long double dd = dist(rx, ry, x[j], y[j]);
            if (dd > r) {
                r = dd;
                x0 = x[j], y0 = y[j];
            }
        }

        long double dx = x0 - rx, dy = y0 - ry;

        rx += dx * lambda, ry += dy * lambda;

        if ((i + 1) % 1000 == 0) {
            lambda /= 10;
        }
    }

    print(r);

}


Measured memory_bytes: 3856
//
//  AOJ0006.c
//
//
//  Created by 中野 優 on 2014/02/23.
//
//

#include <stdio.h>
int main(void){
    char str[20];
    int i=0,j;
    while(scanf("%c",&str[i])!=EOF) i++;
    for(j=i-2;j>=0;j--) printf("%c",str[j]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
import java.util.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	static int N;
	static int M;
	static int R;
	static int[] r;
	static int[] A;
	static int[] B;
	static int[] C;
	static int[][] d;
	static int INF = 2 << 28;
	
	static int dfs(int now, boolean[] visit, int cost) {
		boolean ok = true;
		for(int i = 0; i < visit.length; i++) {
			if(!visit[i]) ok = false;
		}
		if(ok) {
			return cost;
		}
		int ret = INF;
		for(int i = 0; i < visit.length; i++) {
			if(!visit[i]) {
				visit[i] = true;
				ret = Math.min(ret, dfs(r[i],visit,cost + d[now][r[i]]));
				visit[i] = false;
			}
		}
		return ret;
	}
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		N = sc.nextInt();
		M = sc.nextInt();
		R = sc.nextInt();
		r = new int[R];
		for(int i = 0; i < R; i++) {
			r[i] = sc.nextInt()-1;
		}
		A = new int[M];
		B = new int[M];
		C = new int[M];
		d = new int[N][N];
		
		for(int i = 0; i < M; i++) {
			A[i] = sc.nextInt()-1;
			B[i] = sc.nextInt()-1;
			C[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				d[i][j] = INF;
			}
		}
		for(int i = 0; i < M; i++) {
			d[A[i]][B[i]] = C[i];
			d[B[i]][A[i]] = C[i];
		}
		for(int k = 0; k < N; k++) {
			for(int i = 0; i < N; i++) {
				for(int j  = 0; j < N; j++) {
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		
		int ans = INF;
		
		for(int i = 0; i < R; i++) {
			boolean[] a = new boolean[R];
			a[i] = true;
			ans = Math.min(dfs(r[i],a,0),ans);
		}
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 48188
N = int(input())
D = [int(j) for j in input().split()]
import bisect
cnt = 0
mi = min(D)
ma = max(D)
D = sorted(D)
for i in range(mi,ma+1):
    if bisect.bisect_left(D,i) == N/2:
        cnt+=1
print(cnt)

Measured memory_bytes: 14396
import re

s = input()

max_len = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        a = s[i:j + 1]
        if re.fullmatch(r'(A|C|G|T)*', a):
            # print(a)
            max_len = max(max_len, len(a))

print(max_len)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll prev = -1;
    ll now;
    ll max_cnt = 0;
    ll cnt = 0;
    REP(i, n){
        cin >> now;
        if (now > prev){
            max_cnt = max(cnt, max_cnt);
            cnt = 0;
        } else {
            cnt++;
        }
        prev = now;
    }
    max_cnt = max(cnt, max_cnt);
    cout << max_cnt << endl;
    return 0;
}

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

int main()
{
	long long int N, H, a[100000], b[100000], ans = 0;

	cin >> N >> H;

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

	sort(a, a + N);
	sort(b, b + N);

	reverse(a, a + N);
	reverse(b, b + N);

	for (int i = 0; i < N; i++) {
		if (a[0] >= b[i]|| H <= 0)break;
		H -= b[i];
		ans++;
	}

	if (H > 0) {
		ans += H / a[0];
		if (H%a[0])ans++;
	}

	cout << ans;

	return 0;
}

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

using namespace std;
typedef long long LL;

const int maxn=50;

int n,p;
int A[maxn+5];
LL C[maxn+5][maxn+5];

void f()
{
	C[0][0]=1;
	for (int i=1;i<=maxn;++i)
	{
		C[i][0]=1;
		for (int j=1;j<=i;++j)
		{
			C[i][j]=C[i][j-1]*(i-j+1)/j;
			//printf("C[%d][%d]=%lld\n",i,j,C[i][j]);
		}
	}
}

void solve()
{
	int cnt=0;
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&A[i]);
		if (A[i]&1) ++cnt;
	}
	
	long long sum=0;
	if (p==0)
	{
		for (int i=0;i<=cnt;i+=2)
		{
			sum+=C[cnt][i];
		}
		sum*=(1LL<<(n-cnt));
	}
	else 
	{
		for (int i=1;i<=cnt;i+=2)
		{
			sum+=C[cnt][i];
		}
		sum*=(1LL<<(n-cnt));
	}
	//printf("%lld\n",sum);
	cout<<sum<<endl;
} 

int main(void)
{
	#ifdef ex
	freopen ("in","r",stdin);
	#endif
	
	f();
	while (scanf("%d%d",&n,&p)==2)
	{
		solve();
	}
}

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

int main(void){
  string S;
  cin >> S;
  string ans = "None";
  for(char i = 'a'; i <= 'z'; i++){
    if(S.find(i) == string::npos){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <numeric>
#include <iomanip>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N;
    cin >> N;
    int L[N];
    cins(L, L + N);
    sort(L, L + N);
    Yes(L[N - 1] < accumulate(L, L + N - 1, 0));
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	string str;
	cin >> str;
	REP(i, str.size()) {
		if (!(i & 1) && str[i] == 'L') {

			cout << "No" << endl; return 0;
		}
		if ((i & 1) && str[i] == 'R') {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
import math
k=int(input())
sum=k*(k+1)/2
for i in range(1,k+1):
    for j in range(i+1,k+1):
        m=math.gcd(i,j)
        sum+=6*m*(k-j+1)
        for l in range(j+1,k+1):
            n=math.gcd(m,l)
            if n==m:
                continue
            else:
                sum-=6*m-6*n
print(int(sum))


Measured memory_bytes: 9132
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import math

def prime_division2(x):
    q = int(math.sqrt(x))
    h = {}
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            h[i] = ex
    if x>q:
        h[x] = 1
    return h

def prime_division(x):
    q = int(math.sqrt(x))
    a = []
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            a.append([i,ex])
    if x>q:
        a.append([x,1])
    return a

def nxt(es,es0):
    for i in range(len(es)):
        if es[i]<es0[i]:
            es[i] += 1
            return
        es[i] = 0

def ok(n,k):
    while n>=k:
        if n%k==0:
            n = n//k
        else:
            n = n%k
    return 1 if n==1 else 0

n = inn()
sm = 0
for m in [n-1,n]:
    ps = prime_division(m)
    es = [0]*len(ps)
    es0 = [pe[1] for pe in ps]
    while es != es0:
        nxt(es,es0)
        t = 1
        for i in range(len(ps)):
            t *= ps[i][0]**es[i]
        sm += ok(n,t)
print(sm)


Measured memory_bytes: 41052
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >>n;
    vector<double> x(n,0.0);
    vector<string> u(n);
    rep(i,0,n) cin >> x[i] >> u[i]; 

    double sum(0.0);
    rep(i,0,n) 
    {
        if(u[i] == "BTC")
            sum+=x[i]*380000;
        else
            sum+=x[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int n;cin>>n;
  int ans = 0;
  for(int i=1;i*i <= n;i++){
    if(n%i != 0 || n/i-i <= 1)continue;
    int m = max(i, n/i);
    ans += m-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n / 2; ++i) {
    if (s[i] != s[n - i - 1]) ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

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

	int n;
	string s;

	cin >> n;
	cin >> s;

	for(int i=0;i<s.length();i++)
	{
		int x = s[i] - 'A';
		x = (x + n)%26;
		cout << (char)(x+'A');
	}
	cout << '\n';
	
	return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  ll mx = 0, cnt;
  rep(i,k) mx += p[i];
  cnt = mx;
  int ansi = 0;
  rep(i,n-k){
    cnt = cnt - p[i] + p[k+i];
    if(mx < cnt) {
      mx = cnt;
      ansi = i+1;
    }
  }
  ll dbans = 0;
  rep(i,k) dbans += p[ansi + i] + 1;
  if(dbans%2 == 0) cout << dbans/2 << endl;
  else{
    cout << dbans/2 << ".5" << endl;
  }
}


Measured memory_bytes: 4056
s=input()
if len(s)!=26:
    c = sorted(set("abcdefghijklmnopqrstuvwxyz")-set(s))[0]
    print(s+c)
elif s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    s=list(s)
    m=[s.pop()]
    while 1:
        q=s.pop()
        if max(m)>q:
            c=min(a for a in m if a>q)
            print("".join(s)+c)
            break
        else:
            m.append(q)

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

int main()
{
  int N;
  cin >> N;
  int a[N],b[N],c[N];
  int sumb = 0;
  int bonus = 0;
  
  for(int i=0;i<N;i++){cin >> a[i];}
  for(int i=0;i<N;i++){cin >> b[i]; sumb += b[i];}
  for(int i=0;i<N;i++){cin >> c[i];}
  
  for(int i=0;i<N-1;i++){if(a[i+1]==a[i]+1) bonus += c[a[i]-1];}
  
  cout<<sumb+bonus<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> C(n);
  vector<vector<int>> G(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i, n) cin >> C[i];
  sort(all(C), greater<ll>());
  vector<int> ans(n);
  int tmp = 0;
  auto dfs = [&](auto dfs, int cur, int par) -> void {
    ans[cur] = C[tmp++];
    for(int ne: G[cur]) {
      if(ne != par) dfs(dfs, ne, cur);
    }
  };
  rep(i, n) {
    if(G[i].size() == 1) {
      dfs(dfs, i, -1);
      break;
    }
  }
  cout << accumulate(begin(C)+1, end(C), 0LL) << endk;
  rep(i, n) cout << ans[i] << ' '; cout << endk;
  return 0;
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using PLL = pair<ll, ll>;
template <typename T> using V = vector<T>;
#define ALL(V) (V).begin(), (V).end()
#define endl '\n'

ll pow2(ll a) { return a * a; }
ll pow2(PLL a) { return pow2(a.first) + pow2(a.second); }

auto comp = [&](PLL a, PLL b) {
    ll la = pow2(a);
    ll lb = pow2(b);
    if(la != lb) return la < lb;
    else return a.first < b.first;
};

bool solve() {
    ll H, W;
    cin >> H >> W;
    if(!(H + W)) return false;
    V<PLL> v;
    for(ll h = 1; h <= 200; h++) for(ll w = h + 1; w <= 200; w++) if(comp(PLL(H, W), PLL(h, w))) v.emplace_back(h, w);
    auto p = *min_element(ALL(v), comp);
    cout << p.first << ' ' << p.second << endl;
    return true;
}

int main() {
    while(solve());
    return 0;
}



Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

print(sum(p[:K]))



Measured memory_bytes: 67168
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
char s[20];
int main()
{     int a,b,c,d,n,m,i,j,k;
      cin>>s[1]>>s[2]>>s[3]>>s[4];
      a=s[1]-'0';
      b=s[2]-'0';
      c=s[3]-'0';
      d=s[4]-'0';
      if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
        else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
        else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
        else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
        else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
        else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
        else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
        else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
	  return 0;
}


Measured memory_bytes: 256
gets
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
sum = 0
(a.size).times{|i|
    sum += b[a[i]-1]
}
(a.size - 1).times{|i|
    sum += c[a[i]-1] if a[i] + 1 == a[i + 1]
}
puts sum

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

ll N;
string S;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> S;
  ll white = 0;
  for (ll i = 0; i < N; i++) {
    if (S.at(i) == '.')  white++;
  }
  ll ans = white;
  ll cur = white;
  for (ll i = 0; i < N; i++) {
    if (S.at(i) == '.')  cur--;
    else                 cur++;
    ans = min(ans, cur);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 720
#include<cstdio>

int main(){
	int N[4];
	for (int i = 1; i <= 3; ++i) N[i] = 0;
	int a, b;
	scanf("%d %d", &a, &b);
	N[a]++, N[b]++;
	scanf("%d %d", &a, &b);
	N[a]++, N[b]++;
	scanf("%d %d", &a, &b);
	if(N[a] == 2 || N[b] == 2) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	string s;
	cin>>s;
	
	int ans = 0;
	for(int i=0;i<4;i++){
		if(s[i]=='2')ans++;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;
 
#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
 
ll n;
struct tup{
	double x,y,z;
	tup(){}
	tup(double _x,double _y,double _z):x(_x),y(_y),z(_z){}
};

double dis(tup a,tup b){
	double x = a.x - b.x;
	double y = a.y - b.y;
	double z = a.z - b.z;
	return sqrt(x*x + y*y + z*z);
}

struct edge{ 
	ll to;
	double cost; 
	edge(ll _to,double _cost):to(_to),cost(_cost){};
};

vector<edge> G[110];
double mincost[110];
bool used[110];

double prim(){
	double res = 0.0;
	rep(i,110){
		mincost[i] = INF;
		used[i] = false;
	}

	typedef pair<double,ll> PD;
	priority_queue<PD, vector<PD>, greater<PD>> que;
	que.push(PD(0.0, 0));

	while (que.size()){
		PD p = que.top(); 
		que.pop();
		double cost = p.first;
		ll v = p.second;
		if (used[v])continue;
		used[v] = 1;
		mincost[v] = cost;
		rep(i,G[v].size()){
			edge e = G[v][i];
			que.push(PD(e.cost, e.to));
		}
	}
	rep(i,n)res += mincost[i];
	return res;
}

int main(){
	while(cin >> n && n){
		rep(i,n)G[i].clear();
		vector<tup> v(n);
		vector<double> r(n);
		rep(i,n)cin >> v[i].x >> v[i].y >> v[i].z >> r[i];
		rep(i,n){
			FOR(j,i+1,n){
				double dd = max(dis(v[i],v[j]) - r[i] - r[j],0.0);
				G[i].push_back(edge(j,dd));
				G[j].push_back(edge(i,dd));
			}
		}
		printf("%.3lf\n",prim());
	}
}


Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

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

struct UF {
	vector<int> par; // 親のインデックスを記憶する配列
	vector<int> sz; // サイズを記憶する。
	vector<int> rank;
	vector<ll> val;
	// 初期化
	UF(int n, vector<ll> v):par(n),sz(n),rank(n),val(v){
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;rank[i] = 0;
		}
	}
	// 親を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
			val[y] += val[x];
		}
		else{
			par[y] = x;
			sz[x] += sz[y];
			val[x] += val[y];
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	// 素の集合のサイズを求める
	int size(int n){return sz[find(n)];}
	ll value(int n){return val[find(n)];}
};

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

	ll n, k;cin >> n >> k;
	vector<ll> p(n);
	REP(i, n) {
		cin >> p[i];
		p[i]--;
	}

	ll sum = 0;
	vector<ll> c(n);
	REP(i, n) {
		cin >> c[i];
		sum += c[i];
	}

	UF uf(n, c);
	REP(i, n)uf.unite(i, p[i]);

	ll ans = -INF;
	REP(num, n){
		ll cycle = uf.size(num);
		ll syou = max(0LL, (k / cycle) - 1);
		ll sum = uf.value(num);

		if(sum > 0){
			ll now = syou * sum;
			ll kai = k - syou * cycle;
			ll pla = num;
			REP(i, kai) {
				pla = p[pla];
				now += c[pla];
				ans = max(ans, now);
			}
		}
		else {
			ll now = 0;
			ll pla = num;
			REP(i, min(n, k)) {
				pla = p[pla];
				now += c[pla];
				ans = max(ans, now);
			}
		}
	}

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define maxn 2005
#define maxl 1000000000

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, -1, 1, 0, -1, -1, 1, 1},
          dy[] = {-1, 0, 0, 1, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;

void Solve() {
  // TODO
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  int x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += b[a[i]];
    if (i > 0 && a[i] == a[i - 1] + 1) res += c[a[i - 1]];
  }
  cout << res << '\n';
  return;
}

void Prepare() {
  // TODO
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // Prepare();
  // cin >> T;
  // for (t = 1; t <= T; t++) {
  //   printf("Case #%d: ", t);
  Solve();
  // }
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int l = scan.nextInt();
		String s[] = new String[n];
		for(int i=0;i<n;i++) {
			s[i]=scan.next();
		}
		scan.close();

		Arrays.sort(s);
		for(int i=0;i<n;i++) {
			System.out.print(s[i]);
		}
		System.out.println();

	}
}


Measured memory_bytes: 23376